Index: chrome/browser/ui/webui/chromeos/set_time_ui.cc |
diff --git a/chrome/browser/ui/webui/chromeos/set_time_ui.cc b/chrome/browser/ui/webui/chromeos/set_time_ui.cc |
index 98871678f7e8a217b48ccf01af37e73d426bafec..62433a99ad19061c17cf2b766e22b58a6f30f60c 100644 |
--- a/chrome/browser/ui/webui/chromeos/set_time_ui.cc |
+++ b/chrome/browser/ui/webui/chromeos/set_time_ui.cc |
@@ -15,6 +15,8 @@ |
#include "chrome/browser/chromeos/settings/cros_settings.h" |
#include "chrome/browser/chromeos/system/timezone_util.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/profiles/profile_manager.h" |
+#include "chrome/common/pref_names.h" |
#include "chrome/common/url_constants.h" |
#include "chrome/grit/browser_resources.h" |
#include "chrome/grit/generated_resources.h" |
@@ -22,6 +24,8 @@ |
#include "chromeos/dbus/system_clock_client.h" |
#include "chromeos/login/login_state.h" |
#include "chromeos/settings/timezone_settings.h" |
+#include "components/prefs/pref_service.h" |
+#include "content/public/browser/web_contents.h" |
#include "content/public/browser/web_ui.h" |
#include "content/public/browser/web_ui_data_source.h" |
#include "content/public/browser/web_ui_message_handler.h" |
@@ -30,6 +34,16 @@ namespace chromeos { |
namespace { |
+void SetUserTimezone(content::BrowserContext* browser_context, |
+ const std::string& timezone_id) { |
+ Profile* profile = Profile::FromBrowserContext(browser_context); |
+ DCHECK(profile); |
+ Profile* primary_profile = ProfileManager::GetPrimaryUserProfile(); |
+ if (primary_profile && profile->IsSameProfile(primary_profile)) { |
+ profile->GetPrefs()->SetString(prefs::kUserTimezone, timezone_id); |
+ } |
+} |
+ |
class SetTimeMessageHandler : public content::WebUIMessageHandler, |
public chromeos::SystemClockClient::Observer, |
public system::TimezoneSettings::Observer { |
@@ -63,6 +77,10 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler, |
web_ui()->CallJavascriptFunctionUnsafe("settime.TimeSetter.updateTime"); |
} |
+ // UI actually shows real device timezone, but only allows changing the user |
+ // timezone. If user timezone settings are different from system, this means |
+ // that user settings are overriden and must be disabled. (And we will still |
+ // show the actual device timezone.) |
// system::TimezoneSettings::Observer: |
void TimezoneChanged(const icu::TimeZone& timezone) override { |
base::Value timezone_id(system::TimezoneSettings::GetTimezoneID(timezone)); |
@@ -94,7 +112,12 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler, |
return; |
} |
- CrosSettings::Get()->SetString(kSystemTimezone, timezone_id); |
+ if (system::PerUserTimezoneEnabled()) { |
+ SetUserTimezone(web_ui()->GetWebContents()->GetBrowserContext(), |
michaelpg
2017/05/30 22:21:23
Please test this UI on the sign-in screen as well
Alexander Alekseev
2017/07/06 06:30:29
SigninProfile.
I updated this code (in timezone_u
|
+ timezone_id); |
+ } else { |
+ CrosSettings::Get()->SetString(kSystemTimezone, timezone_id); |
+ } |
} |
DISALLOW_COPY_AND_ASSIGN(SetTimeMessageHandler); |