• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_ACTION_CONTEXT_MENU_H_
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_ACTION_CONTEXT_MENU_H_
7 #pragma once
8 
9 #import <Cocoa/Cocoa.h>
10 
11 #include "base/memory/scoped_nsobject.h"
12 #include "base/memory/scoped_ptr.h"
13 
14 class AsyncUninstaller;
15 class DevmodeObserver;
16 class Extension;
17 class ExtensionAction;
18 class NotificationRegistrar;
19 class Profile;
20 
21 namespace extension_action_context_menu {
22 
23 class DevmodeObserver;
24 class ProfileObserverBridge;
25 
26 }  // namespace extension_action_context_menu
27 
28 // A context menu used by any extension UI components that require it.
29 @interface ExtensionActionContextMenu : NSMenu {
30  @private
31   // The extension that this menu belongs to. Weak.
32   const Extension* extension_;
33 
34   // The extension action this menu belongs to. Weak.
35   ExtensionAction* action_;
36 
37   // The browser profile of the window that contains this extension. Weak.
38   Profile* profile_;
39 
40   // The inspector menu item.  Need to keep this around to add and remove it.
41   scoped_nsobject<NSMenuItem> inspectorItem_;
42 
43   // The observer used to listen for pref changed notifications.
44   scoped_ptr<extension_action_context_menu::DevmodeObserver> observer_;
45 
46   // The observer used to reset |observer_| when the profile is destroyed.
47   scoped_ptr<extension_action_context_menu::ProfileObserverBridge>
48       profile_observer_;
49 
50   // Used to load the extension icon asynchronously on the I/O thread then show
51   // the uninstall confirmation dialog.
52   scoped_ptr<AsyncUninstaller> uninstaller_;
53 }
54 
55 // Initializes and returns a context menu for the given extension and profile.
56 - (id)initWithExtension:(const Extension*)extension
57                 profile:(Profile*)profile
58         extensionAction:(ExtensionAction*)action;
59 
60 // Show or hide the inspector menu item.
61 - (void)updateInspectorItem;
62 
63 // Notifies the ExtensionActionContextMenu that the profile is is being
64 // destroyed.
65 - (void)invalidateProfile;
66 
67 @end
68 
69 typedef ExtensionActionContextMenu ExtensionActionContextMenuMac;
70 
71 #endif  // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_ACTION_CONTEXT_MENU_H_
72