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..5645f6d4bf5d11ef290adae3d401e0f9c86c8178 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" |
@@ -63,6 +67,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 +102,17 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler, |
return; |
} |
- CrosSettings::Get()->SetString(kSystemTimezone, timezone_id); |
+ if (system::PerUserTimezoneEnabled()) { |
+ Profile* profile = Profile::FromBrowserContext( |
+ web_ui()->GetWebContents()->GetBrowserContext()); |
+ DCHECK(profile); |
+ Profile* primary_profile = ProfileManager::GetPrimaryUserProfile(); |
+ if (primary_profile && profile->IsSameProfile(primary_profile)) { |
+ profile->GetPrefs()->SetString(prefs::kUserTimezone, timezone_id); |
+ } |
+ } else { |
+ CrosSettings::Get()->SetString(kSystemTimezone, timezone_id); |
+ } |
stevenjb
2017/05/25 22:13:06
This seems like another case where it would be bet
Alexander Alekseev
2017/05/29 21:10:23
Done.
stevenjb
2017/05/30 16:47:18
Again, this is logic I would prefer to see in timz
Alexander Alekseev
2017/07/06 06:30:28
Done.
|
} |
DISALLOW_COPY_AND_ASSIGN(SetTimeMessageHandler); |