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

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: Build fix. 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 b80538f96b7a55d215c838f78c9531661557c64c..85eaef3d055e89e45d97faa63213a32a2ad53939 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();
+ list_args->Append(argument);
extension_event_router->DispatchEventToRenderers(
- event_name, json_args, NULL, GURL());
+ event_name, list_args, NULL, GURL());
}
} // 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);
}
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