Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1603)

Unified Diff: chrome/browser/extensions/menu_manager.cc

Issue 10694085: Refactor extension event distribution to use Values instead of JSON strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing memory leak in a test. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/menu_manager.cc
diff --git a/chrome/browser/extensions/menu_manager.cc b/chrome/browser/extensions/menu_manager.cc
index 92154f981e8a0f222515f477b05df60376a12daa..657d32a2ca12a8007eeb41ad6be74e96fef2a85c 100644
--- a/chrome/browser/extensions/menu_manager.cc
+++ b/chrome/browser/extensions/menu_manager.cc
@@ -584,7 +584,7 @@ void MenuManager::ExecuteCommand(Profile* profile,
if (item->type() == MenuItem::RADIO)
RadioItemSelected(item);
- ListValue args;
+ scoped_ptr<ListValue> args(new ListValue());
DictionaryValue* properties = new DictionaryValue();
SetIdKeyValue(properties, "menuItemId", item->id());
@@ -614,14 +614,14 @@ void MenuManager::ExecuteCommand(Profile* profile,
properties->SetBoolean("editable", params.is_editable);
- args.Append(properties);
+ args->Append(properties);
// Add the tab info to the argument list.
// Note: web_contents only NULL in unit tests :(
if (web_contents)
- args.Append(ExtensionTabUtil::CreateTabValue(web_contents));
+ args->Append(ExtensionTabUtil::CreateTabValue(web_contents));
else
- args.Append(new DictionaryValue());
+ args->Append(new DictionaryValue());
if (item->type() == MenuItem::CHECKBOX ||
item->type() == MenuItem::RADIO) {
@@ -647,15 +647,13 @@ void MenuManager::ExecuteCommand(Profile* profile,
GrantIfRequested(extension);
}
- std::string json_args;
- base::JSONWriter::Write(&args, &json_args);
event_router->DispatchEventToExtension(
item->extension_id(), event_names::kOnContextMenus,
- json_args, profile, GURL(),
+ scoped_ptr<ListValue>(args->DeepCopy()), profile, GURL(),
EventRouter::USER_GESTURE_ENABLED);
event_router->DispatchEventToExtension(
item->extension_id(), event_names::kOnContextMenuClicked,
- json_args, profile, GURL(),
+ args.Pass(), profile, GURL(),
EventRouter::USER_GESTURE_ENABLED);
}
« no previous file with comments | « chrome/browser/extensions/extension_processes_api.cc ('k') | chrome/browser/extensions/menu_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698