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

Unified Diff: chrome/browser/extensions/system/system_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/extensions/system/system_api.cc
diff --git a/chrome/browser/extensions/system/system_api.cc b/chrome/browser/extensions/system/system_api.cc
index 042eb3566775c28b4d083a956b1e1b9de96c65f8..8860db00642910e1ef3d20288ebf7fb404d7141a 100644
--- a/chrome/browser/extensions/system/system_api.cc
+++ b/chrome/browser/extensions/system/system_api.cc
@@ -49,7 +49,7 @@ const char kOnScreenUnlocked[] = "systemPrivate.onScreenUnlocked";
const char kOnWokeUp[] = "systemPrivate.onWokeUp";
// Dispatches an extension event with |args|
-void DispatchEvent(const std::string& event_name, const ListValue& args) {
+void DispatchEvent(const std::string& event_name, base::Value* argument) {
Profile* profile = ProfileManager::GetDefaultProfile();
if (!profile)
return;
@@ -57,10 +57,11 @@ void DispatchEvent(const std::string& event_name, const ListValue& args) {
profile->GetExtensionEventRouter();
if (!extension_event_router)
return;
- std::string json_args;
- base::JSONWriter::Write(&args, &json_args);
+
+ base::ListValue* list_args = new base::ListValue();
miket_OOO 2012/07/10 22:33:19 Just args! They must all be the same!
+ list_args->Append(argument);
extension_event_router->DispatchEventToRenderers(
- event_name, json_args, NULL, GURL(), extensions::EventFilteringInfo());
+ event_name, list_args, NULL, GURL(), extensions::EventFilteringInfo());
}
} // namespace
@@ -140,31 +141,25 @@ bool GetUpdateStatusFunction::RunImpl() {
}
void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) {
- ListValue args;
DictionaryValue* dict = new DictionaryValue();
dict->SetDouble(kVolumeKey, volume);
dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted);
- args.Append(dict);
- DispatchEvent(kOnVolumeChanged, args);
+ DispatchEvent(kOnVolumeChanged, dict);
miket_OOO 2012/07/10 22:33:19 aaarrrrgs!
}
void DispatchBrightnessChangedEvent(int brightness, bool user_initiated) {
- ListValue args;
DictionaryValue* dict = new DictionaryValue();
dict->SetInteger(kBrightnessKey, brightness);
dict->SetBoolean(kUserInitiatedKey, user_initiated);
- args.Append(dict);
- DispatchEvent(kOnBrightnessChanged, args);
+ DispatchEvent(kOnBrightnessChanged, dict);
}
void DispatchScreenUnlockedEvent() {
- ListValue args;
- DispatchEvent(kOnScreenUnlocked, args);
+ DispatchEvent(kOnScreenUnlocked, NULL);
}
void DispatchWokeUpEvent() {
- ListValue args;
- DispatchEvent(kOnWokeUp, args);
+ DispatchEvent(kOnWokeUp, NULL);
}
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698