blob: 1bf44022401779b6aa342720f22f1bc159261031 [file] [log] [blame]
[email protected]7dddebc32012-01-11 22:01:031// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]2e3b5202010-03-23 06:52:412// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]5aeeae12012-07-05 19:13:115#ifndef CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_
6#define CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_
[email protected]2e3b5202010-03-23 06:52:417
8#include <map>
9#include <set>
10#include <string>
11#include <vector>
12
13#include "base/basictypes.h"
[email protected]17902752011-08-31 22:52:5414#include "base/compiler_specific.h"
[email protected]2b07c93f2010-08-02 23:13:0415#include "base/gtest_prod_util.h"
[email protected]3b63f8f42011-03-28 01:54:1516#include "base/memory/scoped_ptr.h"
[email protected]bec64552012-06-13 20:25:4917#include "base/memory/weak_ptr.h"
[email protected]00ee2f52014-04-25 09:25:5218#include "base/scoped_observer.h"
[email protected]46acbf12013-06-10 18:43:4219#include "base/strings/string16.h"
[email protected]a0011472012-05-30 17:15:4020#include "base/values.h"
[email protected]b671760b2010-07-15 21:13:4721#include "chrome/browser/extensions/extension_icon_manager.h"
[email protected]b33f0b112014-03-13 17:05:3022#include "components/keyed_service/core/keyed_service.h"
[email protected]6c2381d2011-10-19 02:52:5323#include "content/public/browser/notification_observer.h"
24#include "content/public/browser/notification_registrar.h"
[email protected]00ee2f52014-04-25 09:25:5225#include "extensions/browser/extension_registry_observer.h"
[email protected]e9f541a2012-11-19 21:52:3126#include "extensions/common/url_pattern_set.h"
[email protected]2e3b5202010-03-23 06:52:4127
[email protected]b671760b2010-07-15 21:13:4728class SkBitmap;
[email protected]ea049a02011-12-25 21:37:0929
30namespace content {
[email protected]f5fede02014-07-29 02:48:2131class BrowserContext;
[email protected]ea049a02011-12-25 21:37:0932class WebContents;
[email protected]35be7ec2012-02-12 20:42:5133struct ContextMenuParams;
[email protected]ea049a02011-12-25 21:37:0934}
[email protected]2e3b5202010-03-23 06:52:4135
[email protected]1c321ee52012-05-21 03:02:3436namespace extensions {
37class Extension;
[email protected]00ee2f52014-04-25 09:25:5238class ExtensionRegistry;
[email protected]b673a5942013-11-14 11:14:1939class StateStore;
[email protected]1c321ee52012-05-21 03:02:3440
[email protected]2e3b5202010-03-23 06:52:4141// Represents a menu item added by an extension.
[email protected]5aeeae12012-07-05 19:13:1142class MenuItem {
[email protected]2e3b5202010-03-23 06:52:4143 public:
[email protected]5aeeae12012-07-05 19:13:1144 // A list of MenuItems.
45 typedef std::vector<MenuItem*> List;
[email protected]2e3b5202010-03-23 06:52:4146
paulmeyered437262015-07-09 16:05:2947 // Key used to identify which extension a menu item belongs to. A menu item
48 // can also belong to a <webview>, in which case |webview_embedder_process_id|
49 // and |webview_instance_id| will be non-zero. When two ExtensionKeys are
50 // compared, an empty |extension_id| will match any other extension ID. This
51 // allows menu items belonging to webviews to be found with only the two
52 // webview IDs when the extension ID is not known. This is currently done from
53 // ChromeExtensionsBrowserClient::CleanUpWebView().
[email protected]6f9d2c62014-03-10 12:12:0554 struct ExtensionKey {
55 std::string extension_id;
paulmeyered437262015-07-09 16:05:2956 int webview_embedder_process_id;
[email protected]6f9d2c62014-03-10 12:12:0557 int webview_instance_id;
58
59 ExtensionKey();
[email protected]6f9d2c62014-03-10 12:12:0560 explicit ExtensionKey(const std::string& extension_id);
paulmeyered437262015-07-09 16:05:2961 ExtensionKey(const std::string& extension_id,
62 int webview_embedder_process_id,
63 int webview_instance_id);
[email protected]6f9d2c62014-03-10 12:12:0564
65 bool operator==(const ExtensionKey& other) const;
66 bool operator!=(const ExtensionKey& other) const;
67 bool operator<(const ExtensionKey& other) const;
68
69 bool empty() const;
70 };
71
[email protected]5a7b5eaf2010-11-02 20:52:1972 // An Id uniquely identifies a context menu item registered by an extension.
73 struct Id {
74 Id();
[email protected]619c5dba2012-05-16 00:44:4875 // Since the unique ID (uid or string_uid) is parsed from API arguments,
76 // the normal usage is to set the uid or string_uid immediately after
77 // construction.
[email protected]6f9d2c62014-03-10 12:12:0578 Id(bool incognito, const ExtensionKey& extension_key);
[email protected]5a7b5eaf2010-11-02 20:52:1979 ~Id();
80
81 bool operator==(const Id& other) const;
82 bool operator!=(const Id& other) const;
83 bool operator<(const Id& other) const;
84
[email protected]9a4cb812012-05-23 20:32:3285 bool incognito;
[email protected]6f9d2c62014-03-10 12:12:0586 ExtensionKey extension_key;
[email protected]619c5dba2012-05-16 00:44:4887 // Only one of uid or string_uid will be defined.
[email protected]5a7b5eaf2010-11-02 20:52:1988 int uid;
[email protected]619c5dba2012-05-16 00:44:4889 std::string string_uid;
[email protected]5a7b5eaf2010-11-02 20:52:1990 };
[email protected]9e9d7912010-07-18 21:05:2891
[email protected]a11fa342010-07-09 16:56:0092 // For context menus, these are the contexts where an item can appear.
[email protected]2e3b5202010-03-23 06:52:4193 enum Context {
94 ALL = 1,
95 PAGE = 2,
96 SELECTION = 4,
97 LINK = 8,
98 EDITABLE = 16,
99 IMAGE = 32,
100 VIDEO = 64,
101 AUDIO = 128,
[email protected]0e5e8d52011-04-06 21:02:51102 FRAME = 256,
[email protected]69e1c12d2014-08-13 08:25:34103 LAUNCHER = 512,
104 BROWSER_ACTION = 1024,
105 PAGE_ACTION = 2048
[email protected]2e3b5202010-03-23 06:52:41106 };
107
108 // An item can be only one of these types.
109 enum Type {
110 NORMAL,
111 CHECKBOX,
112 RADIO,
113 SEPARATOR
114 };
115
[email protected]a11fa342010-07-09 16:56:00116 // A list of Contexts for an item.
[email protected]2e3b5202010-03-23 06:52:41117 class ContextList {
118 public:
119 ContextList() : value_(0) {}
120 explicit ContextList(Context context) : value_(context) {}
121 ContextList(const ContextList& other) : value_(other.value_) {}
122
123 void operator=(const ContextList& other) {
124 value_ = other.value_;
125 }
126
[email protected]66dbfb2c2010-05-12 20:20:15127 bool operator==(const ContextList& other) const {
128 return value_ == other.value_;
129 }
130
131 bool operator!=(const ContextList& other) const {
132 return !(*this == other);
133 }
134
[email protected]2e3b5202010-03-23 06:52:41135 bool Contains(Context context) const {
136 return (value_ & context) > 0;
137 }
138
139 void Add(Context context) {
140 value_ |= context;
141 }
142
[email protected]aeca23f2013-06-21 22:34:41143 scoped_ptr<base::Value> ToValue() const {
[email protected]aa15e2e2013-08-14 02:13:58144 return scoped_ptr<base::Value>(
145 new base::FundamentalValue(static_cast<int>(value_)));
[email protected]a0011472012-05-30 17:15:40146 }
147
[email protected]aeca23f2013-06-21 22:34:41148 bool Populate(const base::Value& value) {
[email protected]a0011472012-05-30 17:15:40149 int int_value;
150 if (!value.GetAsInteger(&int_value) || int_value < 0)
151 return false;
152 value_ = int_value;
153 return true;
154 }
155
[email protected]2e3b5202010-03-23 06:52:41156 private:
157 uint32 value_; // A bitmask of Context values.
158 };
159
[email protected]5aeeae12012-07-05 19:13:11160 MenuItem(const Id& id,
161 const std::string& title,
162 bool checked,
163 bool enabled,
164 Type type,
165 const ContextList& contexts);
166 virtual ~MenuItem();
[email protected]2e3b5202010-03-23 06:52:41167
168 // Simple accessor methods.
[email protected]9a4cb812012-05-23 20:32:32169 bool incognito() const { return id_.incognito; }
[email protected]6f9d2c62014-03-10 12:12:05170 const std::string& extension_id() const {
171 return id_.extension_key.extension_id;
172 }
[email protected]2e3b5202010-03-23 06:52:41173 const std::string& title() const { return title_; }
[email protected]63a414b52010-06-03 23:20:49174 const List& children() { return children_; }
[email protected]f4f04592010-07-14 20:40:13175 const Id& id() const { return id_; }
176 Id* parent_id() const { return parent_id_.get(); }
[email protected]2e3b5202010-03-23 06:52:41177 int child_count() const { return children_.size(); }
[email protected]69e1c12d2014-08-13 08:25:34178 const ContextList& contexts() const { return contexts_; }
[email protected]2e3b5202010-03-23 06:52:41179 Type type() const { return type_; }
180 bool checked() const { return checked_; }
[email protected]d4a8b7a2012-04-03 07:27:13181 bool enabled() const { return enabled_; }
[email protected]cced75a2011-05-20 08:31:12182 const URLPatternSet& document_url_patterns() const {
[email protected]9e9d7912010-07-18 21:05:28183 return document_url_patterns_;
184 }
[email protected]cced75a2011-05-20 08:31:12185 const URLPatternSet& target_url_patterns() const {
[email protected]9e9d7912010-07-18 21:05:28186 return target_url_patterns_;
187 }
[email protected]2e3b5202010-03-23 06:52:41188
[email protected]66dbfb2c2010-05-12 20:20:15189 // Simple mutator methods.
[email protected]48329f92011-03-28 19:38:22190 void set_title(const std::string& new_title) { title_ = new_title; }
[email protected]66dbfb2c2010-05-12 20:20:15191 void set_contexts(ContextList contexts) { contexts_ = contexts; }
[email protected]66dbfb2c2010-05-12 20:20:15192 void set_type(Type type) { type_ = type; }
[email protected]d4a8b7a2012-04-03 07:27:13193 void set_enabled(bool enabled) { enabled_ = enabled; }
[email protected]cced75a2011-05-20 08:31:12194 void set_document_url_patterns(const URLPatternSet& patterns) {
[email protected]9e9d7912010-07-18 21:05:28195 document_url_patterns_ = patterns;
196 }
[email protected]cced75a2011-05-20 08:31:12197 void set_target_url_patterns(const URLPatternSet& patterns) {
[email protected]9e9d7912010-07-18 21:05:28198 target_url_patterns_ = patterns;
199 }
[email protected]66dbfb2c2010-05-12 20:20:15200
[email protected]745feedb2010-08-02 04:08:07201 // Returns the title with any instances of %s replaced by |selection|. The
202 // result will be no longer than |max_length|.
[email protected]439f1e32013-12-09 20:09:09203 base::string16 TitleWithReplacement(const base::string16& selection,
[email protected]745feedb2010-08-02 04:08:07204 size_t max_length) const;
[email protected]2e3b5202010-03-23 06:52:41205
[email protected]a0011472012-05-30 17:15:40206 // Sets the checked state to |checked|. Returns true if successful.
[email protected]66dbfb2c2010-05-12 20:20:15207 bool SetChecked(bool checked);
208
[email protected]a0011472012-05-30 17:15:40209 // Converts to Value for serialization to preferences.
210 scoped_ptr<base::DictionaryValue> ToValue() const;
211
[email protected]5aeeae12012-07-05 19:13:11212 // Returns a new MenuItem created from |value|, or NULL if there is
213 // an error. The caller takes ownership of the MenuItem.
214 static MenuItem* Populate(const std::string& extension_id,
[email protected]aeca23f2013-06-21 22:34:41215 const base::DictionaryValue& value,
[email protected]5aeeae12012-07-05 19:13:11216 std::string* error);
[email protected]a0011472012-05-30 17:15:40217
218 // Sets any document and target URL patterns from |properties|.
[email protected]8af81c02012-08-14 23:06:15219 bool PopulateURLPatterns(std::vector<std::string>* document_url_patterns,
220 std::vector<std::string>* target_url_patterns,
[email protected]a0011472012-05-30 17:15:40221 std::string* error);
222
[email protected]2e3b5202010-03-23 06:52:41223 protected:
[email protected]5aeeae12012-07-05 19:13:11224 friend class MenuManager;
[email protected]2e3b5202010-03-23 06:52:41225
[email protected]2e3b5202010-03-23 06:52:41226 // Takes ownership of |item| and sets its parent_id_.
[email protected]5aeeae12012-07-05 19:13:11227 void AddChild(MenuItem* item);
[email protected]2e3b5202010-03-23 06:52:41228
[email protected]66dbfb2c2010-05-12 20:20:15229 // Takes the child item from this parent. The item is returned and the caller
230 // then owns the pointer.
[email protected]5aeeae12012-07-05 19:13:11231 MenuItem* ReleaseChild(const Id& child_id, bool recursive);
[email protected]66dbfb2c2010-05-12 20:20:15232
[email protected]a0011472012-05-30 17:15:40233 // Recursively appends all descendant items (children, grandchildren, etc.)
234 // to the output |list|.
[email protected]5aeeae12012-07-05 19:13:11235 void GetFlattenedSubtree(MenuItem::List* list);
[email protected]a0011472012-05-30 17:15:40236
[email protected]66dbfb2c2010-05-12 20:20:15237 // Recursively removes all descendant items (children, grandchildren, etc.),
238 // returning the ids of the removed items.
[email protected]f4f04592010-07-14 20:40:13239 std::set<Id> RemoveAllDescendants();
[email protected]66dbfb2c2010-05-12 20:20:15240
[email protected]2e3b5202010-03-23 06:52:41241 private:
[email protected]f4f04592010-07-14 20:40:13242 // The unique id for this item.
243 Id id_;
[email protected]2e3b5202010-03-23 06:52:41244
245 // What gets shown in the menu for this item.
246 std::string title_;
247
[email protected]2e3b5202010-03-23 06:52:41248 Type type_;
249
250 // This should only be true for items of type CHECKBOX or RADIO.
251 bool checked_;
252
[email protected]d4a8b7a2012-04-03 07:27:13253 // If the item is enabled or not.
254 bool enabled_;
255
[email protected]2e3b5202010-03-23 06:52:41256 // In what contexts should the item be shown?
257 ContextList contexts_;
258
[email protected]2e3b5202010-03-23 06:52:41259 // If this item is a child of another item, the unique id of its parent. If
[email protected]f4f04592010-07-14 20:40:13260 // this is a top-level item with no parent, this will be NULL.
261 scoped_ptr<Id> parent_id_;
[email protected]2e3b5202010-03-23 06:52:41262
[email protected]9e9d7912010-07-18 21:05:28263 // Patterns for restricting what documents this item will appear for. This
264 // applies to the frame where the click took place.
[email protected]cced75a2011-05-20 08:31:12265 URLPatternSet document_url_patterns_;
[email protected]9e9d7912010-07-18 21:05:28266
267 // Patterns for restricting where items appear based on the src/href
268 // attribute of IMAGE/AUDIO/VIDEO/LINK tags.
[email protected]cced75a2011-05-20 08:31:12269 URLPatternSet target_url_patterns_;
[email protected]9e9d7912010-07-18 21:05:28270
[email protected]2e3b5202010-03-23 06:52:41271 // Any children this item may have.
272 List children_;
273
[email protected]5aeeae12012-07-05 19:13:11274 DISALLOW_COPY_AND_ASSIGN(MenuItem);
[email protected]2e3b5202010-03-23 06:52:41275};
276
277// This class keeps track of menu items added by extensions.
[email protected]5aeeae12012-07-05 19:13:11278class MenuManager : public content::NotificationObserver,
[email protected]b673a5942013-11-14 11:14:19279 public base::SupportsWeakPtr<MenuManager>,
[email protected]00ee2f52014-04-25 09:25:52280 public KeyedService,
281 public ExtensionRegistryObserver {
[email protected]2e3b5202010-03-23 06:52:41282 public:
[email protected]db6bf7f2014-03-27 15:49:26283 static const char kOnContextMenus[];
284 static const char kOnWebviewContextMenus[];
285
[email protected]f5fede02014-07-29 02:48:21286 MenuManager(content::BrowserContext* context, StateStore* store_);
dchengae36a4a2014-10-21 12:36:36287 ~MenuManager() override;
[email protected]2e3b5202010-03-23 06:52:41288
[email protected]f5fede02014-07-29 02:48:21289 // Convenience function to get the MenuManager for a browser context.
290 static MenuManager* Get(content::BrowserContext* context);
[email protected]b673a5942013-11-14 11:14:19291
[email protected]6f9d2c62014-03-10 12:12:05292 // Returns the keys of extensions which have menu items registered.
293 std::set<MenuItem::ExtensionKey> ExtensionIds();
[email protected]2e3b5202010-03-23 06:52:41294
295 // Returns a list of all the *top-level* menu items (added via AddContextItem)
[email protected]6f9d2c62014-03-10 12:12:05296 // for the given extension specified by |extension_key|, *not* including child
297 // items (added via AddChildItem); although those can be reached via the
298 // top-level items' children. A view can then decide how to display these,
299 // including whether to put them into a submenu if there are more than 1.
300 const MenuItem::List* MenuItems(const MenuItem::ExtensionKey& extension_key);
[email protected]2e3b5202010-03-23 06:52:41301
[email protected]052c92702010-06-25 07:25:52302 // Adds a top-level menu item for an extension, requiring the |extension|
303 // pointer so it can load the icon for the extension. Takes ownership of
[email protected]f4f04592010-07-14 20:40:13304 // |item|. Returns a boolean indicating success or failure.
[email protected]5aeeae12012-07-05 19:13:11305 bool AddContextItem(const Extension* extension, MenuItem* item);
[email protected]2e3b5202010-03-23 06:52:41306
307 // Add an item as a child of another item which has been previously added, and
[email protected]f4f04592010-07-14 20:40:13308 // takes ownership of |item|. Returns a boolean indicating success or failure.
[email protected]5aeeae12012-07-05 19:13:11309 bool AddChildItem(const MenuItem::Id& parent_id,
310 MenuItem* child);
[email protected]2e3b5202010-03-23 06:52:41311
[email protected]66dbfb2c2010-05-12 20:20:15312 // Makes existing item with |child_id| a child of the item with |parent_id|.
313 // If the child item was already a child of another parent, this will remove
314 // it from that parent first. It is an error to try and move an item to be a
[email protected]f4f04592010-07-14 20:40:13315 // child of one of its own descendants. It is legal to pass NULL for
316 // |parent_id|, which means the item should be moved to the top-level.
[email protected]5aeeae12012-07-05 19:13:11317 bool ChangeParent(const MenuItem::Id& child_id,
318 const MenuItem::Id* parent_id);
[email protected]66dbfb2c2010-05-12 20:20:15319
[email protected]2e3b5202010-03-23 06:52:41320 // Removes a context menu item with the given id (whether it is a top-level
321 // item or a child of some other item), returning true if the item was found
322 // and removed or false otherwise.
[email protected]5aeeae12012-07-05 19:13:11323 bool RemoveContextMenuItem(const MenuItem::Id& id);
[email protected]2e3b5202010-03-23 06:52:41324
[email protected]6f9d2c62014-03-10 12:12:05325 // Removes all items for the given extension specified by |extension_key|.
326 void RemoveAllContextItems(const MenuItem::ExtensionKey& extension_key);
[email protected]66dbfb2c2010-05-12 20:20:15327
[email protected]2e3b5202010-03-23 06:52:41328 // Returns the item with the given |id| or NULL.
[email protected]5aeeae12012-07-05 19:13:11329 MenuItem* GetItemById(const MenuItem::Id& id) const;
[email protected]2e3b5202010-03-23 06:52:41330
[email protected]5aeeae12012-07-05 19:13:11331 // Notify the MenuManager that an item has been updated not through
332 // an explicit call into MenuManager. For example, if an item is
[email protected]7dddebc32012-01-11 22:01:03333 // acquired by a call to GetItemById and changed, then this should be called.
334 // Returns true if the item was found or false otherwise.
[email protected]5aeeae12012-07-05 19:13:11335 bool ItemUpdated(const MenuItem::Id& id);
[email protected]7dddebc32012-01-11 22:01:03336
[email protected]2e3b5202010-03-23 06:52:41337 // Called when a menu item is clicked on by the user.
[email protected]f5fede02014-07-29 02:48:21338 void ExecuteCommand(content::BrowserContext* context,
[email protected]33a86dbd2012-06-20 03:20:18339 content::WebContents* web_contents,
[email protected]35be7ec2012-02-12 20:42:51340 const content::ContextMenuParams& params,
[email protected]5aeeae12012-07-05 19:13:11341 const MenuItem::Id& menu_item_id);
[email protected]2e3b5202010-03-23 06:52:41342
[email protected]f23a8c12011-03-15 14:43:43343 // This returns a bitmap of width/height kFaviconSize, loaded either from an
[email protected]052c92702010-06-25 07:25:52344 // entry specified in the extension's 'icon' section of the manifest, or a
345 // default extension icon.
346 const SkBitmap& GetIconForExtension(const std::string& extension_id);
347
[email protected]00ee2f52014-04-25 09:25:52348 // content::NotificationObserver implementation.
dchengae36a4a2014-10-21 12:36:36349 void Observe(int type,
350 const content::NotificationSource& source,
351 const content::NotificationDetails& details) override;
[email protected]052c92702010-06-25 07:25:52352
[email protected]00ee2f52014-04-25 09:25:52353 // ExtensionRegistryObserver implementation.
dchengae36a4a2014-10-21 12:36:36354 void OnExtensionLoaded(content::BrowserContext* browser_context,
355 const Extension* extension) override;
356 void OnExtensionUnloaded(content::BrowserContext* browser_context,
357 const Extension* extension,
358 UnloadedExtensionInfo::Reason reason) override;
[email protected]00ee2f52014-04-25 09:25:52359
[email protected]bec64552012-06-13 20:25:49360 // Stores the menu items for the extension in the state storage.
[email protected]6f9d2c62014-03-10 12:12:05361 void WriteToStorage(const Extension* extension,
362 const MenuItem::ExtensionKey& extension_key);
[email protected]a0011472012-05-30 17:15:40363
[email protected]bec64552012-06-13 20:25:49364 // Reads menu items for the extension from the state storage. Any invalid
[email protected]a0011472012-05-30 17:15:40365 // items are ignored.
[email protected]bec64552012-06-13 20:25:49366 void ReadFromStorage(const std::string& extension_id,
367 scoped_ptr<base::Value> value);
[email protected]a0011472012-05-30 17:15:40368
[email protected]63503462012-10-30 22:14:31369 // Removes all "incognito" "split" mode context items.
370 void RemoveAllIncognitoContextItems();
371
[email protected]2e3b5202010-03-23 06:52:41372 private:
[email protected]5aeeae12012-07-05 19:13:11373 FRIEND_TEST_ALL_PREFIXES(MenuManagerTest, DeleteParent);
374 FRIEND_TEST_ALL_PREFIXES(MenuManagerTest, RemoveOneByOne);
[email protected]2b07c93f2010-08-02 23:13:04375
[email protected]2e3b5202010-03-23 06:52:41376 // This is a helper function which takes care of de-selecting any other radio
377 // items in the same group (i.e. that are adjacent in the list).
[email protected]5aeeae12012-07-05 19:13:11378 void RadioItemSelected(MenuItem* item);
[email protected]2e3b5202010-03-23 06:52:41379
[email protected]7dddebc32012-01-11 22:01:03380 // Make sure that there is only one radio item selected at once in any run.
381 // If there are no radio items selected, then the first item in the run
382 // will get selected. If there are multiple radio items selected, then only
383 // the last one will get selcted.
[email protected]5aeeae12012-07-05 19:13:11384 void SanitizeRadioList(const MenuItem::List& item_list);
[email protected]7dddebc32012-01-11 22:01:03385
[email protected]66dbfb2c2010-05-12 20:20:15386 // Returns true if item is a descendant of an item with id |ancestor_id|.
[email protected]5aeeae12012-07-05 19:13:11387 bool DescendantOf(MenuItem* item, const MenuItem::Id& ancestor_id);
[email protected]66dbfb2c2010-05-12 20:20:15388
[email protected]6f9d2c62014-03-10 12:12:05389 // We keep items organized by mapping ExtensionKey to a list of items.
390 typedef std::map<MenuItem::ExtensionKey, MenuItem::List> MenuItemMap;
[email protected]2e3b5202010-03-23 06:52:41391 MenuItemMap context_items_;
392
[email protected]5aeeae12012-07-05 19:13:11393 // This lets us make lookup by id fast. It maps id to MenuItem* for
[email protected]2e3b5202010-03-23 06:52:41394 // all items the menu manager knows about, including all children of top-level
395 // items.
[email protected]5aeeae12012-07-05 19:13:11396 std::map<MenuItem::Id, MenuItem*> items_by_id_;
[email protected]2e3b5202010-03-23 06:52:41397
[email protected]6c2381d2011-10-19 02:52:53398 content::NotificationRegistrar registrar_;
[email protected]2e3b5202010-03-23 06:52:41399
[email protected]00ee2f52014-04-25 09:25:52400 // Listen to extension load, unloaded notifications.
401 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
402 extension_registry_observer_;
403
[email protected]b671760b2010-07-15 21:13:47404 ExtensionIconManager icon_manager_;
[email protected]052c92702010-06-25 07:25:52405
[email protected]f5fede02014-07-29 02:48:21406 content::BrowserContext* browser_context_;
[email protected]a0011472012-05-30 17:15:40407
[email protected]b673a5942013-11-14 11:14:19408 // Owned by ExtensionSystem.
409 StateStore* store_;
410
[email protected]5aeeae12012-07-05 19:13:11411 DISALLOW_COPY_AND_ASSIGN(MenuManager);
[email protected]2e3b5202010-03-23 06:52:41412};
413
[email protected]5aeeae12012-07-05 19:13:11414} // namespace extensions
415
416#endif // CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_