Chromium Code Reviews| 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 default: | 319 default: |
| 320 return base::MakeUnique<base::Value>(kDeviceTypeChromedevice); | 320 return base::MakeUnique<base::Value>(kDeviceTypeChromedevice); |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 | 323 |
| 324 if (property_name == kPropertyClientId) { | 324 if (property_name == kPropertyClientId) { |
| 325 return base::MakeUnique<base::Value>(GetClientId()); | 325 return base::MakeUnique<base::Value>(GetClientId()); |
| 326 } | 326 } |
| 327 | 327 |
| 328 if (property_name == kPropertyTimezone) { | 328 if (property_name == kPropertyTimezone) { |
| 329 // TODO(crbug.com/697817): Convert CrosSettings::Get to take a unique_ptr. | 329 if (chromeos::system::PerUserTimezoneEnabled()) { |
| 330 return base::WrapUnique<base::Value>( | 330 return base::WrapUnique<base::Value>( |
| 331 chromeos::CrosSettings::Get() | 331 Profile::FromBrowserContext(context_) |
| 332 ->GetPref(chromeos::kSystemTimezone) | 332 ->GetPrefs() |
| 333 ->DeepCopy()); | 333 ->GetUserPrefValue(prefs::kUserTimezone) |
| 334 ->DeepCopy()); | |
| 335 } else { | |
|
stevenjb
2017/05/25 22:13:06
no else after return
Also, ideally the PerUserTime
Alexander Alekseev
2017/05/29 21:10:23
Done.
| |
| 336 // TODO(crbug.com/697817): Convert CrosSettings::Get to take a unique_ptr. | |
| 337 return base::WrapUnique<base::Value>( | |
| 338 chromeos::CrosSettings::Get() | |
| 339 ->GetPref(chromeos::kSystemTimezone) | |
| 340 ->DeepCopy()); | |
| 341 } | |
| 334 } | 342 } |
| 335 | 343 |
| 336 if (property_name == kPropertySupportedTimezones) { | 344 if (property_name == kPropertySupportedTimezones) { |
| 337 std::unique_ptr<base::ListValue> values = | 345 std::unique_ptr<base::ListValue> values = |
| 338 chromeos::system::GetTimezoneList(); | 346 chromeos::system::GetTimezoneList(); |
| 339 // TODO(crbug.com/703565): remove std::move() once Xcode 9.0+ is required. | 347 // TODO(crbug.com/703565): remove std::move() once Xcode 9.0+ is required. |
| 340 return std::move(values); | 348 return std::move(values); |
| 341 } | 349 } |
| 342 | 350 |
| 343 const char* pref_name = GetBoolPrefNameForApiProperty(property_name.c_str()); | 351 const char* pref_name = GetBoolPrefNameForApiProperty(property_name.c_str()); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 356 | 364 |
| 357 ChromeosInfoPrivateSetFunction::~ChromeosInfoPrivateSetFunction() { | 365 ChromeosInfoPrivateSetFunction::~ChromeosInfoPrivateSetFunction() { |
| 358 } | 366 } |
| 359 | 367 |
| 360 ExtensionFunction::ResponseAction ChromeosInfoPrivateSetFunction::Run() { | 368 ExtensionFunction::ResponseAction ChromeosInfoPrivateSetFunction::Run() { |
| 361 std::string param_name; | 369 std::string param_name; |
| 362 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, ¶m_name)); | 370 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, ¶m_name)); |
| 363 if (param_name == kPropertyTimezone) { | 371 if (param_name == kPropertyTimezone) { |
| 364 std::string param_value; | 372 std::string param_value; |
| 365 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, ¶m_value)); | 373 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, ¶m_value)); |
| 366 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, | 374 if (chromeos::system::PerUserTimezoneEnabled()) { |
| 367 base::Value(param_value)); | 375 Profile::FromBrowserContext(context_)->GetPrefs()->SetString( |
| 376 prefs::kUserTimezone, param_value); | |
| 377 } else { | |
| 378 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, | |
| 379 base::Value(param_value)); | |
| 380 } | |
| 368 } else { | 381 } else { |
| 369 const char* pref_name = GetBoolPrefNameForApiProperty(param_name.c_str()); | 382 const char* pref_name = GetBoolPrefNameForApiProperty(param_name.c_str()); |
| 370 if (pref_name) { | 383 if (pref_name) { |
| 371 bool param_value; | 384 bool param_value; |
| 372 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, ¶m_value)); | 385 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, ¶m_value)); |
| 373 Profile::FromBrowserContext(context_)->GetPrefs()->SetBoolean( | 386 Profile::FromBrowserContext(context_)->GetPrefs()->SetBoolean( |
| 374 pref_name, | 387 pref_name, |
| 375 param_value); | 388 param_value); |
| 376 } else { | 389 } else { |
| 377 return RespondNow(Error(kPropertyNotFound, param_name)); | 390 return RespondNow(Error(kPropertyNotFound, param_name)); |
| 378 } | 391 } |
| 379 } | 392 } |
| 380 | 393 |
| 381 return RespondNow(NoArguments()); | 394 return RespondNow(NoArguments()); |
| 382 } | 395 } |
| 383 | 396 |
| 384 } // namespace extensions | 397 } // namespace extensions |
| OLD | NEW |