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

Unified Diff: chrome/browser/extensions/api/omnibox/omnibox_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/omnibox/omnibox_api.cc
diff --git a/chrome/browser/extensions/api/omnibox/omnibox_api.cc b/chrome/browser/extensions/api/omnibox/omnibox_api.cc
index 29f3ae8edf4c27bb94cc9e811e9fb30a64be818a..85b352b28d5bc7e95beff5c5af9e933a2be00faf 100644
--- a/chrome/browser/extensions/api/omnibox/omnibox_api.cc
+++ b/chrome/browser/extensions/api/omnibox/omnibox_api.cc
@@ -51,8 +51,9 @@ const char kDescriptionStylesLength[] = "length";
// static
void ExtensionOmniboxEventRouter::OnInputStarted(
Profile* profile, const std::string& extension_id) {
- profile->GetExtensionEventRouter()->DispatchEventToExtension(
- extension_id, events::kOnInputStarted, "[]", profile, GURL());
+ scoped_ptr<ListValue> event_args(new ListValue());
+ profile->GetExtensionEventRouter()->DispatchEventToExtension(extension_id,
+ events::kOnInputStarted, event_args.Pass(), profile, GURL());
}
// static
@@ -63,14 +64,12 @@ bool ExtensionOmniboxEventRouter::OnInputChanged(
extension_id, events::kOnInputChanged))
return false;
- ListValue args;
- args.Set(0, Value::CreateStringValue(input));
- args.Set(1, Value::CreateIntegerValue(suggest_id));
- std::string json_args;
- base::JSONWriter::Write(&args, &json_args);
+ scoped_ptr<ListValue> args(new ListValue());
+ args->Set(0, Value::CreateStringValue(input));
+ args->Set(1, Value::CreateIntegerValue(suggest_id));
profile->GetExtensionEventRouter()->DispatchEventToExtension(
- extension_id, events::kOnInputChanged, json_args, profile, GURL());
+ extension_id, events::kOnInputChanged, args.Pass(), profile, GURL());
return true;
}
@@ -88,13 +87,11 @@ void ExtensionOmniboxEventRouter::OnInputEntered(
tab_contents->extension_tab_helper()->active_tab_permission_manager()->
GrantIfRequested(extension);
- ListValue args;
- args.Set(0, Value::CreateStringValue(input));
- std::string json_args;
- base::JSONWriter::Write(&args, &json_args);
+ scoped_ptr<ListValue> args(new ListValue());
+ args->Set(0, Value::CreateStringValue(input));
profile->GetExtensionEventRouter()->DispatchEventToExtension(
- extension_id, events::kOnInputEntered, json_args, profile, GURL());
+ extension_id, events::kOnInputEntered, args.Pass(), profile, GURL());
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED,
@@ -105,8 +102,9 @@ void ExtensionOmniboxEventRouter::OnInputEntered(
// static
void ExtensionOmniboxEventRouter::OnInputCancelled(
Profile* profile, const std::string& extension_id) {
+ scoped_ptr<ListValue> args(new ListValue());
profile->GetExtensionEventRouter()->DispatchEventToExtension(
- extension_id, events::kOnInputCancelled, "[]", profile, GURL());
+ extension_id, events::kOnInputCancelled, args.Pass(), profile, GURL());
}
bool OmniboxSendSuggestionsFunction::RunImpl() {
« no previous file with comments | « chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc ('k') | chrome/browser/extensions/api/proxy/proxy_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698