| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2009 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_EXTENSIONS_EXTENSION_ACTION_CONTEXT_MENU_MODEL_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_CONTEXT_MENU_MODEL_H_ | |
| 7 | |
| 8 #include "app/menus/simple_menu_model.h" | |
| 9 #include "chrome/browser/extensions/extension_install_ui.h" | |
| 10 | |
| 11 class Extension; | |
| 12 class ExtensionAction; | |
| 13 class PrefService; | |
| 14 | |
| 15 // The menu model for the context menu for extension action icons (browser and | |
| 16 // page actions). | |
| 17 class ExtensionActionContextMenuModel | |
| 18 : public menus::SimpleMenuModel, | |
| 19 public menus::SimpleMenuModel::Delegate, | |
| 20 public ExtensionInstallUI::Delegate { | |
| 21 public: | |
| 22 // Delegate to handle menu commands. | |
| 23 class MenuDelegate { | |
| 24 public: | |
| 25 // Called when the user selects the menu item which requests that the | |
| 26 // popup be shown and inspected. | |
| 27 virtual void ShowPopupForDevToolsWindow(Extension* extension, | |
| 28 ExtensionAction* extension_action) { | |
| 29 } | |
| 30 }; | |
| 31 | |
| 32 // |extension_action|, |prefs|, & |delegate| call all be NULL. If valid | |
| 33 // values are provided for all three, and prefs::kExtensionsUIDeveloperMode | |
| 34 // is enabled in the PrefService, a menu item will be shown for "Inspect | |
| 35 // Popup" which, when selected, will cause ShowPopupForDevToolsWindow() to be | |
| 36 // called on |delegate|. | |
| 37 ExtensionActionContextMenuModel(Extension* extension, | |
| 38 ExtensionAction* extension_action, | |
| 39 PrefService* prefs, | |
| 40 MenuDelegate* delegate); | |
| 41 ~ExtensionActionContextMenuModel(); | |
| 42 | |
| 43 // SimpleMenuModel behavior overrides. | |
| 44 virtual bool IsCommandIdChecked(int command_id) const; | |
| 45 virtual bool IsCommandIdEnabled(int command_id) const; | |
| 46 virtual bool GetAcceleratorForCommandId(int command_id, | |
| 47 menus::Accelerator* accelerator); | |
| 48 virtual void ExecuteCommand(int command_id); | |
| 49 | |
| 50 // ExtensionInstallUI::Delegate overrides. | |
| 51 virtual void InstallUIProceed(bool create_app); | |
| 52 virtual void InstallUIAbort() {} | |
| 53 | |
| 54 private: | |
| 55 // The extension we are displaying the context menu for. | |
| 56 Extension* extension_; | |
| 57 | |
| 58 // The extension action we are displaying the context menu for. | |
| 59 ExtensionAction* extension_action_; | |
| 60 | |
| 61 // The delegate which handles the 'inspect popup' menu command. | |
| 62 MenuDelegate* delegate_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(ExtensionActionContextMenuModel); | |
| 65 }; | |
| 66 | |
| 67 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_CONTEXT_MENU_MODEL_H_ | |
| OLD | NEW |