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

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

Issue 2849823003: ChromeOS: implement per-user time zone preferences. (Closed)
Patch Set: Fixed tests. 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..67e0a5db92dfd50eb2fb44fdb20e3585e5e381ad 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 allows to change only user
stevenjb 2017/05/15 17:08:02 s/to change only user timezone/only allows changin
Alexander Alekseev 2017/05/16 01:11:56 Done.
+ // 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