[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] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 7 | #include "ash/magnifier/magnifier_constants.h" |
[email protected] | 1dfebfc | 2013-06-04 03:14:32 | [diff] [blame] | 8 | #include "ash/shell_delegate.h" |
[email protected] | 20d2a79d | 2012-03-16 23:01:02 | [diff] [blame] | 9 | #include "base/chromeos/chromeos_version.h" |
[email protected] | 775caec | 2011-09-01 17:14:32 | [diff] [blame] | 10 | #include "base/command_line.h" |
[email protected] | 530cd62 | 2011-04-14 15:45:00 | [diff] [blame] | 11 | #include "base/i18n/time_formatting.h" |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 12 | #include "base/metrics/histogram.h" |
[email protected] | 1ab137b | 2013-03-21 03:33:18 | [diff] [blame] | 13 | #include "base/prefs/pref_member.h" |
[email protected] | 681958c | 2013-02-21 13:48:14 | [diff] [blame] | 14 | #include "base/prefs/pref_registry_simple.h" |
[email protected] | 1988e1c | 2013-02-28 20:27:42 | [diff] [blame] | 15 | #include "base/strings/string_split.h" |
[email protected] | 5c07332 | 2013-06-11 08:03:30 | [diff] [blame] | 16 | #include "base/strings/string_util.h" |
[email protected] | 135cb80 | 2013-06-09 16:44:20 | [diff] [blame] | 17 | #include "base/strings/utf_string_conversions.h" |
[email protected] | c0a2128d9 | 2011-07-20 15:04:46 | [diff] [blame] | 18 | #include "chrome/browser/browser_process.h" |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 19 | #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
[email protected] | 4fa2fd5d | 2013-04-26 03:42:52 | [diff] [blame] | 20 | #include "chrome/browser/chromeos/drive/file_system_util.h" |
[email protected] | 9199bd5 | 2010-07-01 05:04:41 | [diff] [blame] | 21 | #include "chrome/browser/chromeos/input_method/input_method_util.h" |
[email protected] | 26012e2 | 2010-12-01 06:44:27 | [diff] [blame] | 22 | #include "chrome/browser/chromeos/login/login_utils.h" |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 23 | #include "chrome/browser/chromeos/login/user_manager.h" |
[email protected] | 82eb8ec | 2011-12-20 22:24:33 | [diff] [blame] | 24 | #include "chrome/browser/chromeos/system/input_device_settings.h" |
[email protected] | de1528d1a | 2012-05-14 10:36:15 | [diff] [blame] | 25 | #include "chrome/browser/chromeos/system/statistics_provider.h" |
[email protected] | 155e1b4 | 2012-07-14 03:06:01 | [diff] [blame] | 26 | #include "chrome/browser/download/download_util.h" |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 27 | #include "chrome/browser/prefs/pref_service_syncable.h" |
[email protected] | b336257 | 2011-08-17 09:28:50 | [diff] [blame] | 28 | #include "chrome/browser/prefs/scoped_user_pref_update.h" |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 29 | #include "chrome/common/chrome_notification_types.h" |
[email protected] | 775caec | 2011-09-01 17:14:32 | [diff] [blame] | 30 | #include "chrome/common/chrome_switches.h" |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 31 | #include "chrome/common/pref_names.h" |
[email protected] | 931d104 | 2013-04-05 17:50:44 | [diff] [blame] | 32 | #include "chromeos/chromeos_switches.h" |
[email protected] | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 33 | #include "chromeos/dbus/dbus_thread_manager.h" |
| 34 | #include "chromeos/dbus/power_policy_controller.h" |
[email protected] | 60049c0 | 2013-04-26 07:52:36 | [diff] [blame] | 35 | #include "chromeos/ime/input_method_manager.h" |
[email protected] | da5cb80 | 2013-03-30 18:58:16 | [diff] [blame] | 36 | #include "chromeos/ime/xkeyboard.h" |
[email protected] | 75fee37 | 2013-03-06 00:42:44 | [diff] [blame] | 37 | #include "components/user_prefs/pref_registry_syncable.h" |
[email protected] | c297d3a | 2013-01-07 22:33:47 | [diff] [blame] | 38 | #include "third_party/icu/public/i18n/unicode/timezone.h" |
[email protected] | 153472d7 | 2012-09-04 21:33:02 | [diff] [blame] | 39 | #include "ui/base/events/event_constants.h" |
[email protected] | e4cc483 | 2012-11-05 17:33:14 | [diff] [blame] | 40 | #include "ui/base/events/event_utils.h" |
[email protected] | a6483d2 | 2013-07-03 22:11:00 | [diff] [blame] | 41 | #include "url/gurl.h" |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 42 | |
[email protected] | de1528d1a | 2012-05-14 10:36:15 | [diff] [blame] | 43 | namespace chromeos { |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 44 | |
[email protected] | 9199bd5 | 2010-07-01 05:04:41 | [diff] [blame] | 45 | static const char kFallbackInputMethodLocale[] = "en-US"; |
[email protected] | 4793c94 | 2010-09-21 23:17:17 | [diff] [blame] | 46 | |
[email protected] | fddc44fe | 2013-07-04 00:03:51 | [diff] [blame] | 47 | // TODO(achuith): Remove deprecated pref in M31. crbug.com/223480. |
| 48 | static const char kEnableTouchpadThreeFingerSwipe[] = |
| 49 | "settings.touchpad.enable_three_finger_swipe"; |
| 50 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 51 | Preferences::Preferences() |
[email protected] | 155e1b4 | 2012-07-14 03:06:01 | [diff] [blame] | 52 | : prefs_(NULL), |
[email protected] | a2d5f5b | 2013-05-14 21:57:01 | [diff] [blame] | 53 | input_method_manager_(input_method::InputMethodManager::Get()) { |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | Preferences::Preferences(input_method::InputMethodManager* input_method_manager) |
[email protected] | eb5624e | 2013-05-23 19:50:27 | [diff] [blame] | 57 | : prefs_(NULL), |
| 58 | input_method_manager_(input_method_manager) { |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 59 | } |
[email protected] | d743a598 | 2010-11-08 17:54:09 | [diff] [blame] | 60 | |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 61 | Preferences::~Preferences() { |
| 62 | prefs_->RemoveObserver(this); |
| 63 | } |
[email protected] | 9199bd5 | 2010-07-01 05:04:41 | [diff] [blame] | 64 | |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 65 | // static |
[email protected] | 681958c | 2013-02-21 13:48:14 | [diff] [blame] | 66 | void Preferences::RegisterPrefs(PrefRegistrySimple* registry) { |
[email protected] | 681958c | 2013-02-21 13:48:14 | [diff] [blame] | 67 | registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false); |
| 68 | registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true); |
[email protected] | 681958c | 2013-02-21 13:48:14 | [diff] [blame] | 69 | registry->RegisterBooleanPref(prefs::kVirtualKeyboardEnabled, false); |
| 70 | } |
| 71 | |
| 72 | // static |
[email protected] | 37ca3fe0 | 2013-07-05 15:32:44 | [diff] [blame^] | 73 | void Preferences::RegisterProfilePrefs( |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 74 | user_prefs::PrefRegistrySyncable* registry) { |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 75 | std::string hardware_keyboard_id; |
| 76 | // TODO(yusukes): Remove the runtime hack. |
| 77 | if (base::chromeos::IsRunningOnChromeOS()) { |
| 78 | input_method::InputMethodManager* manager = |
[email protected] | a2d5f5b | 2013-05-14 21:57:01 | [diff] [blame] | 79 | input_method::InputMethodManager::Get(); |
[email protected] | 1e019ea | 2012-08-09 00:54:04 | [diff] [blame] | 80 | if (manager) { |
| 81 | hardware_keyboard_id = |
| 82 | manager->GetInputMethodUtil()->GetHardwareInputMethodId(); |
| 83 | } |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 84 | } else { |
| 85 | hardware_keyboard_id = "xkb:us::eng"; // only for testing. |
| 86 | } |
[email protected] | a9a8181 | 2011-09-16 11:01:17 | [diff] [blame] | 87 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 88 | registry->RegisterBooleanPref( |
| 89 | prefs::kTapToClickEnabled, |
| 90 | true, |
| 91 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 92 | registry->RegisterBooleanPref( |
| 93 | prefs::kTapDraggingEnabled, |
| 94 | false, |
| 95 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 96 | registry->RegisterBooleanPref( |
| 97 | prefs::kEnableTouchpadThreeFingerClick, |
| 98 | false, |
| 99 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 100 | registry->RegisterBooleanPref( |
[email protected] | 6100873 | 2012-11-27 10:36:05 | [diff] [blame] | 101 | prefs::kNaturalScroll, |
| 102 | CommandLine::ForCurrentProcess()->HasSwitch( |
[email protected] | 2f2d6c3 | 2013-05-10 02:56:24 | [diff] [blame] | 103 | switches::kNaturalScrollDefault), |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 104 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 105 | registry->RegisterBooleanPref( |
| 106 | prefs::kPrimaryMouseButtonRight, |
| 107 | false, |
| 108 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 109 | registry->RegisterBooleanPref( |
| 110 | prefs::kLabsMediaplayerEnabled, |
| 111 | false, |
| 112 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 113 | registry->RegisterBooleanPref( |
| 114 | prefs::kLabsAdvancedFilesystemEnabled, |
| 115 | false, |
| 116 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 117 | registry->RegisterBooleanPref( |
[email protected] | 3206f5f | 2013-06-12 18:13:06 | [diff] [blame] | 118 | prefs::kStickyKeysEnabled, |
| 119 | false, |
| 120 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 121 | registry->RegisterBooleanPref( |
[email protected] | 8126b81 | 2013-06-06 03:49:17 | [diff] [blame] | 122 | prefs::kLargeCursorEnabled, |
| 123 | false, |
| 124 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 125 | registry->RegisterBooleanPref( |
[email protected] | 1dfebfc | 2013-06-04 03:14:32 | [diff] [blame] | 126 | prefs::kSpokenFeedbackEnabled, |
| 127 | false, |
| 128 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 129 | registry->RegisterBooleanPref( |
| 130 | prefs::kHighContrastEnabled, |
| 131 | false, |
| 132 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 133 | registry->RegisterBooleanPref( |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 134 | prefs::kScreenMagnifierEnabled, |
| 135 | false, |
| 136 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 137 | registry->RegisterIntegerPref( |
| 138 | prefs::kScreenMagnifierType, |
| 139 | ash::kDefaultMagnifierType, |
| 140 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 141 | registry->RegisterDoublePref( |
| 142 | prefs::kScreenMagnifierScale, |
| 143 | std::numeric_limits<double>::min(), |
| 144 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 145 | registry->RegisterBooleanPref( |
| 146 | prefs::kShouldAlwaysShowAccessibilityMenu, |
| 147 | false, |
[email protected] | 1dfebfc | 2013-06-04 03:14:32 | [diff] [blame] | 148 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 149 | registry->RegisterIntegerPref( |
| 150 | prefs::kMouseSensitivity, |
| 151 | 3, |
| 152 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 153 | registry->RegisterIntegerPref( |
| 154 | prefs::kTouchpadSensitivity, |
| 155 | 3, |
| 156 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 157 | registry->RegisterBooleanPref( |
| 158 | prefs::kUse24HourClock, |
| 159 | base::GetHourClockType() == base::k24HourClock, |
| 160 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 161 | registry->RegisterBooleanPref( |
| 162 | prefs::kDisableDrive, |
| 163 | false, |
| 164 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 165 | registry->RegisterBooleanPref( |
| 166 | prefs::kDisableDriveOverCellular, |
| 167 | true, |
| 168 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 169 | registry->RegisterBooleanPref( |
| 170 | prefs::kDisableDriveHostedFiles, |
| 171 | false, |
| 172 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 173 | // We don't sync prefs::kLanguageCurrentInputMethod and PreviousInputMethod |
| 174 | // because they're just used to track the logout state of the device. |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 175 | registry->RegisterStringPref( |
| 176 | prefs::kLanguageCurrentInputMethod, |
| 177 | "", |
| 178 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 179 | registry->RegisterStringPref( |
| 180 | prefs::kLanguagePreviousInputMethod, |
| 181 | "", |
| 182 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 183 | // We don't sync the list of input methods and preferred languages since a |
| 184 | // user might use two or more devices with different hardware keyboards. |
| 185 | // crosbug.com/15181 |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 186 | registry->RegisterStringPref( |
| 187 | prefs::kLanguagePreferredLanguages, |
| 188 | kFallbackInputMethodLocale, |
| 189 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 190 | registry->RegisterStringPref( |
| 191 | prefs::kLanguagePreloadEngines, |
| 192 | hardware_keyboard_id, |
| 193 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 194 | registry->RegisterStringPref( |
[email protected] | aef1af4b1 | 2013-05-09 04:50:23 | [diff] [blame] | 195 | prefs::kLanguageEnabledExtensionImes, |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 196 | "", |
| 197 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 198 | for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 199 | registry->RegisterBooleanPref( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 200 | language_prefs::kChewingBooleanPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 201 | language_prefs::kChewingBooleanPrefs[i].default_pref_value, |
[email protected] | da9858f | 2012-04-09 14:50:03 | [diff] [blame] | 202 | language_prefs::kChewingBooleanPrefs[i].sync_status); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 203 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 204 | for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 205 | registry->RegisterStringPref( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 206 | language_prefs::kChewingMultipleChoicePrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 207 | language_prefs::kChewingMultipleChoicePrefs[i].default_pref_value, |
[email protected] | da9858f | 2012-04-09 14:50:03 | [diff] [blame] | 208 | language_prefs::kChewingMultipleChoicePrefs[i].sync_status); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 209 | } |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 210 | registry->RegisterIntegerPref( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 211 | language_prefs::kChewingHsuSelKeyType.pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 212 | language_prefs::kChewingHsuSelKeyType.default_pref_value, |
[email protected] | da9858f | 2012-04-09 14:50:03 | [diff] [blame] | 213 | language_prefs::kChewingHsuSelKeyType.sync_status); |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 214 | |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 215 | for (size_t i = 0; i < language_prefs::kNumChewingIntegerPrefs; ++i) { |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 216 | registry->RegisterIntegerPref( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 217 | language_prefs::kChewingIntegerPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 218 | language_prefs::kChewingIntegerPrefs[i].default_pref_value, |
[email protected] | da9858f | 2012-04-09 14:50:03 | [diff] [blame] | 219 | language_prefs::kChewingIntegerPrefs[i].sync_status); |
[email protected] | 15c5308 | 2010-06-03 03:28:21 | [diff] [blame] | 220 | } |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 221 | registry->RegisterStringPref( |
[email protected] | 20ce516d | 2010-06-18 02:20:04 | [diff] [blame] | 222 | prefs::kLanguageHangulKeyboard, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 223 | language_prefs::kHangulKeyboardNameIDPairs[0].keyboard_id, |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 224 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 225 | registry->RegisterStringPref( |
| 226 | prefs::kLanguageHangulHanjaBindingKeys, |
| 227 | language_prefs::kHangulHanjaBindingKeys, |
| 228 | // Don't sync the pref as it's not user-configurable |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 229 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 230 | for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 231 | registry->RegisterBooleanPref( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 232 | language_prefs::kPinyinBooleanPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 233 | language_prefs::kPinyinBooleanPrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 234 | language_prefs::kPinyinBooleanPrefs[i].sync_status); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 235 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 236 | for (size_t i = 0; i < language_prefs::kNumPinyinIntegerPrefs; ++i) { |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 237 | registry->RegisterIntegerPref( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 238 | language_prefs::kPinyinIntegerPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 239 | language_prefs::kPinyinIntegerPrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 240 | language_prefs::kPinyinIntegerPrefs[i].sync_status); |
[email protected] | 6e5c4b8 | 2010-05-24 08:18:44 | [diff] [blame] | 241 | } |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 242 | registry->RegisterIntegerPref( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 243 | language_prefs::kPinyinDoublePinyinSchema.pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 244 | language_prefs::kPinyinDoublePinyinSchema.default_pref_value, |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 245 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 246 | |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 247 | for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 248 | registry->RegisterBooleanPref( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 249 | language_prefs::kMozcBooleanPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 250 | language_prefs::kMozcBooleanPrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 251 | language_prefs::kMozcBooleanPrefs[i].sync_status); |
[email protected] | 8a1ace2 | 2010-06-10 05:38:25 | [diff] [blame] | 252 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 253 | for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 254 | registry->RegisterStringPref( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 255 | language_prefs::kMozcMultipleChoicePrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 256 | language_prefs::kMozcMultipleChoicePrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 257 | language_prefs::kMozcMultipleChoicePrefs[i].sync_status); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 258 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 259 | for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 260 | registry->RegisterIntegerPref( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 261 | language_prefs::kMozcIntegerPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 262 | language_prefs::kMozcIntegerPrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 263 | language_prefs::kMozcIntegerPrefs[i].sync_status); |
[email protected] | 5403746 | 2010-06-22 02:06:23 | [diff] [blame] | 264 | } |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 265 | registry->RegisterIntegerPref( |
| 266 | prefs::kLanguageRemapSearchKeyTo, |
| 267 | input_method::kSearchKey, |
| 268 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 269 | registry->RegisterIntegerPref( |
| 270 | prefs::kLanguageRemapControlKeyTo, |
| 271 | input_method::kControlKey, |
| 272 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 273 | registry->RegisterIntegerPref( |
| 274 | prefs::kLanguageRemapAltKeyTo, |
| 275 | input_method::kAltKey, |
| 276 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | 0f424fd9 | 2013-05-08 21:12:19 | [diff] [blame] | 277 | // We don't sync the CapsLock remapping pref, since the UI hides this pref |
| 278 | // on certain devices, so syncing a non-default value to a device that |
| 279 | // doesn't allow changing the pref would be odd. http://crbug.com/167237 |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 280 | registry->RegisterIntegerPref( |
| 281 | prefs::kLanguageRemapCapsLockKeyTo, |
| 282 | input_method::kCapsLockKey, |
[email protected] | 0f424fd9 | 2013-05-08 21:12:19 | [diff] [blame] | 283 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 284 | registry->RegisterIntegerPref( |
| 285 | prefs::kLanguageRemapDiamondKeyTo, |
| 286 | input_method::kControlKey, |
| 287 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 288 | // We don't sync the following keyboard prefs since they are not user- |
| 289 | // configurable. |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 290 | registry->RegisterBooleanPref( |
| 291 | prefs::kLanguageXkbAutoRepeatEnabled, |
| 292 | true, |
| 293 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 294 | registry->RegisterIntegerPref( |
| 295 | prefs::kLanguageXkbAutoRepeatDelay, |
| 296 | language_prefs::kXkbAutoRepeatDelayInMs, |
| 297 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 298 | registry->RegisterIntegerPref( |
| 299 | prefs::kLanguageXkbAutoRepeatInterval, |
| 300 | language_prefs::kXkbAutoRepeatIntervalInMs, |
| 301 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 302 | |
| 303 | // Screen lock default to off. |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 304 | registry->RegisterBooleanPref( |
| 305 | prefs::kEnableScreenLock, |
| 306 | false, |
| 307 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | ea1eba5 | 2010-11-23 18:05:38 | [diff] [blame] | 308 | |
| 309 | // Mobile plan notifications default to on. |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 310 | registry->RegisterBooleanPref( |
| 311 | prefs::kShowPlanNotifications, |
| 312 | true, |
| 313 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | c74fffa | 2011-04-27 13:32:24 | [diff] [blame] | 314 | |
| 315 | // 3G first-time usage promo will be shown at least once. |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 316 | registry->RegisterBooleanPref( |
| 317 | prefs::kShow3gPromoNotification, |
| 318 | true, |
| 319 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | d6ae950 | 2011-05-05 18:23:09 | [diff] [blame] | 320 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 321 | // Initially all existing users would see "What's new" for current version |
| 322 | // after update. |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 323 | registry->RegisterStringPref(prefs::kChromeOSReleaseNotesVersion, |
| 324 | "0.0.0.0", |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 325 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
[email protected] | efb770c | 2012-05-04 22:31:48 | [diff] [blame] | 326 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 327 | registry->RegisterBooleanPref( |
| 328 | prefs::kExternalStorageDisabled, |
| 329 | false, |
| 330 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 331 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 332 | registry->RegisterIntegerPref( |
| 333 | prefs::kPowerAcScreenDimDelayMs, |
| 334 | 420000, |
| 335 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 336 | registry->RegisterIntegerPref( |
| 337 | prefs::kPowerAcScreenOffDelayMs, |
| 338 | 480000, |
| 339 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 340 | registry->RegisterIntegerPref( |
| 341 | prefs::kPowerAcScreenLockDelayMs, |
| 342 | 0, |
| 343 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 344 | registry->RegisterIntegerPref( |
| 345 | prefs::kPowerAcIdleWarningDelayMs, |
| 346 | 0, |
| 347 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 348 | registry->RegisterIntegerPref( |
| 349 | prefs::kPowerAcIdleDelayMs, |
| 350 | 1800000, |
| 351 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 352 | registry->RegisterIntegerPref( |
| 353 | prefs::kPowerBatteryScreenDimDelayMs, |
| 354 | 300000, |
| 355 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 356 | registry->RegisterIntegerPref( |
| 357 | prefs::kPowerBatteryScreenOffDelayMs, |
| 358 | 360000, |
| 359 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 360 | registry->RegisterIntegerPref( |
| 361 | prefs::kPowerBatteryScreenLockDelayMs, |
| 362 | 0, |
| 363 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 364 | registry->RegisterIntegerPref( |
| 365 | prefs::kPowerBatteryIdleWarningDelayMs, |
| 366 | 0, |
| 367 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 368 | registry->RegisterIntegerPref( |
| 369 | prefs::kPowerBatteryIdleDelayMs, |
| 370 | 600000, |
| 371 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 372 | registry->RegisterIntegerPref( |
[email protected] | 1c37204 | 2013-06-29 01:47:20 | [diff] [blame] | 373 | prefs::kPowerAcIdleAction, |
| 374 | PowerPolicyController::ACTION_SUSPEND, |
| 375 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 376 | registry->RegisterIntegerPref( |
| 377 | prefs::kPowerBatteryIdleAction, |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 378 | PowerPolicyController::ACTION_SUSPEND, |
| 379 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 380 | registry->RegisterIntegerPref( |
| 381 | prefs::kPowerLidClosedAction, |
| 382 | PowerPolicyController::ACTION_SUSPEND, |
| 383 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 384 | registry->RegisterBooleanPref( |
| 385 | prefs::kPowerUseAudioActivity, |
| 386 | true, |
| 387 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 388 | registry->RegisterBooleanPref( |
| 389 | prefs::kPowerUseVideoActivity, |
| 390 | true, |
| 391 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 392 | registry->RegisterBooleanPref( |
| 393 | prefs::kPowerAllowScreenWakeLocks, |
| 394 | true, |
| 395 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 396 | registry->RegisterDoublePref( |
[email protected] | 8101d02 | 2013-06-12 19:56:28 | [diff] [blame] | 397 | prefs::kPowerPresentationScreenDimDelayFactor, |
| 398 | 2.0, |
| 399 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 400 | registry->RegisterDoublePref( |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 401 | prefs::kPowerUserActivityScreenDimDelayFactor, |
[email protected] | fdd7928a | 2013-06-12 16:25:13 | [diff] [blame] | 402 | 2.0, |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 403 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | 73bd1db1 | 2013-02-10 21:51:00 | [diff] [blame] | 404 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 405 | registry->RegisterStringPref( |
| 406 | prefs::kTermsOfServiceURL, |
| 407 | "", |
| 408 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | fddc44fe | 2013-07-04 00:03:51 | [diff] [blame] | 409 | |
| 410 | // TODO(achuith): Remove deprecated pref in M31. crbug.com/223480. |
| 411 | registry->RegisterBooleanPref( |
| 412 | kEnableTouchpadThreeFingerSwipe, |
| 413 | false, |
| 414 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 415 | } |
| 416 | |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 417 | void Preferences::InitUserPrefs(PrefServiceSyncable* prefs) { |
[email protected] | 155e1b4 | 2012-07-14 03:06:01 | [diff] [blame] | 418 | prefs_ = prefs; |
| 419 | |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 420 | BooleanPrefMember::NamedChangeCallback callback = |
| 421 | base::Bind(&Preferences::OnPreferenceChanged, base::Unretained(this)); |
| 422 | |
| 423 | tap_to_click_enabled_.Init(prefs::kTapToClickEnabled, prefs, callback); |
| 424 | tap_dragging_enabled_.Init(prefs::kTapDraggingEnabled, prefs, callback); |
[email protected] | 190349fd | 2012-05-02 00:10:47 | [diff] [blame] | 425 | three_finger_click_enabled_.Init(prefs::kEnableTouchpadThreeFingerClick, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 426 | prefs, callback); |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 427 | natural_scroll_.Init(prefs::kNaturalScroll, prefs, callback); |
[email protected] | 1dfebfc | 2013-06-04 03:14:32 | [diff] [blame] | 428 | a11y_spoken_feedback_enabled_.Init(prefs::kSpokenFeedbackEnabled, |
| 429 | prefs, callback); |
| 430 | a11y_high_contrast_enabled_.Init(prefs::kHighContrastEnabled, |
| 431 | prefs, callback); |
| 432 | a11y_screen_magnifier_enabled_.Init(prefs::kScreenMagnifierEnabled, |
| 433 | prefs, callback); |
| 434 | a11y_screen_magnifier_type_.Init(prefs::kScreenMagnifierType, |
| 435 | prefs, callback); |
| 436 | a11y_screen_magnifier_scale_.Init(prefs::kScreenMagnifierScale, |
| 437 | prefs, callback); |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 438 | mouse_sensitivity_.Init(prefs::kMouseSensitivity, prefs, callback); |
| 439 | touchpad_sensitivity_.Init(prefs::kTouchpadSensitivity, prefs, callback); |
| 440 | use_24hour_clock_.Init(prefs::kUse24HourClock, prefs, callback); |
| 441 | disable_drive_.Init(prefs::kDisableDrive, prefs, callback); |
[email protected] | e1619ee0 | 2012-10-22 08:14:49 | [diff] [blame] | 442 | disable_drive_over_cellular_.Init(prefs::kDisableDriveOverCellular, |
[email protected] | 7585f4c | 2013-01-10 18:26:41 | [diff] [blame] | 443 | prefs, callback); |
[email protected] | e1619ee0 | 2012-10-22 08:14:49 | [diff] [blame] | 444 | disable_drive_hosted_files_.Init(prefs::kDisableDriveHostedFiles, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 445 | prefs, callback); |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 446 | download_default_directory_.Init(prefs::kDownloadDefaultDirectory, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 447 | prefs, callback); |
[email protected] | 1746ac92 | 2013-04-10 04:53:24 | [diff] [blame] | 448 | select_file_last_directory_.Init(prefs::kSelectFileLastDirectory, |
| 449 | prefs, callback); |
[email protected] | 57229d1 | 2013-04-18 07:13:15 | [diff] [blame] | 450 | save_file_default_directory_.Init(prefs::kSaveFileDefaultDirectory, |
| 451 | prefs, callback); |
[email protected] | 0027fde1 | 2011-12-15 05:09:38 | [diff] [blame] | 452 | primary_mouse_button_right_.Init(prefs::kPrimaryMouseButtonRight, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 453 | prefs, callback); |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 454 | preferred_languages_.Init(prefs::kLanguagePreferredLanguages, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 455 | prefs, callback); |
| 456 | preload_engines_.Init(prefs::kLanguagePreloadEngines, prefs, callback); |
[email protected] | aef1af4b1 | 2013-05-09 04:50:23 | [diff] [blame] | 457 | enabled_extension_imes_.Init(prefs::kLanguageEnabledExtensionImes, |
| 458 | prefs, callback); |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 459 | current_input_method_.Init(prefs::kLanguageCurrentInputMethod, |
| 460 | prefs, callback); |
| 461 | previous_input_method_.Init(prefs::kLanguagePreviousInputMethod, |
| 462 | prefs, callback); |
[email protected] | 22bec1a | 2012-03-27 06:33:48 | [diff] [blame] | 463 | |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 464 | for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 465 | chewing_boolean_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 466 | language_prefs::kChewingBooleanPrefs[i].pref_name, prefs, callback); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 467 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 468 | for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 469 | chewing_multiple_choice_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 470 | language_prefs::kChewingMultipleChoicePrefs[i].pref_name, |
| 471 | prefs, callback); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 472 | } |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 473 | chewing_hsu_sel_key_type_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 474 | language_prefs::kChewingHsuSelKeyType.pref_name, prefs, callback); |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 475 | for (size_t i = 0; i < language_prefs::kNumChewingIntegerPrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 476 | chewing_integer_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 477 | language_prefs::kChewingIntegerPrefs[i].pref_name, prefs, callback); |
[email protected] | 15c5308 | 2010-06-03 03:28:21 | [diff] [blame] | 478 | } |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 479 | hangul_keyboard_.Init(prefs::kLanguageHangulKeyboard, prefs, callback); |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 480 | hangul_hanja_binding_keys_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 481 | prefs::kLanguageHangulHanjaBindingKeys, prefs, callback); |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 482 | for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 483 | pinyin_boolean_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 484 | language_prefs::kPinyinBooleanPrefs[i].pref_name, prefs, callback); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 485 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 486 | for (size_t i = 0; i < language_prefs::kNumPinyinIntegerPrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 487 | pinyin_int_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 488 | language_prefs::kPinyinIntegerPrefs[i].pref_name, prefs, callback); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 489 | } |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 490 | pinyin_double_pinyin_schema_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 491 | language_prefs::kPinyinDoublePinyinSchema.pref_name, prefs, callback); |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 492 | for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 493 | mozc_boolean_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 494 | language_prefs::kMozcBooleanPrefs[i].pref_name, prefs, callback); |
[email protected] | 8a1ace2 | 2010-06-10 05:38:25 | [diff] [blame] | 495 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 496 | for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 497 | mozc_multiple_choice_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 498 | language_prefs::kMozcMultipleChoicePrefs[i].pref_name, prefs, callback); |
[email protected] | 6e5c4b8 | 2010-05-24 08:18:44 | [diff] [blame] | 499 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 500 | for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 501 | mozc_integer_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 502 | language_prefs::kMozcIntegerPrefs[i].pref_name, prefs, callback); |
[email protected] | 5403746 | 2010-06-22 02:06:23 | [diff] [blame] | 503 | } |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 504 | xkb_auto_repeat_enabled_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 505 | prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 506 | xkb_auto_repeat_delay_pref_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 507 | prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 508 | xkb_auto_repeat_interval_pref_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 509 | prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 510 | |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 511 | enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, callback); |
[email protected] | 595a5ed | 2012-05-04 00:39:16 | [diff] [blame] | 512 | |
[email protected] | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 513 | power_ac_screen_dim_delay_ms_.Init( |
| 514 | prefs::kPowerAcScreenDimDelayMs, prefs, callback); |
| 515 | power_ac_screen_off_delay_ms_.Init( |
| 516 | prefs::kPowerAcScreenOffDelayMs, prefs, callback); |
| 517 | power_ac_screen_lock_delay_ms_.Init( |
| 518 | prefs::kPowerAcScreenLockDelayMs, prefs, callback); |
[email protected] | c9b340b | 2013-03-20 21:01:13 | [diff] [blame] | 519 | power_ac_idle_warning_delay_ms_.Init( |
| 520 | prefs::kPowerAcIdleWarningDelayMs, prefs, callback); |
[email protected] | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 521 | power_ac_idle_delay_ms_.Init(prefs::kPowerAcIdleDelayMs, prefs, callback); |
| 522 | power_battery_screen_dim_delay_ms_.Init( |
| 523 | prefs::kPowerBatteryScreenDimDelayMs, prefs, callback); |
| 524 | power_battery_screen_off_delay_ms_.Init( |
| 525 | prefs::kPowerBatteryScreenOffDelayMs, prefs, callback); |
| 526 | power_battery_screen_lock_delay_ms_.Init( |
| 527 | prefs::kPowerBatteryScreenLockDelayMs, prefs, callback); |
[email protected] | c9b340b | 2013-03-20 21:01:13 | [diff] [blame] | 528 | power_battery_idle_warning_delay_ms_.Init( |
| 529 | prefs::kPowerBatteryIdleWarningDelayMs, prefs, callback); |
[email protected] | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 530 | power_battery_idle_delay_ms_.Init( |
| 531 | prefs::kPowerBatteryIdleDelayMs, prefs, callback); |
[email protected] | 1c37204 | 2013-06-29 01:47:20 | [diff] [blame] | 532 | power_ac_idle_action_.Init(prefs::kPowerAcIdleAction, prefs, callback); |
| 533 | power_battery_idle_action_.Init( |
| 534 | prefs::kPowerBatteryIdleAction, prefs, callback); |
[email protected] | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 535 | power_lid_closed_action_.Init(prefs::kPowerLidClosedAction, prefs, callback); |
| 536 | power_use_audio_activity_.Init( |
| 537 | prefs::kPowerUseAudioActivity, prefs, callback); |
| 538 | power_use_video_activity_.Init( |
| 539 | prefs::kPowerUseVideoActivity, prefs, callback); |
[email protected] | ceaf3a1 | 2013-04-30 18:21:31 | [diff] [blame] | 540 | power_allow_screen_wake_locks_.Init( |
| 541 | prefs::kPowerAllowScreenWakeLocks, prefs, callback); |
[email protected] | 8101d02 | 2013-06-12 19:56:28 | [diff] [blame] | 542 | power_presentation_screen_dim_delay_factor_.Init( |
| 543 | prefs::kPowerPresentationScreenDimDelayFactor, prefs, callback); |
[email protected] | 954015b | 2013-04-26 07:42:08 | [diff] [blame] | 544 | power_user_activity_screen_dim_delay_factor_.Init( |
| 545 | prefs::kPowerUserActivityScreenDimDelayFactor, prefs, callback); |
[email protected] | fddc44fe | 2013-07-04 00:03:51 | [diff] [blame] | 546 | |
| 547 | // TODO(achuith): Remove deprecated pref in M31. crbug.com/223480. |
| 548 | prefs->ClearPref(kEnableTouchpadThreeFingerSwipe); |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 549 | } |
| 550 | |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 551 | void Preferences::Init(PrefServiceSyncable* prefs) { |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 552 | InitUserPrefs(prefs); |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 553 | |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 554 | // This causes OnIsSyncingChanged to be called when the value of |
| 555 | // PrefService::IsSyncing() changes. |
| 556 | prefs->AddObserver(this); |
| 557 | |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 558 | // Initialize preferences to currently saved state. |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 559 | NotifyPrefChanged(NULL); |
[email protected] | 26012e2 | 2010-12-01 06:44:27 | [diff] [blame] | 560 | |
| 561 | // If a guest is logged in, initialize the prefs as if this is the first |
| 562 | // login. |
| 563 | if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |
| 564 | LoginUtils::Get()->SetFirstLoginPrefs(prefs); |
| 565 | } |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 566 | } |
| 567 | |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 568 | void Preferences::InitUserPrefsForTesting(PrefServiceSyncable* prefs) { |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 569 | InitUserPrefs(prefs); |
| 570 | } |
| 571 | |
| 572 | void Preferences::SetInputMethodListForTesting() { |
| 573 | SetInputMethodList(); |
| 574 | } |
| 575 | |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 576 | void Preferences::OnPreferenceChanged(const std::string& pref_name) { |
[email protected] | a6a7ced | 2012-11-01 17:24:18 | [diff] [blame] | 577 | NotifyPrefChanged(&pref_name); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 578 | } |
| 579 | |
[email protected] | 57ecc4b | 2010-08-11 03:02:51 | [diff] [blame] | 580 | void Preferences::NotifyPrefChanged(const std::string* pref_name) { |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 581 | if (!pref_name || *pref_name == prefs::kTapToClickEnabled) { |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 582 | const bool enabled = tap_to_click_enabled_.GetValue(); |
[email protected] | 1cbfb3b | 2011-07-11 23:34:08 | [diff] [blame] | 583 | system::touchpad_settings::SetTapToClick(enabled); |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 584 | if (pref_name) |
| 585 | UMA_HISTOGRAM_BOOLEAN("Touchpad.TapToClick.Changed", enabled); |
| 586 | else |
| 587 | UMA_HISTOGRAM_BOOLEAN("Touchpad.TapToClick.Started", enabled); |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 588 | |
| 589 | // Save owner preference in local state to use on login screen. |
| 590 | if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { |
| 591 | PrefService* prefs = g_browser_process->local_state(); |
| 592 | if (prefs->GetBoolean(prefs::kOwnerTapToClickEnabled) != enabled) |
| 593 | prefs->SetBoolean(prefs::kOwnerTapToClickEnabled, enabled); |
| 594 | } |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 595 | } |
[email protected] | 1b46af0 | 2012-10-31 05:23:54 | [diff] [blame] | 596 | if (!pref_name || *pref_name == prefs::kTapDraggingEnabled) { |
| 597 | const bool enabled = tap_dragging_enabled_.GetValue(); |
| 598 | system::touchpad_settings::SetTapDragging(enabled); |
| 599 | if (pref_name) |
| 600 | UMA_HISTOGRAM_BOOLEAN("Touchpad.TapDragging.Changed", enabled); |
| 601 | else |
| 602 | UMA_HISTOGRAM_BOOLEAN("Touchpad.TapDragging.Started", enabled); |
| 603 | } |
[email protected] | 190349fd | 2012-05-02 00:10:47 | [diff] [blame] | 604 | if (!pref_name || *pref_name == prefs::kEnableTouchpadThreeFingerClick) { |
| 605 | const bool enabled = three_finger_click_enabled_.GetValue(); |
| 606 | system::touchpad_settings::SetThreeFingerClick(enabled); |
| 607 | if (pref_name) |
| 608 | UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerClick.Changed", enabled); |
| 609 | else |
| 610 | UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerClick.Started", enabled); |
| 611 | } |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 612 | if (!pref_name || *pref_name == prefs::kNaturalScroll) { |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 613 | // Force natural scroll default if we've sync'd and if the cmd line arg is |
| 614 | // set. |
| 615 | ForceNaturalScrollDefault(); |
[email protected] | 223059e | 2012-10-05 01:44:49 | [diff] [blame] | 616 | |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 617 | const bool enabled = natural_scroll_.GetValue(); |
[email protected] | 223059e | 2012-10-05 01:44:49 | [diff] [blame] | 618 | DVLOG(1) << "Natural scroll set to " << enabled; |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 619 | ui::SetNaturalScroll(enabled); |
| 620 | if (pref_name) |
| 621 | UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Changed", enabled); |
| 622 | else |
| 623 | UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Started", enabled); |
| 624 | } |
[email protected] | 563fb5f | 2012-03-31 00:39:28 | [diff] [blame] | 625 | if (!pref_name || *pref_name == prefs::kMouseSensitivity) { |
| 626 | const int sensitivity = mouse_sensitivity_.GetValue(); |
| 627 | system::mouse_settings::SetSensitivity(sensitivity); |
| 628 | if (pref_name) { |
[email protected] | 3a337d3 | 2013-07-02 05:14:24 | [diff] [blame] | 629 | UMA_HISTOGRAM_ENUMERATION("Mouse.PointerSensitivity.Changed", |
| 630 | sensitivity, |
| 631 | system::kMaxPointerSensitivity + 1); |
[email protected] | 563fb5f | 2012-03-31 00:39:28 | [diff] [blame] | 632 | } else { |
[email protected] | 3a337d3 | 2013-07-02 05:14:24 | [diff] [blame] | 633 | UMA_HISTOGRAM_ENUMERATION("Mouse.PointerSensitivity.Started", |
| 634 | sensitivity, |
| 635 | system::kMaxPointerSensitivity + 1); |
[email protected] | 563fb5f | 2012-03-31 00:39:28 | [diff] [blame] | 636 | } |
| 637 | } |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 638 | if (!pref_name || *pref_name == prefs::kTouchpadSensitivity) { |
[email protected] | 563fb5f | 2012-03-31 00:39:28 | [diff] [blame] | 639 | const int sensitivity = touchpad_sensitivity_.GetValue(); |
| 640 | system::touchpad_settings::SetSensitivity(sensitivity); |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 641 | if (pref_name) { |
[email protected] | 3a337d3 | 2013-07-02 05:14:24 | [diff] [blame] | 642 | UMA_HISTOGRAM_ENUMERATION("Touchpad.PointerSensitivity.Changed", |
| 643 | sensitivity, |
| 644 | system::kMaxPointerSensitivity + 1); |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 645 | } else { |
[email protected] | 3a337d3 | 2013-07-02 05:14:24 | [diff] [blame] | 646 | UMA_HISTOGRAM_ENUMERATION("Touchpad.PointerSensitivity.Started", |
| 647 | sensitivity, |
| 648 | system::kMaxPointerSensitivity + 1); |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 649 | } |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 650 | } |
[email protected] | 0027fde1 | 2011-12-15 05:09:38 | [diff] [blame] | 651 | if (!pref_name || *pref_name == prefs::kPrimaryMouseButtonRight) { |
| 652 | const bool right = primary_mouse_button_right_.GetValue(); |
| 653 | system::mouse_settings::SetPrimaryButtonRight(right); |
| 654 | if (pref_name) |
[email protected] | 6c8599e | 2012-01-20 04:31:58 | [diff] [blame] | 655 | UMA_HISTOGRAM_BOOLEAN("Mouse.PrimaryButtonRight.Changed", right); |
[email protected] | 0027fde1 | 2011-12-15 05:09:38 | [diff] [blame] | 656 | else |
[email protected] | 6c8599e | 2012-01-20 04:31:58 | [diff] [blame] | 657 | UMA_HISTOGRAM_BOOLEAN("Mouse.PrimaryButtonRight.Started", right); |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 658 | |
| 659 | // Save owner preference in local state to use on login screen. |
| 660 | if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { |
| 661 | PrefService* prefs = g_browser_process->local_state(); |
| 662 | if (prefs->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight) != right) |
| 663 | prefs->SetBoolean(prefs::kOwnerPrimaryMouseButtonRight, right); |
| 664 | } |
[email protected] | 0027fde1 | 2011-12-15 05:09:38 | [diff] [blame] | 665 | } |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 666 | if (!pref_name || *pref_name == prefs::kDownloadDefaultDirectory) { |
[email protected] | 68f0d2d | 2013-03-25 11:30:58 | [diff] [blame] | 667 | const base::FilePath pref_path = download_default_directory_.GetValue(); |
[email protected] | 1746ac92 | 2013-04-10 04:53:24 | [diff] [blame] | 668 | // TODO(haruki): Remove this when migration completes. crbug.com/229304. |
[email protected] | 68f0d2d | 2013-03-25 11:30:58 | [diff] [blame] | 669 | if (drive::util::NeedsNamespaceMigration(pref_path)) { |
| 670 | prefs_->SetFilePath(prefs::kDownloadDefaultDirectory, |
| 671 | drive::util::ConvertToMyDriveNamespace(pref_path)); |
| 672 | } |
| 673 | |
[email protected] | d9d04df | 2012-10-12 07:06:35 | [diff] [blame] | 674 | const bool default_download_to_drive = drive::util::IsUnderDriveMountPoint( |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 675 | download_default_directory_.GetValue()); |
| 676 | if (pref_name) |
[email protected] | e8307a1 | 2012-09-12 20:06:34 | [diff] [blame] | 677 | UMA_HISTOGRAM_BOOLEAN( |
| 678 | "FileBrowser.DownloadDestination.IsGoogleDrive.Changed", |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 679 | default_download_to_drive); |
| 680 | else |
[email protected] | e8307a1 | 2012-09-12 20:06:34 | [diff] [blame] | 681 | UMA_HISTOGRAM_BOOLEAN( |
| 682 | "FileBrowser.DownloadDestination.IsGoogleDrive.Started", |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 683 | default_download_to_drive); |
| 684 | } |
[email protected] | 1746ac92 | 2013-04-10 04:53:24 | [diff] [blame] | 685 | if (!pref_name || *pref_name == prefs::kSelectFileLastDirectory) { |
| 686 | const base::FilePath pref_path = select_file_last_directory_.GetValue(); |
| 687 | // This pref can contain a Drive path, which needs to be updated due to |
| 688 | // namespaces introduced by crbug.com/174233. |
| 689 | // TODO(haruki): Remove this when migration completes. crbug.com/229304. |
| 690 | if (drive::util::NeedsNamespaceMigration(pref_path)) { |
| 691 | prefs_->SetFilePath(prefs::kSelectFileLastDirectory, |
| 692 | drive::util::ConvertToMyDriveNamespace(pref_path)); |
| 693 | } |
| 694 | } |
[email protected] | 57229d1 | 2013-04-18 07:13:15 | [diff] [blame] | 695 | if (!pref_name || *pref_name == prefs::kSaveFileDefaultDirectory) { |
| 696 | const base::FilePath pref_path = save_file_default_directory_.GetValue(); |
| 697 | // This pref can contain a Drive path, which needs to be updated due to |
| 698 | // namespaces introduced by crbug.com/174233. |
| 699 | // TODO(haruki): Remove this when migration completes. crbug.com/229304. |
| 700 | if (drive::util::NeedsNamespaceMigration(pref_path)) { |
| 701 | prefs_->SetFilePath(prefs::kSaveFileDefaultDirectory, |
| 702 | drive::util::ConvertToMyDriveNamespace(pref_path)); |
| 703 | } |
| 704 | } |
[email protected] | 8be9ff2 | 2010-06-08 02:13:54 | [diff] [blame] | 705 | |
[email protected] | 74b42fc1 | 2010-07-20 10:15:41 | [diff] [blame] | 706 | if (!pref_name || *pref_name == prefs::kLanguagePreferredLanguages) { |
| 707 | // Unlike kLanguagePreloadEngines and some other input method |
| 708 | // preferencs, we don't need to send this to ibus-daemon. |
| 709 | } |
[email protected] | a6e9077 | 2011-02-09 05:38:54 | [diff] [blame] | 710 | |
[email protected] | a6e9077 | 2011-02-09 05:38:54 | [diff] [blame] | 711 | if (!pref_name || *pref_name == prefs::kLanguageXkbAutoRepeatEnabled) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 712 | const bool enabled = xkb_auto_repeat_enabled_.GetValue(); |
[email protected] | cf61f6b0a | 2013-01-03 00:34:12 | [diff] [blame] | 713 | input_method::XKeyboard::SetAutoRepeatEnabled(enabled); |
[email protected] | a6e9077 | 2011-02-09 05:38:54 | [diff] [blame] | 714 | } |
| 715 | if (!pref_name || ((*pref_name == prefs::kLanguageXkbAutoRepeatDelay) || |
| 716 | (*pref_name == prefs::kLanguageXkbAutoRepeatInterval))) { |
| 717 | UpdateAutoRepeatRate(); |
| 718 | } |
| 719 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 720 | if (!pref_name) { |
| 721 | SetInputMethodList(); |
| 722 | } else if (*pref_name == prefs::kLanguagePreloadEngines) { |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 723 | SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, |
| 724 | language_prefs::kPreloadEnginesConfigName, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 725 | preload_engines_.GetValue()); |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 726 | } |
[email protected] | 22bec1a | 2012-03-27 06:33:48 | [diff] [blame] | 727 | |
[email protected] | aef1af4b1 | 2013-05-09 04:50:23 | [diff] [blame] | 728 | if (!pref_name || *pref_name == prefs::kLanguageEnabledExtensionImes) { |
| 729 | std::string value(enabled_extension_imes_.GetValue()); |
[email protected] | 797c680 | 2012-09-20 10:36:13 | [diff] [blame] | 730 | |
| 731 | std::vector<std::string> split_values; |
| 732 | if (!value.empty()) |
| 733 | base::SplitString(value, ',', &split_values); |
| 734 | |
[email protected] | aef1af4b1 | 2013-05-09 04:50:23 | [diff] [blame] | 735 | input_method_manager_->SetEnabledExtensionImes(&split_values); |
[email protected] | 797c680 | 2012-09-20 10:36:13 | [diff] [blame] | 736 | } |
| 737 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 738 | // Do not check |*pref_name| of the prefs for remembering current/previous |
| 739 | // input methods here. We're only interested in initial values of the prefs. |
[email protected] | 22bec1a | 2012-03-27 06:33:48 | [diff] [blame] | 740 | |
[email protected] | ae73781 | 2013-07-02 06:50:51 | [diff] [blame] | 741 | // TODO(nona): remove all IME preference entries. crbug.com/256102 |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 742 | for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { |
| 743 | if (!pref_name || |
| 744 | *pref_name == language_prefs::kChewingBooleanPrefs[i].pref_name) { |
| 745 | SetLanguageConfigBoolean( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 746 | language_prefs::kChewingSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 747 | language_prefs::kChewingBooleanPrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 748 | chewing_boolean_prefs_[i].GetValue()); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 749 | } |
| 750 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 751 | for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { |
| 752 | if (!pref_name || |
| 753 | *pref_name == |
| 754 | language_prefs::kChewingMultipleChoicePrefs[i].pref_name) { |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 755 | SetLanguageConfigString( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 756 | language_prefs::kChewingSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 757 | language_prefs::kChewingMultipleChoicePrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 758 | chewing_multiple_choice_prefs_[i].GetValue()); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 759 | } |
| 760 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 761 | if (!pref_name || |
| 762 | *pref_name == language_prefs::kChewingHsuSelKeyType.pref_name) { |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 763 | SetLanguageConfigInteger( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 764 | language_prefs::kChewingSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 765 | language_prefs::kChewingHsuSelKeyType.ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 766 | chewing_hsu_sel_key_type_.GetValue()); |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 767 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 768 | for (size_t i = 0; i < language_prefs::kNumChewingIntegerPrefs; ++i) { |
| 769 | if (!pref_name || |
| 770 | *pref_name == language_prefs::kChewingIntegerPrefs[i].pref_name) { |
| 771 | SetLanguageConfigInteger( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 772 | language_prefs::kChewingSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 773 | language_prefs::kChewingIntegerPrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 774 | chewing_integer_prefs_[i].GetValue()); |
[email protected] | 15c5308 | 2010-06-03 03:28:21 | [diff] [blame] | 775 | } |
| 776 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 777 | if (!pref_name || |
| 778 | *pref_name == prefs::kLanguageHangulKeyboard) { |
[email protected] | ae73781 | 2013-07-02 06:50:51 | [diff] [blame] | 779 | std::vector<std::string> new_input_method_ids; |
| 780 | if (input_method_manager_->MigrateKoreanKeyboard( |
| 781 | hangul_keyboard_.GetValue(), |
| 782 | &new_input_method_ids)) { |
| 783 | preload_engines_.SetValue(JoinString(new_input_method_ids, ',')); |
| 784 | hangul_keyboard_.SetValue("dummy_value_already_migrated"); |
| 785 | } |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 786 | } |
[email protected] | 33444cf | 2011-08-04 06:33:55 | [diff] [blame] | 787 | if (!pref_name || *pref_name == prefs::kLanguageHangulHanjaBindingKeys) { |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 788 | SetLanguageConfigString(language_prefs::kHangulSectionName, |
| 789 | language_prefs::kHangulHanjaBindingKeysConfigName, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 790 | hangul_hanja_binding_keys_.GetValue()); |
[email protected] | 33444cf | 2011-08-04 06:33:55 | [diff] [blame] | 791 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 792 | for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { |
| 793 | if (!pref_name || |
| 794 | *pref_name == language_prefs::kPinyinBooleanPrefs[i].pref_name) { |
| 795 | SetLanguageConfigBoolean( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 796 | language_prefs::kPinyinSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 797 | language_prefs::kPinyinBooleanPrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 798 | pinyin_boolean_prefs_[i].GetValue()); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 799 | } |
| 800 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 801 | for (size_t i = 0; i < language_prefs::kNumPinyinIntegerPrefs; ++i) { |
| 802 | if (!pref_name || |
| 803 | *pref_name == language_prefs::kPinyinIntegerPrefs[i].pref_name) { |
| 804 | SetLanguageConfigInteger( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 805 | language_prefs::kPinyinSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 806 | language_prefs::kPinyinIntegerPrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 807 | pinyin_int_prefs_[i].GetValue()); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 808 | } |
| 809 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 810 | if (!pref_name || |
| 811 | *pref_name == language_prefs::kPinyinDoublePinyinSchema.pref_name) { |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 812 | SetLanguageConfigInteger( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 813 | language_prefs::kPinyinSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 814 | language_prefs::kPinyinDoublePinyinSchema.ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 815 | pinyin_double_pinyin_schema_.GetValue()); |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 816 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 817 | for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { |
| 818 | if (!pref_name || |
| 819 | *pref_name == language_prefs::kMozcBooleanPrefs[i].pref_name) { |
| 820 | SetLanguageConfigBoolean( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 821 | language_prefs::kMozcSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 822 | language_prefs::kMozcBooleanPrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 823 | mozc_boolean_prefs_[i].GetValue()); |
[email protected] | 8a1ace2 | 2010-06-10 05:38:25 | [diff] [blame] | 824 | } |
| 825 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 826 | for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { |
| 827 | if (!pref_name || |
| 828 | *pref_name == language_prefs::kMozcMultipleChoicePrefs[i].pref_name) { |
[email protected] | 6e5c4b8 | 2010-05-24 08:18:44 | [diff] [blame] | 829 | SetLanguageConfigString( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 830 | language_prefs::kMozcSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 831 | language_prefs::kMozcMultipleChoicePrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 832 | mozc_multiple_choice_prefs_[i].GetValue()); |
[email protected] | 6e5c4b8 | 2010-05-24 08:18:44 | [diff] [blame] | 833 | } |
| 834 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 835 | for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { |
| 836 | if (!pref_name || |
| 837 | *pref_name == language_prefs::kMozcIntegerPrefs[i].pref_name) { |
| 838 | SetLanguageConfigInteger( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 839 | language_prefs::kMozcSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 840 | language_prefs::kMozcIntegerPrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 841 | mozc_integer_prefs_[i].GetValue()); |
[email protected] | 5403746 | 2010-06-22 02:06:23 | [diff] [blame] | 842 | } |
| 843 | } |
[email protected] | 4793c94 | 2010-09-21 23:17:17 | [diff] [blame] | 844 | |
[email protected] | e1619ee0 | 2012-10-22 08:14:49 | [diff] [blame] | 845 | // Change the download directory to the default value if a Drive directory is |
| 846 | // selected and Drive is disabled. |
| 847 | if (!pref_name || *pref_name == prefs::kDisableDrive) { |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 848 | if (disable_drive_.GetValue()) { |
[email protected] | d9d04df | 2012-10-12 07:06:35 | [diff] [blame] | 849 | if (drive::util::IsUnderDriveMountPoint( |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 850 | download_default_directory_.GetValue())) { |
[email protected] | 155e1b4 | 2012-07-14 03:06:01 | [diff] [blame] | 851 | prefs_->SetFilePath(prefs::kDownloadDefaultDirectory, |
| 852 | download_util::GetDefaultDownloadDirectory()); |
| 853 | } |
| 854 | } |
| 855 | } |
[email protected] | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 856 | |
| 857 | if (!pref_name || |
| 858 | *pref_name == prefs::kPowerAcScreenDimDelayMs || |
| 859 | *pref_name == prefs::kPowerAcScreenOffDelayMs || |
| 860 | *pref_name == prefs::kPowerAcScreenLockDelayMs || |
[email protected] | c9b340b | 2013-03-20 21:01:13 | [diff] [blame] | 861 | *pref_name == prefs::kPowerAcIdleWarningDelayMs || |
[email protected] | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 862 | *pref_name == prefs::kPowerAcIdleDelayMs || |
| 863 | *pref_name == prefs::kPowerBatteryScreenDimDelayMs || |
| 864 | *pref_name == prefs::kPowerBatteryScreenOffDelayMs || |
| 865 | *pref_name == prefs::kPowerBatteryScreenLockDelayMs || |
[email protected] | c9b340b | 2013-03-20 21:01:13 | [diff] [blame] | 866 | *pref_name == prefs::kPowerBatteryIdleWarningDelayMs || |
[email protected] | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 867 | *pref_name == prefs::kPowerBatteryIdleDelayMs || |
[email protected] | 1c37204 | 2013-06-29 01:47:20 | [diff] [blame] | 868 | *pref_name == prefs::kPowerAcIdleAction || |
| 869 | *pref_name == prefs::kPowerBatteryIdleAction || |
[email protected] | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 870 | *pref_name == prefs::kPowerLidClosedAction || |
| 871 | *pref_name == prefs::kPowerUseAudioActivity || |
| 872 | *pref_name == prefs::kPowerUseVideoActivity || |
[email protected] | ceaf3a1 | 2013-04-30 18:21:31 | [diff] [blame] | 873 | *pref_name == prefs::kPowerAllowScreenWakeLocks || |
[email protected] | 8101d02 | 2013-06-12 19:56:28 | [diff] [blame] | 874 | *pref_name == prefs::kPowerPresentationScreenDimDelayFactor || |
[email protected] | 954015b | 2013-04-26 07:42:08 | [diff] [blame] | 875 | *pref_name == prefs::kPowerUserActivityScreenDimDelayFactor || |
[email protected] | ac7fe1b | 2013-04-20 03:57:44 | [diff] [blame] | 876 | *pref_name == prefs::kEnableScreenLock) { |
| 877 | PowerPolicyController::PrefValues values; |
| 878 | values.ac_screen_dim_delay_ms = power_ac_screen_dim_delay_ms_.GetValue(); |
| 879 | values.ac_screen_off_delay_ms = power_ac_screen_off_delay_ms_.GetValue(); |
| 880 | values.ac_screen_lock_delay_ms = power_ac_screen_lock_delay_ms_.GetValue(); |
| 881 | values.ac_idle_warning_delay_ms = |
| 882 | power_ac_idle_warning_delay_ms_.GetValue(); |
| 883 | values.ac_idle_delay_ms = power_ac_idle_delay_ms_.GetValue(); |
| 884 | values.battery_screen_dim_delay_ms = |
| 885 | power_battery_screen_dim_delay_ms_.GetValue(); |
| 886 | values.battery_screen_off_delay_ms = |
| 887 | power_battery_screen_off_delay_ms_.GetValue(); |
| 888 | values.battery_screen_lock_delay_ms = |
| 889 | power_battery_screen_lock_delay_ms_.GetValue(); |
| 890 | values.battery_idle_warning_delay_ms = |
| 891 | power_battery_idle_warning_delay_ms_.GetValue(); |
| 892 | values.battery_idle_delay_ms = power_battery_idle_delay_ms_.GetValue(); |
[email protected] | e67e1c4 | 2013-06-28 00:10:19 | [diff] [blame] | 893 | values.ac_idle_action = static_cast<PowerPolicyController::Action>( |
[email protected] | 1c37204 | 2013-06-29 01:47:20 | [diff] [blame] | 894 | power_ac_idle_action_.GetValue()); |
[email protected] | e67e1c4 | 2013-06-28 00:10:19 | [diff] [blame] | 895 | values.battery_idle_action = static_cast<PowerPolicyController::Action>( |
[email protected] | 1c37204 | 2013-06-29 01:47:20 | [diff] [blame] | 896 | power_battery_idle_action_.GetValue()); |
[email protected] | ac7fe1b | 2013-04-20 03:57:44 | [diff] [blame] | 897 | values.lid_closed_action = static_cast<PowerPolicyController::Action>( |
| 898 | power_lid_closed_action_.GetValue()); |
| 899 | values.use_audio_activity = power_use_audio_activity_.GetValue(); |
| 900 | values.use_video_activity = power_use_video_activity_.GetValue(); |
[email protected] | ceaf3a1 | 2013-04-30 18:21:31 | [diff] [blame] | 901 | values.allow_screen_wake_locks = power_allow_screen_wake_locks_.GetValue(); |
[email protected] | ac7fe1b | 2013-04-20 03:57:44 | [diff] [blame] | 902 | values.enable_screen_lock = enable_screen_lock_.GetValue(); |
[email protected] | 8101d02 | 2013-06-12 19:56:28 | [diff] [blame] | 903 | values.presentation_screen_dim_delay_factor = |
| 904 | power_presentation_screen_dim_delay_factor_.GetValue(); |
[email protected] | 954015b | 2013-04-26 07:42:08 | [diff] [blame] | 905 | values.user_activity_screen_dim_delay_factor = |
| 906 | power_user_activity_screen_dim_delay_factor_.GetValue(); |
[email protected] | ac7fe1b | 2013-04-20 03:57:44 | [diff] [blame] | 907 | |
| 908 | DBusThreadManager::Get()->GetPowerPolicyController()->ApplyPrefs(values); |
[email protected] | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 909 | } |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 910 | } |
| 911 | |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 912 | void Preferences::OnIsSyncingChanged() { |
| 913 | DVLOG(1) << "OnIsSyncingChanged"; |
| 914 | ForceNaturalScrollDefault(); |
| 915 | } |
| 916 | |
| 917 | void Preferences::ForceNaturalScrollDefault() { |
| 918 | DVLOG(1) << "ForceNaturalScrollDefault"; |
| 919 | if (CommandLine::ForCurrentProcess()->HasSwitch( |
[email protected] | 2f2d6c3 | 2013-05-10 02:56:24 | [diff] [blame] | 920 | switches::kNaturalScrollDefault) && |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 921 | prefs_->IsSyncing() && |
| 922 | !prefs_->GetUserPrefValue(prefs::kNaturalScroll)) { |
| 923 | DVLOG(1) << "Natural scroll forced to true"; |
| 924 | natural_scroll_.SetValue(true); |
| 925 | UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Forced", true); |
| 926 | } |
| 927 | } |
| 928 | |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 929 | void Preferences::SetLanguageConfigBoolean(const char* section, |
| 930 | const char* name, |
| 931 | bool value) { |
[email protected] | 62308c2 | 2012-03-13 12:07:10 | [diff] [blame] | 932 | input_method::InputMethodConfigValue config; |
| 933 | config.type = input_method::InputMethodConfigValue::kValueTypeBool; |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 934 | config.bool_value = value; |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 935 | input_method_manager_->SetInputMethodConfig(section, name, config); |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 936 | } |
| 937 | |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 938 | void Preferences::SetLanguageConfigInteger(const char* section, |
| 939 | const char* name, |
| 940 | int value) { |
[email protected] | 62308c2 | 2012-03-13 12:07:10 | [diff] [blame] | 941 | input_method::InputMethodConfigValue config; |
| 942 | config.type = input_method::InputMethodConfigValue::kValueTypeInt; |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 943 | config.int_value = value; |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 944 | input_method_manager_->SetInputMethodConfig(section, name, config); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 945 | } |
| 946 | |
[email protected] | 5095143 | 2010-03-31 12:12:42 | [diff] [blame] | 947 | void Preferences::SetLanguageConfigString(const char* section, |
| 948 | const char* name, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 949 | const std::string& value) { |
[email protected] | 62308c2 | 2012-03-13 12:07:10 | [diff] [blame] | 950 | input_method::InputMethodConfigValue config; |
| 951 | config.type = input_method::InputMethodConfigValue::kValueTypeString; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 952 | config.string_value = value; |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 953 | input_method_manager_->SetInputMethodConfig(section, name, config); |
[email protected] | 5095143 | 2010-03-31 12:12:42 | [diff] [blame] | 954 | } |
| 955 | |
[email protected] | 2c25ddfd | 2010-04-09 10:35:55 | [diff] [blame] | 956 | void Preferences::SetLanguageConfigStringList( |
| 957 | const char* section, |
| 958 | const char* name, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 959 | const std::vector<std::string>& values) { |
[email protected] | 62308c2 | 2012-03-13 12:07:10 | [diff] [blame] | 960 | input_method::InputMethodConfigValue config; |
| 961 | config.type = input_method::InputMethodConfigValue::kValueTypeStringList; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 962 | for (size_t i = 0; i < values.size(); ++i) |
| 963 | config.string_list_value.push_back(values[i]); |
| 964 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 965 | input_method_manager_->SetInputMethodConfig(section, name, config); |
[email protected] | 2c25ddfd | 2010-04-09 10:35:55 | [diff] [blame] | 966 | } |
| 967 | |
[email protected] | d01bb807 | 2010-04-12 13:00:15 | [diff] [blame] | 968 | void Preferences::SetLanguageConfigStringListAsCSV(const char* section, |
| 969 | const char* name, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 970 | const std::string& value) { |
[email protected] | e24c2c9 | 2010-10-23 01:39:24 | [diff] [blame] | 971 | VLOG(1) << "Setting " << name << " to '" << value << "'"; |
[email protected] | d01bb807 | 2010-04-12 13:00:15 | [diff] [blame] | 972 | |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 973 | std::vector<std::string> split_values; |
| 974 | if (!value.empty()) |
[email protected] | 76eb024 | 2010-10-14 00:35:36 | [diff] [blame] | 975 | base::SplitString(value, ',', &split_values); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 976 | |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 977 | if (section == std::string(language_prefs::kGeneralSectionName) && |
| 978 | name == std::string(language_prefs::kPreloadEnginesConfigName)) { |
[email protected] | c418b6d | 2013-05-02 07:05:29 | [diff] [blame] | 979 | // TODO(nona): Remove this function after few milestones are passed. |
| 980 | // (http://crbug.com/236747) |
| 981 | if (input_method_manager_->MigrateOldInputMethods(&split_values)) |
| 982 | preload_engines_.SetValue(JoinString(split_values, ',')); |
[email protected] | dbc9b19 | 2012-04-18 05:55:34 | [diff] [blame] | 983 | input_method_manager_->EnableInputMethods(split_values); |
| 984 | return; |
| 985 | } |
| 986 | |
[email protected] | 2c25ddfd | 2010-04-09 10:35:55 | [diff] [blame] | 987 | // We should call the cros API even when |value| is empty, to disable default |
[email protected] | d01bb807 | 2010-04-12 13:00:15 | [diff] [blame] | 988 | // config. |
| 989 | SetLanguageConfigStringList(section, name, split_values); |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 990 | } |
| 991 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 992 | void Preferences::SetInputMethodList() { |
| 993 | // When |preload_engines_| are set, InputMethodManager::ChangeInputMethod() |
| 994 | // might be called to change the current input method to the first one in the |
| 995 | // |preload_engines_| list. This also updates previous/current input method |
| 996 | // prefs. That's why GetValue() calls are placed before the |
| 997 | // SetLanguageConfigStringListAsCSV() call below. |
| 998 | const std::string previous_input_method_id = |
| 999 | previous_input_method_.GetValue(); |
| 1000 | const std::string current_input_method_id = current_input_method_.GetValue(); |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 1001 | SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, |
| 1002 | language_prefs::kPreloadEnginesConfigName, |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 1003 | preload_engines_.GetValue()); |
| 1004 | |
| 1005 | // ChangeInputMethod() has to be called AFTER the value of |preload_engines_| |
| 1006 | // is sent to the InputMethodManager. Otherwise, the ChangeInputMethod request |
| 1007 | // might be ignored as an invalid input method ID. The ChangeInputMethod() |
| 1008 | // calls are also necessary to restore the previous/current input method prefs |
| 1009 | // which could have been modified by the SetLanguageConfigStringListAsCSV call |
| 1010 | // above to the original state. |
| 1011 | if (!previous_input_method_id.empty()) |
| 1012 | input_method_manager_->ChangeInputMethod(previous_input_method_id); |
| 1013 | if (!current_input_method_id.empty()) |
| 1014 | input_method_manager_->ChangeInputMethod(current_input_method_id); |
| 1015 | } |
| 1016 | |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 1017 | void Preferences::UpdateAutoRepeatRate() { |
[email protected] | 20979d49 | 2012-02-15 09:26:02 | [diff] [blame] | 1018 | // Avoid setting repeat rate on desktop dev environment. |
[email protected] | 20d2a79d | 2012-03-16 23:01:02 | [diff] [blame] | 1019 | if (!base::chromeos::IsRunningOnChromeOS()) |
[email protected] | 20979d49 | 2012-02-15 09:26:02 | [diff] [blame] | 1020 | return; |
| 1021 | |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 1022 | input_method::AutoRepeatRate rate; |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 1023 | rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); |
| 1024 | rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 1025 | DCHECK(rate.initial_delay_in_ms > 0); |
| 1026 | DCHECK(rate.repeat_interval_in_ms > 0); |
[email protected] | cf61f6b0a | 2013-01-03 00:34:12 | [diff] [blame] | 1027 | input_method::XKeyboard::SetAutoRepeatRate(rate); |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 1028 | } |
| 1029 | |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 1030 | } // namespace chromeos |