| 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/browser/ui/ash/system_tray_client.h" | 36 #include "chrome/browser/ui/ash/system_tray_client.h" |
| 34 #include "chrome/common/chrome_features.h" | 37 #include "chrome/common/chrome_features.h" |
| 35 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
| 36 #include "chromeos/chromeos_switches.h" | 39 #include "chromeos/chromeos_switches.h" |
| 40 #include "chromeos/settings/cros_settings_names.h" |
| 37 #include "chromeos/system/devicemode.h" | 41 #include "chromeos/system/devicemode.h" |
| 38 #include "chromeos/system/statistics_provider.h" | 42 #include "chromeos/system/statistics_provider.h" |
| 39 #include "chromeos/timezone/timezone_resolver.h" | 43 #include "chromeos/timezone/timezone_resolver.h" |
| 40 #include "components/drive/drive_pref_names.h" | 44 #include "components/drive/drive_pref_names.h" |
| 41 #include "components/feedback/tracing_manager.h" | 45 #include "components/feedback/tracing_manager.h" |
| 42 #include "components/pref_registry/pref_registry_syncable.h" | 46 #include "components/pref_registry/pref_registry_syncable.h" |
| 43 #include "components/prefs/pref_member.h" | 47 #include "components/prefs/pref_member.h" |
| 44 #include "components/prefs/pref_registry_simple.h" | 48 #include "components/prefs/pref_registry_simple.h" |
| 45 #include "components/prefs/scoped_user_pref_update.h" | 49 #include "components/prefs/scoped_user_pref_update.h" |
| 46 #include "components/sync_preferences/pref_service_syncable.h" | 50 #include "components/sync_preferences/pref_service_syncable.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 113 |
| 110 // static | 114 // static |
| 111 void Preferences::RegisterPrefs(PrefRegistrySimple* registry) { | 115 void Preferences::RegisterPrefs(PrefRegistrySimple* registry) { |
| 112 registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false); | 116 registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false); |
| 113 registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true); | 117 registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true); |
| 114 registry->RegisterBooleanPref(prefs::kAccessibilityVirtualKeyboardEnabled, | 118 registry->RegisterBooleanPref(prefs::kAccessibilityVirtualKeyboardEnabled, |
| 115 false); | 119 false); |
| 116 registry->RegisterBooleanPref(prefs::kAccessibilityMonoAudioEnabled, | 120 registry->RegisterBooleanPref(prefs::kAccessibilityMonoAudioEnabled, |
| 117 false); | 121 false); |
| 118 registry->RegisterStringPref(prefs::kLogoutStartedLast, std::string()); | 122 registry->RegisterStringPref(prefs::kLogoutStartedLast, std::string()); |
| 123 registry->RegisterStringPref(prefs::kSigninScreenTimezone, std::string()); |
| 119 registry->RegisterBooleanPref(prefs::kResolveDeviceTimezoneByGeolocation, | 124 registry->RegisterBooleanPref(prefs::kResolveDeviceTimezoneByGeolocation, |
| 120 true); | 125 true); |
| 121 registry->RegisterIntegerPref( | 126 registry->RegisterIntegerPref( |
| 122 prefs::kSystemTimezoneAutomaticDetectionPolicy, | 127 prefs::kSystemTimezoneAutomaticDetectionPolicy, |
| 123 enterprise_management::SystemTimezoneProto::USERS_DECIDE); | 128 enterprise_management::SystemTimezoneProto::USERS_DECIDE); |
| 124 | 129 |
| 125 registry->RegisterStringPref(prefs::kCastReceiverName, ""); | 130 registry->RegisterStringPref(prefs::kCastReceiverName, ""); |
| 126 | 131 |
| 127 // Register ash prefs. | 132 // Register ash prefs. |
| 128 if (!ash_util::IsRunningInMash()) | 133 if (!ash_util::IsRunningInMash()) |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 registry->RegisterBooleanPref(prefs::kExternalStorageReadOnly, false); | 351 registry->RegisterBooleanPref(prefs::kExternalStorageReadOnly, false); |
| 347 | 352 |
| 348 registry->RegisterStringPref(prefs::kTermsOfServiceURL, ""); | 353 registry->RegisterStringPref(prefs::kTermsOfServiceURL, ""); |
| 349 | 354 |
| 350 registry->RegisterBooleanPref(prefs::kTouchHudProjectionEnabled, false); | 355 registry->RegisterBooleanPref(prefs::kTouchHudProjectionEnabled, false); |
| 351 | 356 |
| 352 registry->RegisterBooleanPref(prefs::kTouchVirtualKeyboardEnabled, false); | 357 registry->RegisterBooleanPref(prefs::kTouchVirtualKeyboardEnabled, false); |
| 353 | 358 |
| 354 input_method::InputMethodSyncer::RegisterProfilePrefs(registry); | 359 input_method::InputMethodSyncer::RegisterProfilePrefs(registry); |
| 355 | 360 |
| 361 std::string current_timezone_id; |
| 362 if (chromeos::CrosSettings::IsInitialized()) { |
| 363 // In unit tests CrosSettings is not always initialized. |
| 364 chromeos::CrosSettings::Get()->GetString(kSystemTimezone, |
| 365 ¤t_timezone_id); |
| 366 } |
| 367 // |current_timezone_id| will be empty if CrosSettings doesn't know the |
| 368 // timezone yet. |
| 369 registry->RegisterStringPref(prefs::kUserTimezone, current_timezone_id); |
| 370 |
| 356 registry->RegisterBooleanPref( | 371 registry->RegisterBooleanPref( |
| 357 prefs::kResolveTimezoneByGeolocation, true, | 372 prefs::kResolveTimezoneByGeolocation, true, |
| 358 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 373 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 359 | 374 |
| 360 registry->RegisterBooleanPref(prefs::kCaptivePortalAuthenticationIgnoresProxy, | 375 registry->RegisterBooleanPref(prefs::kCaptivePortalAuthenticationIgnoresProxy, |
| 361 true); | 376 true); |
| 362 | 377 |
| 363 registry->RegisterBooleanPref(prefs::kForceMaximizeOnFirstRun, false); | 378 registry->RegisterBooleanPref(prefs::kForceMaximizeOnFirstRun, false); |
| 364 | 379 |
| 365 registry->RegisterBooleanPref(prefs::kLanguageImeMenuActivated, false); | 380 registry->RegisterBooleanPref(prefs::kLanguageImeMenuActivated, false); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); | 440 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); |
| 426 xkb_auto_repeat_delay_pref_.Init( | 441 xkb_auto_repeat_delay_pref_.Init( |
| 427 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); | 442 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); |
| 428 xkb_auto_repeat_interval_pref_.Init( | 443 xkb_auto_repeat_interval_pref_.Init( |
| 429 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); | 444 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); |
| 430 | 445 |
| 431 wake_on_wifi_darkconnect_.Init(prefs::kWakeOnWifiDarkConnect, prefs, | 446 wake_on_wifi_darkconnect_.Init(prefs::kWakeOnWifiDarkConnect, prefs, |
| 432 callback); | 447 callback); |
| 433 | 448 |
| 434 pref_change_registrar_.Init(prefs); | 449 pref_change_registrar_.Init(prefs); |
| 450 pref_change_registrar_.Add(prefs::kUserTimezone, callback); |
| 435 pref_change_registrar_.Add(prefs::kResolveTimezoneByGeolocation, callback); | 451 pref_change_registrar_.Add(prefs::kResolveTimezoneByGeolocation, callback); |
| 436 pref_change_registrar_.Add(prefs::kUse24HourClock, callback); | 452 pref_change_registrar_.Add(prefs::kUse24HourClock, callback); |
| 437 for (auto* remap_pref : kLanguageRemapPrefs) | 453 for (auto* remap_pref : kLanguageRemapPrefs) |
| 438 pref_change_registrar_.Add(remap_pref, callback); | 454 pref_change_registrar_.Add(remap_pref, callback); |
| 439 } | 455 } |
| 440 | 456 |
| 441 void Preferences::Init(Profile* profile, const user_manager::User* user) { | 457 void Preferences::Init(Profile* profile, const user_manager::User* user) { |
| 442 DCHECK(profile); | 458 DCHECK(profile); |
| 443 DCHECK(user); | 459 DCHECK(user); |
| 444 sync_preferences::PrefServiceSyncable* prefs = | 460 sync_preferences::PrefServiceSyncable* prefs = |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 // The flag enables wake on WiFi packet feature but doesn't update a | 736 // The flag enables wake on WiFi packet feature but doesn't update a |
| 721 // preference. | 737 // preference. |
| 722 if (base::CommandLine::ForCurrentProcess()-> | 738 if (base::CommandLine::ForCurrentProcess()-> |
| 723 HasSwitch(switches::kWakeOnWifiPacket)) { | 739 HasSwitch(switches::kWakeOnWifiPacket)) { |
| 724 features |= WakeOnWifiManager::WAKE_ON_WIFI_PACKET; | 740 features |= WakeOnWifiManager::WAKE_ON_WIFI_PACKET; |
| 725 } | 741 } |
| 726 WakeOnWifiManager::Get()->OnPreferenceChanged( | 742 WakeOnWifiManager::Get()->OnPreferenceChanged( |
| 727 static_cast<WakeOnWifiManager::WakeOnWifiFeature>(features)); | 743 static_cast<WakeOnWifiManager::WakeOnWifiFeature>(features)); |
| 728 } | 744 } |
| 729 | 745 |
| 746 if (pref_name == prefs::kUserTimezone && |
| 747 reason != REASON_ACTIVE_USER_CHANGED) { |
| 748 system::UpdateSystemTimezone(ProfileHelper::Get()->GetProfileByUser(user_)); |
| 749 } |
| 750 |
| 730 if (pref_name == prefs::kResolveTimezoneByGeolocation && | 751 if (pref_name == prefs::kResolveTimezoneByGeolocation && |
| 731 reason != REASON_ACTIVE_USER_CHANGED) { | 752 reason != REASON_ACTIVE_USER_CHANGED) { |
| 732 const bool value = prefs_->GetBoolean(prefs::kResolveTimezoneByGeolocation); | 753 const bool value = prefs_->GetBoolean(prefs::kResolveTimezoneByGeolocation); |
| 733 if (user_is_owner) { | 754 if (user_is_owner) { |
| 734 g_browser_process->local_state()->SetBoolean( | 755 g_browser_process->local_state()->SetBoolean( |
| 735 prefs::kResolveDeviceTimezoneByGeolocation, value); | 756 prefs::kResolveDeviceTimezoneByGeolocation, value); |
| 736 } | 757 } |
| 737 if (user_is_primary_) { | 758 if (user_is_primary_) { |
| 738 g_browser_process->platform_part() | 759 g_browser_process->platform_part() |
| 739 ->GetTimezoneResolverManager() | 760 ->GetTimezoneResolverManager() |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 touch_hud_projection_enabled_.SetValue(enabled); | 876 touch_hud_projection_enabled_.SetValue(enabled); |
| 856 } | 877 } |
| 857 | 878 |
| 858 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { | 879 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { |
| 859 if (active_user != user_) | 880 if (active_user != user_) |
| 860 return; | 881 return; |
| 861 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); | 882 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); |
| 862 } | 883 } |
| 863 | 884 |
| 864 } // namespace chromeos | 885 } // namespace chromeos |
| OLD | NEW |