OLD | NEW |
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/browser/ui/ash/ash_util.h" | 35 #include "chrome/browser/ui/ash/ash_util.h" |
33 #include "chrome/common/chrome_features.h" | 36 #include "chrome/common/chrome_features.h" |
34 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
35 #include "chromeos/chromeos_switches.h" | 38 #include "chromeos/chromeos_switches.h" |
| 39 #include "chromeos/settings/cros_settings_names.h" |
36 #include "chromeos/system/devicemode.h" | 40 #include "chromeos/system/devicemode.h" |
37 #include "chromeos/system/statistics_provider.h" | 41 #include "chromeos/system/statistics_provider.h" |
38 #include "chromeos/timezone/timezone_resolver.h" | 42 #include "chromeos/timezone/timezone_resolver.h" |
39 #include "components/drive/drive_pref_names.h" | 43 #include "components/drive/drive_pref_names.h" |
40 #include "components/feedback/tracing_manager.h" | 44 #include "components/feedback/tracing_manager.h" |
41 #include "components/pref_registry/pref_registry_syncable.h" | 45 #include "components/pref_registry/pref_registry_syncable.h" |
42 #include "components/prefs/pref_member.h" | 46 #include "components/prefs/pref_member.h" |
43 #include "components/prefs/pref_registry_simple.h" | 47 #include "components/prefs/pref_registry_simple.h" |
44 #include "components/prefs/scoped_user_pref_update.h" | 48 #include "components/prefs/scoped_user_pref_update.h" |
45 #include "components/sync_preferences/pref_service_syncable.h" | 49 #include "components/sync_preferences/pref_service_syncable.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 112 |
109 // static | 113 // static |
110 void Preferences::RegisterPrefs(PrefRegistrySimple* registry) { | 114 void Preferences::RegisterPrefs(PrefRegistrySimple* registry) { |
111 registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false); | 115 registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false); |
112 registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true); | 116 registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true); |
113 registry->RegisterBooleanPref(prefs::kAccessibilityVirtualKeyboardEnabled, | 117 registry->RegisterBooleanPref(prefs::kAccessibilityVirtualKeyboardEnabled, |
114 false); | 118 false); |
115 registry->RegisterBooleanPref(prefs::kAccessibilityMonoAudioEnabled, | 119 registry->RegisterBooleanPref(prefs::kAccessibilityMonoAudioEnabled, |
116 false); | 120 false); |
117 registry->RegisterStringPref(prefs::kLogoutStartedLast, std::string()); | 121 registry->RegisterStringPref(prefs::kLogoutStartedLast, std::string()); |
| 122 registry->RegisterStringPref(prefs::kSigninScreenTimezone, std::string()); |
118 registry->RegisterBooleanPref(prefs::kResolveDeviceTimezoneByGeolocation, | 123 registry->RegisterBooleanPref(prefs::kResolveDeviceTimezoneByGeolocation, |
119 true); | 124 true); |
120 registry->RegisterIntegerPref( | 125 registry->RegisterIntegerPref( |
121 prefs::kSystemTimezoneAutomaticDetectionPolicy, | 126 prefs::kSystemTimezoneAutomaticDetectionPolicy, |
122 enterprise_management::SystemTimezoneProto::USERS_DECIDE); | 127 enterprise_management::SystemTimezoneProto::USERS_DECIDE); |
123 } | 128 } |
124 | 129 |
125 // static | 130 // static |
126 void Preferences::RegisterProfilePrefs( | 131 void Preferences::RegisterProfilePrefs( |
127 user_prefs::PrefRegistrySyncable* registry) { | 132 user_prefs::PrefRegistrySyncable* registry) { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 registry->RegisterBooleanPref(prefs::kExternalStorageReadOnly, false); | 342 registry->RegisterBooleanPref(prefs::kExternalStorageReadOnly, false); |
338 | 343 |
339 registry->RegisterStringPref(prefs::kTermsOfServiceURL, ""); | 344 registry->RegisterStringPref(prefs::kTermsOfServiceURL, ""); |
340 | 345 |
341 registry->RegisterBooleanPref(prefs::kTouchHudProjectionEnabled, false); | 346 registry->RegisterBooleanPref(prefs::kTouchHudProjectionEnabled, false); |
342 | 347 |
343 registry->RegisterBooleanPref(prefs::kTouchVirtualKeyboardEnabled, false); | 348 registry->RegisterBooleanPref(prefs::kTouchVirtualKeyboardEnabled, false); |
344 | 349 |
345 input_method::InputMethodSyncer::RegisterProfilePrefs(registry); | 350 input_method::InputMethodSyncer::RegisterProfilePrefs(registry); |
346 | 351 |
| 352 std::string current_timezone_id; |
| 353 if (chromeos::CrosSettings::IsInitialized()) { |
| 354 // In unit tests CrosSettings is not always initialized. |
| 355 chromeos::CrosSettings::Get()->GetString(kSystemTimezone, |
| 356 ¤t_timezone_id); |
| 357 } |
| 358 // |current_timezone_id| will be empty if CrosSettings doesn't know the |
| 359 // timezone yet. |
| 360 registry->RegisterStringPref(prefs::kUserTimezone, current_timezone_id); |
| 361 |
347 registry->RegisterBooleanPref( | 362 registry->RegisterBooleanPref( |
348 prefs::kResolveTimezoneByGeolocation, true, | 363 prefs::kResolveTimezoneByGeolocation, true, |
349 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 364 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
350 | 365 |
351 registry->RegisterBooleanPref(prefs::kCaptivePortalAuthenticationIgnoresProxy, | 366 registry->RegisterBooleanPref(prefs::kCaptivePortalAuthenticationIgnoresProxy, |
352 true); | 367 true); |
353 | 368 |
354 registry->RegisterBooleanPref(prefs::kForceMaximizeOnFirstRun, false); | 369 registry->RegisterBooleanPref(prefs::kForceMaximizeOnFirstRun, false); |
355 | 370 |
356 registry->RegisterBooleanPref(prefs::kLanguageImeMenuActivated, false); | 371 registry->RegisterBooleanPref(prefs::kLanguageImeMenuActivated, false); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); | 429 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); |
415 xkb_auto_repeat_delay_pref_.Init( | 430 xkb_auto_repeat_delay_pref_.Init( |
416 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); | 431 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); |
417 xkb_auto_repeat_interval_pref_.Init( | 432 xkb_auto_repeat_interval_pref_.Init( |
418 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); | 433 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); |
419 | 434 |
420 wake_on_wifi_darkconnect_.Init(prefs::kWakeOnWifiDarkConnect, prefs, | 435 wake_on_wifi_darkconnect_.Init(prefs::kWakeOnWifiDarkConnect, prefs, |
421 callback); | 436 callback); |
422 | 437 |
423 pref_change_registrar_.Init(prefs); | 438 pref_change_registrar_.Init(prefs); |
| 439 pref_change_registrar_.Add(prefs::kUserTimezone, callback); |
424 pref_change_registrar_.Add(prefs::kResolveTimezoneByGeolocation, callback); | 440 pref_change_registrar_.Add(prefs::kResolveTimezoneByGeolocation, callback); |
425 pref_change_registrar_.Add(prefs::kUse24HourClock, callback); | 441 pref_change_registrar_.Add(prefs::kUse24HourClock, callback); |
426 for (auto* remap_pref : kLanguageRemapPrefs) | 442 for (auto* remap_pref : kLanguageRemapPrefs) |
427 pref_change_registrar_.Add(remap_pref, callback); | 443 pref_change_registrar_.Add(remap_pref, callback); |
428 } | 444 } |
429 | 445 |
430 void Preferences::Init(Profile* profile, const user_manager::User* user) { | 446 void Preferences::Init(Profile* profile, const user_manager::User* user) { |
431 DCHECK(profile); | 447 DCHECK(profile); |
432 DCHECK(user); | 448 DCHECK(user); |
433 sync_preferences::PrefServiceSyncable* prefs = | 449 sync_preferences::PrefServiceSyncable* prefs = |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 // The flag enables wake on WiFi packet feature but doesn't update a | 724 // The flag enables wake on WiFi packet feature but doesn't update a |
709 // preference. | 725 // preference. |
710 if (base::CommandLine::ForCurrentProcess()-> | 726 if (base::CommandLine::ForCurrentProcess()-> |
711 HasSwitch(switches::kWakeOnWifiPacket)) { | 727 HasSwitch(switches::kWakeOnWifiPacket)) { |
712 features |= WakeOnWifiManager::WAKE_ON_WIFI_PACKET; | 728 features |= WakeOnWifiManager::WAKE_ON_WIFI_PACKET; |
713 } | 729 } |
714 WakeOnWifiManager::Get()->OnPreferenceChanged( | 730 WakeOnWifiManager::Get()->OnPreferenceChanged( |
715 static_cast<WakeOnWifiManager::WakeOnWifiFeature>(features)); | 731 static_cast<WakeOnWifiManager::WakeOnWifiFeature>(features)); |
716 } | 732 } |
717 | 733 |
| 734 if (pref_name == prefs::kUserTimezone && |
| 735 reason != REASON_ACTIVE_USER_CHANGED) { |
| 736 system::UpdateSystemTimezone(ProfileHelper::Get()->GetProfileByUser(user_)); |
| 737 } |
| 738 |
718 if (pref_name == prefs::kResolveTimezoneByGeolocation && | 739 if (pref_name == prefs::kResolveTimezoneByGeolocation && |
719 reason != REASON_ACTIVE_USER_CHANGED) { | 740 reason != REASON_ACTIVE_USER_CHANGED) { |
720 const bool value = prefs_->GetBoolean(prefs::kResolveTimezoneByGeolocation); | 741 const bool value = prefs_->GetBoolean(prefs::kResolveTimezoneByGeolocation); |
721 if (user_is_owner) { | 742 if (user_is_owner) { |
722 g_browser_process->local_state()->SetBoolean( | 743 g_browser_process->local_state()->SetBoolean( |
723 prefs::kResolveDeviceTimezoneByGeolocation, value); | 744 prefs::kResolveDeviceTimezoneByGeolocation, value); |
724 } | 745 } |
725 if (user_is_primary_) { | 746 if (user_is_primary_) { |
726 g_browser_process->platform_part() | 747 g_browser_process->platform_part() |
727 ->GetTimezoneResolverManager() | 748 ->GetTimezoneResolverManager() |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 touch_hud_projection_enabled_.SetValue(enabled); | 864 touch_hud_projection_enabled_.SetValue(enabled); |
844 } | 865 } |
845 | 866 |
846 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { | 867 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { |
847 if (active_user != user_) | 868 if (active_user != user_) |
848 return; | 869 return; |
849 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); | 870 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); |
850 } | 871 } |
851 | 872 |
852 } // namespace chromeos | 873 } // namespace chromeos |
OLD | NEW |