[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] | 20d2a79d | 2012-03-16 23:01:02 | [diff] [blame] | 7 | #include "base/chromeos/chromeos_version.h" |
[email protected] | 775caec | 2011-09-01 17:14:32 | [diff] [blame] | 8 | #include "base/command_line.h" |
[email protected] | 530cd62 | 2011-04-14 15:45:00 | [diff] [blame] | 9 | #include "base/i18n/time_formatting.h" |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 10 | #include "base/metrics/histogram.h" |
[email protected] | 0abb6712 | 2012-12-12 11:36:05 | [diff] [blame] | 11 | #include "base/prefs/public/pref_member.h" |
[email protected] | 4e5ae20f | 2010-09-24 04:52:11 | [diff] [blame] | 12 | #include "base/string_split.h" |
[email protected] | de1528d1a | 2012-05-14 10:36:15 | [diff] [blame] | 13 | #include "base/string_util.h" |
[email protected] | 5095143 | 2010-03-31 12:12:42 | [diff] [blame] | 14 | #include "base/utf_string_conversions.h" |
[email protected] | c0a2128d9 | 2011-07-20 15:04:46 | [diff] [blame] | 15 | #include "chrome/browser/browser_process.h" |
[email protected] | 15de814 | 2012-10-11 06:00:54 | [diff] [blame] | 16 | #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
[email protected] | c02a424 | 2012-12-11 18:36:32 | [diff] [blame] | 17 | #include "chrome/browser/chromeos/input_method/input_method_configuration.h" |
[email protected] | c8d4e946 | 2011-06-29 23:18:57 | [diff] [blame] | 18 | #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
[email protected] | 9199bd5 | 2010-07-01 05:04:41 | [diff] [blame] | 19 | #include "chrome/browser/chromeos/input_method/input_method_util.h" |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 20 | #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
[email protected] | 26012e2 | 2010-12-01 06:44:27 | [diff] [blame] | 21 | #include "chrome/browser/chromeos/login/login_utils.h" |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 22 | #include "chrome/browser/chromeos/login/user_manager.h" |
[email protected] | 595a5ed | 2012-05-04 00:39:16 | [diff] [blame] | 23 | #include "chrome/browser/chromeos/system/drm_settings.h" |
[email protected] | 82eb8ec | 2011-12-20 22:24:33 | [diff] [blame] | 24 | #include "chrome/browser/chromeos/system/input_device_settings.h" |
[email protected] | 58a4677 | 2012-07-11 02:16:08 | [diff] [blame] | 25 | #include "chrome/browser/chromeos/system/power_manager_settings.h" |
[email protected] | de1528d1a | 2012-05-14 10:36:15 | [diff] [blame] | 26 | #include "chrome/browser/chromeos/system/statistics_provider.h" |
[email protected] | 155e1b4 | 2012-07-14 03:06:01 | [diff] [blame] | 27 | #include "chrome/browser/download/download_util.h" |
[email protected] | 37858e5 | 2010-08-26 00:22:02 | [diff] [blame] | 28 | #include "chrome/browser/prefs/pref_service.h" |
[email protected] | b336257 | 2011-08-17 09:28:50 | [diff] [blame] | 29 | #include "chrome/browser/prefs/scoped_user_pref_update.h" |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 30 | #include "chrome/common/chrome_notification_types.h" |
[email protected] | 775caec | 2011-09-01 17:14:32 | [diff] [blame] | 31 | #include "chrome/common/chrome_switches.h" |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 32 | #include "chrome/common/pref_names.h" |
[email protected] | 6f96cbcb | 2011-11-04 02:26:07 | [diff] [blame] | 33 | #include "googleurl/src/gurl.h" |
[email protected] | 153472d7 | 2012-09-04 21:33:02 | [diff] [blame] | 34 | #include "ui/base/events/event_constants.h" |
[email protected] | e4cc483 | 2012-11-05 17:33:14 | [diff] [blame] | 35 | #include "ui/base/events/event_utils.h" |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 36 | #include "unicode/timezone.h" |
| 37 | |
[email protected] | de1528d1a | 2012-05-14 10:36:15 | [diff] [blame] | 38 | namespace chromeos { |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 39 | |
[email protected] | 9199bd5 | 2010-07-01 05:04:41 | [diff] [blame] | 40 | static const char kFallbackInputMethodLocale[] = "en-US"; |
[email protected] | 4793c94 | 2010-09-21 23:17:17 | [diff] [blame] | 41 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 42 | Preferences::Preferences() |
[email protected] | 155e1b4 | 2012-07-14 03:06:01 | [diff] [blame] | 43 | : prefs_(NULL), |
[email protected] | c02a424 | 2012-12-11 18:36:32 | [diff] [blame] | 44 | input_method_manager_(input_method::GetInputMethodManager()) { |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | Preferences::Preferences(input_method::InputMethodManager* input_method_manager) |
| 48 | : input_method_manager_(input_method_manager) { |
| 49 | } |
[email protected] | d743a598 | 2010-11-08 17:54:09 | [diff] [blame] | 50 | |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 51 | Preferences::~Preferences() { |
| 52 | prefs_->RemoveObserver(this); |
| 53 | } |
[email protected] | 9199bd5 | 2010-07-01 05:04:41 | [diff] [blame] | 54 | |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 55 | // static |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 56 | void Preferences::RegisterUserPrefs(PrefServiceSyncable* prefs) { |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 57 | std::string hardware_keyboard_id; |
| 58 | // TODO(yusukes): Remove the runtime hack. |
| 59 | if (base::chromeos::IsRunningOnChromeOS()) { |
| 60 | input_method::InputMethodManager* manager = |
[email protected] | c02a424 | 2012-12-11 18:36:32 | [diff] [blame] | 61 | input_method::GetInputMethodManager(); |
[email protected] | 1e019ea | 2012-08-09 00:54:04 | [diff] [blame] | 62 | if (manager) { |
| 63 | hardware_keyboard_id = |
| 64 | manager->GetInputMethodUtil()->GetHardwareInputMethodId(); |
| 65 | } |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 66 | } else { |
| 67 | hardware_keyboard_id = "xkb:us::eng"; // only for testing. |
| 68 | } |
[email protected] | a9a8181 | 2011-09-16 11:01:17 | [diff] [blame] | 69 | |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 70 | prefs->RegisterBooleanPref(prefs::kTapToClickEnabled, |
[email protected] | 392abf5 | 2012-09-25 00:21:58 | [diff] [blame] | 71 | true, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 72 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | 1b46af0 | 2012-10-31 05:23:54 | [diff] [blame] | 73 | prefs->RegisterBooleanPref(prefs::kTapDraggingEnabled, |
| 74 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 75 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | 190349fd | 2012-05-02 00:10:47 | [diff] [blame] | 76 | prefs->RegisterBooleanPref(prefs::kEnableTouchpadThreeFingerClick, |
| 77 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 78 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | fbc176b6 | 2012-10-27 02:19:58 | [diff] [blame] | 79 | prefs->RegisterBooleanPref(prefs::kEnableTouchpadThreeFingerSwipe, |
| 80 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 81 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | 6100873 | 2012-11-27 10:36:05 | [diff] [blame] | 82 | prefs->RegisterBooleanPref( |
| 83 | prefs::kNaturalScroll, |
| 84 | CommandLine::ForCurrentProcess()->HasSwitch( |
| 85 | switches::kNaturalScrollDefault), |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 86 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | 0027fde1 | 2011-12-15 05:09:38 | [diff] [blame] | 87 | prefs->RegisterBooleanPref(prefs::kPrimaryMouseButtonRight, |
| 88 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 89 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 90 | prefs->RegisterBooleanPref(prefs::kLabsMediaplayerEnabled, |
| 91 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 92 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 93 | prefs->RegisterBooleanPref(prefs::kLabsAdvancedFilesystemEnabled, |
| 94 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 95 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | 27f20d5 | 2010-09-18 00:59:31 | [diff] [blame] | 96 | // Check if the accessibility pref is already registered, which can happen |
| 97 | // in WizardController::RegisterPrefs. We still want to try to register |
| 98 | // the pref here in case of Chrome/Linux with ChromeOS=1. |
[email protected] | 7ef254b | 2011-12-08 03:24:45 | [diff] [blame] | 99 | if (prefs->FindPreference(prefs::kSpokenFeedbackEnabled) == NULL) { |
| 100 | prefs->RegisterBooleanPref(prefs::kSpokenFeedbackEnabled, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 101 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 102 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | 27f20d5 | 2010-09-18 00:59:31 | [diff] [blame] | 103 | } |
[email protected] | 487ba146 | 2012-01-05 03:13:09 | [diff] [blame] | 104 | if (prefs->FindPreference(prefs::kHighContrastEnabled) == NULL) { |
| 105 | prefs->RegisterBooleanPref(prefs::kHighContrastEnabled, |
| 106 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 107 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | 487ba146 | 2012-01-05 03:13:09 | [diff] [blame] | 108 | } |
[email protected] | a53804ba | 2012-12-17 12:07:42 | [diff] [blame] | 109 | if (prefs->FindPreference(prefs::kScreenMagnifierEnabled) == NULL) { |
| 110 | prefs->RegisterBooleanPref(prefs::kScreenMagnifierEnabled, |
| 111 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 112 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | a53804ba | 2012-12-17 12:07:42 | [diff] [blame] | 113 | } |
[email protected] | dddc4a07 | 2012-10-16 19:30:03 | [diff] [blame] | 114 | if (prefs->FindPreference(prefs::kScreenMagnifierScale) == NULL) { |
| 115 | prefs->RegisterDoublePref(prefs::kScreenMagnifierScale, |
| 116 | std::numeric_limits<double>::min(), |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 117 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | dddc4a07 | 2012-10-16 19:30:03 | [diff] [blame] | 118 | } |
[email protected] | 5c85d5d | 2012-12-03 14:22:56 | [diff] [blame] | 119 | if (prefs->FindPreference(prefs::kShouldAlwaysShowAccessibilityMenu) == |
| 120 | NULL) { |
| 121 | prefs->RegisterBooleanPref(prefs::kShouldAlwaysShowAccessibilityMenu, |
[email protected] | 5100990 | 2012-12-03 18:37:31 | [diff] [blame] | 122 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 123 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | 77f7c13 | 2012-11-15 06:52:54 | [diff] [blame] | 124 | } |
[email protected] | 487ba146 | 2012-01-05 03:13:09 | [diff] [blame] | 125 | if (prefs->FindPreference(prefs::kVirtualKeyboardEnabled) == NULL) { |
| 126 | prefs->RegisterBooleanPref(prefs::kVirtualKeyboardEnabled, |
| 127 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 128 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | 487ba146 | 2012-01-05 03:13:09 | [diff] [blame] | 129 | } |
[email protected] | 563fb5f | 2012-03-31 00:39:28 | [diff] [blame] | 130 | prefs->RegisterIntegerPref(prefs::kMouseSensitivity, |
| 131 | 3, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 132 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 133 | prefs->RegisterIntegerPref(prefs::kTouchpadSensitivity, |
| 134 | 3, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 135 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | 530cd62 | 2011-04-14 15:45:00 | [diff] [blame] | 136 | prefs->RegisterBooleanPref(prefs::kUse24HourClock, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 137 | base::GetHourClockType() == base::k24HourClock, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 138 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | e1619ee0 | 2012-10-22 08:14:49 | [diff] [blame] | 139 | prefs->RegisterBooleanPref(prefs::kDisableDrive, |
[email protected] | 3cbae79b0 | 2012-03-21 19:21:49 | [diff] [blame] | 140 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 141 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | e1619ee0 | 2012-10-22 08:14:49 | [diff] [blame] | 142 | prefs->RegisterBooleanPref(prefs::kDisableDriveOverCellular, |
[email protected] | 3cbae79b0 | 2012-03-21 19:21:49 | [diff] [blame] | 143 | true, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 144 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | e1619ee0 | 2012-10-22 08:14:49 | [diff] [blame] | 145 | prefs->RegisterBooleanPref(prefs::kDisableDriveHostedFiles, |
[email protected] | 3cbae79b0 | 2012-03-21 19:21:49 | [diff] [blame] | 146 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 147 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 148 | // We don't sync prefs::kLanguageCurrentInputMethod and PreviousInputMethod |
| 149 | // because they're just used to track the logout state of the device. |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 150 | prefs->RegisterStringPref(prefs::kLanguageCurrentInputMethod, |
| 151 | "", |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 152 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 153 | prefs->RegisterStringPref(prefs::kLanguagePreviousInputMethod, |
| 154 | "", |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 155 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 156 | // We don't sync the list of input methods and preferred languages since a |
| 157 | // user might use two or more devices with different hardware keyboards. |
| 158 | // crosbug.com/15181 |
[email protected] | c5d4543 | 2010-09-07 08:25:35 | [diff] [blame] | 159 | prefs->RegisterStringPref(prefs::kLanguagePreferredLanguages, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 160 | kFallbackInputMethodLocale, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 161 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 162 | prefs->RegisterStringPref(prefs::kLanguagePreloadEngines, |
| 163 | hardware_keyboard_id, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 164 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | 797c680 | 2012-09-20 10:36:13 | [diff] [blame] | 165 | prefs->RegisterStringPref(prefs::kLanguageFilteredExtensionImes, |
| 166 | "", |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 167 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 168 | for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { |
| 169 | prefs->RegisterBooleanPref( |
| 170 | language_prefs::kChewingBooleanPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 171 | language_prefs::kChewingBooleanPrefs[i].default_pref_value, |
[email protected] | da9858f | 2012-04-09 14:50:03 | [diff] [blame] | 172 | language_prefs::kChewingBooleanPrefs[i].sync_status); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 173 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 174 | for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 175 | prefs->RegisterStringPref( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 176 | language_prefs::kChewingMultipleChoicePrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 177 | language_prefs::kChewingMultipleChoicePrefs[i].default_pref_value, |
[email protected] | da9858f | 2012-04-09 14:50:03 | [diff] [blame] | 178 | language_prefs::kChewingMultipleChoicePrefs[i].sync_status); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 179 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 180 | prefs->RegisterIntegerPref( |
| 181 | language_prefs::kChewingHsuSelKeyType.pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 182 | language_prefs::kChewingHsuSelKeyType.default_pref_value, |
[email protected] | da9858f | 2012-04-09 14:50:03 | [diff] [blame] | 183 | language_prefs::kChewingHsuSelKeyType.sync_status); |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 184 | |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 185 | for (size_t i = 0; i < language_prefs::kNumChewingIntegerPrefs; ++i) { |
| 186 | prefs->RegisterIntegerPref( |
| 187 | language_prefs::kChewingIntegerPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 188 | language_prefs::kChewingIntegerPrefs[i].default_pref_value, |
[email protected] | da9858f | 2012-04-09 14:50:03 | [diff] [blame] | 189 | language_prefs::kChewingIntegerPrefs[i].sync_status); |
[email protected] | 15c5308 | 2010-06-03 03:28:21 | [diff] [blame] | 190 | } |
[email protected] | 20ce516d | 2010-06-18 02:20:04 | [diff] [blame] | 191 | prefs->RegisterStringPref( |
| 192 | prefs::kLanguageHangulKeyboard, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 193 | language_prefs::kHangulKeyboardNameIDPairs[0].keyboard_id, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 194 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | 33444cf | 2011-08-04 06:33:55 | [diff] [blame] | 195 | prefs->RegisterStringPref(prefs::kLanguageHangulHanjaBindingKeys, |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 196 | language_prefs::kHangulHanjaBindingKeys, |
[email protected] | 33444cf | 2011-08-04 06:33:55 | [diff] [blame] | 197 | // Don't sync the pref as it's not user-configurable |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 198 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 199 | for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { |
| 200 | prefs->RegisterBooleanPref( |
| 201 | language_prefs::kPinyinBooleanPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 202 | language_prefs::kPinyinBooleanPrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 203 | language_prefs::kPinyinBooleanPrefs[i].sync_status); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 204 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 205 | for (size_t i = 0; i < language_prefs::kNumPinyinIntegerPrefs; ++i) { |
| 206 | prefs->RegisterIntegerPref( |
| 207 | language_prefs::kPinyinIntegerPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 208 | language_prefs::kPinyinIntegerPrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 209 | language_prefs::kPinyinIntegerPrefs[i].sync_status); |
[email protected] | 6e5c4b8 | 2010-05-24 08:18:44 | [diff] [blame] | 210 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 211 | prefs->RegisterIntegerPref( |
| 212 | language_prefs::kPinyinDoublePinyinSchema.pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 213 | language_prefs::kPinyinDoublePinyinSchema.default_pref_value, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 214 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 215 | |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 216 | for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { |
| 217 | prefs->RegisterBooleanPref( |
| 218 | language_prefs::kMozcBooleanPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 219 | language_prefs::kMozcBooleanPrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 220 | language_prefs::kMozcBooleanPrefs[i].sync_status); |
[email protected] | 8a1ace2 | 2010-06-10 05:38:25 | [diff] [blame] | 221 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 222 | for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 223 | prefs->RegisterStringPref( |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 224 | language_prefs::kMozcMultipleChoicePrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 225 | language_prefs::kMozcMultipleChoicePrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 226 | language_prefs::kMozcMultipleChoicePrefs[i].sync_status); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 227 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 228 | for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { |
| 229 | prefs->RegisterIntegerPref( |
| 230 | language_prefs::kMozcIntegerPrefs[i].pref_name, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 231 | language_prefs::kMozcIntegerPrefs[i].default_pref_value, |
[email protected] | 203bec6 | 2011-05-16 06:17:51 | [diff] [blame] | 232 | language_prefs::kMozcIntegerPrefs[i].sync_status); |
[email protected] | 5403746 | 2010-06-22 02:06:23 | [diff] [blame] | 233 | } |
[email protected] | a25f48c | 2012-10-30 00:32:13 | [diff] [blame] | 234 | prefs->RegisterIntegerPref(prefs::kLanguageRemapSearchKeyTo, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 235 | input_method::kSearchKey, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 236 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | a25f48c | 2012-10-30 00:32:13 | [diff] [blame] | 237 | prefs->RegisterIntegerPref(prefs::kLanguageRemapControlKeyTo, |
[email protected] | 99c6cbe | 2012-05-23 08:34:04 | [diff] [blame] | 238 | input_method::kControlKey, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 239 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | a25f48c | 2012-10-30 00:32:13 | [diff] [blame] | 240 | prefs->RegisterIntegerPref(prefs::kLanguageRemapAltKeyTo, |
[email protected] | 99c6cbe | 2012-05-23 08:34:04 | [diff] [blame] | 241 | input_method::kAltKey, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 242 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | 872ead34 | 2012-10-31 17:50:01 | [diff] [blame] | 243 | prefs->RegisterIntegerPref(prefs::kLanguageRemapCapsLockKeyTo, |
| 244 | input_method::kCapsLockKey, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 245 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | aa96e37 | 2011-05-16 06:23:10 | [diff] [blame] | 246 | // We don't sync the following keyboard prefs since they are not user- |
| 247 | // configurable. |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 248 | prefs->RegisterBooleanPref(prefs::kLanguageXkbAutoRepeatEnabled, |
| 249 | true, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 250 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | 4743dad | 2010-08-30 01:41:07 | [diff] [blame] | 251 | prefs->RegisterIntegerPref(prefs::kLanguageXkbAutoRepeatDelay, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 252 | language_prefs::kXkbAutoRepeatDelayInMs, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 253 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | 4743dad | 2010-08-30 01:41:07 | [diff] [blame] | 254 | prefs->RegisterIntegerPref(prefs::kLanguageXkbAutoRepeatInterval, |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 255 | language_prefs::kXkbAutoRepeatIntervalInMs, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 256 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 257 | |
| 258 | // Screen lock default to off. |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 259 | prefs->RegisterBooleanPref(prefs::kEnableScreenLock, |
| 260 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 261 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | ea1eba5 | 2010-11-23 18:05:38 | [diff] [blame] | 262 | |
| 263 | // Mobile plan notifications default to on. |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 264 | prefs->RegisterBooleanPref(prefs::kShowPlanNotifications, |
| 265 | true, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 266 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | c74fffa | 2011-04-27 13:32:24 | [diff] [blame] | 267 | |
| 268 | // 3G first-time usage promo will be shown at least once. |
[email protected] | d36f941b | 2011-05-09 06:19:16 | [diff] [blame] | 269 | prefs->RegisterBooleanPref(prefs::kShow3gPromoNotification, |
| 270 | true, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 271 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | d6ae950 | 2011-05-05 18:23:09 | [diff] [blame] | 272 | |
[email protected] | efb770c | 2012-05-04 22:31:48 | [diff] [blame] | 273 | // Initially all existing users would see "What's new" |
| 274 | // for current version after update. |
| 275 | prefs->RegisterStringPref(prefs::kChromeOSReleaseNotesVersion, |
| 276 | "0.0.0.0", |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 277 | PrefServiceSyncable::SYNCABLE_PREF); |
[email protected] | efb770c | 2012-05-04 22:31:48 | [diff] [blame] | 278 | |
[email protected] | cc8f247 | 2011-08-01 07:14:46 | [diff] [blame] | 279 | // OAuth1 all access token and secret pair. |
| 280 | prefs->RegisterStringPref(prefs::kOAuth1Token, |
| 281 | "", |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 282 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | cc8f247 | 2011-08-01 07:14:46 | [diff] [blame] | 283 | prefs->RegisterStringPref(prefs::kOAuth1Secret, |
| 284 | "", |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 285 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | 595a5ed | 2012-05-04 00:39:16 | [diff] [blame] | 286 | |
| 287 | // TODO(wad): Once UI is connected, a final default can be set. At that point |
| 288 | // change this pref from UNSYNCABLE to SYNCABLE. |
| 289 | prefs->RegisterBooleanPref(prefs::kEnableCrosDRM, |
| 290 | true, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 291 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | 5258406 | 2012-07-24 08:46:13 | [diff] [blame] | 292 | |
| 293 | prefs->RegisterBooleanPref(prefs::kExternalStorageDisabled, |
| 294 | false, |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 295 | PrefServiceSyncable::UNSYNCABLE_PREF); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 296 | } |
| 297 | |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 298 | void Preferences::InitUserPrefs(PrefServiceSyncable* prefs) { |
[email protected] | 155e1b4 | 2012-07-14 03:06:01 | [diff] [blame] | 299 | prefs_ = prefs; |
| 300 | |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 301 | BooleanPrefMember::NamedChangeCallback callback = |
| 302 | base::Bind(&Preferences::OnPreferenceChanged, base::Unretained(this)); |
| 303 | |
| 304 | tap_to_click_enabled_.Init(prefs::kTapToClickEnabled, prefs, callback); |
| 305 | tap_dragging_enabled_.Init(prefs::kTapDraggingEnabled, prefs, callback); |
[email protected] | 190349fd | 2012-05-02 00:10:47 | [diff] [blame] | 306 | three_finger_click_enabled_.Init(prefs::kEnableTouchpadThreeFingerClick, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 307 | prefs, callback); |
[email protected] | fbc176b6 | 2012-10-27 02:19:58 | [diff] [blame] | 308 | three_finger_swipe_enabled_.Init(prefs::kEnableTouchpadThreeFingerSwipe, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 309 | prefs, callback); |
| 310 | natural_scroll_.Init(prefs::kNaturalScroll, prefs, callback); |
| 311 | accessibility_enabled_.Init(prefs::kSpokenFeedbackEnabled, prefs, callback); |
[email protected] | a53804ba | 2012-12-17 12:07:42 | [diff] [blame] | 312 | screen_magnifier_enabled_.Init(prefs::kScreenMagnifierEnabled, |
| 313 | prefs, callback); |
[email protected] | ea2110d | 2012-11-26 19:20:24 | [diff] [blame] | 314 | screen_magnifier_scale_.Init(prefs::kScreenMagnifierScale, prefs, callback); |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 315 | mouse_sensitivity_.Init(prefs::kMouseSensitivity, prefs, callback); |
| 316 | touchpad_sensitivity_.Init(prefs::kTouchpadSensitivity, prefs, callback); |
| 317 | use_24hour_clock_.Init(prefs::kUse24HourClock, prefs, callback); |
| 318 | disable_drive_.Init(prefs::kDisableDrive, prefs, callback); |
[email protected] | e1619ee0 | 2012-10-22 08:14:49 | [diff] [blame] | 319 | disable_drive_over_cellular_.Init(prefs::kDisableDriveOverCellular, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 320 | prefs, callback); |
[email protected] | e1619ee0 | 2012-10-22 08:14:49 | [diff] [blame] | 321 | disable_drive_hosted_files_.Init(prefs::kDisableDriveHostedFiles, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 322 | prefs, callback); |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 323 | download_default_directory_.Init(prefs::kDownloadDefaultDirectory, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 324 | prefs, callback); |
[email protected] | 0027fde1 | 2011-12-15 05:09:38 | [diff] [blame] | 325 | primary_mouse_button_right_.Init(prefs::kPrimaryMouseButtonRight, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 326 | prefs, callback); |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 327 | preferred_languages_.Init(prefs::kLanguagePreferredLanguages, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 328 | prefs, callback); |
| 329 | preload_engines_.Init(prefs::kLanguagePreloadEngines, prefs, callback); |
[email protected] | 797c680 | 2012-09-20 10:36:13 | [diff] [blame] | 330 | filtered_extension_imes_.Init(prefs::kLanguageFilteredExtensionImes, |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 331 | prefs, callback); |
| 332 | current_input_method_.Init(prefs::kLanguageCurrentInputMethod, |
| 333 | prefs, callback); |
| 334 | previous_input_method_.Init(prefs::kLanguagePreviousInputMethod, |
| 335 | prefs, callback); |
[email protected] | 22bec1a | 2012-03-27 06:33:48 | [diff] [blame] | 336 | |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 337 | for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 338 | chewing_boolean_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 339 | language_prefs::kChewingBooleanPrefs[i].pref_name, prefs, callback); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 340 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 341 | for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 342 | chewing_multiple_choice_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 343 | language_prefs::kChewingMultipleChoicePrefs[i].pref_name, |
| 344 | prefs, callback); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 345 | } |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 346 | chewing_hsu_sel_key_type_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 347 | language_prefs::kChewingHsuSelKeyType.pref_name, prefs, callback); |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 348 | for (size_t i = 0; i < language_prefs::kNumChewingIntegerPrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 349 | chewing_integer_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 350 | language_prefs::kChewingIntegerPrefs[i].pref_name, prefs, callback); |
[email protected] | 15c5308 | 2010-06-03 03:28:21 | [diff] [blame] | 351 | } |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 352 | hangul_keyboard_.Init(prefs::kLanguageHangulKeyboard, prefs, callback); |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 353 | hangul_hanja_binding_keys_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 354 | prefs::kLanguageHangulHanjaBindingKeys, prefs, callback); |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 355 | for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 356 | pinyin_boolean_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 357 | language_prefs::kPinyinBooleanPrefs[i].pref_name, prefs, callback); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 358 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 359 | for (size_t i = 0; i < language_prefs::kNumPinyinIntegerPrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 360 | pinyin_int_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 361 | language_prefs::kPinyinIntegerPrefs[i].pref_name, prefs, callback); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 362 | } |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 363 | pinyin_double_pinyin_schema_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 364 | language_prefs::kPinyinDoublePinyinSchema.pref_name, prefs, callback); |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 365 | for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 366 | mozc_boolean_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 367 | language_prefs::kMozcBooleanPrefs[i].pref_name, prefs, callback); |
[email protected] | 8a1ace2 | 2010-06-10 05:38:25 | [diff] [blame] | 368 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 369 | for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 370 | mozc_multiple_choice_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 371 | language_prefs::kMozcMultipleChoicePrefs[i].pref_name, prefs, callback); |
[email protected] | 6e5c4b8 | 2010-05-24 08:18:44 | [diff] [blame] | 372 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 373 | for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 374 | mozc_integer_prefs_[i].Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 375 | language_prefs::kMozcIntegerPrefs[i].pref_name, prefs, callback); |
[email protected] | 5403746 | 2010-06-22 02:06:23 | [diff] [blame] | 376 | } |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 377 | xkb_auto_repeat_enabled_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 378 | prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 379 | xkb_auto_repeat_delay_pref_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 380 | prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 381 | xkb_auto_repeat_interval_pref_.Init( |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 382 | prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 383 | |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 384 | enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, callback); |
[email protected] | 595a5ed | 2012-05-04 00:39:16 | [diff] [blame] | 385 | |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 386 | enable_drm_.Init(prefs::kEnableCrosDRM, prefs, callback); |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 387 | } |
| 388 | |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 389 | void Preferences::Init(PrefServiceSyncable* prefs) { |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 390 | InitUserPrefs(prefs); |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 391 | |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 392 | // This causes OnIsSyncingChanged to be called when the value of |
| 393 | // PrefService::IsSyncing() changes. |
| 394 | prefs->AddObserver(this); |
| 395 | |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 396 | // Initialize preferences to currently saved state. |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 397 | NotifyPrefChanged(NULL); |
[email protected] | 26012e2 | 2010-12-01 06:44:27 | [diff] [blame] | 398 | |
| 399 | // If a guest is logged in, initialize the prefs as if this is the first |
| 400 | // login. |
| 401 | if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |
| 402 | LoginUtils::Get()->SetFirstLoginPrefs(prefs); |
| 403 | } |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 404 | } |
| 405 | |
[email protected] | 5b19952 | 2012-12-22 17:24:44 | [diff] [blame] | 406 | void Preferences::InitUserPrefsForTesting(PrefServiceSyncable* prefs) { |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 407 | InitUserPrefs(prefs); |
| 408 | } |
| 409 | |
| 410 | void Preferences::SetInputMethodListForTesting() { |
| 411 | SetInputMethodList(); |
| 412 | } |
| 413 | |
[email protected] | e7bff3e | 2012-11-14 15:34:44 | [diff] [blame] | 414 | void Preferences::OnPreferenceChanged(const std::string& pref_name) { |
[email protected] | a6a7ced | 2012-11-01 17:24:18 | [diff] [blame] | 415 | NotifyPrefChanged(&pref_name); |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 416 | } |
| 417 | |
[email protected] | 57ecc4b | 2010-08-11 03:02:51 | [diff] [blame] | 418 | void Preferences::NotifyPrefChanged(const std::string* pref_name) { |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 419 | if (!pref_name || *pref_name == prefs::kTapToClickEnabled) { |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 420 | const bool enabled = tap_to_click_enabled_.GetValue(); |
[email protected] | 1cbfb3b | 2011-07-11 23:34:08 | [diff] [blame] | 421 | system::touchpad_settings::SetTapToClick(enabled); |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 422 | if (pref_name) |
| 423 | UMA_HISTOGRAM_BOOLEAN("Touchpad.TapToClick.Changed", enabled); |
| 424 | else |
| 425 | UMA_HISTOGRAM_BOOLEAN("Touchpad.TapToClick.Started", enabled); |
[email protected] | 022c3b9 | 2012-09-13 19:45:59 | [diff] [blame] | 426 | |
| 427 | // Save owner preference in local state to use on login screen. |
| 428 | if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { |
| 429 | PrefService* prefs = g_browser_process->local_state(); |
| 430 | if (prefs->GetBoolean(prefs::kOwnerTapToClickEnabled) != enabled) |
| 431 | prefs->SetBoolean(prefs::kOwnerTapToClickEnabled, enabled); |
| 432 | } |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 433 | } |
[email protected] | 1b46af0 | 2012-10-31 05:23:54 | [diff] [blame] | 434 | if (!pref_name || *pref_name == prefs::kTapDraggingEnabled) { |
| 435 | const bool enabled = tap_dragging_enabled_.GetValue(); |
| 436 | system::touchpad_settings::SetTapDragging(enabled); |
| 437 | if (pref_name) |
| 438 | UMA_HISTOGRAM_BOOLEAN("Touchpad.TapDragging.Changed", enabled); |
| 439 | else |
| 440 | UMA_HISTOGRAM_BOOLEAN("Touchpad.TapDragging.Started", enabled); |
| 441 | } |
[email protected] | 190349fd | 2012-05-02 00:10:47 | [diff] [blame] | 442 | if (!pref_name || *pref_name == prefs::kEnableTouchpadThreeFingerClick) { |
| 443 | const bool enabled = three_finger_click_enabled_.GetValue(); |
| 444 | system::touchpad_settings::SetThreeFingerClick(enabled); |
| 445 | if (pref_name) |
| 446 | UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerClick.Changed", enabled); |
| 447 | else |
| 448 | UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerClick.Started", enabled); |
| 449 | } |
[email protected] | fbc176b6 | 2012-10-27 02:19:58 | [diff] [blame] | 450 | if (!pref_name || *pref_name == prefs::kEnableTouchpadThreeFingerSwipe) { |
| 451 | const bool enabled = three_finger_swipe_enabled_.GetValue(); |
| 452 | system::touchpad_settings::SetThreeFingerSwipe(enabled); |
| 453 | if (pref_name) |
| 454 | UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerSwipe.Changed", enabled); |
| 455 | else |
| 456 | UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerSwipe.Started", enabled); |
| 457 | } |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 458 | if (!pref_name || *pref_name == prefs::kNaturalScroll) { |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 459 | // Force natural scroll default if we've sync'd and if the cmd line arg is |
| 460 | // set. |
| 461 | ForceNaturalScrollDefault(); |
[email protected] | 223059e | 2012-10-05 01:44:49 | [diff] [blame] | 462 | |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 463 | const bool enabled = natural_scroll_.GetValue(); |
[email protected] | 223059e | 2012-10-05 01:44:49 | [diff] [blame] | 464 | DVLOG(1) << "Natural scroll set to " << enabled; |
[email protected] | b685fbd | 2012-03-24 09:23:04 | [diff] [blame] | 465 | ui::SetNaturalScroll(enabled); |
| 466 | if (pref_name) |
| 467 | UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Changed", enabled); |
| 468 | else |
| 469 | UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Started", enabled); |
| 470 | } |
[email protected] | 563fb5f | 2012-03-31 00:39:28 | [diff] [blame] | 471 | if (!pref_name || *pref_name == prefs::kMouseSensitivity) { |
| 472 | const int sensitivity = mouse_sensitivity_.GetValue(); |
| 473 | system::mouse_settings::SetSensitivity(sensitivity); |
| 474 | if (pref_name) { |
| 475 | UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 476 | "Mouse.Sensitivity.Changed", sensitivity, 1, 5, 5); |
| 477 | } else { |
| 478 | UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 479 | "Mouse.Sensitivity.Started", sensitivity, 1, 5, 5); |
| 480 | } |
| 481 | } |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 482 | if (!pref_name || *pref_name == prefs::kTouchpadSensitivity) { |
[email protected] | 563fb5f | 2012-03-31 00:39:28 | [diff] [blame] | 483 | const int sensitivity = touchpad_sensitivity_.GetValue(); |
| 484 | system::touchpad_settings::SetSensitivity(sensitivity); |
[email protected] | d7ca1ba | 2011-05-09 20:09:08 | [diff] [blame] | 485 | if (pref_name) { |
| 486 | UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 487 | "Touchpad.Sensitivity.Changed", sensitivity, 1, 5, 5); |
| 488 | } else { |
| 489 | UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 490 | "Touchpad.Sensitivity.Started", sensitivity, 1, 5, 5); |
| 491 | } |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 492 | } |
[email protected] | 0027fde1 | 2011-12-15 05:09:38 | [diff] [blame] | 493 | if (!pref_name || *pref_name == prefs::kPrimaryMouseButtonRight) { |
| 494 | const bool right = primary_mouse_button_right_.GetValue(); |
| 495 | system::mouse_settings::SetPrimaryButtonRight(right); |
| 496 | if (pref_name) |
[email protected] | 6c8599e | 2012-01-20 04:31:58 | [diff] [blame] | 497 | UMA_HISTOGRAM_BOOLEAN("Mouse.PrimaryButtonRight.Changed", right); |
[email protected] | 0027fde1 | 2011-12-15 05:09:38 | [diff] [blame] | 498 | else |
[email protected] | 6c8599e | 2012-01-20 04:31:58 | [diff] [blame] | 499 | UMA_HISTOGRAM_BOOLEAN("Mouse.PrimaryButtonRight.Started", right); |
[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::kOwnerPrimaryMouseButtonRight) != right) |
| 505 | prefs->SetBoolean(prefs::kOwnerPrimaryMouseButtonRight, right); |
| 506 | } |
[email protected] | 0027fde1 | 2011-12-15 05:09:38 | [diff] [blame] | 507 | } |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 508 | if (!pref_name || *pref_name == prefs::kDownloadDefaultDirectory) { |
[email protected] | d9d04df | 2012-10-12 07:06:35 | [diff] [blame] | 509 | const bool default_download_to_drive = drive::util::IsUnderDriveMountPoint( |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 510 | download_default_directory_.GetValue()); |
| 511 | if (pref_name) |
[email protected] | e8307a1 | 2012-09-12 20:06:34 | [diff] [blame] | 512 | UMA_HISTOGRAM_BOOLEAN( |
| 513 | "FileBrowser.DownloadDestination.IsGoogleDrive.Changed", |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 514 | default_download_to_drive); |
| 515 | else |
[email protected] | e8307a1 | 2012-09-12 20:06:34 | [diff] [blame] | 516 | UMA_HISTOGRAM_BOOLEAN( |
| 517 | "FileBrowser.DownloadDestination.IsGoogleDrive.Started", |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 518 | default_download_to_drive); |
| 519 | } |
[email protected] | 8be9ff2 | 2010-06-08 02:13:54 | [diff] [blame] | 520 | |
[email protected] | 74b42fc1 | 2010-07-20 10:15:41 | [diff] [blame] | 521 | if (!pref_name || *pref_name == prefs::kLanguagePreferredLanguages) { |
| 522 | // Unlike kLanguagePreloadEngines and some other input method |
| 523 | // preferencs, we don't need to send this to ibus-daemon. |
| 524 | } |
[email protected] | a6e9077 | 2011-02-09 05:38:54 | [diff] [blame] | 525 | |
[email protected] | a6e9077 | 2011-02-09 05:38:54 | [diff] [blame] | 526 | if (!pref_name || *pref_name == prefs::kLanguageXkbAutoRepeatEnabled) { |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 527 | const bool enabled = xkb_auto_repeat_enabled_.GetValue(); |
[email protected] | cf61f6b0a | 2013-01-03 00:34:12 | [diff] [blame^] | 528 | input_method::XKeyboard::SetAutoRepeatEnabled(enabled); |
[email protected] | a6e9077 | 2011-02-09 05:38:54 | [diff] [blame] | 529 | } |
| 530 | if (!pref_name || ((*pref_name == prefs::kLanguageXkbAutoRepeatDelay) || |
| 531 | (*pref_name == prefs::kLanguageXkbAutoRepeatInterval))) { |
| 532 | UpdateAutoRepeatRate(); |
| 533 | } |
| 534 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 535 | if (!pref_name) { |
| 536 | SetInputMethodList(); |
| 537 | } else if (*pref_name == prefs::kLanguagePreloadEngines) { |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 538 | SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, |
| 539 | language_prefs::kPreloadEnginesConfigName, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 540 | preload_engines_.GetValue()); |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 541 | } |
[email protected] | 22bec1a | 2012-03-27 06:33:48 | [diff] [blame] | 542 | |
[email protected] | 797c680 | 2012-09-20 10:36:13 | [diff] [blame] | 543 | if (!pref_name || *pref_name == prefs::kLanguageFilteredExtensionImes) { |
| 544 | std::string value(filtered_extension_imes_.GetValue()); |
| 545 | |
| 546 | std::vector<std::string> split_values; |
| 547 | if (!value.empty()) |
| 548 | base::SplitString(value, ',', &split_values); |
| 549 | |
| 550 | input_method_manager_->SetFilteredExtensionImes(&split_values); |
| 551 | } |
| 552 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 553 | // Do not check |*pref_name| of the prefs for remembering current/previous |
| 554 | // input methods here. We're only interested in initial values of the prefs. |
[email protected] | 22bec1a | 2012-03-27 06:33:48 | [diff] [blame] | 555 | |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 556 | for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { |
| 557 | if (!pref_name || |
| 558 | *pref_name == language_prefs::kChewingBooleanPrefs[i].pref_name) { |
| 559 | SetLanguageConfigBoolean( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 560 | language_prefs::kChewingSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 561 | language_prefs::kChewingBooleanPrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 562 | chewing_boolean_prefs_[i].GetValue()); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 563 | } |
| 564 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 565 | for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { |
| 566 | if (!pref_name || |
| 567 | *pref_name == |
| 568 | language_prefs::kChewingMultipleChoicePrefs[i].pref_name) { |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 569 | SetLanguageConfigString( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 570 | language_prefs::kChewingSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 571 | language_prefs::kChewingMultipleChoicePrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 572 | chewing_multiple_choice_prefs_[i].GetValue()); |
[email protected] | 525dbe2 | 2010-06-01 07:05:43 | [diff] [blame] | 573 | } |
| 574 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 575 | if (!pref_name || |
| 576 | *pref_name == language_prefs::kChewingHsuSelKeyType.pref_name) { |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 577 | SetLanguageConfigInteger( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 578 | language_prefs::kChewingSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 579 | language_prefs::kChewingHsuSelKeyType.ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 580 | chewing_hsu_sel_key_type_.GetValue()); |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 581 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 582 | for (size_t i = 0; i < language_prefs::kNumChewingIntegerPrefs; ++i) { |
| 583 | if (!pref_name || |
| 584 | *pref_name == language_prefs::kChewingIntegerPrefs[i].pref_name) { |
| 585 | SetLanguageConfigInteger( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 586 | language_prefs::kChewingSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 587 | language_prefs::kChewingIntegerPrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 588 | chewing_integer_prefs_[i].GetValue()); |
[email protected] | 15c5308 | 2010-06-03 03:28:21 | [diff] [blame] | 589 | } |
| 590 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 591 | if (!pref_name || |
| 592 | *pref_name == prefs::kLanguageHangulKeyboard) { |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 593 | SetLanguageConfigString(language_prefs::kHangulSectionName, |
| 594 | language_prefs::kHangulKeyboardConfigName, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 595 | hangul_keyboard_.GetValue()); |
[email protected] | 3b02de29 | 2010-05-13 06:05:05 | [diff] [blame] | 596 | } |
[email protected] | 33444cf | 2011-08-04 06:33:55 | [diff] [blame] | 597 | if (!pref_name || *pref_name == prefs::kLanguageHangulHanjaBindingKeys) { |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 598 | SetLanguageConfigString(language_prefs::kHangulSectionName, |
| 599 | language_prefs::kHangulHanjaBindingKeysConfigName, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 600 | hangul_hanja_binding_keys_.GetValue()); |
[email protected] | 33444cf | 2011-08-04 06:33:55 | [diff] [blame] | 601 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 602 | for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { |
| 603 | if (!pref_name || |
| 604 | *pref_name == language_prefs::kPinyinBooleanPrefs[i].pref_name) { |
| 605 | SetLanguageConfigBoolean( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 606 | language_prefs::kPinyinSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 607 | language_prefs::kPinyinBooleanPrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 608 | pinyin_boolean_prefs_[i].GetValue()); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 609 | } |
| 610 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 611 | for (size_t i = 0; i < language_prefs::kNumPinyinIntegerPrefs; ++i) { |
| 612 | if (!pref_name || |
| 613 | *pref_name == language_prefs::kPinyinIntegerPrefs[i].pref_name) { |
| 614 | SetLanguageConfigInteger( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 615 | language_prefs::kPinyinSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 616 | language_prefs::kPinyinIntegerPrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 617 | pinyin_int_prefs_[i].GetValue()); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 618 | } |
| 619 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 620 | if (!pref_name || |
| 621 | *pref_name == language_prefs::kPinyinDoublePinyinSchema.pref_name) { |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 622 | SetLanguageConfigInteger( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 623 | language_prefs::kPinyinSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 624 | language_prefs::kPinyinDoublePinyinSchema.ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 625 | pinyin_double_pinyin_schema_.GetValue()); |
[email protected] | 7ac5af9 | 2010-06-07 01:25:44 | [diff] [blame] | 626 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 627 | for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { |
| 628 | if (!pref_name || |
| 629 | *pref_name == language_prefs::kMozcBooleanPrefs[i].pref_name) { |
| 630 | SetLanguageConfigBoolean( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 631 | language_prefs::kMozcSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 632 | language_prefs::kMozcBooleanPrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 633 | mozc_boolean_prefs_[i].GetValue()); |
[email protected] | 8a1ace2 | 2010-06-10 05:38:25 | [diff] [blame] | 634 | } |
| 635 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 636 | for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { |
| 637 | if (!pref_name || |
| 638 | *pref_name == language_prefs::kMozcMultipleChoicePrefs[i].pref_name) { |
[email protected] | 6e5c4b8 | 2010-05-24 08:18:44 | [diff] [blame] | 639 | SetLanguageConfigString( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 640 | language_prefs::kMozcSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 641 | language_prefs::kMozcMultipleChoicePrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 642 | mozc_multiple_choice_prefs_[i].GetValue()); |
[email protected] | 6e5c4b8 | 2010-05-24 08:18:44 | [diff] [blame] | 643 | } |
| 644 | } |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 645 | for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { |
| 646 | if (!pref_name || |
| 647 | *pref_name == language_prefs::kMozcIntegerPrefs[i].pref_name) { |
| 648 | SetLanguageConfigInteger( |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 649 | language_prefs::kMozcSectionName, |
[email protected] | b65c5d2 | 2010-08-20 02:50:23 | [diff] [blame] | 650 | language_prefs::kMozcIntegerPrefs[i].ibus_config_name, |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 651 | mozc_integer_prefs_[i].GetValue()); |
[email protected] | 5403746 | 2010-06-22 02:06:23 | [diff] [blame] | 652 | } |
| 653 | } |
[email protected] | 4793c94 | 2010-09-21 23:17:17 | [diff] [blame] | 654 | |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 655 | // Init or update power manager config. |
| 656 | if (!pref_name || *pref_name == prefs::kEnableScreenLock) { |
[email protected] | 58a4677 | 2012-07-11 02:16:08 | [diff] [blame] | 657 | system::power_manager_settings::EnableScreenLock( |
[email protected] | 4ccc05e | 2010-10-06 19:32:15 | [diff] [blame] | 658 | enable_screen_lock_.GetValue()); |
| 659 | } |
[email protected] | 595a5ed | 2012-05-04 00:39:16 | [diff] [blame] | 660 | |
| 661 | // Init or update protected content (DRM) support. |
| 662 | if (!pref_name || *pref_name == prefs::kEnableCrosDRM) { |
| 663 | system::ToggleDrm(enable_drm_.GetValue()); |
| 664 | } |
[email protected] | 155e1b4 | 2012-07-14 03:06:01 | [diff] [blame] | 665 | |
[email protected] | e1619ee0 | 2012-10-22 08:14:49 | [diff] [blame] | 666 | // Change the download directory to the default value if a Drive directory is |
| 667 | // selected and Drive is disabled. |
| 668 | if (!pref_name || *pref_name == prefs::kDisableDrive) { |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 669 | if (disable_drive_.GetValue()) { |
[email protected] | d9d04df | 2012-10-12 07:06:35 | [diff] [blame] | 670 | if (drive::util::IsUnderDriveMountPoint( |
[email protected] | 78a6b64 | 2012-09-12 02:07:03 | [diff] [blame] | 671 | download_default_directory_.GetValue())) { |
[email protected] | 155e1b4 | 2012-07-14 03:06:01 | [diff] [blame] | 672 | prefs_->SetFilePath(prefs::kDownloadDefaultDirectory, |
| 673 | download_util::GetDefaultDownloadDirectory()); |
| 674 | } |
| 675 | } |
| 676 | } |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 677 | } |
| 678 | |
[email protected] | 7f914fd | 2012-12-20 23:55:25 | [diff] [blame] | 679 | void Preferences::OnIsSyncingChanged() { |
| 680 | DVLOG(1) << "OnIsSyncingChanged"; |
| 681 | ForceNaturalScrollDefault(); |
| 682 | } |
| 683 | |
| 684 | void Preferences::ForceNaturalScrollDefault() { |
| 685 | DVLOG(1) << "ForceNaturalScrollDefault"; |
| 686 | if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 687 | switches::kNaturalScrollDefault) && |
| 688 | prefs_->IsSyncing() && |
| 689 | !prefs_->GetUserPrefValue(prefs::kNaturalScroll)) { |
| 690 | DVLOG(1) << "Natural scroll forced to true"; |
| 691 | natural_scroll_.SetValue(true); |
| 692 | UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Forced", true); |
| 693 | } |
| 694 | } |
| 695 | |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 696 | void Preferences::SetLanguageConfigBoolean(const char* section, |
| 697 | const char* name, |
| 698 | bool value) { |
[email protected] | 62308c2 | 2012-03-13 12:07:10 | [diff] [blame] | 699 | input_method::InputMethodConfigValue config; |
| 700 | config.type = input_method::InputMethodConfigValue::kValueTypeBool; |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 701 | config.bool_value = value; |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 702 | input_method_manager_->SetInputMethodConfig(section, name, config); |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 703 | } |
| 704 | |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 705 | void Preferences::SetLanguageConfigInteger(const char* section, |
| 706 | const char* name, |
| 707 | int value) { |
[email protected] | 62308c2 | 2012-03-13 12:07:10 | [diff] [blame] | 708 | input_method::InputMethodConfigValue config; |
| 709 | config.type = input_method::InputMethodConfigValue::kValueTypeInt; |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 710 | config.int_value = value; |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 711 | input_method_manager_->SetInputMethodConfig(section, name, config); |
[email protected] | 9040ad2 | 2010-04-22 04:29:28 | [diff] [blame] | 712 | } |
| 713 | |
[email protected] | 5095143 | 2010-03-31 12:12:42 | [diff] [blame] | 714 | void Preferences::SetLanguageConfigString(const char* section, |
| 715 | const char* name, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 716 | const std::string& value) { |
[email protected] | 62308c2 | 2012-03-13 12:07:10 | [diff] [blame] | 717 | input_method::InputMethodConfigValue config; |
| 718 | config.type = input_method::InputMethodConfigValue::kValueTypeString; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 719 | config.string_value = value; |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 720 | input_method_manager_->SetInputMethodConfig(section, name, config); |
[email protected] | 5095143 | 2010-03-31 12:12:42 | [diff] [blame] | 721 | } |
| 722 | |
[email protected] | 2c25ddfd | 2010-04-09 10:35:55 | [diff] [blame] | 723 | void Preferences::SetLanguageConfigStringList( |
| 724 | const char* section, |
| 725 | const char* name, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 726 | const std::vector<std::string>& values) { |
[email protected] | 62308c2 | 2012-03-13 12:07:10 | [diff] [blame] | 727 | input_method::InputMethodConfigValue config; |
| 728 | config.type = input_method::InputMethodConfigValue::kValueTypeStringList; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 729 | for (size_t i = 0; i < values.size(); ++i) |
| 730 | config.string_list_value.push_back(values[i]); |
| 731 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 732 | input_method_manager_->SetInputMethodConfig(section, name, config); |
[email protected] | 2c25ddfd | 2010-04-09 10:35:55 | [diff] [blame] | 733 | } |
| 734 | |
[email protected] | d01bb807 | 2010-04-12 13:00:15 | [diff] [blame] | 735 | void Preferences::SetLanguageConfigStringListAsCSV(const char* section, |
| 736 | const char* name, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 737 | const std::string& value) { |
[email protected] | e24c2c9 | 2010-10-23 01:39:24 | [diff] [blame] | 738 | VLOG(1) << "Setting " << name << " to '" << value << "'"; |
[email protected] | d01bb807 | 2010-04-12 13:00:15 | [diff] [blame] | 739 | |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 740 | std::vector<std::string> split_values; |
| 741 | if (!value.empty()) |
[email protected] | 76eb024 | 2010-10-14 00:35:36 | [diff] [blame] | 742 | base::SplitString(value, ',', &split_values); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 743 | |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 744 | if (section == std::string(language_prefs::kGeneralSectionName) && |
| 745 | name == std::string(language_prefs::kPreloadEnginesConfigName)) { |
[email protected] | dbc9b19 | 2012-04-18 05:55:34 | [diff] [blame] | 746 | input_method_manager_->EnableInputMethods(split_values); |
| 747 | return; |
| 748 | } |
| 749 | |
[email protected] | 2c25ddfd | 2010-04-09 10:35:55 | [diff] [blame] | 750 | // 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] | 751 | // config. |
| 752 | SetLanguageConfigStringList(section, name, split_values); |
[email protected] | 70aa5b3 | 2010-04-05 08:30:34 | [diff] [blame] | 753 | } |
| 754 | |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 755 | void Preferences::SetInputMethodList() { |
| 756 | // When |preload_engines_| are set, InputMethodManager::ChangeInputMethod() |
| 757 | // might be called to change the current input method to the first one in the |
| 758 | // |preload_engines_| list. This also updates previous/current input method |
| 759 | // prefs. That's why GetValue() calls are placed before the |
| 760 | // SetLanguageConfigStringListAsCSV() call below. |
| 761 | const std::string previous_input_method_id = |
| 762 | previous_input_method_.GetValue(); |
| 763 | const std::string current_input_method_id = current_input_method_.GetValue(); |
[email protected] | 7f132d0 | 2013-01-03 00:32:26 | [diff] [blame] | 764 | SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, |
| 765 | language_prefs::kPreloadEnginesConfigName, |
[email protected] | 2c62b3f | 2012-04-12 12:07:50 | [diff] [blame] | 766 | preload_engines_.GetValue()); |
| 767 | |
| 768 | // ChangeInputMethod() has to be called AFTER the value of |preload_engines_| |
| 769 | // is sent to the InputMethodManager. Otherwise, the ChangeInputMethod request |
| 770 | // might be ignored as an invalid input method ID. The ChangeInputMethod() |
| 771 | // calls are also necessary to restore the previous/current input method prefs |
| 772 | // which could have been modified by the SetLanguageConfigStringListAsCSV call |
| 773 | // above to the original state. |
| 774 | if (!previous_input_method_id.empty()) |
| 775 | input_method_manager_->ChangeInputMethod(previous_input_method_id); |
| 776 | if (!current_input_method_id.empty()) |
| 777 | input_method_manager_->ChangeInputMethod(current_input_method_id); |
| 778 | } |
| 779 | |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 780 | void Preferences::UpdateAutoRepeatRate() { |
[email protected] | 20979d49 | 2012-02-15 09:26:02 | [diff] [blame] | 781 | // Avoid setting repeat rate on desktop dev environment. |
[email protected] | 20d2a79d | 2012-03-16 23:01:02 | [diff] [blame] | 782 | if (!base::chromeos::IsRunningOnChromeOS()) |
[email protected] | 20979d49 | 2012-02-15 09:26:02 | [diff] [blame] | 783 | return; |
| 784 | |
[email protected] | c010f63 | 2011-04-01 06:44:39 | [diff] [blame] | 785 | input_method::AutoRepeatRate rate; |
[email protected] | c67a3093 | 2012-03-14 05:23:00 | [diff] [blame] | 786 | rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); |
| 787 | rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 788 | DCHECK(rate.initial_delay_in_ms > 0); |
| 789 | DCHECK(rate.repeat_interval_in_ms > 0); |
[email protected] | cf61f6b0a | 2013-01-03 00:34:12 | [diff] [blame^] | 790 | input_method::XKeyboard::SetAutoRepeatRate(rate); |
[email protected] | a995b39 | 2010-08-11 04:38:59 | [diff] [blame] | 791 | } |
| 792 | |
[email protected] | fecc152 | 2009-10-15 21:08:29 | [diff] [blame] | 793 | } // namespace chromeos |