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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 DLOG(ERROR) << "Unknown property request: " << property_name; | 178 DLOG(ERROR) << "Unknown property request: " << property_name; |
179 return NULL; | 179 return NULL; |
180 } | 180 } |
181 | 181 |
182 ChromeosInfoPrivateSetFunction::ChromeosInfoPrivateSetFunction() { | 182 ChromeosInfoPrivateSetFunction::ChromeosInfoPrivateSetFunction() { |
183 } | 183 } |
184 | 184 |
185 ChromeosInfoPrivateSetFunction::~ChromeosInfoPrivateSetFunction() { | 185 ChromeosInfoPrivateSetFunction::~ChromeosInfoPrivateSetFunction() { |
186 } | 186 } |
187 | 187 |
188 bool ChromeosInfoPrivateSetFunction::RunImpl() { | 188 bool ChromeosInfoPrivateSetFunction::RunSync() { |
189 std::string param_name; | 189 std::string param_name; |
190 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, ¶m_name)); | 190 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, ¶m_name)); |
191 if (param_name == kPropertyTimezone) { | 191 if (param_name == kPropertyTimezone) { |
192 std::string param_value; | 192 std::string param_value; |
193 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, ¶m_value)); | 193 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, ¶m_value)); |
194 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, | 194 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, |
195 base::StringValue(param_value)); | 195 base::StringValue(param_value)); |
196 } else { | 196 } else { |
197 const char* pref_name = GetBoolPrefNameForApiProperty(param_name.c_str()); | 197 const char* pref_name = GetBoolPrefNameForApiProperty(param_name.c_str()); |
198 if (pref_name) { | 198 if (pref_name) { |
199 bool param_value; | 199 bool param_value; |
200 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, ¶m_value)); | 200 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, ¶m_value)); |
201 Profile::FromBrowserContext(context_)->GetPrefs()->SetBoolean( | 201 Profile::FromBrowserContext(context_)->GetPrefs()->SetBoolean( |
202 pref_name, | 202 pref_name, |
203 param_value); | 203 param_value); |
204 } else { | 204 } else { |
205 error_ = ErrorUtils::FormatErrorMessage(kPropertyNotFound, param_name); | 205 error_ = ErrorUtils::FormatErrorMessage(kPropertyNotFound, param_name); |
206 return false; | 206 return false; |
207 } | 207 } |
208 } | 208 } |
209 | 209 |
210 return true; | 210 return true; |
211 } | 211 } |
212 | 212 |
213 } // namespace extensions | 213 } // namespace extensions |
OLD | NEW |