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/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 Loading... |
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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 registry->RegisterBooleanPref(prefs::kExternalStorageReadOnly, false); | 340 registry->RegisterBooleanPref(prefs::kExternalStorageReadOnly, false); |
336 | 341 |
337 registry->RegisterStringPref(prefs::kTermsOfServiceURL, ""); | 342 registry->RegisterStringPref(prefs::kTermsOfServiceURL, ""); |
338 | 343 |
339 registry->RegisterBooleanPref(prefs::kTouchHudProjectionEnabled, false); | 344 registry->RegisterBooleanPref(prefs::kTouchHudProjectionEnabled, false); |
340 | 345 |
341 registry->RegisterBooleanPref(prefs::kTouchVirtualKeyboardEnabled, false); | 346 registry->RegisterBooleanPref(prefs::kTouchVirtualKeyboardEnabled, false); |
342 | 347 |
343 input_method::InputMethodSyncer::RegisterProfilePrefs(registry); | 348 input_method::InputMethodSyncer::RegisterProfilePrefs(registry); |
344 | 349 |
| 350 std::string current_timezone_id; |
| 351 if (chromeos::CrosSettings::IsInitialized()) { |
| 352 // In unit tests CrosSettings is not always initialized. |
| 353 chromeos::CrosSettings::Get()->GetString(kSystemTimezone, |
| 354 ¤t_timezone_id); |
| 355 } |
| 356 // |current_timezone_id| will be empty if CrosSettings doesn't know the |
| 357 // timezone yet. |
| 358 registry->RegisterStringPref(prefs::kUserTimezone, current_timezone_id); |
| 359 |
345 registry->RegisterBooleanPref( | 360 registry->RegisterBooleanPref( |
346 prefs::kResolveTimezoneByGeolocation, true, | 361 prefs::kResolveTimezoneByGeolocation, true, |
347 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 362 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
348 | 363 |
349 registry->RegisterBooleanPref(prefs::kCaptivePortalAuthenticationIgnoresProxy, | 364 registry->RegisterBooleanPref(prefs::kCaptivePortalAuthenticationIgnoresProxy, |
350 true); | 365 true); |
351 | 366 |
352 registry->RegisterBooleanPref(prefs::kForceMaximizeOnFirstRun, false); | 367 registry->RegisterBooleanPref(prefs::kForceMaximizeOnFirstRun, false); |
353 | 368 |
354 registry->RegisterBooleanPref(prefs::kLanguageImeMenuActivated, false); | 369 registry->RegisterBooleanPref(prefs::kLanguageImeMenuActivated, false); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); | 427 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); |
413 xkb_auto_repeat_delay_pref_.Init( | 428 xkb_auto_repeat_delay_pref_.Init( |
414 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); | 429 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); |
415 xkb_auto_repeat_interval_pref_.Init( | 430 xkb_auto_repeat_interval_pref_.Init( |
416 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); | 431 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); |
417 | 432 |
418 wake_on_wifi_darkconnect_.Init(prefs::kWakeOnWifiDarkConnect, prefs, | 433 wake_on_wifi_darkconnect_.Init(prefs::kWakeOnWifiDarkConnect, prefs, |
419 callback); | 434 callback); |
420 | 435 |
421 pref_change_registrar_.Init(prefs); | 436 pref_change_registrar_.Init(prefs); |
| 437 pref_change_registrar_.Add(prefs::kUserTimezone, callback); |
422 pref_change_registrar_.Add(prefs::kResolveTimezoneByGeolocation, callback); | 438 pref_change_registrar_.Add(prefs::kResolveTimezoneByGeolocation, callback); |
423 pref_change_registrar_.Add(prefs::kUse24HourClock, callback); | 439 pref_change_registrar_.Add(prefs::kUse24HourClock, callback); |
424 for (auto* remap_pref : kLanguageRemapPrefs) | 440 for (auto* remap_pref : kLanguageRemapPrefs) |
425 pref_change_registrar_.Add(remap_pref, callback); | 441 pref_change_registrar_.Add(remap_pref, callback); |
426 } | 442 } |
427 | 443 |
428 void Preferences::Init(Profile* profile, const user_manager::User* user) { | 444 void Preferences::Init(Profile* profile, const user_manager::User* user) { |
429 DCHECK(profile); | 445 DCHECK(profile); |
430 DCHECK(user); | 446 DCHECK(user); |
431 sync_preferences::PrefServiceSyncable* prefs = | 447 sync_preferences::PrefServiceSyncable* prefs = |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 // The flag enables wake on WiFi packet feature but doesn't update a | 722 // The flag enables wake on WiFi packet feature but doesn't update a |
707 // preference. | 723 // preference. |
708 if (base::CommandLine::ForCurrentProcess()-> | 724 if (base::CommandLine::ForCurrentProcess()-> |
709 HasSwitch(switches::kWakeOnWifiPacket)) { | 725 HasSwitch(switches::kWakeOnWifiPacket)) { |
710 features |= WakeOnWifiManager::WAKE_ON_WIFI_PACKET; | 726 features |= WakeOnWifiManager::WAKE_ON_WIFI_PACKET; |
711 } | 727 } |
712 WakeOnWifiManager::Get()->OnPreferenceChanged( | 728 WakeOnWifiManager::Get()->OnPreferenceChanged( |
713 static_cast<WakeOnWifiManager::WakeOnWifiFeature>(features)); | 729 static_cast<WakeOnWifiManager::WakeOnWifiFeature>(features)); |
714 } | 730 } |
715 | 731 |
| 732 if (pref_name == prefs::kUserTimezone && |
| 733 reason != REASON_ACTIVE_USER_CHANGED) { |
| 734 system::UpdateSystemTimezone(ProfileHelper::Get()->GetProfileByUser(user_)); |
| 735 } |
| 736 |
716 if (pref_name == prefs::kResolveTimezoneByGeolocation && | 737 if (pref_name == prefs::kResolveTimezoneByGeolocation && |
717 reason != REASON_ACTIVE_USER_CHANGED) { | 738 reason != REASON_ACTIVE_USER_CHANGED) { |
718 const bool value = prefs_->GetBoolean(prefs::kResolveTimezoneByGeolocation); | 739 const bool value = prefs_->GetBoolean(prefs::kResolveTimezoneByGeolocation); |
719 if (user_is_owner) { | 740 if (user_is_owner) { |
720 g_browser_process->local_state()->SetBoolean( | 741 g_browser_process->local_state()->SetBoolean( |
721 prefs::kResolveDeviceTimezoneByGeolocation, value); | 742 prefs::kResolveDeviceTimezoneByGeolocation, value); |
722 } | 743 } |
723 if (user_is_primary_) { | 744 if (user_is_primary_) { |
724 g_browser_process->platform_part() | 745 g_browser_process->platform_part() |
725 ->GetTimezoneResolverManager() | 746 ->GetTimezoneResolverManager() |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 touch_hud_projection_enabled_.SetValue(enabled); | 862 touch_hud_projection_enabled_.SetValue(enabled); |
842 } | 863 } |
843 | 864 |
844 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { | 865 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { |
845 if (active_user != user_) | 866 if (active_user != user_) |
846 return; | 867 return; |
847 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); | 868 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); |
848 } | 869 } |
849 | 870 |
850 } // namespace chromeos | 871 } // namespace chromeos |
OLD | NEW |