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

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

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 namespace system_private = api::system_private; 72 namespace system_private = api::system_private;
73 73
74 ExtensionFunction::ResponseAction 74 ExtensionFunction::ResponseAction
75 SystemPrivateGetIncognitoModeAvailabilityFunction::Run() { 75 SystemPrivateGetIncognitoModeAvailabilityFunction::Run() {
76 PrefService* prefs = 76 PrefService* prefs =
77 Profile::FromBrowserContext(browser_context())->GetPrefs(); 77 Profile::FromBrowserContext(browser_context())->GetPrefs();
78 int value = prefs->GetInteger(prefs::kIncognitoModeAvailability); 78 int value = prefs->GetInteger(prefs::kIncognitoModeAvailability);
79 EXTENSION_FUNCTION_VALIDATE( 79 EXTENSION_FUNCTION_VALIDATE(
80 value >= 0 && 80 value >= 0 &&
81 value < static_cast<int>(arraysize(kIncognitoModeAvailabilityStrings))); 81 value < static_cast<int>(arraysize(kIncognitoModeAvailabilityStrings)));
82 return RespondNow(OneArgument(base::MakeUnique<base::StringValue>( 82 return RespondNow(OneArgument(
83 kIncognitoModeAvailabilityStrings[value]))); 83 base::MakeUnique<base::Value>(kIncognitoModeAvailabilityStrings[value])));
84 } 84 }
85 85
86 ExtensionFunction::ResponseAction SystemPrivateGetUpdateStatusFunction::Run() { 86 ExtensionFunction::ResponseAction SystemPrivateGetUpdateStatusFunction::Run() {
87 std::string state; 87 std::string state;
88 double download_progress = 0; 88 double download_progress = 0;
89 #if defined(OS_CHROMEOS) 89 #if defined(OS_CHROMEOS)
90 // With UpdateEngineClient, we can provide more detailed information about 90 // With UpdateEngineClient, we can provide more detailed information about
91 // system updates on ChromeOS. 91 // system updates on ChromeOS.
92 const chromeos::UpdateEngineClient::Status status = 92 const chromeos::UpdateEngineClient::Status status =
93 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()-> 93 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 138 }
139 #endif 139 #endif
140 140
141 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 141 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
142 dict->SetString(kStateKey, state); 142 dict->SetString(kStateKey, state);
143 dict->SetDouble(kDownloadProgressKey, download_progress); 143 dict->SetDouble(kDownloadProgressKey, download_progress);
144 return RespondNow(OneArgument(std::move(dict))); 144 return RespondNow(OneArgument(std::move(dict)));
145 } 145 }
146 146
147 ExtensionFunction::ResponseAction SystemPrivateGetApiKeyFunction::Run() { 147 ExtensionFunction::ResponseAction SystemPrivateGetApiKeyFunction::Run() {
148 return RespondNow(OneArgument( 148 return RespondNow(
149 base::MakeUnique<base::StringValue>(google_apis::GetAPIKey()))); 149 OneArgument(base::MakeUnique<base::Value>(google_apis::GetAPIKey())));
150 } 150 }
151 151
152 void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) { 152 void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) {
153 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 153 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
154 dict->SetDouble(kVolumeKey, volume); 154 dict->SetDouble(kVolumeKey, volume);
155 dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted); 155 dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted);
156 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_VOLUME_CHANGED, 156 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_VOLUME_CHANGED,
157 system_private::OnVolumeChanged::kEventName, std::move(dict)); 157 system_private::OnVolumeChanged::kEventName, std::move(dict));
158 } 158 }
159 159
(...skipping 10 matching lines...) Expand all
170 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_SCREEN_UNLOCKED, 170 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_SCREEN_UNLOCKED,
171 system_private::OnScreenUnlocked::kEventName, nullptr); 171 system_private::OnScreenUnlocked::kEventName, nullptr);
172 } 172 }
173 173
174 void DispatchWokeUpEvent() { 174 void DispatchWokeUpEvent() {
175 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_WOKE_UP, 175 DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_WOKE_UP,
176 system_private::OnWokeUp::kEventName, nullptr); 176 system_private::OnWokeUp::kEventName, nullptr);
177 } 177 }
178 178
179 } // namespace extensions 179 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/sync_file_system/sync_file_system_api.cc ('k') | chrome/browser/extensions/api/tabs/tabs_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698