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/context_menu_matcher.h" | |
11 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 12 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
13 #include "chrome/browser/extensions/menu_manager.h" | |
12 #include "ui/base/models/simple_menu_model.h" | 14 #include "ui/base/models/simple_menu_model.h" |
13 | 15 |
14 class Browser; | 16 class Browser; |
15 class ExtensionAction; | 17 class ExtensionAction; |
16 class Profile; | 18 class Profile; |
17 | 19 |
18 namespace extensions { | 20 namespace extensions { |
19 class Extension; | 21 class Extension; |
20 } | 22 } |
21 | 23 |
22 // The context menu model for extension icons. | 24 // The context menu model for extension icons. |
23 class ExtensionContextMenuModel | 25 class ExtensionContextMenuModel |
24 : public base::RefCounted<ExtensionContextMenuModel>, | 26 : public base::RefCounted<ExtensionContextMenuModel>, |
25 public ui::SimpleMenuModel, | 27 public ui::SimpleMenuModel, |
26 public ui::SimpleMenuModel::Delegate, | 28 public ui::SimpleMenuModel::Delegate, |
27 public extensions::ExtensionUninstallDialog::Delegate { | 29 public extensions::ExtensionUninstallDialog::Delegate { |
28 public: | 30 public: |
29 enum MenuEntries { | 31 enum MenuEntries { |
30 NAME = 0, | 32 NAME = 0, |
31 CONFIGURE, | 33 CONFIGURE, |
32 HIDE, | 34 HIDE, |
33 UNINSTALL, | 35 UNINSTALL, |
34 MANAGE, | 36 MANAGE, |
35 INSPECT_POPUP | 37 INSPECT_POPUP |
36 }; | 38 }; |
37 | 39 |
40 enum ActionType { | |
Yoyo Zhou
2014/06/27 23:37:57
This should definitely have a default 'none' (NO_A
gpdavis
2014/06/28 00:05:41
I was under the impression that this class was spe
gpdavis
2014/06/30 21:11:11
Ah, you're right. The second constructor is calle
| |
41 BROWSER_ACTION = 0, | |
42 PAGE_ACTION | |
43 }; | |
44 | |
38 // Delegate to handle showing an ExtensionAction popup. | 45 // Delegate to handle showing an ExtensionAction popup. |
39 class PopupDelegate { | 46 class PopupDelegate { |
40 public: | 47 public: |
41 // Called when the user selects the menu item which requests that the | 48 // Called when the user selects the menu item which requests that the |
42 // popup be shown and inspected. | 49 // popup be shown and inspected. |
43 virtual void InspectPopup(ExtensionAction* action) = 0; | 50 virtual void InspectPopup(ExtensionAction* action) = 0; |
44 | 51 |
45 protected: | 52 protected: |
46 virtual ~PopupDelegate() {} | 53 virtual ~PopupDelegate() {} |
47 }; | 54 }; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 // it has one, otherwise NULL). | 95 // it has one, otherwise NULL). |
89 ExtensionAction* extension_action_; | 96 ExtensionAction* extension_action_; |
90 | 97 |
91 Browser* browser_; | 98 Browser* browser_; |
92 | 99 |
93 Profile* profile_; | 100 Profile* profile_; |
94 | 101 |
95 // The delegate which handles the 'inspect popup' menu command (or NULL). | 102 // The delegate which handles the 'inspect popup' menu command (or NULL). |
96 PopupDelegate* delegate_; | 103 PopupDelegate* delegate_; |
97 | 104 |
105 ActionType action_type_; | |
106 | |
98 // Keeps track of the extension uninstall dialog. | 107 // Keeps track of the extension uninstall dialog. |
99 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; | 108 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; |
100 | 109 |
110 // Menu matcher for extensions context menu items. | |
Yoyo Zhou
2014/06/27 23:37:57
This should be more specific - these are the ones
gpdavis
2014/06/30 21:11:11
Done.
| |
111 extensions::ContextMenuMatcher extension_items_; | |
112 | |
113 void AppendExtensionItems(); | |
Yoyo Zhou
2014/06/27 23:37:57
Private functions should go above members.
gpdavis
2014/06/30 21:11:11
Done.
| |
114 | |
115 // Determines whether this context menu was created for a browser action or | |
116 // a page action. | |
117 ActionType GetActionType(const extensions::Extension* extension); | |
118 | |
119 // Matches extensions menu items by ActionType. | |
120 static bool MenuItemMatchesContext(ActionType type, | |
121 const extensions::MenuItem* item); | |
122 | |
101 DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel); | 123 DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel); |
102 }; | 124 }; |
103 | 125 |
104 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ | 126 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ |
OLD | NEW |