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

Unified Diff: chrome/browser/ui/webui/chromeos/set_time_ui.cc

Issue 2849823003: ChromeOS: implement per-user time zone preferences. (Closed)
Patch Set: Try remove g_browser_process check 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/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..f19c9a0be42eb89c834278fe3ba3b8cbe6cadd39 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));
@@ -93,8 +101,13 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler,
NOTREACHED();
return;
}
-
- CrosSettings::Get()->SetString(kSystemTimezone, timezone_id);
+ 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);
+ }
}
DISALLOW_COPY_AND_ASSIGN(SetTimeMessageHandler);

Powered by Google App Engine
This is Rietveld 408576698