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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/preferences.h" 5 #include "chrome/browser/chromeos/preferences.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/accessibility_types.h" 9 #include "ash/accessibility_types.h"
10 #include "ash/ash_constants.h" 10 #include "ash/ash_constants.h"
11 #include "ash/autoclick/autoclick_controller.h" 11 #include "ash/autoclick/autoclick_controller.h"
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/i18n/time_formatting.h" 14 #include "base/i18n/time_formatting.h"
15 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/chrome_notification_types.h" 20 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 21 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
22 #include "chrome/browser/chromeos/ash_config.h" 22 #include "chrome/browser/chromeos/ash_config.h"
23 #include "chrome/browser/chromeos/drive/file_system_util.h" 23 #include "chrome/browser/chromeos/drive/file_system_util.h"
24 #include "chrome/browser/chromeos/input_method/input_method_syncer.h" 24 #include "chrome/browser/chromeos/input_method/input_method_syncer.h"
25 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 25 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
26 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" 26 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h"
27 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 27 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
28 #include "chrome/browser/chromeos/profiles/profile_helper.h"
29 #include "chrome/browser/chromeos/settings/cros_settings.h"
28 #include "chrome/browser/chromeos/system/input_device_settings.h" 30 #include "chrome/browser/chromeos/system/input_device_settings.h"
29 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" 31 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h"
32 #include "chrome/browser/chromeos/system/timezone_util.h"
30 #include "chrome/browser/download/download_prefs.h" 33 #include "chrome/browser/download/download_prefs.h"
31 #include "chrome/browser/prefs/pref_service_syncable_util.h" 34 #include "chrome/browser/prefs/pref_service_syncable_util.h"
32 #include "chrome/common/chrome_features.h" 35 #include "chrome/common/chrome_features.h"
33 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
34 #include "chromeos/chromeos_switches.h" 37 #include "chromeos/chromeos_switches.h"
38 #include "chromeos/settings/cros_settings_names.h"
35 #include "chromeos/system/devicemode.h" 39 #include "chromeos/system/devicemode.h"
36 #include "chromeos/system/statistics_provider.h" 40 #include "chromeos/system/statistics_provider.h"
37 #include "chromeos/timezone/timezone_resolver.h" 41 #include "chromeos/timezone/timezone_resolver.h"
38 #include "components/drive/drive_pref_names.h" 42 #include "components/drive/drive_pref_names.h"
39 #include "components/feedback/tracing_manager.h" 43 #include "components/feedback/tracing_manager.h"
40 #include "components/pref_registry/pref_registry_syncable.h" 44 #include "components/pref_registry/pref_registry_syncable.h"
41 #include "components/prefs/pref_member.h" 45 #include "components/prefs/pref_member.h"
42 #include "components/prefs/pref_registry_simple.h" 46 #include "components/prefs/pref_registry_simple.h"
43 #include "components/prefs/scoped_user_pref_update.h" 47 #include "components/prefs/scoped_user_pref_update.h"
44 #include "components/sync_preferences/pref_service_syncable.h" 48 #include "components/sync_preferences/pref_service_syncable.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 111
108 // static 112 // static
109 void Preferences::RegisterPrefs(PrefRegistrySimple* registry) { 113 void Preferences::RegisterPrefs(PrefRegistrySimple* registry) {
110 registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false); 114 registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false);
111 registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true); 115 registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true);
112 registry->RegisterBooleanPref(prefs::kAccessibilityVirtualKeyboardEnabled, 116 registry->RegisterBooleanPref(prefs::kAccessibilityVirtualKeyboardEnabled,
113 false); 117 false);
114 registry->RegisterBooleanPref(prefs::kAccessibilityMonoAudioEnabled, 118 registry->RegisterBooleanPref(prefs::kAccessibilityMonoAudioEnabled,
115 false); 119 false);
116 registry->RegisterStringPref(prefs::kLogoutStartedLast, std::string()); 120 registry->RegisterStringPref(prefs::kLogoutStartedLast, std::string());
121 registry->RegisterStringPref(prefs::kSigninScreenTimezone, std::string());
117 registry->RegisterBooleanPref(prefs::kResolveDeviceTimezoneByGeolocation, 122 registry->RegisterBooleanPref(prefs::kResolveDeviceTimezoneByGeolocation,
118 true); 123 true);
119 registry->RegisterIntegerPref( 124 registry->RegisterIntegerPref(
120 prefs::kSystemTimezoneAutomaticDetectionPolicy, 125 prefs::kSystemTimezoneAutomaticDetectionPolicy,
121 enterprise_management::SystemTimezoneProto::USERS_DECIDE); 126 enterprise_management::SystemTimezoneProto::USERS_DECIDE);
122 } 127 }
123 128
124 // static 129 // static
125 void Preferences::RegisterProfilePrefs( 130 void Preferences::RegisterProfilePrefs(
126 user_prefs::PrefRegistrySyncable* registry) { 131 user_prefs::PrefRegistrySyncable* registry) {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 registry->RegisterBooleanPref(prefs::kExternalStorageReadOnly, false); 335 registry->RegisterBooleanPref(prefs::kExternalStorageReadOnly, false);
331 336
332 registry->RegisterStringPref(prefs::kTermsOfServiceURL, ""); 337 registry->RegisterStringPref(prefs::kTermsOfServiceURL, "");
333 338
334 registry->RegisterBooleanPref(prefs::kTouchHudProjectionEnabled, false); 339 registry->RegisterBooleanPref(prefs::kTouchHudProjectionEnabled, false);
335 340
336 registry->RegisterBooleanPref(prefs::kTouchVirtualKeyboardEnabled, false); 341 registry->RegisterBooleanPref(prefs::kTouchVirtualKeyboardEnabled, false);
337 342
338 input_method::InputMethodSyncer::RegisterProfilePrefs(registry); 343 input_method::InputMethodSyncer::RegisterProfilePrefs(registry);
339 344
345 std::string current_timezone_id;
346 chromeos::CrosSettings::Get()->GetString(kSystemTimezone,
347 &current_timezone_id);
348 // |current_timezone_id| will be empty if CrosSettings doesn't know the
349 // timezone yet.
350 registry->RegisterStringPref(prefs::kUserTimezone, current_timezone_id);
351
340 registry->RegisterBooleanPref( 352 registry->RegisterBooleanPref(
341 prefs::kResolveTimezoneByGeolocation, true, 353 prefs::kResolveTimezoneByGeolocation, true,
342 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 354 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
343 355
344 registry->RegisterBooleanPref(prefs::kCaptivePortalAuthenticationIgnoresProxy, 356 registry->RegisterBooleanPref(prefs::kCaptivePortalAuthenticationIgnoresProxy,
345 true); 357 true);
346 358
347 registry->RegisterBooleanPref(prefs::kForceMaximizeOnFirstRun, false); 359 registry->RegisterBooleanPref(prefs::kForceMaximizeOnFirstRun, false);
348 360
349 registry->RegisterBooleanPref(prefs::kLanguageImeMenuActivated, false); 361 registry->RegisterBooleanPref(prefs::kLanguageImeMenuActivated, false);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); 419 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback);
408 xkb_auto_repeat_delay_pref_.Init( 420 xkb_auto_repeat_delay_pref_.Init(
409 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); 421 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback);
410 xkb_auto_repeat_interval_pref_.Init( 422 xkb_auto_repeat_interval_pref_.Init(
411 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); 423 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback);
412 424
413 wake_on_wifi_darkconnect_.Init(prefs::kWakeOnWifiDarkConnect, prefs, 425 wake_on_wifi_darkconnect_.Init(prefs::kWakeOnWifiDarkConnect, prefs,
414 callback); 426 callback);
415 427
416 pref_change_registrar_.Init(prefs); 428 pref_change_registrar_.Init(prefs);
429 pref_change_registrar_.Add(prefs::kUserTimezone, callback);
417 pref_change_registrar_.Add(prefs::kResolveTimezoneByGeolocation, callback); 430 pref_change_registrar_.Add(prefs::kResolveTimezoneByGeolocation, callback);
418 pref_change_registrar_.Add(prefs::kUse24HourClock, callback); 431 pref_change_registrar_.Add(prefs::kUse24HourClock, callback);
419 for (auto* remap_pref : kLanguageRemapPrefs) 432 for (auto* remap_pref : kLanguageRemapPrefs)
420 pref_change_registrar_.Add(remap_pref, callback); 433 pref_change_registrar_.Add(remap_pref, callback);
421 } 434 }
422 435
423 void Preferences::Init(Profile* profile, const user_manager::User* user) { 436 void Preferences::Init(Profile* profile, const user_manager::User* user) {
424 DCHECK(profile); 437 DCHECK(profile);
425 DCHECK(user); 438 DCHECK(user);
426 sync_preferences::PrefServiceSyncable* prefs = 439 sync_preferences::PrefServiceSyncable* prefs =
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 // The flag enables wake on WiFi packet feature but doesn't update a 714 // The flag enables wake on WiFi packet feature but doesn't update a
702 // preference. 715 // preference.
703 if (base::CommandLine::ForCurrentProcess()-> 716 if (base::CommandLine::ForCurrentProcess()->
704 HasSwitch(switches::kWakeOnWifiPacket)) { 717 HasSwitch(switches::kWakeOnWifiPacket)) {
705 features |= WakeOnWifiManager::WAKE_ON_WIFI_PACKET; 718 features |= WakeOnWifiManager::WAKE_ON_WIFI_PACKET;
706 } 719 }
707 WakeOnWifiManager::Get()->OnPreferenceChanged( 720 WakeOnWifiManager::Get()->OnPreferenceChanged(
708 static_cast<WakeOnWifiManager::WakeOnWifiFeature>(features)); 721 static_cast<WakeOnWifiManager::WakeOnWifiFeature>(features));
709 } 722 }
710 723
724 if (pref_name == prefs::kUserTimezone &&
725 reason != REASON_ACTIVE_USER_CHANGED) {
726 system::UpdateSystemTimezone(ProfileHelper::Get()->GetProfileByUser(user_));
727 }
728
711 if (pref_name == prefs::kResolveTimezoneByGeolocation && 729 if (pref_name == prefs::kResolveTimezoneByGeolocation &&
712 reason != REASON_ACTIVE_USER_CHANGED) { 730 reason != REASON_ACTIVE_USER_CHANGED) {
713 const bool value = prefs_->GetBoolean(prefs::kResolveTimezoneByGeolocation); 731 const bool value = prefs_->GetBoolean(prefs::kResolveTimezoneByGeolocation);
714 if (user_is_owner) { 732 if (user_is_owner) {
715 g_browser_process->local_state()->SetBoolean( 733 g_browser_process->local_state()->SetBoolean(
716 prefs::kResolveDeviceTimezoneByGeolocation, value); 734 prefs::kResolveDeviceTimezoneByGeolocation, value);
717 } 735 }
718 if (user_is_primary_) { 736 if (user_is_primary_) {
719 g_browser_process->platform_part() 737 g_browser_process->platform_part()
720 ->GetTimezoneResolverManager() 738 ->GetTimezoneResolverManager()
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 touch_hud_projection_enabled_.SetValue(enabled); 854 touch_hud_projection_enabled_.SetValue(enabled);
837 } 855 }
838 856
839 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { 857 void Preferences::ActiveUserChanged(const user_manager::User* active_user) {
840 if (active_user != user_) 858 if (active_user != user_)
841 return; 859 return;
842 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); 860 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, "");
843 } 861 }
844 862
845 } // namespace chromeos 863 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698