Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: chrome/browser/chromeos/preferences.cc

Issue 3038025: Implement the "Configure modifier keys" drop-down (Closed)
Patch Set: review fix Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/preferences.h" 5 #include "chrome/browser/chromeos/preferences.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chromeos/cros/cros_library.h" 10 #include "chrome/browser/chromeos/cros/cros_library.h"
11 #include "chrome/browser/chromeos/cros/keyboard_library.h"
11 #include "chrome/browser/chromeos/cros/input_method_library.h" 12 #include "chrome/browser/chromeos/cros/input_method_library.h"
12 #include "chrome/browser/chromeos/cros/synaptics_library.h" 13 #include "chrome/browser/chromeos/cros/synaptics_library.h"
13 #include "chrome/browser/chromeos/input_method/input_method_util.h" 14 #include "chrome/browser/chromeos/input_method/input_method_util.h"
14 #include "chrome/browser/pref_member.h" 15 #include "chrome/browser/pref_member.h"
15 #include "chrome/browser/pref_service.h" 16 #include "chrome/browser/pref_service.h"
16 #include "chrome/common/notification_service.h" 17 #include "chrome/common/notification_service.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "unicode/timezone.h" 19 #include "unicode/timezone.h"
19 20
20 namespace chromeos { 21 namespace chromeos {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 77 }
77 for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) { 78 for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
78 prefs->RegisterStringPref( 79 prefs->RegisterStringPref(
79 kMozcMultipleChoicePrefs[i].pref_name, 80 kMozcMultipleChoicePrefs[i].pref_name,
80 kMozcMultipleChoicePrefs[i].default_pref_value); 81 kMozcMultipleChoicePrefs[i].default_pref_value);
81 } 82 }
82 for (size_t i = 0; i < kNumMozcIntegerPrefs; ++i) { 83 for (size_t i = 0; i < kNumMozcIntegerPrefs; ++i) {
83 prefs->RegisterIntegerPref(kMozcIntegerPrefs[i].pref_name, 84 prefs->RegisterIntegerPref(kMozcIntegerPrefs[i].pref_name,
84 kMozcIntegerPrefs[i].default_pref_value); 85 kMozcIntegerPrefs[i].default_pref_value);
85 } 86 }
87 prefs->RegisterIntegerPref(
88 kXkbModifierMultipleChoicePrefs.pref_name,
89 kXkbModifierMultipleChoicePrefs.default_pref_value);
86 } 90 }
87 91
88 void Preferences::Init(PrefService* prefs) { 92 void Preferences::Init(PrefService* prefs) {
89 tap_to_click_enabled_.Init(prefs::kTapToClickEnabled, prefs, this); 93 tap_to_click_enabled_.Init(prefs::kTapToClickEnabled, prefs, this);
90 accessibility_enabled_.Init(prefs::kAccessibilityEnabled, prefs, this); 94 accessibility_enabled_.Init(prefs::kAccessibilityEnabled, prefs, this);
91 vert_edge_scroll_enabled_.Init(prefs::kVertEdgeScrollEnabled, prefs, this); 95 vert_edge_scroll_enabled_.Init(prefs::kVertEdgeScrollEnabled, prefs, this);
92 speed_factor_.Init(prefs::kTouchpadSpeedFactor, prefs, this); 96 speed_factor_.Init(prefs::kTouchpadSpeedFactor, prefs, this);
93 sensitivity_.Init(prefs::kTouchpadSensitivity, prefs, this); 97 sensitivity_.Init(prefs::kTouchpadSensitivity, prefs, this);
94 language_hotkey_next_engine_in_menu_.Init( 98 language_hotkey_next_engine_in_menu_.Init(
95 prefs::kLanguageHotkeyNextEngineInMenu, prefs, this); 99 prefs::kLanguageHotkeyNextEngineInMenu, prefs, this);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 kMozcBooleanPrefs[i].pref_name, prefs, this); 134 kMozcBooleanPrefs[i].pref_name, prefs, this);
131 } 135 }
132 for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) { 136 for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
133 language_mozc_multiple_choice_prefs_[i].Init( 137 language_mozc_multiple_choice_prefs_[i].Init(
134 kMozcMultipleChoicePrefs[i].pref_name, prefs, this); 138 kMozcMultipleChoicePrefs[i].pref_name, prefs, this);
135 } 139 }
136 for (size_t i = 0; i < kNumMozcIntegerPrefs; ++i) { 140 for (size_t i = 0; i < kNumMozcIntegerPrefs; ++i) {
137 language_mozc_integer_prefs_[i].Init( 141 language_mozc_integer_prefs_[i].Init(
138 kMozcIntegerPrefs[i].pref_name, prefs, this); 142 kMozcIntegerPrefs[i].pref_name, prefs, this);
139 } 143 }
144 language_xkb_modifier_remap_.Init(
145 kXkbModifierMultipleChoicePrefs.pref_name, prefs, this);
140 146
141 std::string locale(g_browser_process->GetApplicationLocale()); 147 std::string locale(g_browser_process->GetApplicationLocale());
142 // Add input methods based on the application locale when the user first 148 // Add input methods based on the application locale when the user first
143 // logs in. For instance, if the user chooses Japanese as the UI 149 // logs in. For instance, if the user chooses Japanese as the UI
144 // language at the first login, we'll add input methods associated with 150 // language at the first login, we'll add input methods associated with
145 // Japanese, such as mozc. 151 // Japanese, such as mozc.
146 if (locale != kFallbackInputMethodLocale && 152 if (locale != kFallbackInputMethodLocale &&
147 !prefs->HasPrefPath(prefs::kLanguagePreloadEngines)) { 153 !prefs->HasPrefPath(prefs::kLanguagePreloadEngines)) {
148 std::string preload_engines(language_preload_engines_.GetValue()); 154 std::string preload_engines(language_preload_engines_.GetValue());
149 std::vector<std::string> input_method_ids; 155 std::vector<std::string> input_method_ids;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 language_mozc_multiple_choice_prefs_[i].GetValue()); 295 language_mozc_multiple_choice_prefs_[i].GetValue());
290 } 296 }
291 } 297 }
292 for (size_t i = 0; i < kNumMozcIntegerPrefs; ++i) { 298 for (size_t i = 0; i < kNumMozcIntegerPrefs; ++i) {
293 if (!pref_name || *pref_name == kMozcIntegerPrefs[i].pref_name) { 299 if (!pref_name || *pref_name == kMozcIntegerPrefs[i].pref_name) {
294 SetLanguageConfigInteger(kMozcSectionName, 300 SetLanguageConfigInteger(kMozcSectionName,
295 kMozcIntegerPrefs[i].ibus_config_name, 301 kMozcIntegerPrefs[i].ibus_config_name,
296 language_mozc_integer_prefs_[i].GetValue()); 302 language_mozc_integer_prefs_[i].GetValue());
297 } 303 }
298 } 304 }
305 if (!pref_name || *pref_name == kXkbModifierMultipleChoicePrefs.pref_name) {
306 chromeos::ModifierMap modifier_map;
307 const int remap_type = language_xkb_modifier_remap_.GetValue();
308 switch (remap_type) {
309 default:
310 LOG(ERROR) << "Unknown XKB remapping type: " << remap_type;
311 /* fall through */
312 case kNoRemap:
313 modifier_map.push_back(ModifierKeyPair(kSearchKey, kSearchKey));
314 modifier_map.push_back(
315 ModifierKeyPair(kLeftControlKey, kLeftControlKey));
316 modifier_map.push_back(ModifierKeyPair(kLeftAltKey, kLeftAltKey));
317 break;
318 case kSwapCtrlAndAlt:
319 modifier_map.push_back(ModifierKeyPair(kSearchKey, kSearchKey));
320 modifier_map.push_back(ModifierKeyPair(kLeftControlKey, kLeftAltKey));
321 modifier_map.push_back(ModifierKeyPair(kLeftAltKey, kLeftControlKey));
322 break;
323 case kSwapSearchAndCtrl:
324 modifier_map.push_back(ModifierKeyPair(kSearchKey, kLeftControlKey));
325 modifier_map.push_back(ModifierKeyPair(kLeftControlKey, kSearchKey));
326 modifier_map.push_back(ModifierKeyPair(kLeftAltKey, kLeftAltKey));
327 break;
328 }
329 CrosLibrary::Get()->GetKeyboardLibrary()->RemapModifierKeys(modifier_map);
330 }
299 } 331 }
300 332
301 void Preferences::SetLanguageConfigBoolean(const char* section, 333 void Preferences::SetLanguageConfigBoolean(const char* section,
302 const char* name, 334 const char* name,
303 bool value) { 335 bool value) {
304 ImeConfigValue config; 336 ImeConfigValue config;
305 config.type = ImeConfigValue::kValueTypeBool; 337 config.type = ImeConfigValue::kValueTypeBool;
306 config.bool_value = value; 338 config.bool_value = value;
307 CrosLibrary::Get()->GetInputMethodLibrary()-> 339 CrosLibrary::Get()->GetInputMethodLibrary()->
308 SetImeConfig(section, name, config); 340 SetImeConfig(section, name, config);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 std::vector<std::string> split_values; 381 std::vector<std::string> split_values;
350 if (!value.empty()) 382 if (!value.empty())
351 SplitString(value, ',', &split_values); 383 SplitString(value, ',', &split_values);
352 384
353 // We should call the cros API even when |value| is empty, to disable default 385 // We should call the cros API even when |value| is empty, to disable default
354 // config. 386 // config.
355 SetLanguageConfigStringList(section, name, split_values); 387 SetLanguageConfigStringList(section, name, split_values);
356 } 388 }
357 389
358 } // namespace chromeos 390 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698