| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 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 ExtensionAction; | 15 class ExtensionAction; |
| 16 class Profile; | 16 class Profile; |
| 17 | 17 |
| 18 namespace content { |
| 19 class WebContents; |
| 20 } |
| 21 |
| 18 namespace extensions { | 22 namespace extensions { |
| 19 class Extension; | 23 class Extension; |
| 20 } | 24 } |
| 21 | 25 |
| 22 // The context menu model for extension icons. | 26 // The context menu model for extension icons. |
| 23 class ExtensionContextMenuModel | 27 class ExtensionContextMenuModel |
| 24 : public base::RefCounted<ExtensionContextMenuModel>, | 28 : public base::RefCounted<ExtensionContextMenuModel>, |
| 25 public ui::SimpleMenuModel, | 29 public ui::SimpleMenuModel, |
| 26 public ui::SimpleMenuModel::Delegate, | 30 public ui::SimpleMenuModel::Delegate, |
| 27 public extensions::ExtensionUninstallDialog::Delegate { | 31 public extensions::ExtensionUninstallDialog::Delegate { |
| 28 public: | 32 public: |
| 29 enum MenuEntries { | 33 enum MenuEntries { |
| 30 NAME = 0, | 34 NAME = 0, |
| 31 CONFIGURE, | 35 CONFIGURE, |
| 32 HIDE, | 36 HIDE, |
| 33 UNINSTALL, | 37 UNINSTALL, |
| 34 MANAGE, | 38 MANAGE, |
| 35 INSPECT_POPUP | 39 INSPECT_POPUP, |
| 40 ALWAYS_RUN |
| 36 }; | 41 }; |
| 37 | 42 |
| 38 // Delegate to handle showing an ExtensionAction popup. | 43 // Delegate to handle showing an ExtensionAction popup. |
| 39 class PopupDelegate { | 44 class PopupDelegate { |
| 40 public: | 45 public: |
| 41 // Called when the user selects the menu item which requests that the | 46 // Called when the user selects the menu item which requests that the |
| 42 // popup be shown and inspected. | 47 // popup be shown and inspected. |
| 43 // The delegate should know which popup to display. | 48 // The delegate should know which popup to display. |
| 44 virtual void InspectPopup() = 0; | 49 virtual void InspectPopup() = 0; |
| 45 | 50 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 75 private: | 80 private: |
| 76 friend class base::RefCounted<ExtensionContextMenuModel>; | 81 friend class base::RefCounted<ExtensionContextMenuModel>; |
| 77 virtual ~ExtensionContextMenuModel(); | 82 virtual ~ExtensionContextMenuModel(); |
| 78 | 83 |
| 79 void InitMenu(const extensions::Extension* extension); | 84 void InitMenu(const extensions::Extension* extension); |
| 80 | 85 |
| 81 // Gets the extension we are displaying the menu for. Returns NULL if the | 86 // Gets the extension we are displaying the menu for. Returns NULL if the |
| 82 // extension has been uninstalled and no longer exists. | 87 // extension has been uninstalled and no longer exists. |
| 83 const extensions::Extension* GetExtension() const; | 88 const extensions::Extension* GetExtension() const; |
| 84 | 89 |
| 90 // Returns the active web contents. |
| 91 content::WebContents* GetActiveWebContents() const; |
| 92 |
| 85 // A copy of the extension's id. | 93 // A copy of the extension's id. |
| 86 std::string extension_id_; | 94 std::string extension_id_; |
| 87 | 95 |
| 88 // The extension action of the extension we are displaying the menu for (if | 96 // The extension action of the extension we are displaying the menu for (if |
| 89 // it has one, otherwise NULL). | 97 // it has one, otherwise NULL). |
| 90 ExtensionAction* extension_action_; | 98 ExtensionAction* extension_action_; |
| 91 | 99 |
| 92 Browser* browser_; | 100 Browser* browser_; |
| 93 | 101 |
| 94 Profile* profile_; | 102 Profile* profile_; |
| 95 | 103 |
| 96 // The delegate which handles the 'inspect popup' menu command (or NULL). | 104 // The delegate which handles the 'inspect popup' menu command (or NULL). |
| 97 PopupDelegate* delegate_; | 105 PopupDelegate* delegate_; |
| 98 | 106 |
| 99 // Keeps track of the extension uninstall dialog. | 107 // Keeps track of the extension uninstall dialog. |
| 100 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; | 108 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; |
| 101 | 109 |
| 102 DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel); | 110 DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel); |
| 103 }; | 111 }; |
| 104 | 112 |
| 105 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ | 113 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ |
| OLD | NEW |