[email protected] | 487ba146 | 2012-01-05 03:13:09 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/chromeos/preferences.h" |
| 6 | |
Meilin Wang | 8a1e95b4 | 2019-02-27 22:01:51 | [diff] [blame] | 7 | #include <limits> |
[email protected] | 39699140 | 2014-02-17 10:56:17 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
Ken Rockot | b9bab54 | 2019-12-12 00:53:30 | [diff] [blame] | 10 | #include "ash/public/ash_interfaces.h" |
Steven Bennetts | 93d3e5b1 | 2018-05-05 01:14:50 | [diff] [blame] | 11 | #include "ash/public/cpp/ash_constants.h" |
James Cook | c63b9fd | 2017-08-18 18:48:32 | [diff] [blame] | 12 | #include "ash/public/cpp/ash_pref_names.h" |
Xiyuan Xia | 14619a2 | 2019-05-14 20:20:44 | [diff] [blame] | 13 | #include "ash/public/cpp/ash_prefs.h" |
Miyoung Shin | 7e1b1b1 | 2019-08-02 12:23:50 | [diff] [blame] | 14 | #include "ash/public/mojom/cros_display_config.mojom.h" |
Sebastien Marchand | f1349f5 | 2019-01-25 03:16:41 | [diff] [blame] | 15 | #include "base/bind.h" |
[email protected] | 775caec | 2011-09-01 17:14:32 | [diff] [blame] | 16 | #include "base/command_line.h" |
Kyle Horimoto | 5ab70b90 | 2020-04-01 22:23:59 | [diff] [blame] | 17 | #include "base/feature_list.h" |
[email protected] | 530cd62 | 2011-04-14 15:45:00 | [diff] [blame] | 18 | #include "base/i18n/time_formatting.h" |
Zentaro Kavanagh | 65b3e11 | 2019-09-03 16:18:23 | [diff] [blame] | 19 | #include "base/metrics/histogram_functions.h" |
asvitkine | b5663751 | 2016-09-01 19:41:40 | [diff] [blame] | 20 | #include "base/metrics/histogram_macros.h" |
[email protected] | 1988e1c | 2013-02-28 20:27:42 | [diff] [blame] | 21 | #include "base/strings/string_split.h" |
[email protected] | 5c07332 | 2013-06-11 08:03:30 | [diff] [blame] | 22 | #include "base/strings/string_util.h" |
[email protected] | 135cb80 | 2013-06-09 16:44:20 | [diff] [blame] | 23 | #include "base/strings/utf_string_conversions.h" |
[email protected] | c0a2128d9 | 2011-07-20 15:04:46 | [diff] [blame] | 24 | #include "chrome/browser/browser_process.h" |
Hans Wennborg | 6334445 | 2019-10-15 10:15:21 | [diff] [blame] | 25 | #include "chrome/browser/browser_process_platform_part.h" |
[email protected] | fdf40f3e | 2013-07-11 23:55:46 | [diff] [blame] | 26 | #include "chrome/browser/chrome_notification_types.h" |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 27 | #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
Zakhar Voit | 1f16c5e | 2018-10-26 12:08:23 | [diff] [blame] | 28 | #include "chrome/browser/chromeos/base/locale_util.h" |
Henrique Grandinetti | dc2db07 | 2019-05-03 13:18:26 | [diff] [blame] | 29 | #include "chrome/browser/chromeos/child_accounts/parent_access_code/parent_access_service.h" |
Erik Chen | c9e8dfb | 2020-07-30 01:35:09 | [diff] [blame] | 30 | #include "chrome/browser/chromeos/crosapi/browser_util.h" |
lukasza | 6364a02 | 2015-08-21 01:13:24 | [diff] [blame] | 31 | #include "chrome/browser/chromeos/drive/file_system_util.h" |
Rachel Carpenter | 928b0e6 | 2020-06-17 01:06:57 | [diff] [blame] | 32 | #include "chrome/browser/chromeos/first_run/help_app_first_run_field_trial.h" |
Alexander Alekseev | 45f8433 | 2020-10-29 07:25:37 | [diff] [blame] | 33 | #include "chrome/browser/chromeos/input_method/input_method_persistence.h" |
michaelpg | 975f218 | 2014-12-05 04:00:14 | [diff] [blame] | 34 | #include "chrome/browser/chromeos/input_method/input_method_syncer.h" |
Roman Aleksandrov | 6a6a63c | 2020-07-02 11:26:45 | [diff] [blame] | 35 | #include "chrome/browser/chromeos/login/login_pref_names.h" |
[email protected] | 295ca1a7 | 2014-07-01 16:14:31 | [diff] [blame] | 36 | #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
alemate | 2cb0d75 | 2017-08-11 05:22:16 | [diff] [blame] | 37 | #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 38 | #include "chrome/browser/chromeos/settings/cros_settings.h" |
James Cook | 42ba265 | 2020-06-05 19:31:15 | [diff] [blame] | 39 | #include "chrome/browser/chromeos/sync/split_settings_sync_field_trial.h" |
James Cook | ac8291e | 2019-12-20 23:42:48 | [diff] [blame] | 40 | #include "chrome/browser/chromeos/sync/turn_sync_on_helper.h" |
[email protected] | 82eb8ec | 2011-12-20 22:24:33 | [diff] [blame] | 41 | #include "chrome/browser/chromeos/system/input_device_settings.h" |
alemate | 75b7a5c | 2016-03-29 06:39:46 | [diff] [blame] | 42 | #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" |
alemate | 2cb0d75 | 2017-08-11 05:22:16 | [diff] [blame] | 43 | #include "chrome/browser/chromeos/system/timezone_util.h" |
[email protected] | b1d9727 | 2013-08-17 13:38:49 | [diff] [blame] | 44 | #include "chrome/browser/download/download_prefs.h" |
sdefresne | ed27d86b | 2015-09-14 11:02:38 | [diff] [blame] | 45 | #include "chrome/browser/prefs/pref_service_syncable_util.h" |
James Cook | 671818f | 2017-07-10 19:31:45 | [diff] [blame] | 46 | #include "chrome/browser/ui/ash/system_tray_client.h" |
azurewei | 19663e2 | 2016-03-24 01:30:52 | [diff] [blame] | 47 | #include "chrome/common/chrome_features.h" |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 48 | #include "chrome/common/pref_names.h" |
Kyle Horimoto | 5ab70b90 | 2020-04-01 22:23:59 | [diff] [blame] | 49 | #include "chromeos/constants/chromeos_features.h" |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 50 | #include "chromeos/constants/chromeos_pref_names.h" |
Steven Bennetts | 38e9bde2 | 2019-01-03 17:31:10 | [diff] [blame] | 51 | #include "chromeos/constants/chromeos_switches.h" |
alemate | 2cb0d75 | 2017-08-11 05:22:16 | [diff] [blame] | 52 | #include "chromeos/settings/cros_settings_names.h" |
reveman | 2415898 | 2017-01-10 05:58:45 | [diff] [blame] | 53 | #include "chromeos/system/devicemode.h" |
[email protected] | 279690f8 | 2013-10-09 08:23:52 | [diff] [blame] | 54 | #include "chromeos/system/statistics_provider.h" |
alemate | 48255f3d | 2015-01-30 18:11:41 | [diff] [blame] | 55 | #include "chromeos/timezone/timezone_resolver.h" |
lukasza | 76b4a98 | 2015-08-08 00:36:39 | [diff] [blame] | 56 | #include "components/drive/drive_pref_names.h" |
[email protected] | 1eab4e9 | 2014-05-09 02:17:19 | [diff] [blame] | 57 | #include "components/feedback/tracing_manager.h" |
Alexandre Frechette | 572755b | 2019-02-13 22:30:20 | [diff] [blame] | 58 | #include "components/language/core/browser/pref_names.h" |
Roman Sorokin | 1b1677d07 | 2017-10-16 12:27:48 | [diff] [blame] | 59 | #include "components/policy/proto/chrome_device_policy.pb.h" |
[email protected] | f0c8c499 | 2014-05-15 17:37:26 | [diff] [blame] | 60 | #include "components/pref_registry/pref_registry_syncable.h" |
brettw | b1fc1b8 | 2016-02-02 00:19:08 | [diff] [blame] | 61 | #include "components/prefs/pref_member.h" |
| 62 | #include "components/prefs/pref_registry_simple.h" |
| 63 | #include "components/prefs/scoped_user_pref_update.h" |
maxbogue | ea16ff41 | 2016-10-28 16:35:29 | [diff] [blame] | 64 | #include "components/sync_preferences/pref_service_syncable.h" |
alemate | 8730a2f | 2015-12-19 07:13:09 | [diff] [blame] | 65 | #include "components/user_manager/known_user.h" |
[email protected] | 2fda997 | 2014-07-23 14:51:59 | [diff] [blame] | 66 | #include "components/user_manager/user.h" |
alemate | 8730a2f | 2015-12-19 07:13:09 | [diff] [blame] | 67 | #include "components/user_manager/user_manager.h" |
michaelpg | 975f218 | 2014-12-05 04:00:14 | [diff] [blame] | 68 | #include "content/public/browser/browser_thread.h" |
Darin Fisher | a26aa7e | 2019-09-02 20:22:59 | [diff] [blame] | 69 | #include "third_party/blink/public/mojom/speech/speech_synthesis.mojom.h" |
xiaoyinh | f39e3dd | 2016-06-18 04:50:23 | [diff] [blame] | 70 | #include "third_party/cros_system_api/dbus/update_engine/dbus-constants.h" |
[email protected] | 8bbf619 | 2013-07-18 11:14:04 | [diff] [blame] | 71 | #include "third_party/icu/source/i18n/unicode/timezone.h" |
shuchen | 179b1f4 | 2014-11-27 17:24:40 | [diff] [blame] | 72 | #include "ui/base/ime/chromeos/extension_ime_util.h" |
| 73 | #include "ui/base/ime/chromeos/ime_keyboard.h" |
| 74 | #include "ui/base/ime/chromeos/input_method_manager.h" |
Blake O'Hare | d00831e | 2017-10-06 12:37:25 | [diff] [blame] | 75 | #include "ui/chromeos/events/modifier_key.h" |
penghuang | e5df282 | 2017-03-16 22:54:36 | [diff] [blame] | 76 | #include "ui/chromeos/events/pref_names.h" |
[email protected] | 86ccbd4 | 2013-09-18 18:11:54 | [diff] [blame] | 77 | #include "ui/events/event_constants.h" |
| 78 | #include "ui/events/event_utils.h" |
[email protected] | a6483d2 | 2013-07-03 22:11:00 | [diff] [blame] | 79 | #include "url/gurl.h" |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 80 | |
[email protected] | de1528d1a | 2012-05-14 10:36:15 | [diff] [blame] | 81 | namespace chromeos { |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 82 | |
xdai | e6172c9 | 2017-02-24 19:01:51 | [diff] [blame] | 83 | namespace { |
| 84 | |
xdai | e6172c9 | 2017-02-24 19:01:51 | [diff] [blame] | 85 | // The keyboard preferences that determine how we remap modifier keys. These |
| 86 | // preferences will be saved in global user preferences dictionary so that they |
| 87 | // can be used on signin screen. |
| 88 | const char* const kLanguageRemapPrefs[] = { |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 89 | ::prefs::kLanguageRemapSearchKeyTo, |
| 90 | ::prefs::kLanguageRemapControlKeyTo, |
| 91 | ::prefs::kLanguageRemapAltKeyTo, |
| 92 | ::prefs::kLanguageRemapCapsLockKeyTo, |
| 93 | ::prefs::kLanguageRemapEscapeKeyTo, |
| 94 | ::prefs::kLanguageRemapBackspaceKeyTo, |
| 95 | ::prefs::kLanguageRemapExternalCommandKeyTo, |
| 96 | ::prefs::kLanguageRemapExternalMetaKeyTo}; |
xdai | e6172c9 | 2017-02-24 19:01:51 | [diff] [blame] | 97 | |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 98 | // Migrates kResolveTimezoneByGeolocation value to |
| 99 | // kResolveTimezoneByGeolocationMethod. |
| 100 | // Default preference value will become another default value. |
| 101 | // TODO(alemate): https://crbug.com/783367 Remove outdated prefs. |
James Cook | 181be00 | 2020-05-05 20:55:19 | [diff] [blame] | 102 | void TryMigrateToResolveTimezoneByGeolocationMethod( |
| 103 | sync_preferences::PrefServiceSyncable* prefs) { |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 104 | if (prefs->GetBoolean(::prefs::kResolveTimezoneByGeolocationMigratedToMethod)) |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 105 | return; |
| 106 | |
James Cook | 181be00 | 2020-05-05 20:55:19 | [diff] [blame] | 107 | // Timezone resolution method is a non-priority pref. Wait to migrate until |
| 108 | // that type of pref has synced. |
| 109 | bool is_syncing = chromeos::features::IsSplitSettingsSyncEnabled() |
| 110 | ? prefs->AreOsPrefsSyncing() |
| 111 | : prefs->IsSyncing(); |
| 112 | if (!is_syncing) |
| 113 | return; |
| 114 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 115 | prefs->SetBoolean(::prefs::kResolveTimezoneByGeolocationMigratedToMethod, |
| 116 | true); |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 117 | const PrefService::Preference* old_preference = |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 118 | prefs->FindPreference(::prefs::kResolveTimezoneByGeolocation); |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 119 | if (old_preference->IsDefaultValue()) |
| 120 | return; |
| 121 | |
| 122 | const PrefService::Preference* new_preference = |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 123 | prefs->FindPreference(::prefs::kResolveTimezoneByGeolocationMethod); |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 124 | if (!new_preference->IsDefaultValue()) |
| 125 | return; |
| 126 | |
| 127 | const system::TimeZoneResolverManager::TimeZoneResolveMethod method( |
| 128 | old_preference->GetValue()->GetBool() |
| 129 | ? system::TimeZoneResolverManager::TimeZoneResolveMethod::IP_ONLY |
| 130 | : system::TimeZoneResolverManager::TimeZoneResolveMethod::DISABLED); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 131 | prefs->SetInteger(::prefs::kResolveTimezoneByGeolocationMethod, |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 132 | static_cast<int>(method)); |
| 133 | } |
| 134 | |
Kyle Horimoto | 5ab70b90 | 2020-04-01 22:23:59 | [diff] [blame] | 135 | bool AreScrollSettingsAllowed() { |
| 136 | return base::FeatureList::IsEnabled(features::kAllowScrollSettings); |
| 137 | } |
| 138 | |
xdai | e6172c9 | 2017-02-24 19:01:51 | [diff] [blame] | 139 | } // namespace |
| 140 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 141 | Preferences::Preferences() |
James Cook | bd0b779 | 2017-11-17 03:24:26 | [diff] [blame] | 142 | : Preferences(input_method::InputMethodManager::Get()) {} |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 143 | |
| 144 | Preferences::Preferences(input_method::InputMethodManager* input_method_manager) |
[email protected] | eb5624e | 2013-05-23 19:50:27 | [diff] [blame] | 145 | : prefs_(NULL), |
[email protected] | daf37cc | 2013-11-01 18:10:26 | [diff] [blame] | 146 | input_method_manager_(input_method_manager), |
[email protected] | 50de64ea | 2014-02-19 06:25:50 | [diff] [blame] | 147 | user_(NULL), |
Steven Bennetts | bce1cf5c | 2018-05-23 19:38:12 | [diff] [blame] | 148 | user_is_primary_(false) { |
Ken Rockot | b9bab54 | 2019-12-12 00:53:30 | [diff] [blame] | 149 | ash::BindCrosDisplayConfigController( |
| 150 | cros_display_config_.BindNewPipeAndPassReceiver()); |
Steven Bennetts | bce1cf5c | 2018-05-23 19:38:12 | [diff] [blame] | 151 | } |
[email protected] | d743a598 | 2010-11-08 17:54:09 | [diff] [blame] | 152 | |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 153 | Preferences::~Preferences() { |
| 154 | prefs_->RemoveObserver(this); |
[email protected] | 4d39078 | 2014-08-15 09:22:58 | [diff] [blame] | 155 | user_manager::UserManager::Get()->RemoveSessionStateObserver(this); |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 156 | } |
[email protected] | 9199bd5 | 2010-07-01 05:04:41 | [diff] [blame] | 157 | |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 158 | // static |
[email protected] | 681958c | 2013-02-21 13:48:14 | [diff] [blame] | 159 | void Preferences::RegisterPrefs(PrefRegistrySimple* registry) { |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 160 | registry->RegisterBooleanPref(::prefs::kOwnerPrimaryMouseButtonRight, false); |
| 161 | registry->RegisterBooleanPref(::prefs::kOwnerTapToClickEnabled, true); |
James Cook | c63b9fd | 2017-08-18 18:48:32 | [diff] [blame] | 162 | // TODO(jamescook): Move ownership and registration into ash. |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 163 | registry->RegisterStringPref(::prefs::kLogoutStartedLast, std::string()); |
| 164 | registry->RegisterStringPref(::prefs::kSigninScreenTimezone, std::string()); |
| 165 | registry->RegisterBooleanPref(::prefs::kResolveDeviceTimezoneByGeolocation, |
alemate | 01c62ce | 2015-02-19 17:03:09 | [diff] [blame] | 166 | true); |
alemate | d70e82f | 2016-04-05 12:21:33 | [diff] [blame] | 167 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 168 | ::prefs::kResolveDeviceTimezoneByGeolocationMethod, |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 169 | static_cast<int>( |
| 170 | system::TimeZoneResolverManager::TimeZoneResolveMethod::IP_ONLY)); |
| 171 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 172 | ::prefs::kSystemTimezoneAutomaticDetectionPolicy, |
alemate | d70e82f | 2016-04-05 12:21:33 | [diff] [blame] | 173 | enterprise_management::SystemTimezoneProto::USERS_DECIDE); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 174 | registry->RegisterStringPref(::prefs::kMinimumAllowedChromeVersion, ""); |
Igor | c5014d4 | 2020-10-12 12:48:17 | [diff] [blame] | 175 | registry->RegisterBooleanPref(::prefs::kLacrosAllowed, true); |
Steven Bennetts | ca10851 | 2018-05-02 11:05:03 | [diff] [blame] | 176 | |
Xiyuan Xia | 14619a2 | 2019-05-14 20:20:44 | [diff] [blame] | 177 | ash::RegisterLocalStatePrefs(registry); |
James Cook | 42ba265 | 2020-06-05 19:31:15 | [diff] [blame] | 178 | split_settings_sync_field_trial::RegisterLocalStatePrefs(registry); |
Rachel Carpenter | 928b0e6 | 2020-06-17 01:06:57 | [diff] [blame] | 179 | help_app_first_run_field_trial::RegisterLocalStatePrefs(registry); |
[email protected] | 681958c | 2013-02-21 13:48:14 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | // static |
[email protected] | 37ca3fe0 | 2013-07-05 15:32:44 | [diff] [blame] | 183 | void Preferences::RegisterProfilePrefs( |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 184 | user_prefs::PrefRegistrySyncable* registry) { |
James Cook | ac8291e | 2019-12-20 23:42:48 | [diff] [blame] | 185 | // Some classes register their own prefs. |
| 186 | TurnSyncOnHelper::RegisterProfilePrefs(registry); |
| 187 | input_method::InputMethodSyncer::RegisterProfilePrefs(registry); |
Erik Chen | c9e8dfb | 2020-07-30 01:35:09 | [diff] [blame] | 188 | crosapi::browser_util::RegisterProfilePrefs(registry); |
James Cook | ac8291e | 2019-12-20 23:42:48 | [diff] [blame] | 189 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 190 | std::string hardware_keyboard_id; |
| 191 | // TODO(yusukes): Remove the runtime hack. |
reveman | 2415898 | 2017-01-10 05:58:45 | [diff] [blame] | 192 | if (IsRunningAsSystemCompositor()) { |
[email protected] | 39699140 | 2014-02-17 10:56:17 | [diff] [blame] | 193 | DCHECK(g_browser_process); |
| 194 | PrefService* local_state = g_browser_process->local_state(); |
| 195 | DCHECK(local_state); |
| 196 | hardware_keyboard_id = |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 197 | local_state->GetString(::prefs::kHardwareKeyboardLayout); |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 198 | } else { |
| 199 | hardware_keyboard_id = "xkb:us::eng"; // only for testing. |
| 200 | } |
[email protected] | a9a8181 | 2011-09-16 11:01:17 | [diff] [blame] | 201 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 202 | registry->RegisterBooleanPref(::prefs::kPerformanceTracingEnabled, false); |
[email protected] | a1ea129 | 2013-08-07 23:50:40 | [diff] [blame] | 203 | |
Kush Sinha | 811150f | 2019-01-19 11:14:49 | [diff] [blame] | 204 | // This pref is device specific and must not be synced. |
| 205 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 206 | ::prefs::kAccountManagerNumTimesMigrationRanSuccessfully, |
Kush Sinha | e12d00d | 2019-01-24 18:30:05 | [diff] [blame] | 207 | 0 /* default_value */); |
| 208 | |
| 209 | // This pref is device specific and must not be synced. |
| 210 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 211 | ::prefs::kAccountManagerNumTimesWelcomeScreenShown, |
| 212 | 0 /* default_value */); |
Kush Sinha | 811150f | 2019-01-19 11:14:49 | [diff] [blame] | 213 | |
[email protected] | a1ea129 | 2013-08-07 23:50:40 | [diff] [blame] | 214 | registry->RegisterBooleanPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 215 | ::prefs::kTapToClickEnabled, true, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 216 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 217 | registry->RegisterBooleanPref(::prefs::kEnableTouchpadThreeFingerClick, |
| 218 | false); |
phweiss | a16ceae2 | 2015-09-17 09:33:12 | [diff] [blame] | 219 | // This preference can only be set to true by policy or command_line flag |
| 220 | // and it should not carry over to sessions were neither of these is set. |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 221 | registry->RegisterBooleanPref(::prefs::kUnifiedDesktopEnabledByDefault, false, |
phweiss | a16ceae2 | 2015-09-17 09:33:12 | [diff] [blame] | 222 | PrefRegistry::NO_REGISTRATION_FLAGS); |
Ana Salazar | eb7c2571 | 2020-02-03 20:27:26 | [diff] [blame] | 223 | // TODO(anasalazar): Finish moving this to ash. |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 224 | registry->RegisterBooleanPref( |
Ana Salazar | eb7c2571 | 2020-02-03 20:27:26 | [diff] [blame] | 225 | ash::prefs::kNaturalScroll, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 226 | base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 227 | switches::kNaturalScrollDefault), |
| 228 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 229 | registry->RegisterBooleanPref( |
Ana Salazar | eb7c2571 | 2020-02-03 20:27:26 | [diff] [blame] | 230 | ash::prefs::kMouseReverseScroll, false, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 231 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
Ana Salazar | eb7c2571 | 2020-02-03 20:27:26 | [diff] [blame] | 232 | |
Lann Martin | 9a517ad | 2017-08-29 00:43:39 | [diff] [blame] | 233 | registry->RegisterBooleanPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 234 | ::prefs::kPrimaryMouseButtonRight, false, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 235 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
Zentaro Kavanagh | 65b3e11 | 2019-09-03 16:18:23 | [diff] [blame] | 236 | registry->RegisterBooleanPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 237 | ::prefs::kMouseAcceleration, true, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 238 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
Zentaro Kavanagh | 65b3e11 | 2019-09-03 16:18:23 | [diff] [blame] | 239 | registry->RegisterBooleanPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 240 | ::prefs::kMouseScrollAcceleration, true, |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 241 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
| 242 | registry->RegisterBooleanPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 243 | ::prefs::kTouchpadAcceleration, true, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 244 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 245 | registry->RegisterBooleanPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 246 | ::prefs::kTouchpadScrollAcceleration, true, |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 247 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 248 | registry->RegisterBooleanPref(::prefs::kLabsMediaplayerEnabled, false); |
| 249 | registry->RegisterBooleanPref(::prefs::kLabsAdvancedFilesystemEnabled, false); |
| 250 | registry->RegisterBooleanPref(::prefs::kAppReinstallRecommendationEnabled, |
Rob Schonberger | 76f3770 | 2019-05-03 05:52:25 | [diff] [blame] | 251 | false); |
James Cook | c63b9fd | 2017-08-18 18:48:32 | [diff] [blame] | 252 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 253 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 254 | ::prefs::kMouseSensitivity, 3, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 255 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 256 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 257 | ::prefs::kMouseScrollSensitivity, 3, |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 258 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
| 259 | registry->RegisterIntegerPref( |
Harry Cutts | c333197 | 2020-11-17 03:54:46 | [diff] [blame] | 260 | ::prefs::kPointingStickSensitivity, 3, |
| 261 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
| 262 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 263 | ::prefs::kTouchpadSensitivity, 3, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 264 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 265 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 266 | ::prefs::kTouchpadScrollSensitivity, 3, |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 267 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 268 | registry->RegisterBooleanPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 269 | ::prefs::kUse24HourClock, base::GetHourClockType() == base::k24HourClock, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 270 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 271 | registry->RegisterBooleanPref( |
lukasza | da911a6 | 2015-06-17 15:39:32 | [diff] [blame] | 272 | drive::prefs::kDisableDrive, false, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 273 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 274 | registry->RegisterBooleanPref( |
lukasza | da911a6 | 2015-06-17 15:39:32 | [diff] [blame] | 275 | drive::prefs::kDisableDriveOverCellular, true, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 276 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); |
Sergei Datsenko | 3b10af072 | 2018-10-11 05:13:29 | [diff] [blame] | 277 | registry->RegisterBooleanPref(drive::prefs::kDriveFsWasLaunchedAtLeastOnce, |
| 278 | false); |
Sergei Datsenko | 1bb7348 | 2018-07-25 01:21:50 | [diff] [blame] | 279 | registry->RegisterStringPref(drive::prefs::kDriveFsProfileSalt, ""); |
Sam McNally | 63e4b8ce | 2018-09-05 05:39:51 | [diff] [blame] | 280 | registry->RegisterBooleanPref(drive::prefs::kDriveFsPinnedMigrated, false); |
Austin Tankiang | eeff20ab | 2020-06-04 05:54:48 | [diff] [blame] | 281 | registry->RegisterBooleanPref(drive::prefs::kDriveFsEnableVerboseLogging, |
| 282 | false); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 283 | // We don't sync ::prefs::kLanguageCurrentInputMethod and PreviousInputMethod |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 284 | // because they're just used to track the logout state of the device. |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 285 | registry->RegisterStringPref(::prefs::kLanguageCurrentInputMethod, ""); |
| 286 | registry->RegisterStringPref(::prefs::kLanguagePreviousInputMethod, ""); |
| 287 | registry->RegisterListPref(::prefs::kLanguageAllowedInputMethods); |
| 288 | registry->RegisterListPref(::prefs::kAllowedLanguages); |
| 289 | registry->RegisterStringPref(::prefs::kLanguagePreloadEngines, |
raymes | aa60872 | 2015-04-27 03:00:25 | [diff] [blame] | 290 | hardware_keyboard_id); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 291 | registry->RegisterStringPref(::prefs::kLanguageEnabledImes, ""); |
| 292 | registry->RegisterDictionaryPref( |
Keith Lee | d737ae3 | 2020-05-18 07:52:50 | [diff] [blame] | 293 | chromeos::prefs::kAssistiveInputFeatureSettings); |
My Nguyen | e49594a | 2020-05-27 07:58:11 | [diff] [blame] | 294 | registry->RegisterBooleanPref(chromeos::prefs::kAssistPersonalInfoEnabled, |
| 295 | true); |
My Nguyen | 49d0468 | 2020-06-18 05:29:02 | [diff] [blame] | 296 | registry->RegisterBooleanPref(chromeos::prefs::kEmojiSuggestionEnabled, true); |
My Nguyen | d45c3b81 | 2020-07-27 19:39:57 | [diff] [blame] | 297 | registry->RegisterBooleanPref( |
| 298 | chromeos::prefs::kEmojiSuggestionEnterpriseAllowed, true); |
Keith Lee | d737ae3 | 2020-05-18 07:52:50 | [diff] [blame] | 299 | registry->RegisterDictionaryPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 300 | ::prefs::kLanguageInputMethodSpecificSettings); |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 301 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 302 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 303 | ::prefs::kLanguageRemapSearchKeyTo, |
Blake O'Hare | a09fa45a | 2017-10-13 04:19:58 | [diff] [blame] | 304 | static_cast<int>(ui::chromeos::ModifierKey::kSearchKey), |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 305 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 306 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 307 | ::prefs::kLanguageRemapControlKeyTo, |
Blake O'Hare | a09fa45a | 2017-10-13 04:19:58 | [diff] [blame] | 308 | static_cast<int>(ui::chromeos::ModifierKey::kControlKey), |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 309 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 310 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 311 | ::prefs::kLanguageRemapAltKeyTo, |
Blake O'Hare | a09fa45a | 2017-10-13 04:19:58 | [diff] [blame] | 312 | static_cast<int>(ui::chromeos::ModifierKey::kAltKey), |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 313 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
Meilin Wang | 8a1e95b4 | 2019-02-27 22:01:51 | [diff] [blame] | 314 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 315 | ::prefs::kLanguageRemapAssistantKeyTo, |
Meilin Wang | 8a1e95b4 | 2019-02-27 22:01:51 | [diff] [blame] | 316 | static_cast<int>(ui::chromeos::ModifierKey::kAssistantKey), |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 317 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
[email protected] | 0f424fd9 | 2013-05-08 21:12:19 | [diff] [blame] | 318 | // We don't sync the CapsLock remapping pref, since the UI hides this pref |
| 319 | // on certain devices, so syncing a non-default value to a device that |
| 320 | // doesn't allow changing the pref would be odd. http://crbug.com/167237 |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 321 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 322 | ::prefs::kLanguageRemapCapsLockKeyTo, |
Blake O'Hare | a09fa45a | 2017-10-13 04:19:58 | [diff] [blame] | 323 | static_cast<int>(ui::chromeos::ModifierKey::kCapsLockKey)); |
| 324 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 325 | ::prefs::kLanguageRemapEscapeKeyTo, |
Blake O'Hare | a09fa45a | 2017-10-13 04:19:58 | [diff] [blame] | 326 | static_cast<int>(ui::chromeos::ModifierKey::kEscapeKey), |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 327 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
michaelpg | 168ecd7 | 2016-08-25 04:00:42 | [diff] [blame] | 328 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 329 | ::prefs::kLanguageRemapBackspaceKeyTo, |
Blake O'Hare | a09fa45a | 2017-10-13 04:19:58 | [diff] [blame] | 330 | static_cast<int>(ui::chromeos::ModifierKey::kBackspaceKey), |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 331 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
Ahmed Fakhry | 629985b | 2018-07-30 20:57:32 | [diff] [blame] | 332 | // The Command key on external Apple keyboards is remapped by default to Ctrl |
| 333 | // until the user changes it from the keyboard settings. |
| 334 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 335 | ::prefs::kLanguageRemapExternalCommandKeyTo, |
Ahmed Fakhry | 629985b | 2018-07-30 20:57:32 | [diff] [blame] | 336 | static_cast<int>(ui::chromeos::ModifierKey::kControlKey), |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 337 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
Ahmed Fakhry | 629985b | 2018-07-30 20:57:32 | [diff] [blame] | 338 | // The Meta key (Search or Windows keys) on external keyboards is remapped by |
| 339 | // default to Search until the user changes it from the keyboard settings. |
| 340 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 341 | ::prefs::kLanguageRemapExternalMetaKeyTo, |
Ahmed Fakhry | 629985b | 2018-07-30 20:57:32 | [diff] [blame] | 342 | static_cast<int>(ui::chromeos::ModifierKey::kSearchKey), |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 343 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PRIORITY_PREF); |
[email protected] | e2204a70 | 2013-10-29 21:58:54 | [diff] [blame] | 344 | // The following pref isn't synced since the user may desire a different value |
| 345 | // depending on whether an external keyboard is attached to a particular |
| 346 | // device. |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 347 | registry->RegisterBooleanPref(::prefs::kLanguageSendFunctionKeys, false); |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 348 | |
derat | b4fee74c | 2016-12-17 04:11:46 | [diff] [blame] | 349 | // Don't sync the note-taking app; it may not be installed on other devices. |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 350 | registry->RegisterStringPref(::prefs::kNoteTakingAppId, std::string()); |
| 351 | registry->RegisterBooleanPref(::prefs::kNoteTakingAppEnabledOnLockScreen, |
| 352 | true); |
Brian Malcolm | b0904f3a | 2020-07-31 23:13:48 | [diff] [blame] | 353 | registry->RegisterListPref(::prefs::kNoteTakingAppsLockScreenAllowlist); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 354 | registry->RegisterBooleanPref(::prefs::kRestoreLastLockScreenNote, true); |
| 355 | registry->RegisterDictionaryPref( |
| 356 | ::prefs::kNoteTakingAppsLockScreenToastShown); |
jdufault | 5d4c81c6 | 2016-07-28 20:22:06 | [diff] [blame] | 357 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 358 | registry->RegisterBooleanPref(::prefs::kShowMobileDataNotification, true); |
[email protected] | d6ae950 | 2011-05-05 18:23:09 | [diff] [blame] | 359 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 360 | // Initially all existing users would see "What's new" for current version |
| 361 | // after update. |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 362 | registry->RegisterStringPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 363 | ::prefs::kChromeOSReleaseNotesVersion, "0.0.0.0", |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 364 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); |
[email protected] | efb770c | 2012-05-04 22:31:48 | [diff] [blame] | 365 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 366 | registry->RegisterBooleanPref(::prefs::kExternalStorageDisabled, false); |
[email protected] | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 367 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 368 | registry->RegisterBooleanPref(::prefs::kExternalStorageReadOnly, false); |
yamaguchi | cc8186b | 2016-08-08 06:38:54 | [diff] [blame] | 369 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 370 | registry->RegisterStringPref(::prefs::kTermsOfServiceURL, ""); |
[email protected] | fddc44fe | 2013-07-04 00:03:51 | [diff] [blame] | 371 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 372 | registry->RegisterBooleanPref(::prefs::kTouchVirtualKeyboardEnabled, false); |
michaelpg | 975f218 | 2014-12-05 04:00:14 | [diff] [blame] | 373 | |
alemate | 2cb0d75 | 2017-08-11 05:22:16 | [diff] [blame] | 374 | std::string current_timezone_id; |
| 375 | if (chromeos::CrosSettings::IsInitialized()) { |
| 376 | // In unit tests CrosSettings is not always initialized. |
| 377 | chromeos::CrosSettings::Get()->GetString(kSystemTimezone, |
| 378 | ¤t_timezone_id); |
| 379 | } |
| 380 | // |current_timezone_id| will be empty if CrosSettings doesn't know the |
| 381 | // timezone yet. |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 382 | registry->RegisterStringPref(::prefs::kUserTimezone, current_timezone_id); |
alemate | 2cb0d75 | 2017-08-11 05:22:16 | [diff] [blame] | 383 | |
alemate | 48255f3d | 2015-01-30 18:11:41 | [diff] [blame] | 384 | registry->RegisterBooleanPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 385 | ::prefs::kResolveTimezoneByGeolocation, true, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 386 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); |
alemate | 48255f3d | 2015-01-30 18:11:41 | [diff] [blame] | 387 | |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 388 | registry->RegisterBooleanPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 389 | ::prefs::kResolveTimezoneByGeolocationMigratedToMethod, false, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 390 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 391 | |
Alexander Alekseev | d99f60d | 2020-01-31 00:53:05 | [diff] [blame] | 392 | bool allow_time_zone_resolve_by_default = true; |
| 393 | // CfM devices default to static timezone unless time zone resolving is |
| 394 | // explicitly enabled for the signin screen (usually by policy). |
Alexander Alekseev | 40004e1 | 2020-03-22 06:53:10 | [diff] [blame] | 395 | // We need local_state fully initialized, which does not happen in tests. |
| 396 | if (!g_browser_process->local_state() || |
| 397 | g_browser_process->local_state() |
| 398 | ->GetAllPrefStoresInitializationStatus() == |
| 399 | PrefService::INITIALIZATION_STATUS_WAITING || |
| 400 | system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation() || |
Alexander Alekseev | d99f60d | 2020-01-31 00:53:05 | [diff] [blame] | 401 | !system::TimeZoneResolverManager:: |
| 402 | IfServiceShouldBeRunningForSigninScreen()) { |
| 403 | allow_time_zone_resolve_by_default = false; |
| 404 | } |
| 405 | |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 406 | registry->RegisterIntegerPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 407 | ::prefs::kResolveTimezoneByGeolocationMethod, |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 408 | static_cast<int>( |
Alexander Alekseev | d99f60d | 2020-01-31 00:53:05 | [diff] [blame] | 409 | allow_time_zone_resolve_by_default |
| 410 | ? system::TimeZoneResolverManager::TimeZoneResolveMethod::IP_ONLY |
| 411 | : system::TimeZoneResolverManager::TimeZoneResolveMethod:: |
| 412 | DISABLED), |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 413 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 414 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 415 | registry->RegisterBooleanPref( |
| 416 | ::prefs::kCaptivePortalAuthenticationIgnoresProxy, true); |
peletskyi | da0bbb1 | 2015-04-08 17:11:04 | [diff] [blame] | 417 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 418 | registry->RegisterBooleanPref(::prefs::kForceMaximizeOnFirstRun, false); |
azurewei | 103ed212 | 2016-01-10 07:01:14 | [diff] [blame] | 419 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 420 | registry->RegisterBooleanPref(::prefs::kLanguageImeMenuActivated, false); |
malaykeshav | dcf78b9 | 2016-05-19 00:42:28 | [diff] [blame] | 421 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 422 | registry->RegisterInt64Pref(::prefs::kHatsLastInteractionTimestamp, |
malaykeshav | dcf78b9 | 2016-05-19 00:42:28 | [diff] [blame] | 423 | base::Time().ToInternalValue()); |
xiaoyinh | f39e3dd | 2016-06-18 04:50:23 | [diff] [blame] | 424 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 425 | registry->RegisterInt64Pref(::prefs::kHatsSurveyCycleEndTimestamp, |
malaykeshav | 4518a18 | 2016-10-10 19:47:29 | [diff] [blame] | 426 | base::Time().ToInternalValue()); |
| 427 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 428 | registry->RegisterBooleanPref(::prefs::kHatsDeviceIsSelected, false); |
malaykeshav | 4518a18 | 2016-10-10 19:47:29 | [diff] [blame] | 429 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 430 | registry->RegisterBooleanPref(::prefs::kPinUnlockFeatureNotificationShown, |
malaykeshav | b2b9f12 | 2016-07-13 09:25:54 | [diff] [blame] | 431 | false); |
sammiequon | d1c5539 | 2017-03-22 18:59:22 | [diff] [blame] | 432 | registry->RegisterBooleanPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 433 | ::prefs::kFingerprintUnlockFeatureNotificationShown, false); |
malaykeshav | b2b9f12 | 2016-07-13 09:25:54 | [diff] [blame] | 434 | |
xiaoyinh | f39e3dd | 2016-06-18 04:50:23 | [diff] [blame] | 435 | // We don't sync EOL related prefs because they are device specific. |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 436 | registry->RegisterBooleanPref(::prefs::kEolNotificationDismissed, false); |
| 437 | registry->RegisterTimePref(::prefs::kEndOfLifeDate, base::Time()); |
| 438 | registry->RegisterBooleanPref(::prefs::kFirstEolWarningDismissed, false); |
| 439 | registry->RegisterBooleanPref(::prefs::kSecondEolWarningDismissed, false); |
Yves Arrouye | 454e1e57 | 2017-08-02 19:13:09 | [diff] [blame] | 440 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 441 | registry->RegisterBooleanPref(::prefs::kCastReceiverEnabled, false); |
| 442 | registry->RegisterBooleanPref(::prefs::kShowArcSettingsOnSessionStart, false); |
| 443 | registry->RegisterBooleanPref(::prefs::kShowSyncSettingsOnSessionStart, |
| 444 | false); |
Katie D | 8a5d91bf | 2018-04-19 02:50:32 | [diff] [blame] | 445 | |
Roman Aleksandrov | 6a6a63c | 2020-07-02 11:26:45 | [diff] [blame] | 446 | // OOBE and login related prefs. |
Roman Sorokin | c258ab0 | 2020-09-25 05:14:31 | [diff] [blame] | 447 | registry->RegisterStringPref(chromeos::prefs::kLastLoginInputMethod, |
| 448 | std::string(), |
| 449 | PrefRegistry::NO_REGISTRATION_FLAGS); |
Roman Aleksandrov | 6a6a63c | 2020-07-02 11:26:45 | [diff] [blame] | 450 | registry->RegisterTimePref(chromeos::prefs::kOobeOnboardingTime, |
| 451 | base::Time()); |
| 452 | |
Katie D | 8a5d91bf | 2018-04-19 02:50:32 | [diff] [blame] | 453 | // Text-to-speech prefs. |
| 454 | registry->RegisterDictionaryPref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 455 | ::prefs::kTextToSpeechLangToVoiceName, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 456 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); |
| 457 | registry->RegisterDoublePref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 458 | ::prefs::kTextToSpeechRate, blink::mojom::kSpeechSynthesisDefaultRate, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 459 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); |
| 460 | registry->RegisterDoublePref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 461 | ::prefs::kTextToSpeechPitch, blink::mojom::kSpeechSynthesisDefaultPitch, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 462 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); |
| 463 | registry->RegisterDoublePref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 464 | ::prefs::kTextToSpeechVolume, blink::mojom::kSpeechSynthesisDefaultVolume, |
James Cook | bf73f08 | 2019-10-23 03:19:04 | [diff] [blame] | 465 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); |
Aga Wronska | 4eafa17 | 2018-05-26 00:39:26 | [diff] [blame] | 466 | |
| 467 | // By default showing Sync Consent is set to true. It can changed by policy. |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 468 | registry->RegisterBooleanPref(::prefs::kEnableSyncConsent, true); |
Mattias Nissler | 0ef395b | 2018-08-15 23:41:21 | [diff] [blame] | 469 | |
James Cook | 6e731ae | 2020-05-22 01:46:47 | [diff] [blame] | 470 | registry->RegisterBooleanPref(chromeos::prefs::kSyncOobeCompleted, false); |
| 471 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 472 | registry->RegisterBooleanPref(::prefs::kTPMFirmwareUpdateCleanupDismissed, |
Mattias Nissler | 0ef395b | 2018-08-15 23:41:21 | [diff] [blame] | 473 | false); |
Jit Yao Yap | d219c5f | 2019-05-24 13:07:43 | [diff] [blame] | 474 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 475 | registry->RegisterBooleanPref(::prefs::kStartupBrowserWindowLaunchSuppressed, |
Jit Yao Yap | d219c5f | 2019-05-24 13:07:43 | [diff] [blame] | 476 | false); |
Regan Hsu | b380490 | 2019-08-03 00:35:18 | [diff] [blame] | 477 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 478 | registry->RegisterBooleanPref(::prefs::kSettingsShowOSBanner, true); |
Jit Yao Yap | b1c6024 | 2020-01-10 15:24:12 | [diff] [blame] | 479 | |
| 480 | // This pref is a per-session pref and must not be synced. |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 481 | registry->RegisterStringPref(::prefs::kLoginExtensionApiLaunchExtensionId, |
Jit Yao Yap | b1c6024 | 2020-01-10 15:24:12 | [diff] [blame] | 482 | std::string(), |
| 483 | PrefRegistry::NO_REGISTRATION_FLAGS); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 484 | |
| 485 | registry->RegisterBooleanPref( |
| 486 | chromeos::prefs::kLoginDisplayPasswordButtonEnabled, true); |
Rachel Wong | 847db0e3 | 2020-06-01 03:28:58 | [diff] [blame] | 487 | |
Rachel Wong | 6066d45d | 2020-06-13 03:20:54 | [diff] [blame] | 488 | registry->RegisterBooleanPref( |
| 489 | chromeos::prefs::kSuggestedContentEnabled, true, |
| 490 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); |
tby | 78ad33d | 2020-10-21 22:56:24 | [diff] [blame] | 491 | registry->RegisterBooleanPref( |
| 492 | chromeos::prefs::kLauncherResultEverLaunched, false, |
| 493 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); |
Wei Lee | 5fd6c51 | 2020-11-26 07:52:27 | [diff] [blame] | 494 | |
| 495 | registry->RegisterBooleanPref( |
| 496 | chromeos::prefs::kHasCameraAppMigratedToSWA, false, |
| 497 | user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 498 | } |
| 499 | |
maxbogue | ea16ff41 | 2016-10-28 16:35:29 | [diff] [blame] | 500 | void Preferences::InitUserPrefs(sync_preferences::PrefServiceSyncable* prefs) { |
[email protected] | 155e1b4 | 2012-07-14 03:06:01 | [diff] [blame] | 501 | prefs_ = prefs; |
| 502 | |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 503 | BooleanPrefMember::NamedChangeCallback callback = |
| 504 | base::Bind(&Preferences::OnPreferenceChanged, base::Unretained(this)); |
| 505 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 506 | performance_tracing_enabled_.Init(::prefs::kPerformanceTracingEnabled, prefs, |
| 507 | callback); |
| 508 | tap_to_click_enabled_.Init(::prefs::kTapToClickEnabled, prefs, callback); |
| 509 | three_finger_click_enabled_.Init(::prefs::kEnableTouchpadThreeFingerClick, |
phweiss | a16ceae2 | 2015-09-17 09:33:12 | [diff] [blame] | 510 | prefs, callback); |
| 511 | unified_desktop_enabled_by_default_.Init( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 512 | ::prefs::kUnifiedDesktopEnabledByDefault, prefs, callback); |
Ana Salazar | eb7c2571 | 2020-02-03 20:27:26 | [diff] [blame] | 513 | // TODO(anasalazar): Finish moving this to ash. |
| 514 | natural_scroll_.Init(ash::prefs::kNaturalScroll, prefs, callback); |
| 515 | mouse_reverse_scroll_.Init(ash::prefs::kMouseReverseScroll, prefs, callback); |
| 516 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 517 | mouse_sensitivity_.Init(::prefs::kMouseSensitivity, prefs, callback); |
| 518 | mouse_scroll_sensitivity_.Init(::prefs::kMouseScrollSensitivity, prefs, |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 519 | callback); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 520 | touchpad_sensitivity_.Init(::prefs::kTouchpadSensitivity, prefs, callback); |
| 521 | touchpad_scroll_sensitivity_.Init(::prefs::kTouchpadScrollSensitivity, prefs, |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 522 | callback); |
Harry Cutts | c333197 | 2020-11-17 03:54:46 | [diff] [blame] | 523 | pointing_stick_sensitivity_.Init(::prefs::kPointingStickSensitivity, prefs, |
| 524 | callback); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 525 | primary_mouse_button_right_.Init(::prefs::kPrimaryMouseButtonRight, prefs, |
| 526 | callback); |
| 527 | mouse_acceleration_.Init(::prefs::kMouseAcceleration, prefs, callback); |
| 528 | mouse_scroll_acceleration_.Init(::prefs::kMouseScrollAcceleration, prefs, |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 529 | callback); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 530 | touchpad_acceleration_.Init(::prefs::kTouchpadAcceleration, prefs, callback); |
| 531 | touchpad_scroll_acceleration_.Init(::prefs::kTouchpadScrollAcceleration, |
| 532 | prefs, callback); |
| 533 | download_default_directory_.Init(::prefs::kDownloadDefaultDirectory, prefs, |
| 534 | callback); |
| 535 | preload_engines_.Init(::prefs::kLanguagePreloadEngines, prefs, callback); |
| 536 | enabled_imes_.Init(::prefs::kLanguageEnabledImes, prefs, callback); |
| 537 | current_input_method_.Init(::prefs::kLanguageCurrentInputMethod, prefs, |
| 538 | callback); |
| 539 | previous_input_method_.Init(::prefs::kLanguagePreviousInputMethod, prefs, |
Alexander Hendrich | a4c3953 | 2018-06-27 08:33:05 | [diff] [blame] | 540 | callback); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 541 | allowed_input_methods_.Init(::prefs::kLanguageAllowedInputMethods, prefs, |
| 542 | callback); |
| 543 | allowed_languages_.Init(::prefs::kAllowedLanguages, prefs, callback); |
Alexandre Frechette | 572755b | 2019-02-13 22:30:20 | [diff] [blame] | 544 | preferred_languages_.Init(language::prefs::kPreferredLanguages, prefs, |
Zakhar Voit | 1f16c5e | 2018-10-26 12:08:23 | [diff] [blame] | 545 | callback); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 546 | ime_menu_activated_.Init(::prefs::kLanguageImeMenuActivated, prefs, callback); |
azurewei | 048e27ba | 2016-03-16 09:00:23 | [diff] [blame] | 547 | // Notifies the system tray to remove the IME items. |
Elly Fong-Jones | c00b17c28 | 2019-02-20 14:32:22 | [diff] [blame] | 548 | if (ime_menu_activated_.GetValue()) |
azurewei | 048e27ba | 2016-03-16 09:00:23 | [diff] [blame] | 549 | input_method::InputMethodManager::Get()->ImeMenuActivationChanged(true); |
[email protected] | 22bec1a | 2012-03-27 06:33:48 | [diff] [blame] | 550 | |
Chloe Pelling | 186ed3e | 2020-04-27 01:08:34 | [diff] [blame] | 551 | xkb_auto_repeat_enabled_.Init(ash::prefs::kXkbAutoRepeatEnabled, prefs, |
| 552 | callback); |
| 553 | xkb_auto_repeat_delay_pref_.Init(ash::prefs::kXkbAutoRepeatDelay, prefs, |
| 554 | callback); |
| 555 | xkb_auto_repeat_interval_pref_.Init(ash::prefs::kXkbAutoRepeatInterval, prefs, |
| 556 | callback); |
chirantan | 1c4090c | 2014-11-18 22:34:12 | [diff] [blame] | 557 | |
alemate | 48255f3d | 2015-01-30 18:11:41 | [diff] [blame] | 558 | pref_change_registrar_.Init(prefs); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 559 | pref_change_registrar_.Add(::prefs::kUserTimezone, callback); |
| 560 | pref_change_registrar_.Add(::prefs::kResolveTimezoneByGeolocation, callback); |
| 561 | pref_change_registrar_.Add(::prefs::kResolveTimezoneByGeolocationMethod, |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 562 | callback); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 563 | pref_change_registrar_.Add(::prefs::kUse24HourClock, callback); |
| 564 | pref_change_registrar_.Add(::prefs::kParentAccessCodeConfig, callback); |
vmpstr | 843b41a | 2017-03-01 21:15:03 | [diff] [blame] | 565 | for (auto* remap_pref : kLanguageRemapPrefs) |
xdai | e6172c9 | 2017-02-24 19:01:51 | [diff] [blame] | 566 | pref_change_registrar_.Add(remap_pref, callback); |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 567 | } |
| 568 | |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 569 | void Preferences::Init(Profile* profile, const user_manager::User* user) { |
| 570 | DCHECK(profile); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 571 | DCHECK(user); |
maxbogue | ea16ff41 | 2016-10-28 16:35:29 | [diff] [blame] | 572 | sync_preferences::PrefServiceSyncable* prefs = |
sdefresne | 50c1e52 | 2015-09-18 09:47:51 | [diff] [blame] | 573 | PrefServiceSyncableFromProfile(profile); |
michaelpg | 975f218 | 2014-12-05 04:00:14 | [diff] [blame] | 574 | // This causes OnIsSyncingChanged to be called when the value of |
| 575 | // PrefService::IsSyncing() changes. |
| 576 | prefs->AddObserver(this); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 577 | user_ = user; |
[email protected] | 4d39078 | 2014-08-15 09:22:58 | [diff] [blame] | 578 | user_is_primary_ = |
| 579 | user_manager::UserManager::Get()->GetPrimaryUser() == user_; |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 580 | InitUserPrefs(prefs); |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 581 | |
[email protected] | 4d39078 | 2014-08-15 09:22:58 | [diff] [blame] | 582 | user_manager::UserManager::Get()->AddSessionStateObserver(this); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 583 | |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 584 | UserSessionManager* session_manager = UserSessionManager::GetInstance(); |
| 585 | DCHECK(session_manager); |
alemate | 829e2bf | 2014-09-06 13:24:46 | [diff] [blame] | 586 | ime_state_ = session_manager->GetDefaultIMEState(profile); |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 587 | |
alemate | d70e82f | 2016-04-05 12:21:33 | [diff] [blame] | 588 | if (user_is_primary_) { |
| 589 | g_browser_process->platform_part() |
| 590 | ->GetTimezoneResolverManager() |
| 591 | ->SetPrimaryUserPrefs(prefs_); |
| 592 | } |
| 593 | |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 594 | // Initialize preferences to currently saved state. |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 595 | ApplyPreferences(REASON_INITIALIZATION, ""); |
alemate | 01c3b2c | 2015-02-10 18:26:09 | [diff] [blame] | 596 | |
Alexander Alekseev | 45f8433 | 2020-10-29 07:25:37 | [diff] [blame] | 597 | const std::string& login_input_method_used = |
| 598 | session_manager->user_context().GetLoginInputMethodUsed(); |
| 599 | |
| 600 | if (user_is_primary_ && !login_input_method_used.empty()) { |
| 601 | // Persist input method when transitioning from Login screen into the |
| 602 | // session. |
| 603 | input_method::InputMethodPersistence::SetUserLastLoginInputMethod( |
| 604 | login_input_method_used, input_method::InputMethodManager::Get(), |
| 605 | profile); |
| 606 | } |
| 607 | |
alemate | 01c3b2c | 2015-02-10 18:26:09 | [diff] [blame] | 608 | // Note that |ime_state_| was modified by ApplyPreferences(), and |
| 609 | // SetState() is modifying |current_input_method_| (via |
| 610 | // PersistUserInputMethod() ). This way SetState() here may be called only |
| 611 | // after ApplyPreferences(). |
Shu Chen | 8e53e8e | 2018-07-10 01:56:41 | [diff] [blame] | 612 | // As InputMethodManager only holds the active state for the active user, |
| 613 | // SetState() is only called if the preferences belongs to the active user. |
| 614 | // See https://crbug.com/841112. |
| 615 | if (user->is_active()) |
| 616 | input_method_manager_->SetState(ime_state_); |
alemate | 01c3b2c | 2015-02-10 18:26:09 | [diff] [blame] | 617 | |
michaelpg | 975f218 | 2014-12-05 04:00:14 | [diff] [blame] | 618 | input_method_syncer_.reset( |
| 619 | new input_method::InputMethodSyncer(prefs, ime_state_)); |
| 620 | input_method_syncer_->Initialize(); |
[email protected] | 26012e2 | 2010-12-01 06:44:27 | [diff] [blame] | 621 | |
| 622 | // If a guest is logged in, initialize the prefs as if this is the first |
[email protected] | bb9c5d7 | 2014-06-14 19:21:21 | [diff] [blame] | 623 | // login. For a regular user this is done in |
[email protected] | 295ca1a7 | 2014-07-01 16:14:31 | [diff] [blame] | 624 | // UserSessionManager::InitProfilePreferences(). |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 625 | if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 626 | switches::kGuestSession)) |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 627 | session_manager->SetFirstLoginPrefs(profile, std::string(), std::string()); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 628 | } |
| 629 | |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 630 | void Preferences::InitUserPrefsForTesting( |
maxbogue | ea16ff41 | 2016-10-28 16:35:29 | [diff] [blame] | 631 | sync_preferences::PrefServiceSyncable* prefs, |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 632 | const user_manager::User* user, |
| 633 | scoped_refptr<input_method::InputMethodManager::State> ime_state) { |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 634 | user_ = user; |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 635 | ime_state_ = ime_state; |
| 636 | |
dcheng | 4c384d9 | 2014-09-15 23:29:45 | [diff] [blame] | 637 | if (ime_state.get()) |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 638 | input_method_manager_->SetState(ime_state); |
| 639 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 640 | InitUserPrefs(prefs); |
michaelpg | 975f218 | 2014-12-05 04:00:14 | [diff] [blame] | 641 | |
| 642 | input_method_syncer_.reset( |
| 643 | new input_method::InputMethodSyncer(prefs, ime_state_)); |
| 644 | input_method_syncer_->Initialize(); |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | void Preferences::SetInputMethodListForTesting() { |
| 648 | SetInputMethodList(); |
| 649 | } |
| 650 | |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 651 | void Preferences::OnPreferenceChanged(const std::string& pref_name) { |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 652 | ApplyPreferences(REASON_PREF_CHANGED, pref_name); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 653 | } |
| 654 | |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 655 | void Preferences::ReportBooleanPrefApplication( |
| 656 | ApplyReason reason, |
| 657 | const std::string& changed_histogram_name, |
| 658 | const std::string& started_histogram_name, |
| 659 | bool sample) { |
| 660 | if (reason == REASON_PREF_CHANGED) |
| 661 | base::UmaHistogramBoolean(changed_histogram_name, sample); |
| 662 | else if (reason == REASON_INITIALIZATION) |
| 663 | base::UmaHistogramBoolean(started_histogram_name, sample); |
| 664 | } |
| 665 | |
| 666 | void Preferences::ReportSensitivityPrefApplication( |
| 667 | ApplyReason reason, |
| 668 | const std::string& changed_histogram_name, |
| 669 | const std::string& started_histogram_name, |
| 670 | int sensitivity_int) { |
| 671 | system::PointerSensitivity sensitivity = |
| 672 | static_cast<system::PointerSensitivity>(sensitivity_int); |
| 673 | if (reason == REASON_PREF_CHANGED) |
| 674 | base::UmaHistogramEnumeration(changed_histogram_name, sensitivity); |
| 675 | else if (reason == REASON_INITIALIZATION) |
| 676 | base::UmaHistogramEnumeration(started_histogram_name, sensitivity); |
| 677 | } |
| 678 | |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 679 | void Preferences::ApplyPreferences(ApplyReason reason, |
| 680 | const std::string& pref_name) { |
| 681 | DCHECK(reason != REASON_PREF_CHANGED || !pref_name.empty()); |
| 682 | const bool user_is_owner = |
alemate | 3ffbde6f | 2015-11-03 02:02:55 | [diff] [blame] | 683 | user_manager::UserManager::Get()->GetOwnerAccountId() == |
| 684 | user_->GetAccountId(); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 685 | const bool user_is_active = user_->is_active(); |
| 686 | |
[email protected] | bd36e17 | 2014-02-14 19:49:57 | [diff] [blame] | 687 | system::TouchpadSettings touchpad_settings; |
| 688 | system::MouseSettings mouse_settings; |
Harry Cutts | c333197 | 2020-11-17 03:54:46 | [diff] [blame] | 689 | system::PointingStickSettings pointing_stick_settings; |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 690 | |
| 691 | if (user_is_primary_ && (reason == REASON_INITIALIZATION || |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 692 | pref_name == ::prefs::kPerformanceTracingEnabled)) { |
[email protected] | a1ea129 | 2013-08-07 23:50:40 | [diff] [blame] | 693 | const bool enabled = performance_tracing_enabled_.GetValue(); |
| 694 | if (enabled) |
| 695 | tracing_manager_ = TracingManager::Create(); |
| 696 | else |
| 697 | tracing_manager_.reset(); |
James Cook | 671818f | 2017-07-10 19:31:45 | [diff] [blame] | 698 | SystemTrayClient::Get()->SetPerformanceTracingIconVisible(enabled); |
[email protected] | a1ea129 | 2013-08-07 23:50:40 | [diff] [blame] | 699 | } |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 700 | if (reason != REASON_PREF_CHANGED || |
| 701 | pref_name == ::prefs::kTapToClickEnabled) { |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 702 | const bool enabled = tap_to_click_enabled_.GetValue(); |
Michael Giuffrida | c997aa7 | 2018-08-31 23:38:59 | [diff] [blame] | 703 | if (user_is_active) |
| 704 | touchpad_settings.SetTapToClick(enabled); |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 705 | ReportBooleanPrefApplication(reason, "Touchpad.TapToClick.Changed", |
| 706 | "Touchpad.TapToClick.Started", enabled); |
Michael Giuffrida | c997aa7 | 2018-08-31 23:38:59 | [diff] [blame] | 707 | |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 708 | // Save owner preference in local state to use on login screen. |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 709 | if (user_is_owner) { |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 710 | PrefService* prefs = g_browser_process->local_state(); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 711 | if (prefs->GetBoolean(::prefs::kOwnerTapToClickEnabled) != enabled) |
| 712 | prefs->SetBoolean(::prefs::kOwnerTapToClickEnabled, enabled); |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 713 | } |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 714 | } |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 715 | if (reason != REASON_PREF_CHANGED || |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 716 | pref_name == ::prefs::kEnableTouchpadThreeFingerClick) { |
[email protected] | 190349fd | 2012-05-02 00:10:47 | [diff] [blame] | 717 | const bool enabled = three_finger_click_enabled_.GetValue(); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 718 | if (user_is_active) |
| 719 | touchpad_settings.SetThreeFingerClick(enabled); |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 720 | ReportBooleanPrefApplication(reason, "Touchpad.ThreeFingerClick.Changed", |
| 721 | "Touchpad.ThreeFingerClick.Started", enabled); |
[email protected] | 190349fd | 2012-05-02 00:10:47 | [diff] [blame] | 722 | } |
phweiss | a16ceae2 | 2015-09-17 09:33:12 | [diff] [blame] | 723 | if (reason != REASON_PREF_CHANGED || |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 724 | pref_name == ::prefs::kUnifiedDesktopEnabledByDefault) { |
Steven Bennetts | bce1cf5c | 2018-05-23 19:38:12 | [diff] [blame] | 725 | // "Unified Desktop" is a per-user policy setting which will not be applied |
| 726 | // until a user logs in. |
Henrique Ferreiro | 9bf2637 | 2019-10-15 11:15:58 | [diff] [blame] | 727 | if (cros_display_config_) { // May be null in tests. |
| 728 | cros_display_config_->SetUnifiedDesktopEnabled( |
Steven Bennetts | bce1cf5c | 2018-05-23 19:38:12 | [diff] [blame] | 729 | unified_desktop_enabled_by_default_.GetValue()); |
phweiss | a16ceae2 | 2015-09-17 09:33:12 | [diff] [blame] | 730 | } |
| 731 | } |
Ana Salazar | eb7c2571 | 2020-02-03 20:27:26 | [diff] [blame] | 732 | // TODO(anasalazar): Finish moving this to ash. |
| 733 | if (reason != REASON_PREF_CHANGED || |
| 734 | pref_name == ash::prefs::kNaturalScroll) { |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 735 | // Force natural scroll default if we've sync'd and if the cmd line arg is |
| 736 | // set. |
| 737 | ForceNaturalScrollDefault(); |
[email protected] | 223059e | 2012-10-05 01:44:49 | [diff] [blame] | 738 | |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 739 | const bool enabled = natural_scroll_.GetValue(); |
[email protected] | 223059e | 2012-10-05 01:44:49 | [diff] [blame] | 740 | DVLOG(1) << "Natural scroll set to " << enabled; |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 741 | if (user_is_active) |
[email protected] | 15877542 | 2014-04-03 18:15:59 | [diff] [blame] | 742 | touchpad_settings.SetNaturalScroll(enabled); |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 743 | ReportBooleanPrefApplication(reason, "Touchpad.NaturalScroll.Changed", |
| 744 | "Touchpad.NaturalScroll.Started", enabled); |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 745 | } |
Ana Salazar | eb7c2571 | 2020-02-03 20:27:26 | [diff] [blame] | 746 | if (reason != REASON_PREF_CHANGED || |
| 747 | pref_name == ash::prefs::kMouseReverseScroll) { |
| 748 | const bool enabled = mouse_reverse_scroll_.GetValue(); |
| 749 | if (user_is_active) |
| 750 | mouse_settings.SetReverseScroll(enabled); |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 751 | ReportBooleanPrefApplication(reason, "Mouse.ReverseScroll.Changed", |
| 752 | "Mouse.ReverseScroll.Started", enabled); |
Ana Salazar | eb7c2571 | 2020-02-03 20:27:26 | [diff] [blame] | 753 | } |
| 754 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 755 | if (reason != REASON_PREF_CHANGED || |
| 756 | pref_name == ::prefs::kMouseSensitivity) { |
Kyle Horimoto | 5ab70b90 | 2020-04-01 22:23:59 | [diff] [blame] | 757 | const int sensitivity_int = mouse_sensitivity_.GetValue(); |
| 758 | if (user_is_active) { |
| 759 | mouse_settings.SetSensitivity(sensitivity_int); |
| 760 | |
| 761 | // With the flag off, also set scroll sensitivity (legacy fallback). |
| 762 | // TODO(https://crbug.com/836258): Remove check when flag is removed. |
| 763 | if (!AreScrollSettingsAllowed()) |
| 764 | mouse_settings.SetScrollSensitivity(sensitivity_int); |
| 765 | } |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 766 | ReportSensitivityPrefApplication(reason, "Mouse.PointerSensitivity.Changed", |
| 767 | "Mouse.PointerSensitivity.Started", |
| 768 | sensitivity_int); |
[email protected] | 563fb5f | 2012-03-31 00:39:28 | [diff] [blame] | 769 | } |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 770 | if (reason != REASON_PREF_CHANGED || |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 771 | pref_name == ::prefs::kMouseScrollSensitivity) { |
Kyle Horimoto | 5ab70b90 | 2020-04-01 22:23:59 | [diff] [blame] | 772 | // With the flag off, use to normal sensitivity (legacy fallback). |
| 773 | // TODO(https://crbug.com/836258): Remove check when flag is removed. |
| 774 | const int sensitivity_int = AreScrollSettingsAllowed() |
| 775 | ? mouse_scroll_sensitivity_.GetValue() |
| 776 | : mouse_sensitivity_.GetValue(); |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 777 | if (user_is_active) |
Kyle Horimoto | 5ab70b90 | 2020-04-01 22:23:59 | [diff] [blame] | 778 | mouse_settings.SetScrollSensitivity(sensitivity_int); |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 779 | ReportSensitivityPrefApplication(reason, "Mouse.ScrollSensitivity.Changed", |
| 780 | "Mouse.ScrollSensitivity.Started", |
| 781 | sensitivity_int); |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 782 | } |
| 783 | if (reason != REASON_PREF_CHANGED || |
Harry Cutts | c333197 | 2020-11-17 03:54:46 | [diff] [blame] | 784 | pref_name == ::prefs::kPointingStickSensitivity) { |
| 785 | const int sensitivity_int = pointing_stick_sensitivity_.GetValue(); |
| 786 | if (user_is_active) { |
| 787 | pointing_stick_settings.SetSensitivity(sensitivity_int); |
| 788 | } |
Harry Cutts | b1a178d | 2020-11-19 04:12:39 | [diff] [blame] | 789 | ReportSensitivityPrefApplication( |
| 790 | reason, "PointingStick.PointerSensitivity.Changed", |
| 791 | "PointingStick.PointerSensitivity.Started", sensitivity_int); |
Harry Cutts | c333197 | 2020-11-17 03:54:46 | [diff] [blame] | 792 | } |
| 793 | if (reason != REASON_PREF_CHANGED || |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 794 | pref_name == ::prefs::kTouchpadSensitivity) { |
Kyle Horimoto | 5ab70b90 | 2020-04-01 22:23:59 | [diff] [blame] | 795 | const int sensitivity_int = touchpad_sensitivity_.GetValue(); |
| 796 | if (user_is_active) { |
| 797 | touchpad_settings.SetSensitivity(sensitivity_int); |
| 798 | |
| 799 | // With the flag off, also set scroll sensitivity (legacy fallback). |
| 800 | // TODO(https://crbug.com/836258): Remove check when flag is removed. |
| 801 | if (!AreScrollSettingsAllowed()) |
| 802 | touchpad_settings.SetScrollSensitivity(sensitivity_int); |
| 803 | } |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 804 | ReportSensitivityPrefApplication( |
| 805 | reason, "Touchpad.PointerSensitivity.Changed", |
| 806 | "Touchpad.PointerSensitivity.Started", sensitivity_int); |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 807 | } |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 808 | if (reason != REASON_PREF_CHANGED || |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 809 | pref_name == ::prefs::kTouchpadScrollSensitivity) { |
Kyle Horimoto | 5ab70b90 | 2020-04-01 22:23:59 | [diff] [blame] | 810 | // With the flag off, use normal sensitivity (legacy fallback). |
| 811 | // TODO(https://crbug.com/836258): Remove check when flag is removed. |
| 812 | const int sensitivity_int = AreScrollSettingsAllowed() |
| 813 | ? touchpad_scroll_sensitivity_.GetValue() |
| 814 | : touchpad_sensitivity_.GetValue(); |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 815 | if (user_is_active) |
Kyle Horimoto | 5ab70b90 | 2020-04-01 22:23:59 | [diff] [blame] | 816 | touchpad_settings.SetScrollSensitivity(sensitivity_int); |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 817 | ReportSensitivityPrefApplication( |
| 818 | reason, "Touchpad.ScrollSensitivity.Changed", |
| 819 | "Touchpad.ScrollSensitivity.Started", sensitivity_int); |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 820 | } |
| 821 | if (reason != REASON_PREF_CHANGED || |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 822 | pref_name == ::prefs::kPrimaryMouseButtonRight) { |
[email protected] | 0027fde1 | 2011-12-15 05:09:38 | [diff] [blame] | 823 | const bool right = primary_mouse_button_right_.GetValue(); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 824 | if (user_is_active) |
| 825 | mouse_settings.SetPrimaryButtonRight(right); |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 826 | ReportBooleanPrefApplication(reason, "Mouse.PrimaryButtonRight.Changed", |
| 827 | "Mouse.PrimaryButtonRight.Started", right); |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 828 | // Save owner preference in local state to use on login screen. |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 829 | if (user_is_owner) { |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 830 | PrefService* prefs = g_browser_process->local_state(); |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 831 | if (prefs->GetBoolean(::prefs::kOwnerPrimaryMouseButtonRight) != right) |
| 832 | prefs->SetBoolean(::prefs::kOwnerPrimaryMouseButtonRight, right); |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 833 | } |
[email protected] | 0027fde1 | 2011-12-15 05:09:38 | [diff] [blame] | 834 | } |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 835 | if (reason != REASON_PREF_CHANGED || |
| 836 | pref_name == ::prefs::kMouseAcceleration) { |
Zentaro Kavanagh | 65b3e11 | 2019-09-03 16:18:23 | [diff] [blame] | 837 | const bool enabled = mouse_acceleration_.GetValue(); |
| 838 | if (user_is_active) |
| 839 | mouse_settings.SetAcceleration(enabled); |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 840 | ReportBooleanPrefApplication(reason, "Mouse.Acceleration.Changed", |
| 841 | "Mouse.Acceleration.Started", enabled); |
Zentaro Kavanagh | 65b3e11 | 2019-09-03 16:18:23 | [diff] [blame] | 842 | } |
| 843 | if (reason != REASON_PREF_CHANGED || |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 844 | pref_name == ::prefs::kMouseScrollAcceleration) { |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 845 | const bool enabled = mouse_scroll_acceleration_.GetValue(); |
| 846 | if (user_is_active) |
| 847 | mouse_settings.SetScrollAcceleration(enabled); |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 848 | ReportBooleanPrefApplication(reason, "Mouse.ScrollAcceleration.Changed", |
| 849 | "Mouse.ScrollAcceleration.Started", enabled); |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 850 | } |
| 851 | if (reason != REASON_PREF_CHANGED || |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 852 | pref_name == ::prefs::kTouchpadAcceleration) { |
Zentaro Kavanagh | 65b3e11 | 2019-09-03 16:18:23 | [diff] [blame] | 853 | const bool enabled = touchpad_acceleration_.GetValue(); |
| 854 | if (user_is_active) |
| 855 | touchpad_settings.SetAcceleration(enabled); |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 856 | ReportBooleanPrefApplication(reason, "Touchpad.Acceleration.Changed", |
| 857 | "Touchpad.Acceleration.Started", enabled); |
Zentaro Kavanagh | 65b3e11 | 2019-09-03 16:18:23 | [diff] [blame] | 858 | } |
Lann Martin | 9a517ad | 2017-08-29 00:43:39 | [diff] [blame] | 859 | if (reason != REASON_PREF_CHANGED || |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 860 | pref_name == ::prefs::kTouchpadScrollAcceleration) { |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 861 | const bool enabled = touchpad_scroll_acceleration_.GetValue(); |
| 862 | if (user_is_active) |
| 863 | touchpad_settings.SetScrollAcceleration(enabled); |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 864 | ReportBooleanPrefApplication(reason, "Touchpad.ScrollAcceleration.Changed", |
| 865 | "Touchpad.ScrollAcceleration.Started", |
| 866 | enabled); |
Kyle Horimoto | 734f075 | 2020-03-20 20:46:54 | [diff] [blame] | 867 | } |
| 868 | if (reason != REASON_PREF_CHANGED || |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 869 | pref_name == ::prefs::kDownloadDefaultDirectory) { |
[email protected] | d9d04df | 2012-10-12 07:06:35 | [diff] [blame] | 870 | const bool default_download_to_drive = drive::util::IsUnderDriveMountPoint( |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 871 | download_default_directory_.GetValue()); |
Harry Cutts | 543a38d7 | 2020-11-12 20:08:08 | [diff] [blame] | 872 | ReportBooleanPrefApplication( |
| 873 | reason, "FileBrowser.DownloadDestination.IsGoogleDrive.Changed", |
| 874 | "FileBrowser.DownloadDestination.IsGoogleDrive.Started", |
| 875 | default_download_to_drive); |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 876 | } |
[email protected] | 8be9ff2 | 2010-06-08 02:13:54 | [diff] [blame] | 877 | |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 878 | if (reason != REASON_PREF_CHANGED || |
Chloe Pelling | 186ed3e | 2020-04-27 01:08:34 | [diff] [blame] | 879 | pref_name == ash::prefs::kXkbAutoRepeatEnabled) { |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 880 | if (user_is_active) { |
| 881 | const bool enabled = xkb_auto_repeat_enabled_.GetValue(); |
[email protected] | fbb141a | 2014-04-11 13:25:52 | [diff] [blame] | 882 | input_method::InputMethodManager::Get() |
| 883 | ->GetImeKeyboard() |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 884 | ->SetAutoRepeatEnabled(enabled); |
xdai | c97cc0a | 2017-02-18 18:10:04 | [diff] [blame] | 885 | |
| 886 | user_manager::known_user::SetBooleanPref( |
Chloe Pelling | 186ed3e | 2020-04-27 01:08:34 | [diff] [blame] | 887 | user_->GetAccountId(), ash::prefs::kXkbAutoRepeatEnabled, enabled); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 888 | } |
| 889 | } |
| 890 | if (reason != REASON_PREF_CHANGED || |
Chloe Pelling | 186ed3e | 2020-04-27 01:08:34 | [diff] [blame] | 891 | pref_name == ash::prefs::kXkbAutoRepeatDelay || |
| 892 | pref_name == ash::prefs::kXkbAutoRepeatInterval) { |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 893 | if (user_is_active) |
| 894 | UpdateAutoRepeatRate(); |
[email protected] | 74b42fc1 | 2010-07-20 10:15:41 | [diff] [blame] | 895 | } |
Alexander Hendrich | a4c3953 | 2018-06-27 08:33:05 | [diff] [blame] | 896 | if (reason != REASON_PREF_CHANGED || |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 897 | pref_name == ::prefs::kLanguageAllowedInputMethods) { |
Alexander Hendrich | a4c3953 | 2018-06-27 08:33:05 | [diff] [blame] | 898 | const std::vector<std::string> allowed_input_methods = |
| 899 | allowed_input_methods_.GetValue(); |
| 900 | |
| 901 | bool managed_by_policy = |
| 902 | ime_state_->SetAllowedInputMethods(allowed_input_methods, false); |
| 903 | |
| 904 | if (managed_by_policy) { |
| 905 | preload_engines_.SetValue( |
| 906 | base::JoinString(ime_state_->GetActiveInputMethodIds(), ",")); |
| 907 | } |
| 908 | } |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 909 | if (reason != REASON_PREF_CHANGED || pref_name == ::prefs::kAllowedLanguages) |
Zakhar Voit | 1f16c5e | 2018-10-26 12:08:23 | [diff] [blame] | 910 | locale_util::RemoveDisallowedLanguagesFromPreferred(prefs_); |
| 911 | |
| 912 | if (reason != REASON_PREF_CHANGED || |
Alexandre Frechette | 572755b | 2019-02-13 22:30:20 | [diff] [blame] | 913 | pref_name == language::prefs::kPreferredLanguages) { |
Zakhar Voit | 1f16c5e | 2018-10-26 12:08:23 | [diff] [blame] | 914 | // In case setting has been changed with sync it can contain disallowed |
| 915 | // values. |
| 916 | locale_util::RemoveDisallowedLanguagesFromPreferred(prefs_); |
| 917 | } |
[email protected] | a6e9077 | 2011-02-09 05:38:54 | [diff] [blame] | 918 | |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 919 | if (reason == REASON_INITIALIZATION) |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 920 | SetInputMethodList(); |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 921 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 922 | if (pref_name == ::prefs::kLanguagePreloadEngines && |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 923 | reason == REASON_PREF_CHANGED) { |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 924 | SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, |
| 925 | language_prefs::kPreloadEnginesConfigName, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 926 | preload_engines_.GetValue()); |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 927 | } |
[email protected] | 22bec1a | 2012-03-27 06:33:48 | [diff] [blame] | 928 | |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 929 | if ((reason == REASON_INITIALIZATION) || |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 930 | (pref_name == ::prefs::kLanguageEnabledImes && |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 931 | reason == REASON_PREF_CHANGED)) { |
Yuichiro Hanada | 1dcf2e8 | 2018-07-02 22:38:38 | [diff] [blame] | 932 | std::string value(enabled_imes_.GetValue()); |
[email protected] | 797c680 | 2012-09-20 10:36:13 | [diff] [blame] | 933 | |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 934 | std::vector<std::string> split_values; |
brettw | c6f82b1 | 2015-07-21 21:37:38 | [diff] [blame] | 935 | if (!value.empty()) { |
| 936 | split_values = base::SplitString(value, ",", base::TRIM_WHITESPACE, |
| 937 | base::SPLIT_WANT_ALL); |
| 938 | } |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 939 | ime_state_->SetEnabledExtensionImes(&split_values); |
[email protected] | 797c680 | 2012-09-20 10:36:13 | [diff] [blame] | 940 | } |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 941 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 942 | if (pref_name == ::prefs::kLanguageImeMenuActivated && |
Elly Fong-Jones | c00b17c28 | 2019-02-20 14:32:22 | [diff] [blame] | 943 | (reason == REASON_PREF_CHANGED || reason == REASON_ACTIVE_USER_CHANGED)) { |
azurewei | 103ed212 | 2016-01-10 07:01:14 | [diff] [blame] | 944 | const bool activated = ime_menu_activated_.GetValue(); |
azurewei | f7a97e0 | 2016-02-04 08:12:48 | [diff] [blame] | 945 | input_method::InputMethodManager::Get()->ImeMenuActivationChanged( |
| 946 | activated); |
azurewei | 103ed212 | 2016-01-10 07:01:14 | [diff] [blame] | 947 | } |
| 948 | |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 949 | if (user_is_active) { |
| 950 | system::InputDeviceSettings::Get()->UpdateTouchpadSettings( |
| 951 | touchpad_settings); |
| 952 | system::InputDeviceSettings::Get()->UpdateMouseSettings(mouse_settings); |
Harry Cutts | c333197 | 2020-11-17 03:54:46 | [diff] [blame] | 953 | system::InputDeviceSettings::Get()->UpdatePointingStickSettings( |
| 954 | pointing_stick_settings); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 955 | } |
michaelpg | 592b07a | 2014-12-23 19:46:09 | [diff] [blame] | 956 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 957 | if (pref_name == ::prefs::kUserTimezone && |
alemate | 2cb0d75 | 2017-08-11 05:22:16 | [diff] [blame] | 958 | reason != REASON_ACTIVE_USER_CHANGED) { |
| 959 | system::UpdateSystemTimezone(ProfileHelper::Get()->GetProfileByUser(user_)); |
| 960 | } |
| 961 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 962 | if ((pref_name == ::prefs::kResolveTimezoneByGeolocation || |
| 963 | pref_name == ::prefs::kResolveTimezoneByGeolocationMethod) && |
alemate | 48255f3d | 2015-01-30 18:11:41 | [diff] [blame] | 964 | reason != REASON_ACTIVE_USER_CHANGED) { |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 965 | if (pref_name == ::prefs::kResolveTimezoneByGeolocationMethod && |
| 966 | !prefs_->FindPreference(::prefs::kResolveTimezoneByGeolocationMethod) |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 967 | ->IsDefaultValue()) { |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 968 | prefs_->SetBoolean(::prefs::kResolveTimezoneByGeolocationMigratedToMethod, |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 969 | true); |
| 970 | } |
alemate | 48255f3d | 2015-01-30 18:11:41 | [diff] [blame] | 971 | if (user_is_owner) { |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 972 | // Policy check is false here, because there is no owner for enterprise. |
| 973 | g_browser_process->local_state()->SetInteger( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 974 | ::prefs::kResolveDeviceTimezoneByGeolocationMethod, |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 975 | static_cast<int>(system::TimeZoneResolverManager:: |
| 976 | GetEffectiveUserTimeZoneResolveMethod( |
| 977 | prefs_, false /* check_policy */))); |
alemate | 48255f3d | 2015-01-30 18:11:41 | [diff] [blame] | 978 | } |
| 979 | if (user_is_primary_) { |
alemate | d70e82f | 2016-04-05 12:21:33 | [diff] [blame] | 980 | g_browser_process->platform_part() |
| 981 | ->GetTimezoneResolverManager() |
| 982 | ->UpdateTimezoneResolver(); |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 983 | if (system::TimeZoneResolverManager:: |
| 984 | GetEffectiveUserTimeZoneResolveMethod( |
| 985 | prefs_, true /* check_policy */) == |
| 986 | system::TimeZoneResolverManager::TimeZoneResolveMethod:: |
| 987 | DISABLED && |
| 988 | reason == REASON_PREF_CHANGED) { |
alemate | 75b7a5c | 2016-03-29 06:39:46 | [diff] [blame] | 989 | // Allow immediate timezone update on Stop + Start. |
| 990 | g_browser_process->local_state()->ClearPref( |
| 991 | TimeZoneResolver::kLastTimeZoneRefreshTime); |
alemate | 48255f3d | 2015-01-30 18:11:41 | [diff] [blame] | 992 | } |
| 993 | } |
| 994 | } |
alemate | 6cf8c6e | 2015-07-23 06:58:50 | [diff] [blame] | 995 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 996 | if (pref_name == ::prefs::kUse24HourClock || |
alemate | 6cf8c6e | 2015-07-23 06:58:50 | [diff] [blame] | 997 | reason != REASON_ACTIVE_USER_CHANGED) { |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 998 | const bool value = prefs_->GetBoolean(::prefs::kUse24HourClock); |
alemate | 8730a2f | 2015-12-19 07:13:09 | [diff] [blame] | 999 | user_manager::known_user::SetBooleanPref(user_->GetAccountId(), |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 1000 | ::prefs::kUse24HourClock, value); |
alemate | 6cf8c6e | 2015-07-23 06:58:50 | [diff] [blame] | 1001 | } |
afakhry | e2bc0da54 | 2016-11-09 19:41:57 | [diff] [blame] | 1002 | |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 1003 | if (pref_name == ::prefs::kParentAccessCodeConfig || |
Henrique Grandinetti | 07dca14 | 2019-04-05 20:38:35 | [diff] [blame] | 1004 | reason != REASON_PREF_CHANGED) { |
| 1005 | const base::Value* value = |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 1006 | prefs_->GetDictionary(::prefs::kParentAccessCodeConfig); |
| 1007 | if (value && |
| 1008 | prefs_->IsManagedPreference(::prefs::kParentAccessCodeConfig) && |
Henrique Grandinetti | dc2db07 | 2019-05-03 13:18:26 | [diff] [blame] | 1009 | user_->IsChild()) { |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 1010 | user_manager::known_user::SetPref( |
| 1011 | user_->GetAccountId(), ::prefs::kKnownUserParentAccessCodeConfig, |
| 1012 | value->Clone()); |
Henrique Grandinetti | dc2db07 | 2019-05-03 13:18:26 | [diff] [blame] | 1013 | parent_access::ParentAccessService::Get().LoadConfigForUser(user_); |
Henrique Grandinetti | 07dca14 | 2019-04-05 20:38:35 | [diff] [blame] | 1014 | } else { |
| 1015 | user_manager::known_user::RemovePref( |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 1016 | user_->GetAccountId(), ::prefs::kKnownUserParentAccessCodeConfig); |
Henrique Grandinetti | 07dca14 | 2019-04-05 20:38:35 | [diff] [blame] | 1017 | } |
| 1018 | } |
| 1019 | |
vmpstr | 843b41a | 2017-03-01 21:15:03 | [diff] [blame] | 1020 | for (auto* remap_pref : kLanguageRemapPrefs) { |
xdai | e6172c9 | 2017-02-24 19:01:51 | [diff] [blame] | 1021 | if (pref_name == remap_pref || reason != REASON_ACTIVE_USER_CHANGED) { |
| 1022 | const int value = prefs_->GetInteger(remap_pref); |
| 1023 | user_manager::known_user::SetIntegerPref(user_->GetAccountId(), |
| 1024 | remap_pref, value); |
| 1025 | } |
| 1026 | } |
Thomas Tellier | aa061790 | 2020-05-04 10:02:59 | [diff] [blame] | 1027 | |
| 1028 | if (pref_name == chromeos::prefs::kLoginDisplayPasswordButtonEnabled || |
| 1029 | reason != REASON_ACTIVE_USER_CHANGED) { |
| 1030 | const bool value = |
| 1031 | prefs_->GetBoolean(chromeos::prefs::kLoginDisplayPasswordButtonEnabled); |
| 1032 | user_manager::known_user::SetBooleanPref( |
| 1033 | user_->GetAccountId(), |
| 1034 | chromeos::prefs::kLoginDisplayPasswordButtonEnabled, value); |
| 1035 | } |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 1036 | } |
| 1037 | |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 1038 | void Preferences::OnIsSyncingChanged() { |
| 1039 | DVLOG(1) << "OnIsSyncingChanged"; |
Alexander Alekseev | 687cdb5 | 2017-11-11 02:40:00 | [diff] [blame] | 1040 | TryMigrateToResolveTimezoneByGeolocationMethod(prefs_); |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 1041 | ForceNaturalScrollDefault(); |
| 1042 | } |
| 1043 | |
Ana Salazar | eb7c2571 | 2020-02-03 20:27:26 | [diff] [blame] | 1044 | // TODO(anasalazar): Finish moving this to ash::TouchDevicesController. |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 1045 | void Preferences::ForceNaturalScrollDefault() { |
| 1046 | DVLOG(1) << "ForceNaturalScrollDefault"; |
James Cook | 181be00 | 2020-05-05 20:55:19 | [diff] [blame] | 1047 | // Natural scroll is a priority pref. |
| 1048 | bool is_syncing = chromeos::features::IsSplitSettingsSyncEnabled() |
| 1049 | ? prefs_->AreOsPriorityPrefsSyncing() |
| 1050 | : prefs_->IsPrioritySyncing(); |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 1051 | if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
[email protected] | bbd0826 | 2013-10-30 09:04:27 | [diff] [blame] | 1052 | switches::kNaturalScrollDefault) && |
James Cook | 181be00 | 2020-05-05 20:55:19 | [diff] [blame] | 1053 | is_syncing && !prefs_->GetUserPrefValue(ash::prefs::kNaturalScroll)) { |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 1054 | DVLOG(1) << "Natural scroll forced to true"; |
| 1055 | natural_scroll_.SetValue(true); |
Harry Cutts | 950265f | 2020-10-22 18:11:47 | [diff] [blame] | 1056 | base::UmaHistogramBoolean("Touchpad.NaturalScroll.Forced", true); |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 1057 | } |
| 1058 | } |
| 1059 | |
[email protected] | d01bb807 | 2010-04-12 13:00:15 | [diff] [blame] | 1060 | void Preferences::SetLanguageConfigStringListAsCSV(const char* section, |
| 1061 | const char* name, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 1062 | const std::string& value) { |
[email protected] | e24c2c9 | 2010-10-23 01:39:24 | [diff] [blame] | 1063 | VLOG(1) << "Setting " << name << " to '" << value << "'"; |
[email protected] | d01bb807 | 2010-04-12 13:00:15 | [diff] [blame] | 1064 | |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 1065 | std::vector<std::string> split_values; |
brettw | c6f82b1 | 2015-07-21 21:37:38 | [diff] [blame] | 1066 | if (!value.empty()) { |
| 1067 | split_values = base::SplitString(value, ",", base::TRIM_WHITESPACE, |
| 1068 | base::SPLIT_WANT_ALL); |
| 1069 | } |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 1070 | |
[email protected] | b071452e | 2014-06-02 19:17:12 | [diff] [blame] | 1071 | // Transfers the xkb id to extension-xkb id. |
| 1072 | if (input_method_manager_->MigrateInputMethods(&split_values)) |
brettw | d94a2214 | 2015-07-15 05:19:26 | [diff] [blame] | 1073 | preload_engines_.SetValue(base::JoinString(split_values, ",")); |
[email protected] | fdcd441 | 2014-03-05 06:01:58 | [diff] [blame] | 1074 | |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 1075 | if (section == std::string(language_prefs::kGeneralSectionName) && |
| 1076 | name == std::string(language_prefs::kPreloadEnginesConfigName)) { |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 1077 | ime_state_->ReplaceEnabledInputMethods(split_values); |
[email protected] | dbc9b19 | 2012-04-18 05:55:34 | [diff] [blame] | 1078 | return; |
| 1079 | } |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 1080 | } |
| 1081 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 1082 | void Preferences::SetInputMethodList() { |
| 1083 | // When |preload_engines_| are set, InputMethodManager::ChangeInputMethod() |
| 1084 | // might be called to change the current input method to the first one in the |
| 1085 | // |preload_engines_| list. This also updates previous/current input method |
| 1086 | // prefs. That's why GetValue() calls are placed before the |
| 1087 | // SetLanguageConfigStringListAsCSV() call below. |
| 1088 | const std::string previous_input_method_id = |
| 1089 | previous_input_method_.GetValue(); |
| 1090 | const std::string current_input_method_id = current_input_method_.GetValue(); |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 1091 | SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, |
| 1092 | language_prefs::kPreloadEnginesConfigName, |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 1093 | preload_engines_.GetValue()); |
| 1094 | |
| 1095 | // ChangeInputMethod() has to be called AFTER the value of |preload_engines_| |
| 1096 | // is sent to the InputMethodManager. Otherwise, the ChangeInputMethod request |
| 1097 | // might be ignored as an invalid input method ID. The ChangeInputMethod() |
| 1098 | // calls are also necessary to restore the previous/current input method prefs |
| 1099 | // which could have been modified by the SetLanguageConfigStringListAsCSV call |
| 1100 | // above to the original state. |
| 1101 | if (!previous_input_method_id.empty()) |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 1102 | ime_state_->ChangeInputMethod(previous_input_method_id, |
| 1103 | false /* show_message */); |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 1104 | if (!current_input_method_id.empty()) |
[email protected] | f0881cf | 2014-08-15 23:31:42 | [diff] [blame] | 1105 | ime_state_->ChangeInputMethod(current_input_method_id, |
| 1106 | false /* show_message */); |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 1107 | } |
| 1108 | |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 1109 | void Preferences::UpdateAutoRepeatRate() { |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 1110 | input_method::AutoRepeatRate rate; |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 1111 | rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); |
| 1112 | rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 1113 | DCHECK(rate.initial_delay_in_ms > 0); |
| 1114 | DCHECK(rate.repeat_interval_in_ms > 0); |
Wei Lee | 5fd6c51 | 2020-11-26 07:52:27 | [diff] [blame] | 1115 | input_method::InputMethodManager::Get()->GetImeKeyboard()->SetAutoRepeatRate( |
| 1116 | rate); |
xdai | c97cc0a | 2017-02-18 18:10:04 | [diff] [blame] | 1117 | |
| 1118 | user_manager::known_user::SetIntegerPref(user_->GetAccountId(), |
Chloe Pelling | 186ed3e | 2020-04-27 01:08:34 | [diff] [blame] | 1119 | ash::prefs::kXkbAutoRepeatDelay, |
xdai | c97cc0a | 2017-02-18 18:10:04 | [diff] [blame] | 1120 | rate.initial_delay_in_ms); |
Chloe Pelling | 186ed3e | 2020-04-27 01:08:34 | [diff] [blame] | 1121 | user_manager::known_user::SetIntegerPref(user_->GetAccountId(), |
| 1122 | ash::prefs::kXkbAutoRepeatInterval, |
| 1123 | rate.repeat_interval_in_ms); |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 1124 | } |
| 1125 | |
Evan Stade | 0881dea | 2019-09-04 18:22:49 | [diff] [blame] | 1126 | void Preferences::ActiveUserChanged(user_manager::User* active_user) { |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 1127 | if (active_user != user_) |
| 1128 | return; |
| 1129 | ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); |
| 1130 | } |
| 1131 | |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 1132 | } // namespace chromeos |