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