| Index: chrome/browser/extensions/menu_manager.h
|
| diff --git a/chrome/browser/extensions/menu_manager.h b/chrome/browser/extensions/menu_manager.h
|
| index ea6cecf90de2aec43d6ac8c8f05304b7d76a279c..94dd3a8afb22c072d6acb50708288a5cba46d94e 100644
|
| --- a/chrome/browser/extensions/menu_manager.h
|
| +++ b/chrome/browser/extensions/menu_manager.h
|
| @@ -42,6 +42,23 @@ class MenuItem {
|
| // A list of MenuItems.
|
| typedef std::vector<MenuItem*> List;
|
|
|
| + // Key used to identify which extension a menu item belongs to.
|
| + // |webview_instance_id| = 0 for regular extension items.
|
| + struct ExtensionKey {
|
| + std::string extension_id;
|
| + int webview_instance_id;
|
| +
|
| + ExtensionKey();
|
| + ExtensionKey(const std::string& extension_id, int webview_instance_id);
|
| + explicit ExtensionKey(const std::string& extension_id);
|
| +
|
| + bool operator==(const ExtensionKey& other) const;
|
| + bool operator!=(const ExtensionKey& other) const;
|
| + bool operator<(const ExtensionKey& other) const;
|
| +
|
| + bool empty() const;
|
| + };
|
| +
|
| // An Id uniquely identifies a context menu item registered by an extension.
|
| struct Id {
|
| Id();
|
| @@ -56,7 +73,7 @@ class MenuItem {
|
| bool operator<(const Id& other) const;
|
|
|
| bool incognito;
|
| - std::string extension_id;
|
| + ExtensionKey extension_key;
|
| // Only one of uid or string_uid will be defined.
|
| int uid;
|
| std::string string_uid;
|
| @@ -138,7 +155,9 @@ class MenuItem {
|
|
|
| // Simple accessor methods.
|
| bool incognito() const { return id_.incognito; }
|
| - const std::string& extension_id() const { return id_.extension_id; }
|
| + const std::string& extension_id() const {
|
| + return id_.extension_key.extension_id;
|
| + }
|
| const std::string& title() const { return title_; }
|
| const List& children() { return children_; }
|
| const Id& id() const { return id_; }
|
| @@ -262,7 +281,7 @@ class MenuManager : public content::NotificationObserver,
|
| // AddChildItem); although those can be reached via the top-level items'
|
| // children. A view can then decide how to display these, including whether to
|
| // put them into a submenu if there are more than 1.
|
| - const MenuItem::List* MenuItems(const std::string& extension_id);
|
| + const MenuItem::List* MenuItems(const MenuItem::ExtensionKey& extension_key);
|
|
|
| // Adds a top-level menu item for an extension, requiring the |extension|
|
| // pointer so it can load the icon for the extension. Takes ownership of
|
| @@ -287,8 +306,8 @@ class MenuManager : public content::NotificationObserver,
|
| // and removed or false otherwise.
|
| bool RemoveContextMenuItem(const MenuItem::Id& id);
|
|
|
| - // Removes all items for the given extension id.
|
| - void RemoveAllContextItems(const std::string& extension_id);
|
| + // Removes all items for the given extension specified by |extension_key|.
|
| + void RemoveAllContextItems(const MenuItem::ExtensionKey& extension_key);
|
|
|
| // Returns the item with the given |id| or NULL.
|
| MenuItem* GetItemById(const MenuItem::Id& id) const;
|
| @@ -315,7 +334,8 @@ class MenuManager : public content::NotificationObserver,
|
| const content::NotificationDetails& details) OVERRIDE;
|
|
|
| // Stores the menu items for the extension in the state storage.
|
| - void WriteToStorage(const Extension* extension);
|
| + void WriteToStorage(const Extension* extension,
|
| + const MenuItem::ExtensionKey& extension_key);
|
|
|
| // Reads menu items for the extension from the state storage. Any invalid
|
| // items are ignored.
|
| @@ -343,7 +363,7 @@ class MenuManager : public content::NotificationObserver,
|
| bool DescendantOf(MenuItem* item, const MenuItem::Id& ancestor_id);
|
|
|
| // We keep items organized by mapping an extension id to a list of items.
|
| - typedef std::map<std::string, MenuItem::List> MenuItemMap;
|
| + typedef std::map<MenuItem::ExtensionKey, MenuItem::List> MenuItemMap;
|
| MenuItemMap context_items_;
|
|
|
| // This lets us make lookup by id fast. It maps id to MenuItem* for
|
|
|