| OLD | NEW |
| 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/chromeos/extensions/info_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/info_private_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 DLOG(ERROR) << "Unknown property request: " << property_name; | 231 DLOG(ERROR) << "Unknown property request: " << property_name; |
| 232 return NULL; | 232 return NULL; |
| 233 } | 233 } |
| 234 | 234 |
| 235 ChromeosInfoPrivateSetFunction::ChromeosInfoPrivateSetFunction() { | 235 ChromeosInfoPrivateSetFunction::ChromeosInfoPrivateSetFunction() { |
| 236 } | 236 } |
| 237 | 237 |
| 238 ChromeosInfoPrivateSetFunction::~ChromeosInfoPrivateSetFunction() { | 238 ChromeosInfoPrivateSetFunction::~ChromeosInfoPrivateSetFunction() { |
| 239 } | 239 } |
| 240 | 240 |
| 241 bool ChromeosInfoPrivateSetFunction::RunSync() { | 241 ExtensionFunction::ResponseAction ChromeosInfoPrivateSetFunction::Run() { |
| 242 std::string param_name; | 242 std::string param_name; |
| 243 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, ¶m_name)); | 243 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, ¶m_name)); |
| 244 if (param_name == kPropertyTimezone) { | 244 if (param_name == kPropertyTimezone) { |
| 245 std::string param_value; | 245 std::string param_value; |
| 246 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, ¶m_value)); | 246 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, ¶m_value)); |
| 247 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, | 247 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, |
| 248 base::StringValue(param_value)); | 248 base::StringValue(param_value)); |
| 249 } else { | 249 } else { |
| 250 const char* pref_name = GetBoolPrefNameForApiProperty(param_name.c_str()); | 250 const char* pref_name = GetBoolPrefNameForApiProperty(param_name.c_str()); |
| 251 if (pref_name) { | 251 if (pref_name) { |
| 252 bool param_value; | 252 bool param_value; |
| 253 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, ¶m_value)); | 253 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, ¶m_value)); |
| 254 Profile::FromBrowserContext(context_)->GetPrefs()->SetBoolean( | 254 Profile::FromBrowserContext(context_)->GetPrefs()->SetBoolean( |
| 255 pref_name, | 255 pref_name, |
| 256 param_value); | 256 param_value); |
| 257 } else { | 257 } else { |
| 258 error_ = ErrorUtils::FormatErrorMessage(kPropertyNotFound, param_name); | 258 return RespondNow(Error(kPropertyNotFound, param_name)); |
| 259 return false; | |
| 260 } | 259 } |
| 261 } | 260 } |
| 262 | 261 |
| 263 return true; | 262 return RespondNow(NoArguments()); |
| 264 } | 263 } |
| 265 | 264 |
| 266 } // namespace extensions | 265 } // namespace extensions |
| OLD | NEW |