 Chromium Code Reviews
 Chromium Code Reviews Issue 2849823003:
  ChromeOS: implement per-user time zone preferences.  (Closed)
    
  
    Issue 2849823003:
  ChromeOS: implement per-user time zone preferences.  (Closed) 
  | Index: chrome/browser/chromeos/extensions/info_private_api.cc | 
| diff --git a/chrome/browser/chromeos/extensions/info_private_api.cc b/chrome/browser/chromeos/extensions/info_private_api.cc | 
| index 29bd74e2387dafa036aa085ba42a4ce3aa4386e8..4ba9f6fab5484b16718859a6d45913df617dbdf6 100644 | 
| --- a/chrome/browser/chromeos/extensions/info_private_api.cc | 
| +++ b/chrome/browser/chromeos/extensions/info_private_api.cc | 
| @@ -214,6 +214,23 @@ std::string GetClientId() { | 
| : std::string(); | 
| } | 
| +std::unique_ptr<base::Value> GetUserTimezoneValue( | 
| + content::BrowserContext* browser_context) { | 
| + if (chromeos::system::PerUserTimezoneEnabled()) { | 
| + return base::WrapUnique<base::Value>( | 
| + Profile::FromBrowserContext(browser_context) | 
| + ->GetPrefs() | 
| + ->GetUserPrefValue(prefs::kUserTimezone) | 
| + ->DeepCopy()); | 
| + } else { | 
| 
stevenjb
2017/05/30 16:47:18
no else after return
 
Alexander Alekseev
2017/07/06 06:30:28
Done.
 | 
| + // TODO(crbug.com/697817): Convert CrosSettings::Get to take a unique_ptr. | 
| + return base::WrapUnique<base::Value>( | 
| + chromeos::CrosSettings::Get() | 
| + ->GetPref(chromeos::kSystemTimezone) | 
| + ->DeepCopy()); | 
| + } | 
| +} | 
| 
stevenjb
2017/05/30 16:47:18
I actually think this code would be better off in
 
Alexander Alekseev
2017/07/06 06:30:28
This is very UI-specific. I'd leave it here.
 | 
| + | 
| } // namespace | 
| ChromeosInfoPrivateGetFunction::ChromeosInfoPrivateGetFunction() { | 
| @@ -325,13 +342,8 @@ std::unique_ptr<base::Value> ChromeosInfoPrivateGetFunction::GetValue( | 
| return base::MakeUnique<base::Value>(GetClientId()); | 
| } | 
| - if (property_name == kPropertyTimezone) { | 
| - // TODO(crbug.com/697817): Convert CrosSettings::Get to take a unique_ptr. | 
| - return base::WrapUnique<base::Value>( | 
| - chromeos::CrosSettings::Get() | 
| - ->GetPref(chromeos::kSystemTimezone) | 
| - ->DeepCopy()); | 
| - } | 
| + if (property_name == kPropertyTimezone) | 
| + return GetUserTimezoneValue(context_); | 
| if (property_name == kPropertySupportedTimezones) { | 
| std::unique_ptr<base::ListValue> values = | 
| @@ -363,8 +375,13 @@ ExtensionFunction::ResponseAction ChromeosInfoPrivateSetFunction::Run() { | 
| if (param_name == kPropertyTimezone) { | 
| std::string param_value; | 
| EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, ¶m_value)); | 
| - chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, | 
| - base::Value(param_value)); | 
| + if (chromeos::system::PerUserTimezoneEnabled()) { | 
| + Profile::FromBrowserContext(context_)->GetPrefs()->SetString( | 
| + prefs::kUserTimezone, param_value); | 
| + } else { | 
| + chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, | 
| + base::Value(param_value)); | 
| + } | 
| } else { | 
| const char* pref_name = GetBoolPrefNameForApiProperty(param_name.c_str()); | 
| if (pref_name) { |