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

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

Issue 359493005: Extend contextMenus API to support browser/page actions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moar minor changes Created 6 years, 5 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 "content/public/common/context_menu_params.h"
Devlin 2014/07/07 20:20:58 Do we still need this?
gpdavis 2014/07/09 02:13:54 Done.
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;
Devlin 2014/07/07 20:20:58 DO we still need this?
gpdavis 2014/07/09 02:13:54 Done.
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
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_;
116
98 // Keeps track of the extension uninstall dialog. 117 // Keeps track of the extension uninstall dialog.
99 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; 118 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_;
100 119
120 // Menu matcher for context menu items specified by the extension.
121 scoped_ptr<extensions::ContextMenuMatcher> extension_items_;
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698