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

Unified Diff: chrome/browser/history/history_extension_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: Rebase and review changes. Created 8 years, 5 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/history/history_extension_api.cc
diff --git a/chrome/browser/history/history_extension_api.cc b/chrome/browser/history/history_extension_api.cc
index a55d0958cc4ee55c105bdb4c47ef8852a0df3aab..6f05b573f0abe28782fc03dc011dc9a64a7b2a4e 100644
--- a/chrome/browser/history/history_extension_api.cc
+++ b/chrome/browser/history/history_extension_api.cc
@@ -129,20 +129,18 @@ void HistoryExtensionEventRouter::Observe(
void HistoryExtensionEventRouter::HistoryUrlVisited(
Profile* profile,
const history::URLVisitedDetails* details) {
- ListValue args;
+ ListValue* args = new ListValue();
DictionaryValue* dict = new DictionaryValue();
GetHistoryItemDictionary(details->row, dict);
- args.Append(dict);
+ args->Append(dict);
- std::string json_args;
- base::JSONWriter::Write(&args, &json_args);
- DispatchEvent(profile, kOnVisited, json_args);
+ DispatchEvent(profile, kOnVisited, args);
}
void HistoryExtensionEventRouter::HistoryUrlsRemoved(
Profile* profile,
const history::URLsDeletedDetails* details) {
- ListValue args;
+ ListValue* args = new ListValue();
DictionaryValue* dict = new DictionaryValue();
dict->SetBoolean(kAllHistoryKey, details->all_history);
ListValue* urls = new ListValue();
@@ -151,19 +149,17 @@ void HistoryExtensionEventRouter::HistoryUrlsRemoved(
urls->Append(new StringValue(iterator->url().spec()));
}
dict->Set(kUrlsKey, urls);
- args.Append(dict);
+ args->Append(dict);
- std::string json_args;
- base::JSONWriter::Write(&args, &json_args);
- DispatchEvent(profile, kOnVisitRemoved, json_args);
+ DispatchEvent(profile, kOnVisitRemoved, args);
}
void HistoryExtensionEventRouter::DispatchEvent(Profile* profile,
const char* event_name,
- const std::string& json_args) {
+ ListValue* event_args) {
if (profile && profile->GetExtensionEventRouter()) {
profile->GetExtensionEventRouter()->DispatchEventToRenderers(
- event_name, json_args, profile, GURL(),
+ event_name, event_args, profile, GURL(),
extensions::EventFilteringInfo());
}
}

Powered by Google App Engine
This is Rietveld 408576698