| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 11 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| 12 #include "ui/base/models/simple_menu_model.h" | 12 #include "ui/base/models/simple_menu_model.h" |
| 13 | 13 |
| 14 class Browser; | 14 class Browser; |
| 15 class Extension; | 15 class Extension; |
| 16 class ExtensionAction; | 16 class ExtensionAction; |
| 17 class Profile; | 17 class Profile; |
| 18 | 18 |
| 19 // The menu model for the context menu for extension action icons (browser and | 19 // The menu model for the context menu for extension action icons (browser and |
| 20 // page actions). | 20 // page actions). |
| 21 class ExtensionContextMenuModel | 21 class ExtensionContextMenuModel |
| 22 : public base::RefCounted<ExtensionContextMenuModel>, | 22 : public base::RefCounted<ExtensionContextMenuModel>, |
| 23 public ui::SimpleMenuModel, | 23 public ui::SimpleMenuModel, |
| 24 public ui::SimpleMenuModel::Delegate, | 24 public ui::SimpleMenuModel::Delegate, |
| 25 public ExtensionUninstallDialog::Delegate { | 25 public ExtensionUninstallDialog::Delegate { |
| 26 public: | 26 public: |
| 27 // Delegate to handle showing an ExtensionAction popup. | 27 // Creates a menu model for the given extension action. |
| 28 class PopupDelegate { | 28 ExtensionContextMenuModel(const Extension* extension, Browser* browser); |
| 29 public: | |
| 30 // Called when the user selects the menu item which requests that the | |
| 31 // popup be shown and inspected. | |
| 32 virtual void InspectPopup(ExtensionAction* action) = 0; | |
| 33 | |
| 34 protected: | |
| 35 virtual ~PopupDelegate() {} | |
| 36 }; | |
| 37 | |
| 38 // Creates a menu model for the given extension action. If | |
| 39 // prefs::kExtensionsUIDeveloperMode is enabled then a menu item | |
| 40 // will be shown for "Inspect Popup" which, when selected, will cause | |
| 41 // ShowPopupForDevToolsWindow() to be called on |delegate|. | |
| 42 ExtensionContextMenuModel(const Extension* extension, | |
| 43 Browser* browser, | |
| 44 PopupDelegate* delegate); | |
| 45 virtual ~ExtensionContextMenuModel(); | 29 virtual ~ExtensionContextMenuModel(); |
| 46 | 30 |
| 47 // SimpleMenuModel::Delegate overrides. | 31 // SimpleMenuModel::Delegate overrides. |
| 48 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 32 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 49 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 33 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 50 virtual bool GetAcceleratorForCommandId( | 34 virtual bool GetAcceleratorForCommandId( |
| 51 int command_id, | 35 int command_id, |
| 52 ui::Accelerator* accelerator) OVERRIDE; | 36 ui::Accelerator* accelerator) OVERRIDE; |
| 53 virtual void ExecuteCommand(int command_id) OVERRIDE; | 37 virtual void ExecuteCommand(int command_id) OVERRIDE; |
| 54 | 38 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 66 // A copy of the extension's id. | 50 // A copy of the extension's id. |
| 67 std::string extension_id_; | 51 std::string extension_id_; |
| 68 | 52 |
| 69 // The extension action we are displaying the menu for (or NULL). | 53 // The extension action we are displaying the menu for (or NULL). |
| 70 ExtensionAction* extension_action_; | 54 ExtensionAction* extension_action_; |
| 71 | 55 |
| 72 Browser* browser_; | 56 Browser* browser_; |
| 73 | 57 |
| 74 Profile* profile_; | 58 Profile* profile_; |
| 75 | 59 |
| 76 // The delegate which handles the 'inspect popup' menu command (or NULL). | |
| 77 PopupDelegate* delegate_; | |
| 78 | |
| 79 // Keeps track of the extension uninstall dialog. | 60 // Keeps track of the extension uninstall dialog. |
| 80 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; | 61 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; |
| 81 | 62 |
| 82 DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel); | 63 DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel); |
| 83 }; | 64 }; |
| 84 | 65 |
| 85 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ | 66 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ |
| OLD | NEW |