bug 818009 - canActivate: only click-to-play-type plugins are valid r=jaws
[gecko.git] / widget / cocoa / nsMenuItemIconX.h
blob87a49ed12efcaeec7414c1872ccaf65706fe6c5b
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /*
7 * Retrieves and displays icons in native menu items on Mac OS X.
8 */
10 #ifndef nsMenuItemIconX_h_
11 #define nsMenuItemIconX_h_
13 #include "nsCOMPtr.h"
14 #include "imgINotificationObserver.h"
16 class nsIURI;
17 class nsIContent;
18 class imgIRequest;
19 class nsMenuObjectX;
21 #import <Cocoa/Cocoa.h>
23 class nsMenuItemIconX : public imgINotificationObserver
25 public:
26 nsMenuItemIconX(nsMenuObjectX* aMenuItem,
27 nsIContent* aContent,
28 NSMenuItem* aNativeMenuItem);
29 private:
30 virtual ~nsMenuItemIconX();
32 public:
33 NS_DECL_ISUPPORTS
34 NS_DECL_IMGINOTIFICATIONOBSERVER
36 // SetupIcon succeeds if it was able to set up the icon, or if there should
37 // be no icon, in which case it clears any existing icon but still succeeds.
38 nsresult SetupIcon();
40 // GetIconURI fails if the item should not have any icon.
41 nsresult GetIconURI(nsIURI** aIconURI);
43 // LoadIcon will set a placeholder image and start a load request for the
44 // icon. The request may not complete until after LoadIcon returns.
45 nsresult LoadIcon(nsIURI* aIconURI);
47 // Unless we take precautions, we may outlive the object that created us
48 // (mMenuObject, which owns our native menu item (mNativeMenuItem)).
49 // Destroy() should be called from mMenuObject's destructor to prevent
50 // this from happening. See bug 499600.
51 void Destroy();
53 protected:
54 nsresult OnStopFrame(imgIRequest* aRequest);
56 nsCOMPtr<nsIContent> mContent;
57 nsCOMPtr<imgIRequest> mIconRequest;
58 nsMenuObjectX* mMenuObject; // [weak]
59 nsIntRect mImageRegionRect;
60 bool mLoadedIcon;
61 bool mSetIcon;
62 NSMenuItem* mNativeMenuItem; // [weak]
65 #endif // nsMenuItemIconX_h_