summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_menu_manager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions/extension_menu_manager.cc')
-rw-r--r--chrome/browser/extensions/extension_menu_manager.cc45
1 files changed, 40 insertions, 5 deletions
diff --git a/chrome/browser/extensions/extension_menu_manager.cc b/chrome/browser/extensions/extension_menu_manager.cc
index 307c339..eae74f6 100644
--- a/chrome/browser/extensions/extension_menu_manager.cc
+++ b/chrome/browser/extensions/extension_menu_manager.cc
@@ -125,7 +125,7 @@ const ExtensionMenuItem::List* ExtensionMenuManager::MenuItems(
return NULL;
}
-bool ExtensionMenuManager::AddContextItem(Extension* extension,
+bool ExtensionMenuManager::AddContextItem(const Extension* extension,
ExtensionMenuItem* item) {
const std::string& extension_id = item->extension_id();
// The item must have a non-empty extension id, and not have already been
@@ -276,8 +276,10 @@ bool ExtensionMenuManager::RemoveContextMenuItem(
items_by_id_.erase(*removed_iter);
}
- if (list.empty())
+ if (list.empty()) {
+ context_items_.erase(extension_id);
icon_manager_.RemoveIcon(extension_id);
+ }
return result;
}
@@ -387,9 +389,9 @@ void ExtensionMenuManager::ExecuteCommand(
ListValue args;
DictionaryValue* properties = new DictionaryValue();
- properties->SetInteger("menuItemId", item->id().second);
+ properties->SetInteger("menuItemId", item->id().uid);
if (item->parent_id())
- properties->SetInteger("parentMenuItemId", item->parent_id()->second);
+ properties->SetInteger("parentMenuItemId", item->parent_id()->uid);
switch (params.media_type) {
case WebKit::WebContextMenuData::MediaTypeImage:
@@ -453,7 +455,7 @@ void ExtensionMenuManager::Observe(NotificationType type,
NOTREACHED();
return;
}
- Extension* extension = Details<Extension>(details).ptr();
+ const Extension* extension = Details<const Extension>(details).ptr();
if (ContainsKey(context_items_, extension->id())) {
RemoveAllContextItems(extension->id());
}
@@ -469,3 +471,36 @@ bool ExtensionMenuManager::HasAllowedScheme(const GURL& url) {
URLPattern pattern(kAllowedSchemes);
return pattern.SetScheme(url.scheme());
}
+
+ExtensionMenuItem::Id::Id()
+ : profile(NULL), uid(0) {
+}
+
+ExtensionMenuItem::Id::Id(Profile* profile, std::string extension_id, int uid)
+ : profile(profile), extension_id(extension_id), uid(uid) {
+}
+
+ExtensionMenuItem::Id::~Id() {
+}
+
+bool ExtensionMenuItem::Id::operator==(const Id& other) const {
+ return (profile == other.profile &&
+ extension_id == other.extension_id &&
+ uid == other.uid);
+}
+
+bool ExtensionMenuItem::Id::operator!=(const Id& other) const {
+ return !(*this == other);
+}
+
+bool ExtensionMenuItem::Id::operator<(const Id& other) const {
+ if (profile < other.profile)
+ return true;
+ if (profile == other.profile) {
+ if (extension_id < other.extension_id)
+ return true;
+ if (extension_id == other.extension_id)
+ return uid < other.uid;
+ }
+ return false;
+}