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

Unified Diff: chrome/browser/extensions/api/app/app_api.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/api/app/app_api.cc
diff --git a/chrome/browser/extensions/api/app/app_api.cc b/chrome/browser/extensions/api/app/app_api.cc
index ff4e2aa0c1e6897ccd0b3b07fe421fd7a2dc6dc9..22ccab68a4cb7ae663f60c773569eed38751ca7a 100644
--- a/chrome/browser/extensions/api/app/app_api.cc
+++ b/chrome/browser/extensions/api/app/app_api.cc
@@ -121,50 +121,49 @@ bool AppClearAllNotificationsFunction::RunImpl() {
// static.
void AppEventRouter::DispatchOnLaunchedEvent(
Profile* profile, const Extension* extension) {
+ scoped_ptr<ListValue> arguments(new ListValue());
profile->GetExtensionEventRouter()->DispatchEventToExtension(
- extension->id(), kOnLaunchedEvent, "[]", NULL, GURL());
+ extension->id(), kOnLaunchedEvent, arguments.Pass(), NULL, GURL());
}
// static.
void AppEventRouter::DispatchOnLaunchedEventWithFileEntry(
Profile* profile, const Extension* extension, const string16& action,
const std::string& file_system_id, const std::string& base_name) {
- ListValue args;
+ scoped_ptr<ListValue> args(new ListValue());
DictionaryValue* launch_data = new DictionaryValue();
DictionaryValue* intent = new DictionaryValue();
intent->SetString("action", UTF16ToUTF8(action));
intent->SetString("type", "chrome-extension://fileentry");
launch_data->Set("intent", intent);
- args.Append(launch_data);
+ args->Append(launch_data);
DictionaryValue* intent_data = new DictionaryValue();
intent_data->SetString("format", "fileEntry");
intent_data->SetString("fileSystemId", file_system_id);
intent_data->SetString("baseName", base_name);
- args.Append(intent_data);
- std::string json_args;
- base::JSONWriter::Write(&args, &json_args);
+ args->Append(intent_data);
profile->GetExtensionEventRouter()->DispatchEventToExtension(
- extension->id(), kOnLaunchedEvent, json_args, NULL, GURL());
+ extension->id(), kOnLaunchedEvent, args.Pass(), NULL, GURL());
}
// static.
void AppEventRouter::DispatchOnLaunchedEventWithWebIntent(
Profile* profile, const Extension* extension,
const webkit_glue::WebIntentData web_intent_data) {
- ListValue args;
+ scoped_ptr<ListValue> args(new ListValue());
DictionaryValue* launch_data = new DictionaryValue();
DictionaryValue* intent = new DictionaryValue();
intent->SetString("action", UTF16ToUTF8(web_intent_data.action));
intent->SetString("type", UTF16ToUTF8(web_intent_data.type));
launch_data->Set("intent", intent);
- args.Append(launch_data);
+ args->Append(launch_data);
DictionaryValue* intent_data;
switch (web_intent_data.data_type) {
case webkit_glue::WebIntentData::SERIALIZED:
intent_data = new DictionaryValue();
intent_data->SetString("format", "serialized");
intent_data->SetString("data", UTF16ToUTF8(web_intent_data.data));
- args.Append(intent_data);
+ args->Append(intent_data);
break;
case webkit_glue::WebIntentData::UNSERIALIZED:
intent->SetString("data", UTF16ToUTF8(web_intent_data.unserialized_data));
@@ -175,16 +174,14 @@ void AppEventRouter::DispatchOnLaunchedEventWithWebIntent(
intent_data->SetString("blobFileName", web_intent_data.blob_file.value());
intent_data->SetString("blobLength",
base::Int64ToString(web_intent_data.blob_length));
- args.Append(intent_data);
+ args->Append(intent_data);
break;
default:
NOTREACHED();
break;
}
- std::string json_args;
- base::JSONWriter::Write(&args, &json_args);
profile->GetExtensionEventRouter()->DispatchEventToExtension(
- extension->id(), kOnLaunchedEvent, json_args, NULL, GURL());
+ extension->id(), kOnLaunchedEvent, args.Pass(), NULL, GURL());
}
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/api_resource_event_notifier.cc ('k') | chrome/browser/extensions/api/cookies/cookies_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698