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 class ContextMenuMatcher; | 24 class ContextMenuMatcher; |
21 class ExtensionContextMenuModelTest; | 25 class ExtensionContextMenuModelTest; |
22 } | 26 } |
23 | 27 |
24 // The context menu model for extension icons. | 28 // The context menu model for extension icons. |
25 class ExtensionContextMenuModel | 29 class ExtensionContextMenuModel |
26 : public base::RefCounted<ExtensionContextMenuModel>, | 30 : public base::RefCounted<ExtensionContextMenuModel>, |
27 public ui::SimpleMenuModel, | 31 public ui::SimpleMenuModel, |
28 public ui::SimpleMenuModel::Delegate, | 32 public ui::SimpleMenuModel::Delegate, |
29 public extensions::ExtensionUninstallDialog::Delegate { | 33 public extensions::ExtensionUninstallDialog::Delegate { |
30 public: | 34 public: |
31 enum MenuEntries { | 35 enum MenuEntries { |
32 NAME = 0, | 36 NAME = 0, |
33 CONFIGURE, | 37 CONFIGURE, |
34 HIDE, | 38 HIDE, |
35 UNINSTALL, | 39 UNINSTALL, |
36 MANAGE, | 40 MANAGE, |
37 INSPECT_POPUP | 41 INSPECT_POPUP, |
| 42 ALWAYS_RUN |
38 }; | 43 }; |
39 | 44 |
40 // Type of action the extension icon represents. | 45 // Type of action the extension icon represents. |
41 enum ActionType { NO_ACTION = 0, BROWSER_ACTION, PAGE_ACTION }; | 46 enum ActionType { NO_ACTION = 0, BROWSER_ACTION, PAGE_ACTION }; |
42 | 47 |
43 // Delegate to handle showing an ExtensionAction popup. | 48 // Delegate to handle showing an ExtensionAction popup. |
44 class PopupDelegate { | 49 class PopupDelegate { |
45 public: | 50 public: |
46 // Called when the user selects the menu item which requests that the | 51 // Called when the user selects the menu item which requests that the |
47 // popup be shown and inspected. | 52 // popup be shown and inspected. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 friend class extensions::ExtensionContextMenuModelTest; | 87 friend class extensions::ExtensionContextMenuModelTest; |
83 | 88 |
84 virtual ~ExtensionContextMenuModel(); | 89 virtual ~ExtensionContextMenuModel(); |
85 | 90 |
86 void InitMenu(const extensions::Extension* extension); | 91 void InitMenu(const extensions::Extension* extension); |
87 | 92 |
88 // Gets the extension we are displaying the menu for. Returns NULL if the | 93 // Gets the extension we are displaying the menu for. Returns NULL if the |
89 // extension has been uninstalled and no longer exists. | 94 // extension has been uninstalled and no longer exists. |
90 const extensions::Extension* GetExtension() const; | 95 const extensions::Extension* GetExtension() const; |
91 | 96 |
| 97 // Returns the active web contents. |
| 98 content::WebContents* GetActiveWebContents() const; |
| 99 |
92 // Appends the extension's context menu items. | 100 // Appends the extension's context menu items. |
93 void AppendExtensionItems(); | 101 void AppendExtensionItems(); |
94 | 102 |
95 // A copy of the extension's id. | 103 // A copy of the extension's id. |
96 std::string extension_id_; | 104 std::string extension_id_; |
97 | 105 |
98 // The extension action of the extension we are displaying the menu for (if | 106 // The extension action of the extension we are displaying the menu for (if |
99 // it has one, otherwise NULL). | 107 // it has one, otherwise NULL). |
100 ExtensionAction* extension_action_; | 108 ExtensionAction* extension_action_; |
101 | 109 |
(...skipping 13 matching lines...) Expand all Loading... |
115 // Menu matcher for context menu items specified by the extension. | 123 // Menu matcher for context menu items specified by the extension. |
116 scoped_ptr<extensions::ContextMenuMatcher> extension_items_; | 124 scoped_ptr<extensions::ContextMenuMatcher> extension_items_; |
117 | 125 |
118 // Number of extension items in this menu. Used for testing. | 126 // Number of extension items in this menu. Used for testing. |
119 int extension_items_count_; | 127 int extension_items_count_; |
120 | 128 |
121 DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel); | 129 DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel); |
122 }; | 130 }; |
123 | 131 |
124 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ | 132 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ |
OLD | NEW |