Chromium Code Reviews| 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 "content/public/common/context_menu_params.h" | |
| 12 #include "ui/base/models/simple_menu_model.h" | 13 #include "ui/base/models/simple_menu_model.h" |
| 13 | 14 |
| 14 class Browser; | 15 class Browser; |
| 15 class ExtensionAction; | 16 class ExtensionAction; |
| 16 class Profile; | 17 class Profile; |
| 17 | 18 |
| 18 namespace extensions { | 19 namespace extensions { |
| 19 class Extension; | 20 class Extension; |
| 21 class ContextMenuMatcher; | |
| 22 class MenuManager; | |
| 20 } | 23 } |
| 21 | 24 |
| 22 // The context menu model for extension icons. | 25 // The context menu model for extension icons. |
| 23 class ExtensionContextMenuModel | 26 class ExtensionContextMenuModel |
| 24 : public base::RefCounted<ExtensionContextMenuModel>, | 27 : public base::RefCounted<ExtensionContextMenuModel>, |
| 25 public ui::SimpleMenuModel, | 28 public ui::SimpleMenuModel, |
| 26 public ui::SimpleMenuModel::Delegate, | 29 public ui::SimpleMenuModel::Delegate, |
| 27 public extensions::ExtensionUninstallDialog::Delegate { | 30 public extensions::ExtensionUninstallDialog::Delegate { |
| 28 public: | 31 public: |
| 29 enum MenuEntries { | 32 enum MenuEntries { |
| 30 NAME = 0, | 33 NAME = 0, |
| 31 CONFIGURE, | 34 CONFIGURE, |
| 32 HIDE, | 35 HIDE, |
| 33 UNINSTALL, | 36 UNINSTALL, |
| 34 MANAGE, | 37 MANAGE, |
| 35 INSPECT_POPUP | 38 INSPECT_POPUP |
| 36 }; | 39 }; |
| 37 | 40 |
| 41 // Type of action the extension icon represents. | |
| 42 enum ActionType { | |
| 43 NO_ACTION = 0, | |
| 44 BROWSER_ACTION, | |
| 45 PAGE_ACTION | |
| 46 }; | |
| 47 | |
| 38 // Delegate to handle showing an ExtensionAction popup. | 48 // Delegate to handle showing an ExtensionAction popup. |
| 39 class PopupDelegate { | 49 class PopupDelegate { |
| 40 public: | 50 public: |
| 41 // 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 |
| 42 // popup be shown and inspected. | 52 // popup be shown and inspected. |
| 43 virtual void InspectPopup(ExtensionAction* action) = 0; | 53 virtual void InspectPopup(ExtensionAction* action) = 0; |
| 44 | 54 |
| 45 protected: | 55 protected: |
| 46 virtual ~PopupDelegate() {} | 56 virtual ~PopupDelegate() {} |
| 47 }; | 57 }; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 74 private: | 84 private: |
| 75 friend class base::RefCounted<ExtensionContextMenuModel>; | 85 friend class base::RefCounted<ExtensionContextMenuModel>; |
| 76 virtual ~ExtensionContextMenuModel(); | 86 virtual ~ExtensionContextMenuModel(); |
| 77 | 87 |
| 78 void InitMenu(const extensions::Extension* extension); | 88 void InitMenu(const extensions::Extension* extension); |
| 79 | 89 |
| 80 // Gets the extension we are displaying the menu for. Returns NULL if the | 90 // Gets the extension we are displaying the menu for. Returns NULL if the |
| 81 // extension has been uninstalled and no longer exists. | 91 // extension has been uninstalled and no longer exists. |
| 82 const extensions::Extension* GetExtension() const; | 92 const extensions::Extension* GetExtension() const; |
| 83 | 93 |
| 94 // Appends the extension's context menu items. | |
| 95 void AppendExtensionItems(); | |
| 96 | |
| 97 // Determines whether this context menu was created for a browser action or | |
| 98 // a page action. | |
| 99 ActionType GetActionType(const extensions::Extension* extension); | |
| 100 | |
| 84 // A copy of the extension's id. | 101 // A copy of the extension's id. |
| 85 std::string extension_id_; | 102 std::string extension_id_; |
| 86 | 103 |
| 87 // The extension action of the extension we are displaying the menu for (if | 104 // The extension action of the extension we are displaying the menu for (if |
| 88 // it has one, otherwise NULL). | 105 // it has one, otherwise NULL). |
| 89 ExtensionAction* extension_action_; | 106 ExtensionAction* extension_action_; |
| 90 | 107 |
| 91 Browser* browser_; | 108 Browser* browser_; |
| 92 | 109 |
| 93 Profile* profile_; | 110 Profile* profile_; |
| 94 | 111 |
| 95 // The delegate which handles the 'inspect popup' menu command (or NULL). | 112 // The delegate which handles the 'inspect popup' menu command (or NULL). |
| 96 PopupDelegate* delegate_; | 113 PopupDelegate* delegate_; |
| 97 | 114 |
| 115 ActionType action_type_; | |
|
Devlin
2014/07/02 17:25:21
comment.
gpdavis
2014/07/03 01:46:58
I'm not sure what to say about this that isn't exp
Devlin
2014/07/07 20:20:57
As a rule of thumb, the comment for the enum as a
gpdavis
2014/07/09 02:13:53
Done.
| |
| 116 | |
| 117 content::ContextMenuParams params_; | |
|
Devlin
2014/07/02 17:25:21
No need for this to be a member variable - you onl
gpdavis
2014/07/03 01:46:58
Done.
| |
| 118 | |
| 98 // Keeps track of the extension uninstall dialog. | 119 // Keeps track of the extension uninstall dialog. |
| 99 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; | 120 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; |
| 100 | 121 |
| 122 // Menu matcher for context menu items specified by the extension. | |
| 123 scoped_ptr<extensions::ContextMenuMatcher> extension_items_; | |
| 124 | |
| 101 DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel); | 125 DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel); |
| 102 }; | 126 }; |
| 103 | 127 |
| 104 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ | 128 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ |
| OLD | NEW |