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

Unified Diff: chrome/browser/chromeos/extensions/info_private_api.cc

Issue 2849823003: ChromeOS: implement per-user time zone preferences. (Closed)
Patch Set: Moved more code to previous CL. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
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..6e50990e7077b2fd5fcd62243e362e899bcfef4a 100644
--- a/chrome/browser/chromeos/extensions/info_private_api.cc
+++ b/chrome/browser/chromeos/extensions/info_private_api.cc
@@ -326,11 +326,19 @@ std::unique_ptr<base::Value> ChromeosInfoPrivateGetFunction::GetValue(
}
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 (chromeos::system::PerUserTimezoneEnabled()) {
+ return base::WrapUnique<base::Value>(
+ Profile::FromBrowserContext(context_)
+ ->GetPrefs()
+ ->GetUserPrefValue(prefs::kUserTimezone)
+ ->DeepCopy());
+ } 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.
+ // 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 == kPropertySupportedTimezones) {
@@ -363,8 +371,13 @@ ExtensionFunction::ResponseAction ChromeosInfoPrivateSetFunction::Run() {
if (param_name == kPropertyTimezone) {
std::string param_value;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &param_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) {

Powered by Google App Engine
This is Rietveld 408576698