[email protected] | 2b2820a | 2011-03-07 22:28:40 | [diff] [blame] | 1 | // Copyright (c) 2011 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] | 775caec | 2011-09-01 17:14:32 | [diff] [blame^] | 7 | #include "base/command_line.h" |
[email protected] | 530cd62 | 2011-04-14 15:45:00 | [diff] [blame] | 8 | #include "base/i18n/time_formatting.h" |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 9 | #include "base/metrics/histogram.h" |
[email protected] | 4e5ae20f | 2010-09-24 04:52:11 | [diff] [blame] | 10 | #include "base/string_split.h" |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 11 | #include "base/string_util.h" |
[email protected] | 5095143 | 2010-03-31 12:12:42 | [diff] [blame] | 12 | #include "base/utf_string_conversions.h" |
[email protected] | c0a2128d9 | 2011-07-20 15:04:46 | [diff] [blame] | 13 | #include "chrome/browser/browser_process.h" |
[email protected] | 62c7ef3 | 2010-03-23 23:44:24 | [diff] [blame] | 14 | #include "chrome/browser/chromeos/cros/cros_library.h" |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 15 | #include "chrome/browser/chromeos/cros/power_library.h" |
[email protected] | c8d4e946 | 2011-06-29 23:18:57 | [diff] [blame] | 16 | #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
[email protected] | 9199bd5 | 2010-07-01 05:04:41 | [diff] [blame] | 17 | #include "chrome/browser/chromeos/input_method/input_method_util.h" |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 18 | #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
[email protected] | 26012e2 | 2010-12-01 06:44:27 | [diff] [blame] | 19 | #include "chrome/browser/chromeos/login/login_utils.h" |
[email protected] | c0a2128d9 | 2011-07-20 15:04:46 | [diff] [blame] | 20 | #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
[email protected] | 1cbfb3b | 2011-07-11 23:34:08 | [diff] [blame] | 21 | #include "chrome/browser/chromeos/system/touchpad_settings.h" |
[email protected] | 37858e5 | 2010-08-26 00:22:02 | [diff] [blame] | 22 | #include "chrome/browser/prefs/pref_member.h" |
| 23 | #include "chrome/browser/prefs/pref_service.h" |
[email protected] | b336257 | 2011-08-17 09:28:50 | [diff] [blame] | 24 | #include "chrome/browser/prefs/scoped_user_pref_update.h" |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 25 | #include "chrome/common/chrome_notification_types.h" |
[email protected] | 775caec | 2011-09-01 17:14:32 | [diff] [blame^] | 26 | #include "chrome/common/chrome_switches.h" |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 27 | #include "chrome/common/pref_names.h" |
[email protected] | 2b2820a | 2011-03-07 22:28:40 | [diff] [blame] | 28 | #include "content/common/notification_details.h" |
| 29 | #include "content/common/notification_source.h" |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 30 | #include "unicode/timezone.h" |
| 31 | |
| 32 | namespace chromeos { |
| 33 | |
[email protected] | 9199bd5 | 2010-07-01 05:04:41 | [diff] [blame] | 34 | static const char kFallbackInputMethodLocale[] = "en-US"; |
[email protected] | 4793c94 | 2010-09-21 23:17:17 | [diff] [blame] | 35 | |
[email protected] | d743a598 | 2010-11-08 17:54:09 | [diff] [blame] | 36 | Preferences::Preferences() {} |
| 37 | |
| 38 | Preferences::~Preferences() {} |
[email protected] | 9199bd5 | 2010-07-01 05:04:41 | [diff] [blame] | 39 | |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 40 | // static |
| 41 | void Preferences::RegisterUserPrefs(PrefService* prefs) { |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 42 | prefs->RegisterBooleanPref(prefs::kTapToClickEnabled, |
| 43 | false, |
| 44 | PrefService::SYNCABLE_PREF); |
| 45 | prefs->RegisterBooleanPref(prefs::kLabsMediaplayerEnabled, |
| 46 | false, |
| 47 | PrefService::UNSYNCABLE_PREF); |
| 48 | prefs->RegisterBooleanPref(prefs::kLabsAdvancedFilesystemEnabled, |
| 49 | false, |
| 50 | PrefService::UNSYNCABLE_PREF); |
[email protected] | 27f20d5 | 2010-09-18 00:59:31 | [diff] [blame] | 51 | // Check if the accessibility pref is already registered, which can happen |
| 52 | // in WizardController::RegisterPrefs. We still want to try to register |
| 53 | // the pref here in case of Chrome/Linux with ChromeOS=1. |
| 54 | if (prefs->FindPreference(prefs::kAccessibilityEnabled) == NULL) { |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 55 | prefs->RegisterBooleanPref(prefs::kAccessibilityEnabled, |
| 56 | false, |
| 57 | PrefService::UNSYNCABLE_PREF); |
[email protected] | 27f20d5 | 2010-09-18 00:59:31 | [diff] [blame] | 58 | } |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 59 | prefs->RegisterIntegerPref(prefs::kTouchpadSensitivity, |
| 60 | 3, |
| 61 | PrefService::UNSYNCABLE_PREF); |
[email protected] | 530cd62 | 2011-04-14 15:45:00 | [diff] [blame] | 62 | prefs->RegisterBooleanPref(prefs::kUse24HourClock, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 63 | base::GetHourClockType() == base::k24HourClock, |
| 64 | PrefService::SYNCABLE_PREF); |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 65 | // We don't sync prefs::kLanguageCurrentInputMethod and PreviousInputMethod |
| 66 | // because they're just used to track the logout state of the device. |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 67 | prefs->RegisterStringPref(prefs::kLanguageCurrentInputMethod, |
| 68 | "", |
| 69 | PrefService::UNSYNCABLE_PREF); |
| 70 | prefs->RegisterStringPref(prefs::kLanguagePreviousInputMethod, |
| 71 | "", |
| 72 | PrefService::UNSYNCABLE_PREF); |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 73 | // We don't sync input method hotkeys since they're not configurable. |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 74 | prefs->RegisterStringPref(prefs::kLanguageHotkeyNextEngineInMenu, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 75 | language_prefs::kHotkeyNextEngineInMenu, |
| 76 | PrefService::UNSYNCABLE_PREF); |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 77 | prefs->RegisterStringPref(prefs::kLanguageHotkeyPreviousEngine, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 78 | language_prefs::kHotkeyPreviousEngine, |
| 79 | PrefService::UNSYNCABLE_PREF); |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 80 | // We don't sync the list of input methods and preferred languages since a |
| 81 | // user might use two or more devices with different hardware keyboards. |
| 82 | // crosbug.com/15181 |
[email protected] | c5d4543 | 2010-09-07 08:25:35 | [diff] [blame] | 83 | prefs->RegisterStringPref(prefs::kLanguagePreferredLanguages, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 84 | kFallbackInputMethodLocale, |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 85 | PrefService::UNSYNCABLE_PREF); |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 86 | prefs->RegisterStringPref(prefs::kLanguagePreloadEngines, |
| 87 | input_method::GetHardwareInputMethodId(), |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 88 | PrefService::UNSYNCABLE_PREF); |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 89 | for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { |
| 90 | prefs->RegisterBooleanPref( |
| 91 | language_prefs::kChewingBooleanPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 92 | language_prefs::kChewingBooleanPrefs[i].default_pref_value, |
| 93 | PrefService::UNSYNCABLE_PREF); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 94 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 95 | for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 96 | prefs->RegisterStringPref( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 97 | language_prefs::kChewingMultipleChoicePrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 98 | language_prefs::kChewingMultipleChoicePrefs[i].default_pref_value, |
| 99 | PrefService::UNSYNCABLE_PREF); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 100 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 101 | prefs->RegisterIntegerPref( |
| 102 | language_prefs::kChewingHsuSelKeyType.pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 103 | language_prefs::kChewingHsuSelKeyType.default_pref_value, |
| 104 | PrefService::UNSYNCABLE_PREF); |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 105 | |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 106 | for (size_t i = 0; i < language_prefs::kNumChewingIntegerPrefs; ++i) { |
| 107 | prefs->RegisterIntegerPref( |
| 108 | language_prefs::kChewingIntegerPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 109 | language_prefs::kChewingIntegerPrefs[i].default_pref_value, |
| 110 | PrefService::UNSYNCABLE_PREF); |
[email protected] | 15c5308 | 2010-06-03 03:28:21 | [diff] [blame] | 111 | } |
[email protected] | 20ce516d | 2010-06-18 02:20:04 | [diff] [blame] | 112 | prefs->RegisterStringPref( |
| 113 | prefs::kLanguageHangulKeyboard, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 114 | language_prefs::kHangulKeyboardNameIDPairs[0].keyboard_id, |
| 115 | PrefService::SYNCABLE_PREF); |
[email protected] | 33444cf | 2011-08-04 06:33:55 | [diff] [blame] | 116 | prefs->RegisterStringPref(prefs::kLanguageHangulHanjaBindingKeys, |
| 117 | language_prefs::kHangulHanjaBindingKeys, |
| 118 | // Don't sync the pref as it's not user-configurable |
| 119 | PrefService::UNSYNCABLE_PREF); |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 120 | for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { |
| 121 | prefs->RegisterBooleanPref( |
| 122 | language_prefs::kPinyinBooleanPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 123 | language_prefs::kPinyinBooleanPrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 124 | language_prefs::kPinyinBooleanPrefs[i].sync_status); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 125 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 126 | for (size_t i = 0; i < language_prefs::kNumPinyinIntegerPrefs; ++i) { |
| 127 | prefs->RegisterIntegerPref( |
| 128 | language_prefs::kPinyinIntegerPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 129 | language_prefs::kPinyinIntegerPrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 130 | language_prefs::kPinyinIntegerPrefs[i].sync_status); |
[email protected] | 6e5c4b8 | 2010-05-24 08:18:44 | [diff] [blame] | 131 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 132 | prefs->RegisterIntegerPref( |
| 133 | language_prefs::kPinyinDoublePinyinSchema.pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 134 | language_prefs::kPinyinDoublePinyinSchema.default_pref_value, |
| 135 | PrefService::UNSYNCABLE_PREF); |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 136 | |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 137 | for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { |
| 138 | prefs->RegisterBooleanPref( |
| 139 | language_prefs::kMozcBooleanPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 140 | language_prefs::kMozcBooleanPrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 141 | language_prefs::kMozcBooleanPrefs[i].sync_status); |
[email protected] | 8a1ace2 | 2010-06-10 05:38:25 | [diff] [blame] | 142 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 143 | for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 144 | prefs->RegisterStringPref( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 145 | language_prefs::kMozcMultipleChoicePrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 146 | language_prefs::kMozcMultipleChoicePrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 147 | language_prefs::kMozcMultipleChoicePrefs[i].sync_status); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 148 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 149 | for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { |
| 150 | prefs->RegisterIntegerPref( |
| 151 | language_prefs::kMozcIntegerPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 152 | language_prefs::kMozcIntegerPrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 153 | language_prefs::kMozcIntegerPrefs[i].sync_status); |
[email protected] | 5403746 | 2010-06-22 02:06:23 | [diff] [blame] | 154 | } |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 155 | prefs->RegisterIntegerPref(prefs::kLanguageXkbRemapSearchKeyTo, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 156 | input_method::kSearchKey, |
| 157 | PrefService::SYNCABLE_PREF); |
[email protected] | b5194dd3 | 2010-08-12 10:40:04 | [diff] [blame] | 158 | prefs->RegisterIntegerPref(prefs::kLanguageXkbRemapControlKeyTo, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 159 | input_method::kLeftControlKey, |
| 160 | PrefService::SYNCABLE_PREF); |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 161 | prefs->RegisterIntegerPref(prefs::kLanguageXkbRemapAltKeyTo, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 162 | input_method::kLeftAltKey, |
| 163 | PrefService::SYNCABLE_PREF); |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 164 | // We don't sync the following keyboard prefs since they are not user- |
| 165 | // configurable. |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 166 | prefs->RegisterBooleanPref(prefs::kLanguageXkbAutoRepeatEnabled, |
| 167 | true, |
| 168 | PrefService::UNSYNCABLE_PREF); |
[email protected] | 4743dad | 2010-08-30 01:41:07 | [diff] [blame] | 169 | prefs->RegisterIntegerPref(prefs::kLanguageXkbAutoRepeatDelay, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 170 | language_prefs::kXkbAutoRepeatDelayInMs, |
| 171 | PrefService::UNSYNCABLE_PREF); |
[email protected] | 4743dad | 2010-08-30 01:41:07 | [diff] [blame] | 172 | prefs->RegisterIntegerPref(prefs::kLanguageXkbAutoRepeatInterval, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 173 | language_prefs::kXkbAutoRepeatIntervalInMs, |
| 174 | PrefService::UNSYNCABLE_PREF); |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 175 | |
[email protected] | f410d61 | 2011-08-05 04:32:24 | [diff] [blame] | 176 | prefs->RegisterDictionaryPref(prefs::kLanguagePreferredVirtualKeyboard, |
| 177 | PrefService::SYNCABLE_PREF); |
| 178 | |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 179 | // Screen lock default to off. |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 180 | prefs->RegisterBooleanPref(prefs::kEnableScreenLock, |
| 181 | false, |
| 182 | PrefService::SYNCABLE_PREF); |
[email protected] | ea1eba5 | 2010-11-23 18:05:38 | [diff] [blame] | 183 | |
| 184 | // Mobile plan notifications default to on. |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 185 | prefs->RegisterBooleanPref(prefs::kShowPlanNotifications, |
| 186 | true, |
| 187 | PrefService::SYNCABLE_PREF); |
[email protected] | c74fffa | 2011-04-27 13:32:24 | [diff] [blame] | 188 | |
| 189 | // 3G first-time usage promo will be shown at least once. |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 190 | prefs->RegisterBooleanPref(prefs::kShow3gPromoNotification, |
| 191 | true, |
| 192 | PrefService::UNSYNCABLE_PREF); |
[email protected] | d6ae950 | 2011-05-05 18:23:09 | [diff] [blame] | 193 | |
[email protected] | ea3cd24 | 2011-05-08 17:35:56 | [diff] [blame] | 194 | // The map of timestamps of the last used file browser handlers. |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 195 | prefs->RegisterDictionaryPref(prefs::kLastUsedFileBrowserHandlers, |
| 196 | PrefService::UNSYNCABLE_PREF); |
[email protected] | c0a2128d9 | 2011-07-20 15:04:46 | [diff] [blame] | 197 | |
| 198 | // Use shared proxies default to off. |
| 199 | prefs->RegisterBooleanPref(prefs::kUseSharedProxies, |
| 200 | false, |
| 201 | PrefService::SYNCABLE_PREF); |
[email protected] | cc8f247 | 2011-08-01 07:14:46 | [diff] [blame] | 202 | |
| 203 | // OAuth1 all access token and secret pair. |
| 204 | prefs->RegisterStringPref(prefs::kOAuth1Token, |
| 205 | "", |
| 206 | PrefService::UNSYNCABLE_PREF); |
| 207 | prefs->RegisterStringPref(prefs::kOAuth1Secret, |
| 208 | "", |
| 209 | PrefService::UNSYNCABLE_PREF); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | void Preferences::Init(PrefService* prefs) { |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 213 | tap_to_click_enabled_.Init(prefs::kTapToClickEnabled, prefs, this); |
[email protected] | fe23d5a3 | 2010-05-28 02:43:04 | [diff] [blame] | 214 | accessibility_enabled_.Init(prefs::kAccessibilityEnabled, prefs, this); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 215 | sensitivity_.Init(prefs::kTouchpadSensitivity, prefs, this); |
[email protected] | 530cd62 | 2011-04-14 15:45:00 | [diff] [blame] | 216 | use_24hour_clock_.Init(prefs::kUse24HourClock, prefs, this); |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 217 | language_hotkey_next_engine_in_menu_.Init( |
| 218 | prefs::kLanguageHotkeyNextEngineInMenu, prefs, this); |
| 219 | language_hotkey_previous_engine_.Init( |
| 220 | prefs::kLanguageHotkeyPreviousEngine, prefs, this); |
[email protected] | 74b42fc1 | 2010-07-20 10:15:41 | [diff] [blame] | 221 | language_preferred_languages_.Init(prefs::kLanguagePreferredLanguages, |
| 222 | prefs, this); |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 223 | language_preload_engines_.Init(prefs::kLanguagePreloadEngines, prefs, this); |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 224 | for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 225 | language_chewing_boolean_prefs_[i].Init( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 226 | language_prefs::kChewingBooleanPrefs[i].pref_name, prefs, this); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 227 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 228 | for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 229 | language_chewing_multiple_choice_prefs_[i].Init( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 230 | language_prefs::kChewingMultipleChoicePrefs[i].pref_name, prefs, this); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 231 | } |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 232 | language_chewing_hsu_sel_key_type_.Init( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 233 | language_prefs::kChewingHsuSelKeyType.pref_name, prefs, this); |
| 234 | for (size_t i = 0; i < language_prefs::kNumChewingIntegerPrefs; ++i) { |
[email protected] | 15c5308 | 2010-06-03 03:28:21 | [diff] [blame] | 235 | language_chewing_integer_prefs_[i].Init( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 236 | language_prefs::kChewingIntegerPrefs[i].pref_name, prefs, this); |
[email protected] | 15c5308 | 2010-06-03 03:28:21 | [diff] [blame] | 237 | } |
[email protected] | 5095143 | 2010-03-31 12:12:42 | [diff] [blame] | 238 | language_hangul_keyboard_.Init(prefs::kLanguageHangulKeyboard, prefs, this); |
[email protected] | 33444cf | 2011-08-04 06:33:55 | [diff] [blame] | 239 | language_hangul_hanja_binding_keys_.Init( |
| 240 | prefs::kLanguageHangulHanjaBindingKeys, prefs, this); |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 241 | for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 242 | language_pinyin_boolean_prefs_[i].Init( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 243 | language_prefs::kPinyinBooleanPrefs[i].pref_name, prefs, this); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 244 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 245 | for (size_t i = 0; i < language_prefs::kNumPinyinIntegerPrefs; ++i) { |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 246 | language_pinyin_int_prefs_[i].Init( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 247 | language_prefs::kPinyinIntegerPrefs[i].pref_name, prefs, this); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 248 | } |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 249 | language_pinyin_double_pinyin_schema_.Init( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 250 | language_prefs::kPinyinDoublePinyinSchema.pref_name, prefs, this); |
| 251 | for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { |
[email protected] | 8a1ace2 | 2010-06-10 05:38:25 | [diff] [blame] | 252 | language_mozc_boolean_prefs_[i].Init( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 253 | language_prefs::kMozcBooleanPrefs[i].pref_name, prefs, this); |
[email protected] | 8a1ace2 | 2010-06-10 05:38:25 | [diff] [blame] | 254 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 255 | for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { |
[email protected] | 6e5c4b8 | 2010-05-24 08:18:44 | [diff] [blame] | 256 | language_mozc_multiple_choice_prefs_[i].Init( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 257 | language_prefs::kMozcMultipleChoicePrefs[i].pref_name, prefs, this); |
[email protected] | 6e5c4b8 | 2010-05-24 08:18:44 | [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] | 5403746 | 2010-06-22 02:06:23 | [diff] [blame] | 260 | language_mozc_integer_prefs_[i].Init( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 261 | language_prefs::kMozcIntegerPrefs[i].pref_name, prefs, this); |
[email protected] | 5403746 | 2010-06-22 02:06:23 | [diff] [blame] | 262 | } |
[email protected] | b5194dd3 | 2010-08-12 10:40:04 | [diff] [blame] | 263 | language_xkb_remap_search_key_to_.Init( |
| 264 | prefs::kLanguageXkbRemapSearchKeyTo, prefs, this); |
| 265 | language_xkb_remap_control_key_to_.Init( |
| 266 | prefs::kLanguageXkbRemapControlKeyTo, prefs, this); |
| 267 | language_xkb_remap_alt_key_to_.Init( |
| 268 | prefs::kLanguageXkbRemapAltKeyTo, prefs, this); |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 269 | language_xkb_auto_repeat_enabled_.Init( |
| 270 | prefs::kLanguageXkbAutoRepeatEnabled, prefs, this); |
| 271 | language_xkb_auto_repeat_delay_pref_.Init( |
[email protected] | 4743dad | 2010-08-30 01:41:07 | [diff] [blame] | 272 | prefs::kLanguageXkbAutoRepeatDelay, prefs, this); |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 273 | language_xkb_auto_repeat_interval_pref_.Init( |
[email protected] | 4743dad | 2010-08-30 01:41:07 | [diff] [blame] | 274 | prefs::kLanguageXkbAutoRepeatInterval, prefs, this); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 275 | |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 276 | enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, this); |
| 277 | |
[email protected] | c0a2128d9 | 2011-07-20 15:04:46 | [diff] [blame] | 278 | use_shared_proxies_.Init(prefs::kUseSharedProxies, prefs, this); |
| 279 | |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 280 | // Initialize preferences to currently saved state. |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 281 | NotifyPrefChanged(NULL); |
[email protected] | 26012e2 | 2010-12-01 06:44:27 | [diff] [blame] | 282 | |
[email protected] | f410d61 | 2011-08-05 04:32:24 | [diff] [blame] | 283 | // Initialize virtual keyboard settings to currently saved state. |
| 284 | UpdateVirturalKeyboardPreference(prefs); |
| 285 | |
[email protected] | 26012e2 | 2010-12-01 06:44:27 | [diff] [blame] | 286 | // If a guest is logged in, initialize the prefs as if this is the first |
| 287 | // login. |
| 288 | if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |
| 289 | LoginUtils::Get()->SetFirstLoginPrefs(prefs); |
| 290 | } |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 291 | } |
| 292 | |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 293 | void Preferences::Observe(int type, |
[email protected] | 5095143 | 2010-03-31 12:12:42 | [diff] [blame] | 294 | const NotificationSource& source, |
| 295 | const NotificationDetails& details) { |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 296 | if (type == chrome::NOTIFICATION_PREF_CHANGED) |
[email protected] | 57ecc4b | 2010-08-11 03:02:51 | [diff] [blame] | 297 | NotifyPrefChanged(Details<std::string>(details).ptr()); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 298 | } |
| 299 | |
[email protected] | 57ecc4b | 2010-08-11 03:02:51 | [diff] [blame] | 300 | void Preferences::NotifyPrefChanged(const std::string* pref_name) { |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 301 | if (!pref_name || *pref_name == prefs::kTapToClickEnabled) { |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 302 | bool enabled = tap_to_click_enabled_.GetValue(); |
[email protected] | 1cbfb3b | 2011-07-11 23:34:08 | [diff] [blame] | 303 | system::touchpad_settings::SetTapToClick(enabled); |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 304 | if (pref_name) |
| 305 | UMA_HISTOGRAM_BOOLEAN("Touchpad.TapToClick.Changed", enabled); |
| 306 | else |
| 307 | UMA_HISTOGRAM_BOOLEAN("Touchpad.TapToClick.Started", enabled); |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 308 | } |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 309 | if (!pref_name || *pref_name == prefs::kTouchpadSensitivity) { |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 310 | int sensitivity = sensitivity_.GetValue(); |
[email protected] | 1cbfb3b | 2011-07-11 23:34:08 | [diff] [blame] | 311 | system::touchpad_settings::SetSensitivity(sensitivity); |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 312 | if (pref_name) { |
| 313 | UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 314 | "Touchpad.Sensitivity.Changed", sensitivity, 1, 5, 5); |
| 315 | } else { |
| 316 | UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 317 | "Touchpad.Sensitivity.Started", sensitivity, 1, 5, 5); |
| 318 | } |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 319 | } |
[email protected] | 8be9ff2 | 2010-06-08 02:13:54 | [diff] [blame] | 320 | |
| 321 | // We don't handle prefs::kLanguageCurrentInputMethod and PreviousInputMethod |
| 322 | // here. |
| 323 | |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 324 | if (!pref_name || *pref_name == prefs::kLanguageHotkeyNextEngineInMenu) { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 325 | SetLanguageConfigStringListAsCSV( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 326 | language_prefs::kHotKeySectionName, |
| 327 | language_prefs::kNextEngineInMenuConfigName, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 328 | language_hotkey_next_engine_in_menu_.GetValue()); |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 329 | } |
| 330 | if (!pref_name || *pref_name == prefs::kLanguageHotkeyPreviousEngine) { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 331 | SetLanguageConfigStringListAsCSV( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 332 | language_prefs::kHotKeySectionName, |
| 333 | language_prefs::kPreviousEngineConfigName, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 334 | language_hotkey_previous_engine_.GetValue()); |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 335 | } |
[email protected] | 74b42fc1 | 2010-07-20 10:15:41 | [diff] [blame] | 336 | if (!pref_name || *pref_name == prefs::kLanguagePreferredLanguages) { |
| 337 | // Unlike kLanguagePreloadEngines and some other input method |
| 338 | // preferencs, we don't need to send this to ibus-daemon. |
| 339 | } |
[email protected] | a6e9077 | 2011-02-09 05:38:54 | [diff] [blame] | 340 | |
| 341 | // Here, we set up the the modifier key mapping. This has to be done |
| 342 | // before changing the current keyboard layout, so that the modifier key |
| 343 | // preference is properly preserved. For this reason, we should do this |
| 344 | // before setting preload engines, that could change the current |
| 345 | // keyboard layout as needed. |
| 346 | if (!pref_name || (*pref_name == prefs::kLanguageXkbRemapSearchKeyTo || |
| 347 | *pref_name == prefs::kLanguageXkbRemapControlKeyTo || |
| 348 | *pref_name == prefs::kLanguageXkbRemapAltKeyTo)) { |
| 349 | UpdateModifierKeyMapping(); |
| 350 | } |
| 351 | if (!pref_name || *pref_name == prefs::kLanguageXkbAutoRepeatEnabled) { |
| 352 | const bool enabled = language_xkb_auto_repeat_enabled_.GetValue(); |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 353 | input_method::SetAutoRepeatEnabled(enabled); |
[email protected] | a6e9077 | 2011-02-09 05:38:54 | [diff] [blame] | 354 | } |
| 355 | if (!pref_name || ((*pref_name == prefs::kLanguageXkbAutoRepeatDelay) || |
| 356 | (*pref_name == prefs::kLanguageXkbAutoRepeatInterval))) { |
| 357 | UpdateAutoRepeatRate(); |
| 358 | } |
| 359 | |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 360 | if (!pref_name || *pref_name == prefs::kLanguagePreloadEngines) { |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 361 | SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, |
| 362 | language_prefs::kPreloadEnginesConfigName, |
[email protected] | d01bb807 | 2010-04-12 13:00:15 | [diff] [blame] | 363 | language_preload_engines_.GetValue()); |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 364 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 365 | for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { |
| 366 | if (!pref_name || |
| 367 | *pref_name == language_prefs::kChewingBooleanPrefs[i].pref_name) { |
| 368 | SetLanguageConfigBoolean( |
| 369 | language_prefs::kChewingSectionName, |
| 370 | language_prefs::kChewingBooleanPrefs[i].ibus_config_name, |
| 371 | language_chewing_boolean_prefs_[i].GetValue()); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 372 | } |
| 373 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 374 | for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { |
| 375 | if (!pref_name || |
| 376 | *pref_name == |
| 377 | language_prefs::kChewingMultipleChoicePrefs[i].pref_name) { |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 378 | SetLanguageConfigString( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 379 | language_prefs::kChewingSectionName, |
| 380 | language_prefs::kChewingMultipleChoicePrefs[i].ibus_config_name, |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 381 | language_chewing_multiple_choice_prefs_[i].GetValue()); |
| 382 | } |
| 383 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 384 | if (!pref_name || |
| 385 | *pref_name == language_prefs::kChewingHsuSelKeyType.pref_name) { |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 386 | SetLanguageConfigInteger( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 387 | language_prefs::kChewingSectionName, |
| 388 | language_prefs::kChewingHsuSelKeyType.ibus_config_name, |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 389 | language_chewing_hsu_sel_key_type_.GetValue()); |
| 390 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 391 | for (size_t i = 0; i < language_prefs::kNumChewingIntegerPrefs; ++i) { |
| 392 | if (!pref_name || |
| 393 | *pref_name == language_prefs::kChewingIntegerPrefs[i].pref_name) { |
| 394 | SetLanguageConfigInteger( |
| 395 | language_prefs::kChewingSectionName, |
| 396 | language_prefs::kChewingIntegerPrefs[i].ibus_config_name, |
| 397 | language_chewing_integer_prefs_[i].GetValue()); |
[email protected] | 15c5308 | 2010-06-03 03:28:21 | [diff] [blame] | 398 | } |
| 399 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 400 | if (!pref_name || |
| 401 | *pref_name == prefs::kLanguageHangulKeyboard) { |
| 402 | SetLanguageConfigString(language_prefs::kHangulSectionName, |
| 403 | language_prefs::kHangulKeyboardConfigName, |
[email protected] | 5095143 | 2010-03-31 12:12:42 | [diff] [blame] | 404 | language_hangul_keyboard_.GetValue()); |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 405 | } |
[email protected] | 33444cf | 2011-08-04 06:33:55 | [diff] [blame] | 406 | if (!pref_name || *pref_name == prefs::kLanguageHangulHanjaBindingKeys) { |
| 407 | SetLanguageConfigString(language_prefs::kHangulSectionName, |
| 408 | language_prefs::kHangulHanjaBindingKeysConfigName, |
| 409 | language_hangul_hanja_binding_keys_.GetValue()); |
| 410 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 411 | for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { |
| 412 | if (!pref_name || |
| 413 | *pref_name == language_prefs::kPinyinBooleanPrefs[i].pref_name) { |
| 414 | SetLanguageConfigBoolean( |
| 415 | language_prefs::kPinyinSectionName, |
| 416 | language_prefs::kPinyinBooleanPrefs[i].ibus_config_name, |
| 417 | language_pinyin_boolean_prefs_[i].GetValue()); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 418 | } |
| 419 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 420 | for (size_t i = 0; i < language_prefs::kNumPinyinIntegerPrefs; ++i) { |
| 421 | if (!pref_name || |
| 422 | *pref_name == language_prefs::kPinyinIntegerPrefs[i].pref_name) { |
| 423 | SetLanguageConfigInteger( |
| 424 | language_prefs::kPinyinSectionName, |
| 425 | language_prefs::kPinyinIntegerPrefs[i].ibus_config_name, |
| 426 | language_pinyin_int_prefs_[i].GetValue()); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 427 | } |
| 428 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 429 | if (!pref_name || |
| 430 | *pref_name == language_prefs::kPinyinDoublePinyinSchema.pref_name) { |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 431 | SetLanguageConfigInteger( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 432 | language_prefs::kPinyinSectionName, |
| 433 | language_prefs::kPinyinDoublePinyinSchema.ibus_config_name, |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 434 | language_pinyin_double_pinyin_schema_.GetValue()); |
| 435 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 436 | for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { |
| 437 | if (!pref_name || |
| 438 | *pref_name == language_prefs::kMozcBooleanPrefs[i].pref_name) { |
| 439 | SetLanguageConfigBoolean( |
| 440 | language_prefs::kMozcSectionName, |
| 441 | language_prefs::kMozcBooleanPrefs[i].ibus_config_name, |
| 442 | language_mozc_boolean_prefs_[i].GetValue()); |
[email protected] | 8a1ace2 | 2010-06-10 05:38:25 | [diff] [blame] | 443 | } |
| 444 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 445 | for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { |
| 446 | if (!pref_name || |
| 447 | *pref_name == language_prefs::kMozcMultipleChoicePrefs[i].pref_name) { |
[email protected] | 6e5c4b8 | 2010-05-24 08:18:44 | [diff] [blame] | 448 | SetLanguageConfigString( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 449 | language_prefs::kMozcSectionName, |
| 450 | language_prefs::kMozcMultipleChoicePrefs[i].ibus_config_name, |
[email protected] | 6e5c4b8 | 2010-05-24 08:18:44 | [diff] [blame] | 451 | language_mozc_multiple_choice_prefs_[i].GetValue()); |
| 452 | } |
| 453 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 454 | for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { |
| 455 | if (!pref_name || |
| 456 | *pref_name == language_prefs::kMozcIntegerPrefs[i].pref_name) { |
| 457 | SetLanguageConfigInteger( |
| 458 | language_prefs::kMozcSectionName, |
| 459 | language_prefs::kMozcIntegerPrefs[i].ibus_config_name, |
| 460 | language_mozc_integer_prefs_[i].GetValue()); |
[email protected] | 5403746 | 2010-06-22 02:06:23 | [diff] [blame] | 461 | } |
| 462 | } |
[email protected] | 4793c94 | 2010-09-21 23:17:17 | [diff] [blame] | 463 | |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 464 | // Init or update power manager config. |
| 465 | if (!pref_name || *pref_name == prefs::kEnableScreenLock) { |
| 466 | CrosLibrary::Get()->GetPowerLibrary()->EnableScreenLock( |
| 467 | enable_screen_lock_.GetValue()); |
| 468 | } |
[email protected] | c0a2128d9 | 2011-07-20 15:04:46 | [diff] [blame] | 469 | |
| 470 | if (!pref_name || *pref_name == prefs::kUseSharedProxies) { |
| 471 | g_browser_process->chromeos_proxy_config_service_impl()-> |
| 472 | UISetUseSharedProxies(use_shared_proxies_.GetValue()); |
| 473 | } |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 474 | } |
| 475 | |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 476 | void Preferences::SetLanguageConfigBoolean(const char* section, |
| 477 | const char* name, |
| 478 | bool value) { |
[email protected] | dc7b094 | 2011-06-15 06:45:53 | [diff] [blame] | 479 | input_method::ImeConfigValue config; |
| 480 | config.type = input_method::ImeConfigValue::kValueTypeBool; |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 481 | config.bool_value = value; |
[email protected] | c8d4e946 | 2011-06-29 23:18:57 | [diff] [blame] | 482 | input_method::InputMethodManager::GetInstance()-> |
[email protected] | 60b0768 | 2010-06-17 08:45:28 | [diff] [blame] | 483 | SetImeConfig(section, name, config); |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 484 | } |
| 485 | |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 486 | void Preferences::SetLanguageConfigInteger(const char* section, |
| 487 | const char* name, |
| 488 | int value) { |
[email protected] | dc7b094 | 2011-06-15 06:45:53 | [diff] [blame] | 489 | input_method::ImeConfigValue config; |
| 490 | config.type = input_method::ImeConfigValue::kValueTypeInt; |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 491 | config.int_value = value; |
[email protected] | c8d4e946 | 2011-06-29 23:18:57 | [diff] [blame] | 492 | input_method::InputMethodManager::GetInstance()-> |
[email protected] | 60b0768 | 2010-06-17 08:45:28 | [diff] [blame] | 493 | SetImeConfig(section, name, config); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 494 | } |
| 495 | |
[email protected] | 5095143 | 2010-03-31 12:12:42 | [diff] [blame] | 496 | void Preferences::SetLanguageConfigString(const char* section, |
| 497 | const char* name, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 498 | const std::string& value) { |
[email protected] | dc7b094 | 2011-06-15 06:45:53 | [diff] [blame] | 499 | input_method::ImeConfigValue config; |
| 500 | config.type = input_method::ImeConfigValue::kValueTypeString; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 501 | config.string_value = value; |
[email protected] | c8d4e946 | 2011-06-29 23:18:57 | [diff] [blame] | 502 | input_method::InputMethodManager::GetInstance()-> |
[email protected] | 60b0768 | 2010-06-17 08:45:28 | [diff] [blame] | 503 | SetImeConfig(section, name, config); |
[email protected] | 5095143 | 2010-03-31 12:12:42 | [diff] [blame] | 504 | } |
| 505 | |
[email protected] | 2c25ddfd | 2010-04-09 10:35:55 | [diff] [blame] | 506 | void Preferences::SetLanguageConfigStringList( |
| 507 | const char* section, |
| 508 | const char* name, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 509 | const std::vector<std::string>& values) { |
[email protected] | dc7b094 | 2011-06-15 06:45:53 | [diff] [blame] | 510 | input_method::ImeConfigValue config; |
| 511 | config.type = input_method::ImeConfigValue::kValueTypeStringList; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 512 | for (size_t i = 0; i < values.size(); ++i) |
| 513 | config.string_list_value.push_back(values[i]); |
| 514 | |
[email protected] | c8d4e946 | 2011-06-29 23:18:57 | [diff] [blame] | 515 | input_method::InputMethodManager::GetInstance()-> |
[email protected] | 60b0768 | 2010-06-17 08:45:28 | [diff] [blame] | 516 | SetImeConfig(section, name, config); |
[email protected] | 2c25ddfd | 2010-04-09 10:35:55 | [diff] [blame] | 517 | } |
| 518 | |
[email protected] | d01bb807 | 2010-04-12 13:00:15 | [diff] [blame] | 519 | void Preferences::SetLanguageConfigStringListAsCSV(const char* section, |
| 520 | const char* name, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 521 | const std::string& value) { |
[email protected] | e24c2c9 | 2010-10-23 01:39:24 | [diff] [blame] | 522 | VLOG(1) << "Setting " << name << " to '" << value << "'"; |
[email protected] | d01bb807 | 2010-04-12 13:00:15 | [diff] [blame] | 523 | |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 524 | std::vector<std::string> split_values; |
| 525 | if (!value.empty()) |
[email protected] | 76eb024 | 2010-10-14 00:35:36 | [diff] [blame] | 526 | base::SplitString(value, ',', &split_values); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 527 | |
[email protected] | 2c25ddfd | 2010-04-09 10:35:55 | [diff] [blame] | 528 | // 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] | 529 | // config. |
| 530 | SetLanguageConfigStringList(section, name, split_values); |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 531 | } |
| 532 | |
[email protected] | b5194dd3 | 2010-08-12 10:40:04 | [diff] [blame] | 533 | void Preferences::UpdateModifierKeyMapping() { |
| 534 | const int search_remap = language_xkb_remap_search_key_to_.GetValue(); |
| 535 | const int control_remap = language_xkb_remap_control_key_to_.GetValue(); |
| 536 | const int alt_remap = language_xkb_remap_alt_key_to_.GetValue(); |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 537 | if ((search_remap < input_method::kNumModifierKeys) && (search_remap >= 0) && |
| 538 | (control_remap < input_method::kNumModifierKeys) && |
| 539 | (control_remap >= 0) && |
| 540 | (alt_remap < input_method::kNumModifierKeys) && (alt_remap >= 0)) { |
| 541 | input_method::ModifierMap modifier_map; |
[email protected] | b5194dd3 | 2010-08-12 10:40:04 | [diff] [blame] | 542 | modifier_map.push_back( |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 543 | input_method::ModifierKeyPair( |
| 544 | input_method::kSearchKey, |
| 545 | input_method::ModifierKey(search_remap))); |
[email protected] | b5194dd3 | 2010-08-12 10:40:04 | [diff] [blame] | 546 | modifier_map.push_back( |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 547 | input_method::ModifierKeyPair( |
| 548 | input_method::kLeftControlKey, |
| 549 | input_method::ModifierKey(control_remap))); |
[email protected] | b5194dd3 | 2010-08-12 10:40:04 | [diff] [blame] | 550 | modifier_map.push_back( |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 551 | input_method::ModifierKeyPair( |
| 552 | input_method::kLeftAltKey, |
| 553 | input_method::ModifierKey(alt_remap))); |
| 554 | input_method::RemapModifierKeys(modifier_map); |
[email protected] | b5194dd3 | 2010-08-12 10:40:04 | [diff] [blame] | 555 | } else { |
| 556 | LOG(ERROR) << "Failed to remap modifier keys. Unexpected value(s): " |
| 557 | << search_remap << ", " << control_remap << ", " << alt_remap; |
| 558 | } |
| 559 | } |
| 560 | |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 561 | void Preferences::UpdateAutoRepeatRate() { |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 562 | input_method::AutoRepeatRate rate; |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 563 | rate.initial_delay_in_ms = language_xkb_auto_repeat_delay_pref_.GetValue(); |
| 564 | rate.repeat_interval_in_ms = |
| 565 | language_xkb_auto_repeat_interval_pref_.GetValue(); |
| 566 | DCHECK(rate.initial_delay_in_ms > 0); |
| 567 | DCHECK(rate.repeat_interval_in_ms > 0); |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 568 | input_method::SetAutoRepeatRate(rate); |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 569 | } |
| 570 | |
[email protected] | f410d61 | 2011-08-05 04:32:24 | [diff] [blame] | 571 | void Preferences::UpdateVirturalKeyboardPreference(PrefService* prefs) { |
| 572 | const DictionaryValue* virtual_keyboard_pref = |
| 573 | prefs->GetDictionary(prefs::kLanguagePreferredVirtualKeyboard); |
| 574 | DCHECK(virtual_keyboard_pref); |
| 575 | |
| 576 | input_method::InputMethodManager* input_method_manager = |
| 577 | input_method::InputMethodManager::GetInstance(); |
| 578 | input_method_manager->ClearAllVirtualKeyboardPreferences(); |
| 579 | |
| 580 | std::string url; |
[email protected] | b336257 | 2011-08-17 09:28:50 | [diff] [blame] | 581 | std::vector<std::string> layouts_to_remove; |
[email protected] | f410d61 | 2011-08-05 04:32:24 | [diff] [blame] | 582 | for (DictionaryValue::key_iterator iter = virtual_keyboard_pref->begin_keys(); |
| 583 | iter != virtual_keyboard_pref->end_keys(); |
| 584 | ++iter) { |
[email protected] | b336257 | 2011-08-17 09:28:50 | [diff] [blame] | 585 | const std::string& layout_id = *iter; // e.g. "us", "handwriting-vk" |
| 586 | if (!virtual_keyboard_pref->GetString(layout_id, &url)) |
[email protected] | f410d61 | 2011-08-05 04:32:24 | [diff] [blame] | 587 | continue; |
[email protected] | b336257 | 2011-08-17 09:28:50 | [diff] [blame] | 588 | if (!input_method_manager->SetVirtualKeyboardPreference( |
| 589 | layout_id, GURL(url))) { |
| 590 | // Either |layout_id| or |url| is invalid. Remove the key from |prefs| |
| 591 | // later. |
| 592 | layouts_to_remove.push_back(layout_id); |
[email protected] | 148994e | 2011-08-17 10:01:48 | [diff] [blame] | 593 | LOG(ERROR) << "Removing invalid virtual keyboard pref: layout=" |
| 594 | << layout_id; |
[email protected] | b336257 | 2011-08-17 09:28:50 | [diff] [blame] | 595 | } |
| 596 | } |
| 597 | |
| 598 | // Remove invalid prefs. |
| 599 | DictionaryPrefUpdate updater(prefs, prefs::kLanguagePreferredVirtualKeyboard); |
| 600 | DictionaryValue* pref_value = updater.Get(); |
| 601 | for (size_t i = 0; i < layouts_to_remove.size(); ++i) { |
| 602 | pref_value->RemoveWithoutPathExpansion(layouts_to_remove[i], NULL); |
[email protected] | f410d61 | 2011-08-05 04:32:24 | [diff] [blame] | 603 | } |
| 604 | } |
| 605 | |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 606 | } // namespace chromeos |