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

Unified Diff: chrome/browser/chromeos/preferences.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/chromeos/preferences.cc
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index 14ec86b2b42664a965fe0e5e656b9d044d7ac1be..dd390765d632a3918ddd6393420b4e99c8d41d82 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -25,13 +25,17 @@
#include "chrome/browser/chromeos/login/session/user_session_manager.h"
#include "chrome/browser/chromeos/net/wake_on_wifi_manager.h"
#include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/chromeos/system/timezone_resolver_manager.h"
+#include "chrome/browser/chromeos/system/timezone_util.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/prefs/pref_service_syncable_util.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chromeos/chromeos_switches.h"
+#include "chromeos/settings/cros_settings_names.h"
#include "chromeos/system/devicemode.h"
#include "chromeos/system/statistics_provider.h"
#include "chromeos/timezone/timezone_resolver.h"
@@ -114,6 +118,7 @@ void Preferences::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kAccessibilityMonoAudioEnabled,
false);
registry->RegisterStringPref(prefs::kLogoutStartedLast, std::string());
+ registry->RegisterStringPref(prefs::kSigninScreenTimezone, std::string());
registry->RegisterBooleanPref(prefs::kResolveDeviceTimezoneByGeolocation,
true);
registry->RegisterIntegerPref(
@@ -337,6 +342,13 @@ void Preferences::RegisterProfilePrefs(
input_method::InputMethodSyncer::RegisterProfilePrefs(registry);
+ std::string current_timezone_id;
+ chromeos::CrosSettings::Get()->GetString(kSystemTimezone,
+ &current_timezone_id);
+ // |current_timezone_id| will be empty if CrosSettings doesn't know the
+ // timezone yet.
+ registry->RegisterStringPref(prefs::kUserTimezone, current_timezone_id);
+
registry->RegisterBooleanPref(
prefs::kResolveTimezoneByGeolocation, true,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
@@ -414,6 +426,7 @@ void Preferences::InitUserPrefs(sync_preferences::PrefServiceSyncable* prefs) {
callback);
pref_change_registrar_.Init(prefs);
+ pref_change_registrar_.Add(prefs::kUserTimezone, callback);
pref_change_registrar_.Add(prefs::kResolveTimezoneByGeolocation, callback);
pref_change_registrar_.Add(prefs::kUse24HourClock, callback);
for (auto* remap_pref : kLanguageRemapPrefs)
@@ -708,6 +721,11 @@ void Preferences::ApplyPreferences(ApplyReason reason,
static_cast<WakeOnWifiManager::WakeOnWifiFeature>(features));
}
+ if (pref_name == prefs::kUserTimezone &&
+ reason != REASON_ACTIVE_USER_CHANGED) {
+ system::UpdateSystemTimezone(ProfileHelper::Get()->GetProfileByUser(user_));
+ }
+
if (pref_name == prefs::kResolveTimezoneByGeolocation &&
reason != REASON_ACTIVE_USER_CHANGED) {
const bool value = prefs_->GetBoolean(prefs::kResolveTimezoneByGeolocation);

Powered by Google App Engine
This is Rietveld 408576698