Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: chrome/browser/extensions/extension_context_menu_model.h

Issue 459493002: Revert of Extend contextMenus API to support browser/page actions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 extensions { 18 namespace extensions {
19 class Extension; 19 class Extension;
20 class ContextMenuMatcher;
21 class ExtensionContextMenuModelTest;
22 } 20 }
23 21
24 // The context menu model for extension icons. 22 // The context menu model for extension icons.
25 class ExtensionContextMenuModel 23 class ExtensionContextMenuModel
26 : public base::RefCounted<ExtensionContextMenuModel>, 24 : public base::RefCounted<ExtensionContextMenuModel>,
27 public ui::SimpleMenuModel, 25 public ui::SimpleMenuModel,
28 public ui::SimpleMenuModel::Delegate, 26 public ui::SimpleMenuModel::Delegate,
29 public extensions::ExtensionUninstallDialog::Delegate { 27 public extensions::ExtensionUninstallDialog::Delegate {
30 public: 28 public:
31 enum MenuEntries { 29 enum MenuEntries {
32 NAME = 0, 30 NAME = 0,
33 CONFIGURE, 31 CONFIGURE,
34 HIDE, 32 HIDE,
35 UNINSTALL, 33 UNINSTALL,
36 MANAGE, 34 MANAGE,
37 INSPECT_POPUP 35 INSPECT_POPUP
38 }; 36 };
39 37
40 // Type of action the extension icon represents.
41 enum ActionType { NO_ACTION = 0, BROWSER_ACTION, PAGE_ACTION };
42
43 // Delegate to handle showing an ExtensionAction popup. 38 // Delegate to handle showing an ExtensionAction popup.
44 class PopupDelegate { 39 class PopupDelegate {
45 public: 40 public:
46 // Called when the user selects the menu item which requests that the 41 // Called when the user selects the menu item which requests that the
47 // popup be shown and inspected. 42 // popup be shown and inspected.
48 // The delegate should know which popup to display. 43 // The delegate should know which popup to display.
49 virtual void InspectPopup() = 0; 44 virtual void InspectPopup() = 0;
50 45
51 protected: 46 protected:
52 virtual ~PopupDelegate() {} 47 virtual ~PopupDelegate() {}
(...skipping 19 matching lines...) Expand all
72 int command_id, 67 int command_id,
73 ui::Accelerator* accelerator) OVERRIDE; 68 ui::Accelerator* accelerator) OVERRIDE;
74 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; 69 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
75 70
76 // ExtensionUninstallDialog::Delegate: 71 // ExtensionUninstallDialog::Delegate:
77 virtual void ExtensionUninstallAccepted() OVERRIDE; 72 virtual void ExtensionUninstallAccepted() OVERRIDE;
78 virtual void ExtensionUninstallCanceled() OVERRIDE; 73 virtual void ExtensionUninstallCanceled() OVERRIDE;
79 74
80 private: 75 private:
81 friend class base::RefCounted<ExtensionContextMenuModel>; 76 friend class base::RefCounted<ExtensionContextMenuModel>;
82 friend class extensions::ExtensionContextMenuModelTest;
83
84 virtual ~ExtensionContextMenuModel(); 77 virtual ~ExtensionContextMenuModel();
85 78
86 void InitMenu(const extensions::Extension* extension); 79 void InitMenu(const extensions::Extension* extension);
87 80
88 // Gets the extension we are displaying the menu for. Returns NULL if the 81 // Gets the extension we are displaying the menu for. Returns NULL if the
89 // extension has been uninstalled and no longer exists. 82 // extension has been uninstalled and no longer exists.
90 const extensions::Extension* GetExtension() const; 83 const extensions::Extension* GetExtension() const;
91 84
92 // Appends the extension's context menu items.
93 void AppendExtensionItems();
94
95 // A copy of the extension's id. 85 // A copy of the extension's id.
96 std::string extension_id_; 86 std::string extension_id_;
97 87
98 // The extension action of the extension we are displaying the menu for (if 88 // The extension action of the extension we are displaying the menu for (if
99 // it has one, otherwise NULL). 89 // it has one, otherwise NULL).
100 ExtensionAction* extension_action_; 90 ExtensionAction* extension_action_;
101 91
102 Browser* browser_; 92 Browser* browser_;
103 93
104 Profile* profile_; 94 Profile* profile_;
105 95
106 // The delegate which handles the 'inspect popup' menu command (or NULL). 96 // The delegate which handles the 'inspect popup' menu command (or NULL).
107 PopupDelegate* delegate_; 97 PopupDelegate* delegate_;
108 98
109 // The type of extension action to which this context menu is attached.
110 ActionType action_type_;
111
112 // Keeps track of the extension uninstall dialog. 99 // Keeps track of the extension uninstall dialog.
113 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; 100 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_;
114 101
115 // Menu matcher for context menu items specified by the extension.
116 scoped_ptr<extensions::ContextMenuMatcher> extension_items_;
117
118 // Number of extension items in this menu. Used for testing.
119 int extension_items_count_;
120
121 DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel); 102 DISALLOW_COPY_AND_ASSIGN(ExtensionContextMenuModel);
122 }; 103 };
123 104
124 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_ 105 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/context_menu_matcher.cc ('k') | chrome/browser/extensions/extension_context_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698