Bug 1646817 - Support DocumentChannel process switching in sidebars and popups r...
[gecko.git] / widget / cocoa / nsMenuItemIconX.h
bloba5ecb3f9914d359a46a9563585dc02044e357cea
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 "IconLoaderHelperCocoa.h"
15 class nsIconLoaderService;
16 class nsIURI;
17 class nsIContent;
18 class nsIPrincipal;
19 class imgRequestProxy;
20 class nsMenuObjectX;
22 #import <Cocoa/Cocoa.h>
24 class nsMenuItemIconX : public mozilla::widget::IconLoaderListenerCocoa {
25 public:
26 nsMenuItemIconX(nsMenuObjectX* aMenuItem, nsIContent* aContent,
27 NSMenuItem* aNativeMenuItem);
29 private:
30 virtual ~nsMenuItemIconX();
32 public:
33 // SetupIcon succeeds if it was able to set up the icon, or if there should
34 // be no icon, in which case it clears any existing icon but still succeeds.
35 nsresult SetupIcon();
37 // GetIconURI fails if the item should not have any icon.
38 nsresult GetIconURI(nsIURI** aIconURI);
40 // Unless we take precautions, we may outlive the object that created us
41 // (mMenuObject, which owns our native menu item (mNativeMenuItem)).
42 // Destroy() should be called from mMenuObject's destructor to prevent
43 // this from happening. See bug 499600.
44 void Destroy();
46 // Implements this method for mozilla::widget::IconLoaderListenerCocoa.
47 // Called once the icon load is complete.
48 nsresult OnComplete();
50 protected:
51 nsCOMPtr<nsIContent> mContent;
52 nsContentPolicyType mContentType;
53 nsMenuObjectX* mMenuObject; // [weak]
54 nsIntRect mImageRegionRect;
55 bool mSetIcon;
56 NSMenuItem* mNativeMenuItem; // [weak]
57 // The icon loader object should never outlive its creating nsMenuItemIconX
58 // object.
59 RefPtr<mozilla::widget::IconLoader> mIconLoader;
60 RefPtr<mozilla::widget::IconLoaderHelperCocoa> mIconLoaderHelper;
63 #endif // nsMenuItemIconX_h_