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

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

Issue 252653002: Rename (Chrome)SyncExtensionFunction::RunImpl to RunSync so that the RunImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 g_browser_process->extension_event_router_forwarder()-> 55 g_browser_process->extension_event_router_forwarder()->
56 BroadcastEventToRenderers(event_name, list_args.Pass(), GURL()); 56 BroadcastEventToRenderers(event_name, list_args.Pass(), GURL());
57 } 57 }
58 58
59 } // namespace 59 } // namespace
60 60
61 namespace extensions { 61 namespace extensions {
62 62
63 namespace system_private = api::system_private; 63 namespace system_private = api::system_private;
64 64
65 bool SystemPrivateGetIncognitoModeAvailabilityFunction::RunImpl() { 65 bool SystemPrivateGetIncognitoModeAvailabilityFunction::RunSync() {
66 PrefService* prefs = GetProfile()->GetPrefs(); 66 PrefService* prefs = GetProfile()->GetPrefs();
67 int value = prefs->GetInteger(prefs::kIncognitoModeAvailability); 67 int value = prefs->GetInteger(prefs::kIncognitoModeAvailability);
68 EXTENSION_FUNCTION_VALIDATE( 68 EXTENSION_FUNCTION_VALIDATE(
69 value >= 0 && 69 value >= 0 &&
70 value < static_cast<int>(arraysize(kIncognitoModeAvailabilityStrings))); 70 value < static_cast<int>(arraysize(kIncognitoModeAvailabilityStrings)));
71 SetResult(new base::StringValue(kIncognitoModeAvailabilityStrings[value])); 71 SetResult(new base::StringValue(kIncognitoModeAvailabilityStrings[value]));
72 return true; 72 return true;
73 } 73 }
74 74
75 bool SystemPrivateGetUpdateStatusFunction::RunImpl() { 75 bool SystemPrivateGetUpdateStatusFunction::RunSync() {
76 std::string state; 76 std::string state;
77 double download_progress = 0; 77 double download_progress = 0;
78 #if defined(OS_CHROMEOS) 78 #if defined(OS_CHROMEOS)
79 // With UpdateEngineClient, we can provide more detailed information about 79 // With UpdateEngineClient, we can provide more detailed information about
80 // system updates on ChromeOS. 80 // system updates on ChromeOS.
81 const chromeos::UpdateEngineClient::Status status = 81 const chromeos::UpdateEngineClient::Status status =
82 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()-> 82 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->
83 GetLastStatus(); 83 GetLastStatus();
84 // |download_progress| is set to 1 after download finishes 84 // |download_progress| is set to 1 after download finishes
85 // (i.e. verify, finalize and need-reboot phase) to indicate the progress 85 // (i.e. verify, finalize and need-reboot phase) to indicate the progress
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 #endif 127 #endif
128 base::DictionaryValue* dict = new base::DictionaryValue(); 128 base::DictionaryValue* dict = new base::DictionaryValue();
129 dict->SetString(kStateKey, state); 129 dict->SetString(kStateKey, state);
130 dict->SetDouble(kDownloadProgressKey, download_progress); 130 dict->SetDouble(kDownloadProgressKey, download_progress);
131 SetResult(dict); 131 SetResult(dict);
132 132
133 return true; 133 return true;
134 } 134 }
135 135
136 bool SystemPrivateGetApiKeyFunction::RunImpl() { 136 bool SystemPrivateGetApiKeyFunction::RunSync() {
137 SetResult(new base::StringValue(google_apis::GetAPIKey())); 137 SetResult(new base::StringValue(google_apis::GetAPIKey()));
138 return true; 138 return true;
139 } 139 }
140 140
141 void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) { 141 void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) {
142 base::DictionaryValue* dict = new base::DictionaryValue(); 142 base::DictionaryValue* dict = new base::DictionaryValue();
143 dict->SetDouble(kVolumeKey, volume); 143 dict->SetDouble(kVolumeKey, volume);
144 dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted); 144 dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted);
145 DispatchEvent(system_private::OnVolumeChanged::kEventName, dict); 145 DispatchEvent(system_private::OnVolumeChanged::kEventName, dict);
146 } 146 }
147 147
148 void DispatchBrightnessChangedEvent(int brightness, bool user_initiated) { 148 void DispatchBrightnessChangedEvent(int brightness, bool user_initiated) {
149 base::DictionaryValue* dict = new base::DictionaryValue(); 149 base::DictionaryValue* dict = new base::DictionaryValue();
150 dict->SetInteger(kBrightnessKey, brightness); 150 dict->SetInteger(kBrightnessKey, brightness);
151 dict->SetBoolean(kUserInitiatedKey, user_initiated); 151 dict->SetBoolean(kUserInitiatedKey, user_initiated);
152 DispatchEvent(system_private::OnBrightnessChanged::kEventName, dict); 152 DispatchEvent(system_private::OnBrightnessChanged::kEventName, dict);
153 } 153 }
154 154
155 void DispatchScreenUnlockedEvent() { 155 void DispatchScreenUnlockedEvent() {
156 DispatchEvent(system_private::OnScreenUnlocked::kEventName, NULL); 156 DispatchEvent(system_private::OnScreenUnlocked::kEventName, NULL);
157 } 157 }
158 158
159 void DispatchWokeUpEvent() { 159 void DispatchWokeUpEvent() {
160 DispatchEvent(system_private::OnWokeUp::kEventName, NULL); 160 DispatchEvent(system_private::OnWokeUp::kEventName, NULL);
161 } 161 }
162 162
163 } // namespace extensions 163 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698