Index: chrome/browser/extensions/extension_context_menu_api.cc |
=================================================================== |
--- chrome/browser/extensions/extension_context_menu_api.cc (revision 116264) |
+++ chrome/browser/extensions/extension_context_menu_api.cc (working copy) |
@@ -269,6 +269,7 @@ |
} |
bool UpdateContextMenuFunction::RunImpl() { |
+ bool radioItemUpdated = false; |
ExtensionMenuItem::Id item_id(profile(), extension_id(), 0); |
EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &item_id.uid)); |
@@ -281,19 +282,21 @@ |
return false; |
} |
- DictionaryValue *properties = NULL; |
+ DictionaryValue* properties = NULL; |
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &properties)); |
EXTENSION_FUNCTION_VALIDATE(properties != NULL); |
- ExtensionMenuManager* menu_manager = |
- profile()->GetExtensionService()->menu_manager(); |
- |
// Type. |
ExtensionMenuItem::Type type; |
if (!ParseType(*properties, item->type(), &type)) |
return false; |
- if (type != item->type()) |
+ if (type != item->type()) { |
+ if (type == ExtensionMenuItem::RADIO || |
+ item->type() == ExtensionMenuItem::RADIO) { |
+ radioItemUpdated = true; |
+ } |
item->set_type(type); |
+ } |
// Title. |
if (properties->HasKey(kTitleKey)) { |
@@ -313,6 +316,7 @@ |
if (checked != item->checked()) { |
if (!item->SetChecked(checked)) |
return false; |
+ radioItemUpdated = true; |
} |
// Contexts. |
@@ -324,14 +328,19 @@ |
// Parent id. |
ExtensionMenuItem* parent = NULL; |
- if (!GetParent(*properties, *menu_manager, &parent)) |
+ if (!GetParent(*properties, *manager, &parent)) |
return false; |
- if (parent && !menu_manager->ChangeParent(item->id(), &parent->id())) |
+ if (parent && !manager->ChangeParent(item->id(), &parent->id())) |
return false; |
if (!SetURLPatterns(*properties, item)) |
return false; |
+ // There is no need to call ItemUpdated if ChangeParent is called because |
+ // all sanitation is taken care of in ChangeParent. |
+ if (!parent && radioItemUpdated && !manager->ItemUpdated(item->id())) |
+ return false; |
+ |
return true; |
} |