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

Side by Side Diff: chrome/browser/extensions/api/system_private/system_private_api.cc

Issue 1236493004: Final batch adding real histogram values for extension events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments, rebase, dcheck, etc Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/system_private/system_private_api.h" 5 #include "chrome/browser/extensions/api/system_private/system_private_api.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/extensions/event_router_forwarder.h" 10 #include "chrome/browser/extensions/event_router_forwarder.h"
(...skipping 29 matching lines...) Expand all
40 40
41 // System update states. 41 // System update states.
42 const char kNotAvailableState[] = "NotAvailable"; 42 const char kNotAvailableState[] = "NotAvailable";
43 const char kNeedRestartState[] = "NeedRestart"; 43 const char kNeedRestartState[] = "NeedRestart";
44 44
45 #if defined(OS_CHROMEOS) 45 #if defined(OS_CHROMEOS)
46 const char kUpdatingState[] = "Updating"; 46 const char kUpdatingState[] = "Updating";
47 #endif // defined(OS_CHROMEOS) 47 #endif // defined(OS_CHROMEOS)
48 48
49 // Dispatches an extension event with |argument| 49 // Dispatches an extension event with |argument|
50 void DispatchEvent(const std::string& event_name, base::Value* argument) { 50 void DispatchEvent(extensions::events::HistogramValue histogram_value,
51 const std::string& event_name,
52 base::Value* argument) {
51 scoped_ptr<base::ListValue> list_args(new base::ListValue()); 53 scoped_ptr<base::ListValue> list_args(new base::ListValue());
52 if (argument) { 54 if (argument) {
53 list_args->Append(argument); 55 list_args->Append(argument);
54 } 56 }
55 g_browser_process->extension_event_router_forwarder()-> 57 g_browser_process->extension_event_router_forwarder()
56 BroadcastEventToRenderers(event_name, list_args.Pass(), GURL()); 58 ->BroadcastEventToRenderers(histogram_value, event_name, list_args.Pass(),
59 GURL());
57 } 60 }
58 61
59 } // namespace 62 } // namespace
60 63
61 namespace extensions { 64 namespace extensions {
62 65
63 namespace system_private = api::system_private; 66 namespace system_private = api::system_private;
64 67
65 bool SystemPrivateGetIncognitoModeAvailabilityFunction::RunSync() { 68 bool SystemPrivateGetIncognitoModeAvailabilityFunction::RunSync() {
66 PrefService* prefs = GetProfile()->GetPrefs(); 69 PrefService* prefs = GetProfile()->GetPrefs();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 139
137 bool SystemPrivateGetApiKeyFunction::RunSync() { 140 bool SystemPrivateGetApiKeyFunction::RunSync() {
138 SetResult(new base::StringValue(google_apis::GetAPIKey())); 141 SetResult(new base::StringValue(google_apis::GetAPIKey()));
139 return true; 142 return true;
140 } 143 }
141 144
142 void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) { 145 void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) {
143 base::DictionaryValue* dict = new base::DictionaryValue(); 146 base::DictionaryValue* dict = new base::DictionaryValue();
144 dict->SetDouble(kVolumeKey, volume); 147 dict->SetDouble(kVolumeKey, volume);
145 dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted); 148 dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted);
146 DispatchEvent(system_private::OnVolumeChanged::kEventName, dict); 149 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_VOLUME_CHANGED,
150 system_private::OnVolumeChanged::kEventName, dict);
147 } 151 }
148 152
149 void DispatchBrightnessChangedEvent(int brightness, bool user_initiated) { 153 void DispatchBrightnessChangedEvent(int brightness, bool user_initiated) {
150 base::DictionaryValue* dict = new base::DictionaryValue(); 154 base::DictionaryValue* dict = new base::DictionaryValue();
151 dict->SetInteger(kBrightnessKey, brightness); 155 dict->SetInteger(kBrightnessKey, brightness);
152 dict->SetBoolean(kUserInitiatedKey, user_initiated); 156 dict->SetBoolean(kUserInitiatedKey, user_initiated);
153 DispatchEvent(system_private::OnBrightnessChanged::kEventName, dict); 157 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_BRIGHTNESS_CHANGED,
158 system_private::OnBrightnessChanged::kEventName, dict);
154 } 159 }
155 160
156 void DispatchScreenUnlockedEvent() { 161 void DispatchScreenUnlockedEvent() {
157 DispatchEvent(system_private::OnScreenUnlocked::kEventName, NULL); 162 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_SCREEN_UNLOCKED,
163 system_private::OnScreenUnlocked::kEventName, NULL);
158 } 164 }
159 165
160 void DispatchWokeUpEvent() { 166 void DispatchWokeUpEvent() {
161 DispatchEvent(system_private::OnWokeUp::kEventName, NULL); 167 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_WOKE_UP,
168 system_private::OnWokeUp::kEventName, NULL);
162 } 169 }
163 170
164 } // namespace extensions 171 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698