[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 | |
[email protected] | 39699140 | 2014-02-17 10:56:17 | [diff] [blame] | 7 | #include <vector> |
| 8 | |
[email protected] | 3c5ec44b | 2013-10-22 08:53:38 | [diff] [blame] | 9 | #include "ash/autoclick/autoclick_controller.h" |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 10 | #include "ash/magnifier/magnifier_constants.h" |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 11 | #include "ash/shell.h" |
[email protected] | 775caec | 2011-09-01 17:14:32 | [diff] [blame] | 12 | #include "base/command_line.h" |
[email protected] | 530cd62 | 2011-04-14 15:45:00 | [diff] [blame] | 13 | #include "base/i18n/time_formatting.h" |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 14 | #include "base/metrics/histogram.h" |
[email protected] | 1ab137b | 2013-03-21 03:33:18 | [diff] [blame] | 15 | #include "base/prefs/pref_member.h" |
[email protected] | 681958c | 2013-02-21 13:48:14 | [diff] [blame] | 16 | #include "base/prefs/pref_registry_simple.h" |
[email protected] | 9eec53fe | 2013-10-30 20:21:17 | [diff] [blame] | 17 | #include "base/prefs/scoped_user_pref_update.h" |
[email protected] | 1988e1c | 2013-02-28 20:27:42 | [diff] [blame] | 18 | #include "base/strings/string_split.h" |
[email protected] | 5c07332 | 2013-06-11 08:03:30 | [diff] [blame] | 19 | #include "base/strings/string_util.h" |
[email protected] | 135cb80 | 2013-06-09 16:44:20 | [diff] [blame] | 20 | #include "base/strings/utf_string_conversions.h" |
[email protected] | 49c4cf85 | 2013-09-27 19:28:24 | [diff] [blame] | 21 | #include "base/sys_info.h" |
[email protected] | c0a2128d9 | 2011-07-20 15:04:46 | [diff] [blame] | 22 | #include "chrome/browser/browser_process.h" |
[email protected] | fdf40f3e | 2013-07-11 23:55:46 | [diff] [blame] | 23 | #include "chrome/browser/chrome_notification_types.h" |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 24 | #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
[email protected] | 4fa2fd5d | 2013-04-26 03:42:52 | [diff] [blame] | 25 | #include "chrome/browser/chromeos/drive/file_system_util.h" |
[email protected] | 9199bd5 | 2010-07-01 05:04:41 | [diff] [blame] | 26 | #include "chrome/browser/chromeos/input_method/input_method_util.h" |
[email protected] | 26012e2 | 2010-12-01 06:44:27 | [diff] [blame] | 27 | #include "chrome/browser/chromeos/login/login_utils.h" |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 28 | #include "chrome/browser/chromeos/login/user.h" |
[email protected] | 82eb8ec | 2011-12-20 22:24:33 | [diff] [blame] | 29 | #include "chrome/browser/chromeos/system/input_device_settings.h" |
[email protected] | b1d9727 | 2013-08-17 13:38:49 | [diff] [blame] | 30 | #include "chrome/browser/download/download_prefs.h" |
[email protected] | a1ea129 | 2013-08-07 23:50:40 | [diff] [blame] | 31 | #include "chrome/browser/feedback/tracing_manager.h" |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 32 | #include "chrome/browser/prefs/pref_service_syncable.h" |
[email protected] | 775caec | 2011-09-01 17:14:32 | [diff] [blame] | 33 | #include "chrome/common/chrome_switches.h" |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 34 | #include "chrome/common/pref_names.h" |
[email protected] | 931d104 | 2013-04-05 17:50:44 | [diff] [blame] | 35 | #include "chromeos/chromeos_switches.h" |
[email protected] | fdcd441 | 2014-03-05 06:01:58 | [diff] [blame^] | 36 | #include "chromeos/ime/extension_ime_util.h" |
[email protected] | 60049c0 | 2013-04-26 07:52:36 | [diff] [blame] | 37 | #include "chromeos/ime/input_method_manager.h" |
[email protected] | da5cb80 | 2013-03-30 18:58:16 | [diff] [blame] | 38 | #include "chromeos/ime/xkeyboard.h" |
[email protected] | 279690f8 | 2013-10-09 08:23:52 | [diff] [blame] | 39 | #include "chromeos/system/statistics_provider.h" |
[email protected] | 75fee37 | 2013-03-06 00:42:44 | [diff] [blame] | 40 | #include "components/user_prefs/pref_registry_syncable.h" |
[email protected] | 8bbf619 | 2013-07-18 11:14:04 | [diff] [blame] | 41 | #include "third_party/icu/source/i18n/unicode/timezone.h" |
[email protected] | 86ccbd4 | 2013-09-18 18:11:54 | [diff] [blame] | 42 | #include "ui/events/event_constants.h" |
| 43 | #include "ui/events/event_utils.h" |
[email protected] | a6483d2 | 2013-07-03 22:11:00 | [diff] [blame] | 44 | #include "url/gurl.h" |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 45 | |
[email protected] | de1528d1a | 2012-05-14 10:36:15 | [diff] [blame] | 46 | namespace chromeos { |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 47 | |
[email protected] | 9199bd5 | 2010-07-01 05:04:41 | [diff] [blame] | 48 | static const char kFallbackInputMethodLocale[] = "en-US"; |
[email protected] | 4793c94 | 2010-09-21 23:17:17 | [diff] [blame] | 49 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 50 | Preferences::Preferences() |
[email protected] | 155e1b4 | 2012-07-14 03:06:01 | [diff] [blame] | 51 | : prefs_(NULL), |
[email protected] | daf37cc | 2013-11-01 18:10:26 | [diff] [blame] | 52 | input_method_manager_(input_method::InputMethodManager::Get()), |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 53 | user_(NULL), |
| 54 | user_is_primary_(false) { |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 55 | // Do not observe shell, if there is no shell instance; e.g., in some unit |
| 56 | // tests. |
| 57 | if (ash::Shell::HasInstance()) |
| 58 | ash::Shell::GetInstance()->AddShellObserver(this); |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | Preferences::Preferences(input_method::InputMethodManager* input_method_manager) |
[email protected] | eb5624e | 2013-05-23 19:50:27 | [diff] [blame] | 62 | : prefs_(NULL), |
[email protected] | daf37cc | 2013-11-01 18:10:26 | [diff] [blame] | 63 | input_method_manager_(input_method_manager), |
[email protected] | 50de64ea | 2014-02-19 06:25:50 | [diff] [blame] | 64 | user_(NULL), |
| 65 | user_is_primary_(false) { |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 66 | // Do not observe shell, if there is no shell instance; e.g., in some unit |
| 67 | // tests. |
| 68 | if (ash::Shell::HasInstance()) |
| 69 | ash::Shell::GetInstance()->AddShellObserver(this); |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 70 | } |
[email protected] | d743a598 | 2010-11-08 17:54:09 | [diff] [blame] | 71 | |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 72 | Preferences::~Preferences() { |
| 73 | prefs_->RemoveObserver(this); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 74 | UserManager::Get()->RemoveSessionStateObserver(this); |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 75 | // If shell instance is destoryed before this preferences instance, there is |
| 76 | // no need to remove this shell observer. |
| 77 | if (ash::Shell::HasInstance()) |
| 78 | ash::Shell::GetInstance()->RemoveShellObserver(this); |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 79 | } |
[email protected] | 9199bd5 | 2010-07-01 05:04:41 | [diff] [blame] | 80 | |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 81 | // static |
[email protected] | 681958c | 2013-02-21 13:48:14 | [diff] [blame] | 82 | void Preferences::RegisterPrefs(PrefRegistrySimple* registry) { |
[email protected] | 681958c | 2013-02-21 13:48:14 | [diff] [blame] | 83 | registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false); |
| 84 | registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true); |
[email protected] | 681958c | 2013-02-21 13:48:14 | [diff] [blame] | 85 | registry->RegisterBooleanPref(prefs::kVirtualKeyboardEnabled, false); |
| 86 | } |
| 87 | |
| 88 | // static |
[email protected] | 37ca3fe0 | 2013-07-05 15:32:44 | [diff] [blame] | 89 | void Preferences::RegisterProfilePrefs( |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 90 | user_prefs::PrefRegistrySyncable* registry) { |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 91 | std::string hardware_keyboard_id; |
| 92 | // TODO(yusukes): Remove the runtime hack. |
[email protected] | 49c4cf85 | 2013-09-27 19:28:24 | [diff] [blame] | 93 | if (base::SysInfo::IsRunningOnChromeOS()) { |
[email protected] | 39699140 | 2014-02-17 10:56:17 | [diff] [blame] | 94 | DCHECK(g_browser_process); |
| 95 | PrefService* local_state = g_browser_process->local_state(); |
| 96 | DCHECK(local_state); |
| 97 | hardware_keyboard_id = |
| 98 | local_state->GetString(prefs::kHardwareKeyboardLayout); |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 99 | } else { |
| 100 | hardware_keyboard_id = "xkb:us::eng"; // only for testing. |
| 101 | } |
[email protected] | a9a8181 | 2011-09-16 11:01:17 | [diff] [blame] | 102 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 103 | registry->RegisterBooleanPref( |
[email protected] | a1ea129 | 2013-08-07 23:50:40 | [diff] [blame] | 104 | prefs::kPerformanceTracingEnabled, |
| 105 | false, |
| 106 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 107 | |
| 108 | registry->RegisterBooleanPref( |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 109 | prefs::kTapToClickEnabled, |
| 110 | true, |
[email protected] | 0e1aef1b | 2013-08-07 00:49:35 | [diff] [blame] | 111 | user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 112 | registry->RegisterBooleanPref( |
| 113 | prefs::kTapDraggingEnabled, |
| 114 | false, |
[email protected] | 0e1aef1b | 2013-08-07 00:49:35 | [diff] [blame] | 115 | user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 116 | registry->RegisterBooleanPref( |
| 117 | prefs::kEnableTouchpadThreeFingerClick, |
| 118 | false, |
| 119 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 120 | registry->RegisterBooleanPref( |
[email protected] | 6100873 | 2012-11-27 10:36:05 | [diff] [blame] | 121 | prefs::kNaturalScroll, |
[email protected] | bbd0826 | 2013-10-30 09:04:27 | [diff] [blame] | 122 | CommandLine::ForCurrentProcess()->HasSwitch( |
| 123 | switches::kNaturalScrollDefault), |
[email protected] | 0e1aef1b | 2013-08-07 00:49:35 | [diff] [blame] | 124 | user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 125 | registry->RegisterBooleanPref( |
| 126 | prefs::kPrimaryMouseButtonRight, |
| 127 | false, |
[email protected] | 0e1aef1b | 2013-08-07 00:49:35 | [diff] [blame] | 128 | user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 129 | registry->RegisterBooleanPref( |
| 130 | prefs::kLabsMediaplayerEnabled, |
| 131 | false, |
| 132 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 133 | registry->RegisterBooleanPref( |
| 134 | prefs::kLabsAdvancedFilesystemEnabled, |
| 135 | false, |
| 136 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 137 | registry->RegisterBooleanPref( |
[email protected] | 3206f5f | 2013-06-12 18:13:06 | [diff] [blame] | 138 | prefs::kStickyKeysEnabled, |
| 139 | false, |
[email protected] | 5256086 | 2013-09-23 04:24:56 | [diff] [blame] | 140 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | 3206f5f | 2013-06-12 18:13:06 | [diff] [blame] | 141 | registry->RegisterBooleanPref( |
[email protected] | 8126b81 | 2013-06-06 03:49:17 | [diff] [blame] | 142 | prefs::kLargeCursorEnabled, |
| 143 | false, |
| 144 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 145 | registry->RegisterBooleanPref( |
[email protected] | 1dfebfc | 2013-06-04 03:14:32 | [diff] [blame] | 146 | prefs::kSpokenFeedbackEnabled, |
| 147 | false, |
[email protected] | 58983d4 | 2013-08-16 13:16:23 | [diff] [blame] | 148 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | 1dfebfc | 2013-06-04 03:14:32 | [diff] [blame] | 149 | registry->RegisterBooleanPref( |
| 150 | prefs::kHighContrastEnabled, |
| 151 | false, |
[email protected] | 5256086 | 2013-09-23 04:24:56 | [diff] [blame] | 152 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | 1dfebfc | 2013-06-04 03:14:32 | [diff] [blame] | 153 | registry->RegisterBooleanPref( |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 154 | prefs::kScreenMagnifierEnabled, |
| 155 | false, |
[email protected] | 5256086 | 2013-09-23 04:24:56 | [diff] [blame] | 156 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 157 | registry->RegisterIntegerPref( |
| 158 | prefs::kScreenMagnifierType, |
| 159 | ash::kDefaultMagnifierType, |
[email protected] | 5256086 | 2013-09-23 04:24:56 | [diff] [blame] | 160 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 161 | registry->RegisterDoublePref( |
| 162 | prefs::kScreenMagnifierScale, |
| 163 | std::numeric_limits<double>::min(), |
| 164 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 165 | registry->RegisterBooleanPref( |
[email protected] | 1c88156 | 2013-10-12 07:52:58 | [diff] [blame] | 166 | prefs::kAutoclickEnabled, |
| 167 | false, |
| 168 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | 3c5ec44b | 2013-10-22 08:53:38 | [diff] [blame] | 169 | registry->RegisterIntegerPref( |
| 170 | prefs::kAutoclickDelayMs, |
| 171 | ash::AutoclickController::kDefaultAutoclickDelayMs, |
| 172 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | 1c88156 | 2013-10-12 07:52:58 | [diff] [blame] | 173 | registry->RegisterBooleanPref( |
[email protected] | e1b299b | 2014-01-29 23:53:41 | [diff] [blame] | 174 | prefs::kVirtualKeyboardEnabled, |
| 175 | false, |
| 176 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 177 | registry->RegisterBooleanPref( |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 178 | prefs::kShouldAlwaysShowAccessibilityMenu, |
| 179 | false, |
[email protected] | 5256086 | 2013-09-23 04:24:56 | [diff] [blame] | 180 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 181 | registry->RegisterIntegerPref( |
| 182 | prefs::kMouseSensitivity, |
| 183 | 3, |
[email protected] | 0e1aef1b | 2013-08-07 00:49:35 | [diff] [blame] | 184 | user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 185 | registry->RegisterIntegerPref( |
| 186 | prefs::kTouchpadSensitivity, |
| 187 | 3, |
[email protected] | 0e1aef1b | 2013-08-07 00:49:35 | [diff] [blame] | 188 | user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 189 | registry->RegisterBooleanPref( |
| 190 | prefs::kUse24HourClock, |
| 191 | base::GetHourClockType() == base::k24HourClock, |
| 192 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 193 | registry->RegisterBooleanPref( |
| 194 | prefs::kDisableDrive, |
| 195 | false, |
| 196 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 197 | registry->RegisterBooleanPref( |
| 198 | prefs::kDisableDriveOverCellular, |
| 199 | true, |
| 200 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 201 | registry->RegisterBooleanPref( |
| 202 | prefs::kDisableDriveHostedFiles, |
| 203 | false, |
| 204 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 205 | // We don't sync prefs::kLanguageCurrentInputMethod and PreviousInputMethod |
| 206 | // because they're just used to track the logout state of the device. |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 207 | registry->RegisterStringPref( |
| 208 | prefs::kLanguageCurrentInputMethod, |
| 209 | "", |
| 210 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 211 | registry->RegisterStringPref( |
| 212 | prefs::kLanguagePreviousInputMethod, |
| 213 | "", |
| 214 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 215 | // We don't sync the list of input methods and preferred languages since a |
| 216 | // user might use two or more devices with different hardware keyboards. |
| 217 | // crosbug.com/15181 |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 218 | registry->RegisterStringPref( |
| 219 | prefs::kLanguagePreferredLanguages, |
| 220 | kFallbackInputMethodLocale, |
| 221 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 222 | registry->RegisterStringPref( |
| 223 | prefs::kLanguagePreloadEngines, |
| 224 | hardware_keyboard_id, |
| 225 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 226 | registry->RegisterStringPref( |
[email protected] | aef1af4b1 | 2013-05-09 04:50:23 | [diff] [blame] | 227 | prefs::kLanguageEnabledExtensionImes, |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 228 | "", |
| 229 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 230 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 231 | registry->RegisterIntegerPref( |
| 232 | prefs::kLanguageRemapSearchKeyTo, |
| 233 | input_method::kSearchKey, |
[email protected] | 0e1aef1b | 2013-08-07 00:49:35 | [diff] [blame] | 234 | user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 235 | registry->RegisterIntegerPref( |
| 236 | prefs::kLanguageRemapControlKeyTo, |
| 237 | input_method::kControlKey, |
[email protected] | 0e1aef1b | 2013-08-07 00:49:35 | [diff] [blame] | 238 | user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 239 | registry->RegisterIntegerPref( |
| 240 | prefs::kLanguageRemapAltKeyTo, |
| 241 | input_method::kAltKey, |
[email protected] | 0e1aef1b | 2013-08-07 00:49:35 | [diff] [blame] | 242 | user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); |
[email protected] | 0f424fd9 | 2013-05-08 21:12:19 | [diff] [blame] | 243 | // We don't sync the CapsLock remapping pref, since the UI hides this pref |
| 244 | // on certain devices, so syncing a non-default value to a device that |
| 245 | // doesn't allow changing the pref would be odd. http://crbug.com/167237 |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 246 | registry->RegisterIntegerPref( |
| 247 | prefs::kLanguageRemapCapsLockKeyTo, |
| 248 | input_method::kCapsLockKey, |
[email protected] | 0f424fd9 | 2013-05-08 21:12:19 | [diff] [blame] | 249 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 250 | registry->RegisterIntegerPref( |
| 251 | prefs::kLanguageRemapDiamondKeyTo, |
| 252 | input_method::kControlKey, |
[email protected] | 0e1aef1b | 2013-08-07 00:49:35 | [diff] [blame] | 253 | user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); |
[email protected] | e2204a70 | 2013-10-29 21:58:54 | [diff] [blame] | 254 | // The following pref isn't synced since the user may desire a different value |
| 255 | // depending on whether an external keyboard is attached to a particular |
| 256 | // device. |
| 257 | registry->RegisterBooleanPref( |
| 258 | prefs::kLanguageSendFunctionKeys, |
| 259 | false, |
| 260 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 261 | // We don't sync the following keyboard prefs since they are not user- |
| 262 | // configurable. |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 263 | registry->RegisterBooleanPref( |
| 264 | prefs::kLanguageXkbAutoRepeatEnabled, |
| 265 | true, |
| 266 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 267 | registry->RegisterIntegerPref( |
| 268 | prefs::kLanguageXkbAutoRepeatDelay, |
| 269 | language_prefs::kXkbAutoRepeatDelayInMs, |
| 270 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 271 | registry->RegisterIntegerPref( |
| 272 | prefs::kLanguageXkbAutoRepeatInterval, |
| 273 | language_prefs::kXkbAutoRepeatIntervalInMs, |
| 274 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 275 | |
[email protected] | ea1eba5 | 2010-11-23 18:05:38 | [diff] [blame] | 276 | // Mobile plan notifications default to on. |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 277 | registry->RegisterBooleanPref( |
| 278 | prefs::kShowPlanNotifications, |
| 279 | true, |
| 280 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | c74fffa | 2011-04-27 13:32:24 | [diff] [blame] | 281 | |
| 282 | // 3G first-time usage promo will be shown at least once. |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 283 | registry->RegisterBooleanPref( |
| 284 | prefs::kShow3gPromoNotification, |
| 285 | true, |
| 286 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | d6ae950 | 2011-05-05 18:23:09 | [diff] [blame] | 287 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 288 | // Initially all existing users would see "What's new" for current version |
| 289 | // after update. |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 290 | registry->RegisterStringPref(prefs::kChromeOSReleaseNotesVersion, |
| 291 | "0.0.0.0", |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 292 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | efb770c | 2012-05-04 22:31:48 | [diff] [blame] | 293 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 294 | registry->RegisterBooleanPref( |
| 295 | prefs::kExternalStorageDisabled, |
| 296 | false, |
| 297 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 298 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 299 | registry->RegisterStringPref( |
| 300 | prefs::kTermsOfServiceURL, |
| 301 | "", |
| 302 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | fddc44fe | 2013-07-04 00:03:51 | [diff] [blame] | 303 | |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 304 | registry->RegisterBooleanPref( |
| 305 | prefs::kTouchHudProjectionEnabled, |
| 306 | false, |
| 307 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 308 | } |
| 309 | |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 310 | void Preferences::InitUserPrefs(PrefServiceSyncable* prefs) { |
[email protected] | 155e1b4 | 2012-07-14 03:06:01 | [diff] [blame] | 311 | prefs_ = prefs; |
| 312 | |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 313 | BooleanPrefMember::NamedChangeCallback callback = |
| 314 | base::Bind(&Preferences::OnPreferenceChanged, base::Unretained(this)); |
| 315 | |
[email protected] | a1ea129 | 2013-08-07 23:50:40 | [diff] [blame] | 316 | performance_tracing_enabled_.Init(prefs::kPerformanceTracingEnabled, |
| 317 | prefs, callback); |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 318 | tap_to_click_enabled_.Init(prefs::kTapToClickEnabled, prefs, callback); |
| 319 | tap_dragging_enabled_.Init(prefs::kTapDraggingEnabled, prefs, callback); |
[email protected] | 190349fd | 2012-05-02 00:10:47 | [diff] [blame] | 320 | three_finger_click_enabled_.Init(prefs::kEnableTouchpadThreeFingerClick, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 321 | prefs, callback); |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 322 | natural_scroll_.Init(prefs::kNaturalScroll, prefs, callback); |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 323 | mouse_sensitivity_.Init(prefs::kMouseSensitivity, prefs, callback); |
| 324 | touchpad_sensitivity_.Init(prefs::kTouchpadSensitivity, prefs, callback); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 325 | primary_mouse_button_right_.Init(prefs::kPrimaryMouseButtonRight, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 326 | prefs, callback); |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 327 | download_default_directory_.Init(prefs::kDownloadDefaultDirectory, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 328 | prefs, callback); |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 329 | touch_hud_projection_enabled_.Init(prefs::kTouchHudProjectionEnabled, |
| 330 | prefs, callback); |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 331 | preload_engines_.Init(prefs::kLanguagePreloadEngines, prefs, callback); |
[email protected] | aef1af4b1 | 2013-05-09 04:50:23 | [diff] [blame] | 332 | enabled_extension_imes_.Init(prefs::kLanguageEnabledExtensionImes, |
| 333 | prefs, callback); |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 334 | current_input_method_.Init(prefs::kLanguageCurrentInputMethod, |
| 335 | prefs, callback); |
| 336 | previous_input_method_.Init(prefs::kLanguagePreviousInputMethod, |
| 337 | prefs, callback); |
[email protected] | 22bec1a | 2012-03-27 06:33:48 | [diff] [blame] | 338 | |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 339 | xkb_auto_repeat_enabled_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 340 | prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 341 | xkb_auto_repeat_delay_pref_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 342 | prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 343 | xkb_auto_repeat_interval_pref_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 344 | prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 345 | } |
| 346 | |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 347 | void Preferences::Init(PrefServiceSyncable* prefs, const User* user) { |
| 348 | DCHECK(user); |
| 349 | user_ = user; |
| 350 | user_is_primary_ = UserManager::Get()->GetPrimaryUser() == user_; |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 351 | InitUserPrefs(prefs); |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 352 | |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 353 | UserManager::Get()->AddSessionStateObserver(this); |
| 354 | |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 355 | // This causes OnIsSyncingChanged to be called when the value of |
| 356 | // PrefService::IsSyncing() changes. |
| 357 | prefs->AddObserver(this); |
| 358 | |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 359 | // Initialize preferences to currently saved state. |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 360 | ApplyPreferences(REASON_INITIALIZATION, ""); |
[email protected] | 26012e2 | 2010-12-01 06:44:27 | [diff] [blame] | 361 | |
| 362 | // If a guest is logged in, initialize the prefs as if this is the first |
| 363 | // login. |
| 364 | if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |
| 365 | LoginUtils::Get()->SetFirstLoginPrefs(prefs); |
| 366 | } |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 367 | } |
| 368 | |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 369 | void Preferences::InitUserPrefsForTesting(PrefServiceSyncable* prefs, |
| 370 | const User* user) { |
| 371 | user_ = user; |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 372 | InitUserPrefs(prefs); |
| 373 | } |
| 374 | |
| 375 | void Preferences::SetInputMethodListForTesting() { |
| 376 | SetInputMethodList(); |
| 377 | } |
| 378 | |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 379 | void Preferences::OnPreferenceChanged(const std::string& pref_name) { |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 380 | ApplyPreferences(REASON_PREF_CHANGED, pref_name); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 381 | } |
| 382 | |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 383 | void Preferences::ApplyPreferences(ApplyReason reason, |
| 384 | const std::string& pref_name) { |
| 385 | DCHECK(reason != REASON_PREF_CHANGED || !pref_name.empty()); |
| 386 | const bool user_is_owner = |
| 387 | UserManager::Get()->GetOwnerEmail() == user_->email(); |
| 388 | const bool user_is_active = user_->is_active(); |
| 389 | |
[email protected] | bd36e17 | 2014-02-14 19:49:57 | [diff] [blame] | 390 | system::TouchpadSettings touchpad_settings; |
| 391 | system::MouseSettings mouse_settings; |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 392 | |
| 393 | if (user_is_primary_ && (reason == REASON_INITIALIZATION || |
| 394 | pref_name == prefs::kPerformanceTracingEnabled)) { |
[email protected] | a1ea129 | 2013-08-07 23:50:40 | [diff] [blame] | 395 | const bool enabled = performance_tracing_enabled_.GetValue(); |
| 396 | if (enabled) |
| 397 | tracing_manager_ = TracingManager::Create(); |
| 398 | else |
| 399 | tracing_manager_.reset(); |
| 400 | } |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 401 | if (reason != REASON_PREF_CHANGED || pref_name == prefs::kTapToClickEnabled) { |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 402 | const bool enabled = tap_to_click_enabled_.GetValue(); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 403 | if (user_is_active) |
| 404 | touchpad_settings.SetTapToClick(enabled); |
| 405 | if (reason == REASON_PREF_CHANGED) |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 406 | UMA_HISTOGRAM_BOOLEAN("Touchpad.TapToClick.Changed", enabled); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 407 | else if (reason == REASON_INITIALIZATION) |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 408 | UMA_HISTOGRAM_BOOLEAN("Touchpad.TapToClick.Started", enabled); |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 409 | |
| 410 | // Save owner preference in local state to use on login screen. |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 411 | if (user_is_owner) { |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 412 | PrefService* prefs = g_browser_process->local_state(); |
| 413 | if (prefs->GetBoolean(prefs::kOwnerTapToClickEnabled) != enabled) |
| 414 | prefs->SetBoolean(prefs::kOwnerTapToClickEnabled, enabled); |
| 415 | } |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 416 | } |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 417 | if (reason != REASON_PREF_CHANGED || |
| 418 | pref_name == prefs::kTapDraggingEnabled) { |
[email protected] | 1b46af0 | 2012-10-31 05:23:54 | [diff] [blame] | 419 | const bool enabled = tap_dragging_enabled_.GetValue(); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 420 | if (user_is_active) |
| 421 | touchpad_settings.SetTapDragging(enabled); |
| 422 | if (reason == REASON_PREF_CHANGED) |
[email protected] | 1b46af0 | 2012-10-31 05:23:54 | [diff] [blame] | 423 | UMA_HISTOGRAM_BOOLEAN("Touchpad.TapDragging.Changed", enabled); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 424 | else if (reason == REASON_INITIALIZATION) |
[email protected] | 1b46af0 | 2012-10-31 05:23:54 | [diff] [blame] | 425 | UMA_HISTOGRAM_BOOLEAN("Touchpad.TapDragging.Started", enabled); |
| 426 | } |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 427 | if (reason != REASON_PREF_CHANGED || |
| 428 | pref_name == prefs::kEnableTouchpadThreeFingerClick) { |
[email protected] | 190349fd | 2012-05-02 00:10:47 | [diff] [blame] | 429 | const bool enabled = three_finger_click_enabled_.GetValue(); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 430 | if (user_is_active) |
| 431 | touchpad_settings.SetThreeFingerClick(enabled); |
| 432 | if (reason == REASON_PREF_CHANGED) |
[email protected] | 190349fd | 2012-05-02 00:10:47 | [diff] [blame] | 433 | UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerClick.Changed", enabled); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 434 | else if (reason == REASON_INITIALIZATION) |
[email protected] | 190349fd | 2012-05-02 00:10:47 | [diff] [blame] | 435 | UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerClick.Started", enabled); |
| 436 | } |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 437 | if (reason != REASON_PREF_CHANGED || pref_name == prefs::kNaturalScroll) { |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 438 | // Force natural scroll default if we've sync'd and if the cmd line arg is |
| 439 | // set. |
| 440 | ForceNaturalScrollDefault(); |
[email protected] | 223059e | 2012-10-05 01:44:49 | [diff] [blame] | 441 | |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 442 | const bool enabled = natural_scroll_.GetValue(); |
[email protected] | 223059e | 2012-10-05 01:44:49 | [diff] [blame] | 443 | DVLOG(1) << "Natural scroll set to " << enabled; |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 444 | if (user_is_active) |
| 445 | ui::SetNaturalScroll(enabled); |
| 446 | if (reason == REASON_PREF_CHANGED) |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 447 | UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Changed", enabled); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 448 | else if (reason == REASON_INITIALIZATION) |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 449 | UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Started", enabled); |
| 450 | } |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 451 | if (reason != REASON_PREF_CHANGED || pref_name == prefs::kMouseSensitivity) { |
[email protected] | 563fb5f | 2012-03-31 00:39:28 | [diff] [blame] | 452 | const int sensitivity = mouse_sensitivity_.GetValue(); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 453 | if (user_is_active) |
| 454 | mouse_settings.SetSensitivity(sensitivity); |
| 455 | if (reason == REASON_PREF_CHANGED) { |
[email protected] | 3a337d3 | 2013-07-02 05:14:24 | [diff] [blame] | 456 | UMA_HISTOGRAM_ENUMERATION("Mouse.PointerSensitivity.Changed", |
| 457 | sensitivity, |
| 458 | system::kMaxPointerSensitivity + 1); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 459 | } else if (reason == REASON_INITIALIZATION) { |
[email protected] | 3a337d3 | 2013-07-02 05:14:24 | [diff] [blame] | 460 | UMA_HISTOGRAM_ENUMERATION("Mouse.PointerSensitivity.Started", |
| 461 | sensitivity, |
| 462 | system::kMaxPointerSensitivity + 1); |
[email protected] | 563fb5f | 2012-03-31 00:39:28 | [diff] [blame] | 463 | } |
| 464 | } |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 465 | if (reason != REASON_PREF_CHANGED || |
| 466 | pref_name == prefs::kTouchpadSensitivity) { |
[email protected] | 563fb5f | 2012-03-31 00:39:28 | [diff] [blame] | 467 | const int sensitivity = touchpad_sensitivity_.GetValue(); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 468 | if (user_is_active) |
| 469 | touchpad_settings.SetSensitivity(sensitivity); |
| 470 | if (reason == REASON_PREF_CHANGED) { |
[email protected] | 3a337d3 | 2013-07-02 05:14:24 | [diff] [blame] | 471 | UMA_HISTOGRAM_ENUMERATION("Touchpad.PointerSensitivity.Changed", |
| 472 | sensitivity, |
| 473 | system::kMaxPointerSensitivity + 1); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 474 | } else if (reason == REASON_INITIALIZATION) { |
[email protected] | 3a337d3 | 2013-07-02 05:14:24 | [diff] [blame] | 475 | UMA_HISTOGRAM_ENUMERATION("Touchpad.PointerSensitivity.Started", |
| 476 | sensitivity, |
| 477 | system::kMaxPointerSensitivity + 1); |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 478 | } |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 479 | } |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 480 | if (reason != REASON_PREF_CHANGED || |
| 481 | pref_name == prefs::kPrimaryMouseButtonRight) { |
[email protected] | 0027fde1 | 2011-12-15 05:09:38 | [diff] [blame] | 482 | const bool right = primary_mouse_button_right_.GetValue(); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 483 | if (user_is_active) |
| 484 | mouse_settings.SetPrimaryButtonRight(right); |
| 485 | if (reason == REASON_PREF_CHANGED) |
[email protected] | 6c8599e | 2012-01-20 04:31:58 | [diff] [blame] | 486 | UMA_HISTOGRAM_BOOLEAN("Mouse.PrimaryButtonRight.Changed", right); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 487 | else if (reason == REASON_INITIALIZATION) |
[email protected] | 6c8599e | 2012-01-20 04:31:58 | [diff] [blame] | 488 | UMA_HISTOGRAM_BOOLEAN("Mouse.PrimaryButtonRight.Started", right); |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 489 | // Save owner preference in local state to use on login screen. |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 490 | if (user_is_owner) { |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 491 | PrefService* prefs = g_browser_process->local_state(); |
| 492 | if (prefs->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight) != right) |
| 493 | prefs->SetBoolean(prefs::kOwnerPrimaryMouseButtonRight, right); |
| 494 | } |
[email protected] | 0027fde1 | 2011-12-15 05:09:38 | [diff] [blame] | 495 | } |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 496 | if (reason != REASON_PREF_CHANGED || |
| 497 | pref_name == prefs::kDownloadDefaultDirectory) { |
[email protected] | d9d04df | 2012-10-12 07:06:35 | [diff] [blame] | 498 | const bool default_download_to_drive = drive::util::IsUnderDriveMountPoint( |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 499 | download_default_directory_.GetValue()); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 500 | if (reason == REASON_PREF_CHANGED) |
[email protected] | e8307a1 | 2012-09-12 20:06:34 | [diff] [blame] | 501 | UMA_HISTOGRAM_BOOLEAN( |
| 502 | "FileBrowser.DownloadDestination.IsGoogleDrive.Changed", |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 503 | default_download_to_drive); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 504 | else if (reason == REASON_INITIALIZATION) |
[email protected] | e8307a1 | 2012-09-12 20:06:34 | [diff] [blame] | 505 | UMA_HISTOGRAM_BOOLEAN( |
| 506 | "FileBrowser.DownloadDestination.IsGoogleDrive.Started", |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 507 | default_download_to_drive); |
| 508 | } |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 509 | if (reason != REASON_PREF_CHANGED || |
| 510 | pref_name == prefs::kTouchHudProjectionEnabled) { |
| 511 | if (user_is_active) { |
| 512 | const bool enabled = touch_hud_projection_enabled_.GetValue(); |
| 513 | ash::Shell::GetInstance()->SetTouchHudProjectionEnabled(enabled); |
| 514 | } |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 515 | } |
[email protected] | 8be9ff2 | 2010-06-08 02:13:54 | [diff] [blame] | 516 | |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 517 | if (reason != REASON_PREF_CHANGED || |
| 518 | pref_name == prefs::kLanguageXkbAutoRepeatEnabled) { |
| 519 | if (user_is_active) { |
| 520 | const bool enabled = xkb_auto_repeat_enabled_.GetValue(); |
| 521 | input_method::InputMethodManager::Get()->GetXKeyboard() |
| 522 | ->SetAutoRepeatEnabled(enabled); |
| 523 | } |
| 524 | } |
| 525 | if (reason != REASON_PREF_CHANGED || |
| 526 | pref_name == prefs::kLanguageXkbAutoRepeatDelay || |
| 527 | pref_name == prefs::kLanguageXkbAutoRepeatInterval) { |
| 528 | if (user_is_active) |
| 529 | UpdateAutoRepeatRate(); |
[email protected] | 74b42fc1 | 2010-07-20 10:15:41 | [diff] [blame] | 530 | } |
[email protected] | a6e9077 | 2011-02-09 05:38:54 | [diff] [blame] | 531 | |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 532 | if (reason != REASON_PREF_CHANGED && user_is_active) { |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 533 | SetInputMethodList(); |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 534 | } else if (pref_name == prefs::kLanguagePreloadEngines && user_is_active) { |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 535 | SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, |
| 536 | language_prefs::kPreloadEnginesConfigName, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 537 | preload_engines_.GetValue()); |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 538 | } |
[email protected] | 22bec1a | 2012-03-27 06:33:48 | [diff] [blame] | 539 | |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 540 | if (reason != REASON_PREF_CHANGED || |
| 541 | pref_name == prefs::kLanguageEnabledExtensionImes) { |
| 542 | if (user_is_active) { |
| 543 | std::string value(enabled_extension_imes_.GetValue()); |
[email protected] | 797c680 | 2012-09-20 10:36:13 | [diff] [blame] | 544 | |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 545 | std::vector<std::string> split_values; |
| 546 | if (!value.empty()) |
| 547 | base::SplitString(value, ',', &split_values); |
[email protected] | 797c680 | 2012-09-20 10:36:13 | [diff] [blame] | 548 | |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 549 | input_method_manager_->SetEnabledExtensionImes(&split_values); |
| 550 | } |
[email protected] | 797c680 | 2012-09-20 10:36:13 | [diff] [blame] | 551 | } |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 552 | |
| 553 | if (user_is_active) { |
| 554 | system::InputDeviceSettings::Get()->UpdateTouchpadSettings( |
| 555 | touchpad_settings); |
| 556 | system::InputDeviceSettings::Get()->UpdateMouseSettings(mouse_settings); |
| 557 | } |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 558 | } |
| 559 | |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 560 | void Preferences::OnIsSyncingChanged() { |
| 561 | DVLOG(1) << "OnIsSyncingChanged"; |
| 562 | ForceNaturalScrollDefault(); |
| 563 | } |
| 564 | |
| 565 | void Preferences::ForceNaturalScrollDefault() { |
| 566 | DVLOG(1) << "ForceNaturalScrollDefault"; |
[email protected] | bbd0826 | 2013-10-30 09:04:27 | [diff] [blame] | 567 | if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 568 | switches::kNaturalScrollDefault) && |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 569 | prefs_->IsSyncing() && |
| 570 | !prefs_->GetUserPrefValue(prefs::kNaturalScroll)) { |
| 571 | DVLOG(1) << "Natural scroll forced to true"; |
| 572 | natural_scroll_.SetValue(true); |
| 573 | UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Forced", true); |
| 574 | } |
| 575 | } |
| 576 | |
[email protected] | d01bb807 | 2010-04-12 13:00:15 | [diff] [blame] | 577 | void Preferences::SetLanguageConfigStringListAsCSV(const char* section, |
| 578 | const char* name, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 579 | const std::string& value) { |
[email protected] | e24c2c9 | 2010-10-23 01:39:24 | [diff] [blame] | 580 | VLOG(1) << "Setting " << name << " to '" << value << "'"; |
[email protected] | d01bb807 | 2010-04-12 13:00:15 | [diff] [blame] | 581 | |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 582 | std::vector<std::string> split_values; |
| 583 | if (!value.empty()) |
[email protected] | 76eb024 | 2010-10-14 00:35:36 | [diff] [blame] | 584 | base::SplitString(value, ',', &split_values); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 585 | |
[email protected] | fdcd441 | 2014-03-05 06:01:58 | [diff] [blame^] | 586 | // TODO(shuchen): migration of the xkb id to extension-xkb id. |
| 587 | // Remove this function after few milestones are passed. |
| 588 | // See: http://crbug.com/345604 |
| 589 | if (input_method_manager_->MigrateXkbInputMethods(&split_values)) |
| 590 | preload_engines_.SetValue(JoinString(split_values, ',')); |
| 591 | |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 592 | if (section == std::string(language_prefs::kGeneralSectionName) && |
| 593 | name == std::string(language_prefs::kPreloadEnginesConfigName)) { |
[email protected] | 39699140 | 2014-02-17 10:56:17 | [diff] [blame] | 594 | input_method_manager_->ReplaceEnabledInputMethods(split_values); |
[email protected] | dbc9b19 | 2012-04-18 05:55:34 | [diff] [blame] | 595 | return; |
| 596 | } |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 597 | } |
| 598 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 599 | void Preferences::SetInputMethodList() { |
| 600 | // When |preload_engines_| are set, InputMethodManager::ChangeInputMethod() |
| 601 | // might be called to change the current input method to the first one in the |
| 602 | // |preload_engines_| list. This also updates previous/current input method |
| 603 | // prefs. That's why GetValue() calls are placed before the |
| 604 | // SetLanguageConfigStringListAsCSV() call below. |
| 605 | const std::string previous_input_method_id = |
| 606 | previous_input_method_.GetValue(); |
| 607 | const std::string current_input_method_id = current_input_method_.GetValue(); |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 608 | SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, |
| 609 | language_prefs::kPreloadEnginesConfigName, |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 610 | preload_engines_.GetValue()); |
| 611 | |
| 612 | // ChangeInputMethod() has to be called AFTER the value of |preload_engines_| |
| 613 | // is sent to the InputMethodManager. Otherwise, the ChangeInputMethod request |
| 614 | // might be ignored as an invalid input method ID. The ChangeInputMethod() |
| 615 | // calls are also necessary to restore the previous/current input method prefs |
| 616 | // which could have been modified by the SetLanguageConfigStringListAsCSV call |
| 617 | // above to the original state. |
| 618 | if (!previous_input_method_id.empty()) |
| 619 | input_method_manager_->ChangeInputMethod(previous_input_method_id); |
| 620 | if (!current_input_method_id.empty()) |
| 621 | input_method_manager_->ChangeInputMethod(current_input_method_id); |
| 622 | } |
| 623 | |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 624 | void Preferences::UpdateAutoRepeatRate() { |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 625 | input_method::AutoRepeatRate rate; |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 626 | rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); |
| 627 | rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 628 | DCHECK(rate.initial_delay_in_ms > 0); |
| 629 | DCHECK(rate.repeat_interval_in_ms > 0); |
[email protected] | b4d95fb | 2014-02-12 14:48:07 | [diff] [blame] | 630 | input_method::InputMethodManager::Get()->GetXKeyboard() |
| 631 | ->SetAutoRepeatRate(rate); |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 632 | } |
| 633 | |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 634 | void Preferences::OnTouchHudProjectionToggled(bool enabled) { |
| 635 | if (touch_hud_projection_enabled_.GetValue() == enabled) |
| 636 | return; |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 637 | if (!user_->is_active()) |
| 638 | return; |
[email protected] | d141b92 | 2013-07-09 08:13:17 | [diff] [blame] | 639 | touch_hud_projection_enabled_.SetValue(enabled); |
| 640 | } |
| 641 | |
[email protected] | aa003a5 | 2014-02-15 06:24:23 | [diff] [blame] | 642 | void Preferences::ActiveUserChanged(const User* active_user) { |
| 643 | if (active_user != user_) |
| 644 | return; |
| 645 | ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); |
| 646 | } |
| 647 | |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 648 | } // namespace chromeos |