diff options
author | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-03 23:20:49 +0000 |
---|---|---|
committer | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-03 23:20:49 +0000 |
commit | 63a414b5568551333549e0147b7bb77e8a0b329c (patch) | |
tree | 27515161ccd8ebfb7de557b2c7a93b0d0cbb0f66 /chrome/browser/extensions/extension_menu_manager.h | |
parent | 23607ccf23fce3ea302ba779a41e102fc3462dea (diff) | |
download | chromium_src-63a414b5568551333549e0147b7bb77e8a0b329c.zip chromium_src-63a414b5568551333549e0147b7bb77e8a0b329c.tar.gz chromium_src-63a414b5568551333549e0147b7bb77e8a0b329c.tar.bz2 |
Fix submenu support for extensions context menu API.
This fixes submenus which broke on all platforms during a recent refactor of
the RenderViewContextMenu class, and adds support for more than one level of
child menus.
BUG=39504
TEST=Create a test extension using the chrome.experimental.contextMenu API and
add multiple levels of child menu items.
Review URL: http://codereview.chromium.org/2443002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48892 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_menu_manager.h')
-rw-r--r-- | chrome/browser/extensions/extension_menu_manager.h | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/chrome/browser/extensions/extension_menu_manager.h b/chrome/browser/extensions/extension_menu_manager.h index 771bf19..e85f5d5 100644 --- a/chrome/browser/extensions/extension_menu_manager.h +++ b/chrome/browser/extensions/extension_menu_manager.h @@ -26,8 +26,8 @@ class TabContents; // Represents a menu item added by an extension. class ExtensionMenuItem { public: - // A list of owned ExtensionMenuItem's. - typedef std::vector<linked_ptr<ExtensionMenuItem> > List; + // A list of ExtensionMenuItem's. + typedef std::vector<ExtensionMenuItem*> List; // For context menus, these are the contexts where an item can appear and // potentially be enabled. @@ -89,6 +89,7 @@ class ExtensionMenuItem { // Simple accessor methods. const std::string& extension_id() const { return extension_id_; } const std::string& title() const { return title_; } + const List& children() { return children_; } int id() const { return id_; } int parent_id() const { return parent_id_; } int child_count() const { return children_.size(); } @@ -103,9 +104,6 @@ class ExtensionMenuItem { void set_enabled_contexts(ContextList contexts) { contexts_ = contexts; } void set_type(Type type) { type_ = type; } - // Returns the child at the given index, or NULL. - ExtensionMenuItem* ChildAt(int index) const; - // Returns the title with any instances of %s replaced by |selection|. string16 TitleWithReplacement(const string16& selection) const; @@ -121,9 +119,6 @@ class ExtensionMenuItem { id_ = id; } - // Provides direct access to the children of this item. - List* children() { return &children_; } - // Takes ownership of |item| and sets its parent_id_. void AddChild(ExtensionMenuItem* item); @@ -183,10 +178,9 @@ class ExtensionMenuManager : public NotificationObserver { // Returns a list of all the *top-level* menu items (added via AddContextItem) // for the given extension id, *not* including child items (added via // AddChildItem); although those can be reached via the top-level items' - // ChildAt function. A view can then decide how to display these, including - // whether to put them into a submenu if there are more than 1. - std::vector<const ExtensionMenuItem*> MenuItems( - const std::string& extension_id); + // 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 ExtensionMenuItem::List* MenuItems(const std::string& extension_id); // Takes ownership of |item|. Returns the id assigned to the item. Has the // side-effect of incrementing the next_item_id_ member. @@ -228,10 +222,6 @@ class ExtensionMenuManager : public NotificationObserver { // items in the same group (i.e. that are adjacent in the list). void RadioItemSelected(ExtensionMenuItem* item); - // If an item with |id| is found, |item| will be set to point to it and - // |index| will be set to its index within the containing list. - void GetItemAndIndex(int id, ExtensionMenuItem** item, size_t* index); - // Returns true if item is a descendant of an item with id |ancestor_id|. bool DescendantOf(ExtensionMenuItem* item, int ancestor_id); |