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

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

Issue 10027008: chrome/browser/chromeos/input_method/ refactoring [part 5 of 6] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromeos/chromeos_version.h" 7 #include "base/chromeos/chromeos_version.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/i18n/time_formatting.h" 9 #include "base/i18n/time_formatting.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 28 matching lines...) Expand all
39 std::string board; 39 std::string board;
40 system::StatisticsProvider::GetInstance()->GetMachineStatistic( 40 system::StatisticsProvider::GetInstance()->GetMachineStatistic(
41 "CHROMEOS_RELEASE_BOARD", &board); 41 "CHROMEOS_RELEASE_BOARD", &board);
42 return StartsWithASCII(board, "lumpy", false); 42 return StartsWithASCII(board, "lumpy", false);
43 } 43 }
44 44
45 } // namespace 45 } // namespace
46 46
47 static const char kFallbackInputMethodLocale[] = "en-US"; 47 static const char kFallbackInputMethodLocale[] = "en-US";
48 48
49 Preferences::Preferences() {} 49 Preferences::Preferences()
50 : input_method_manager_(input_method::InputMethodManager::GetInstance()) {
51 }
52
53 Preferences::Preferences(input_method::InputMethodManager* input_method_manager)
54 : input_method_manager_(input_method_manager) {
55 }
50 56
51 Preferences::~Preferences() {} 57 Preferences::~Preferences() {}
52 58
53 // static 59 // static
54 void Preferences::RegisterUserPrefs(PrefService* prefs) { 60 void Preferences::RegisterUserPrefs(PrefService* prefs) {
55 input_method::InputMethodManager* manager = 61 std::string hardware_keyboard_id;
56 input_method::InputMethodManager::GetInstance(); 62 // TODO(yusukes): Remove the runtime hack.
63 if (base::chromeos::IsRunningOnChromeOS()) {
64 input_method::InputMethodManager* manager =
65 input_method::InputMethodManager::GetInstance();
66 hardware_keyboard_id =
67 manager->GetInputMethodUtil()->GetHardwareInputMethodId();
68 } else {
69 hardware_keyboard_id = "xkb:us::eng"; // only for testing.
70 }
57 71
58 const bool enable_tap_to_click_default = IsLumpy(); 72 const bool enable_tap_to_click_default = IsLumpy();
59 prefs->RegisterBooleanPref(prefs::kTapToClickEnabled, 73 prefs->RegisterBooleanPref(prefs::kTapToClickEnabled,
60 enable_tap_to_click_default, 74 enable_tap_to_click_default,
61 PrefService::SYNCABLE_PREF); 75 PrefService::SYNCABLE_PREF);
62 prefs->RegisterBooleanPref(prefs::kNaturalScroll, 76 prefs->RegisterBooleanPref(prefs::kNaturalScroll,
63 false, 77 false,
64 PrefService::SYNCABLE_PREF); 78 PrefService::SYNCABLE_PREF);
65 prefs->RegisterBooleanPref(prefs::kPrimaryMouseButtonRight, 79 prefs->RegisterBooleanPref(prefs::kPrimaryMouseButtonRight,
66 false, 80 false,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 PrefService::UNSYNCABLE_PREF); 140 PrefService::UNSYNCABLE_PREF);
127 prefs->RegisterStringPref(prefs::kLanguageHotkeyPreviousEngine, 141 prefs->RegisterStringPref(prefs::kLanguageHotkeyPreviousEngine,
128 language_prefs::kHotkeyPreviousEngine, 142 language_prefs::kHotkeyPreviousEngine,
129 PrefService::UNSYNCABLE_PREF); 143 PrefService::UNSYNCABLE_PREF);
130 // We don't sync the list of input methods and preferred languages since a 144 // We don't sync the list of input methods and preferred languages since a
131 // user might use two or more devices with different hardware keyboards. 145 // user might use two or more devices with different hardware keyboards.
132 // crosbug.com/15181 146 // crosbug.com/15181
133 prefs->RegisterStringPref(prefs::kLanguagePreferredLanguages, 147 prefs->RegisterStringPref(prefs::kLanguagePreferredLanguages,
134 kFallbackInputMethodLocale, 148 kFallbackInputMethodLocale,
135 PrefService::UNSYNCABLE_PREF); 149 PrefService::UNSYNCABLE_PREF);
136 prefs->RegisterStringPref( 150 prefs->RegisterStringPref(prefs::kLanguagePreloadEngines,
137 prefs::kLanguagePreloadEngines, 151 hardware_keyboard_id,
138 manager->GetInputMethodUtil()->GetHardwareInputMethodId(), 152 PrefService::UNSYNCABLE_PREF);
139 PrefService::UNSYNCABLE_PREF);
140 for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { 153 for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) {
141 prefs->RegisterBooleanPref( 154 prefs->RegisterBooleanPref(
142 language_prefs::kChewingBooleanPrefs[i].pref_name, 155 language_prefs::kChewingBooleanPrefs[i].pref_name,
143 language_prefs::kChewingBooleanPrefs[i].default_pref_value, 156 language_prefs::kChewingBooleanPrefs[i].default_pref_value,
144 language_prefs::kChewingBooleanPrefs[i].sync_status); 157 language_prefs::kChewingBooleanPrefs[i].sync_status);
145 } 158 }
146 for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { 159 for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) {
147 prefs->RegisterStringPref( 160 prefs->RegisterStringPref(
148 language_prefs::kChewingMultipleChoicePrefs[i].pref_name, 161 language_prefs::kChewingMultipleChoicePrefs[i].pref_name,
149 language_prefs::kChewingMultipleChoicePrefs[i].default_pref_value, 162 language_prefs::kChewingMultipleChoicePrefs[i].default_pref_value,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 257
245 // OAuth1 all access token and secret pair. 258 // OAuth1 all access token and secret pair.
246 prefs->RegisterStringPref(prefs::kOAuth1Token, 259 prefs->RegisterStringPref(prefs::kOAuth1Token,
247 "", 260 "",
248 PrefService::UNSYNCABLE_PREF); 261 PrefService::UNSYNCABLE_PREF);
249 prefs->RegisterStringPref(prefs::kOAuth1Secret, 262 prefs->RegisterStringPref(prefs::kOAuth1Secret,
250 "", 263 "",
251 PrefService::UNSYNCABLE_PREF); 264 PrefService::UNSYNCABLE_PREF);
252 } 265 }
253 266
254 void Preferences::Init(PrefService* prefs) { 267 void Preferences::InitUserPrefs(PrefService* prefs) {
255 tap_to_click_enabled_.Init(prefs::kTapToClickEnabled, prefs, this); 268 tap_to_click_enabled_.Init(prefs::kTapToClickEnabled, prefs, this);
256 natural_scroll_.Init(prefs::kNaturalScroll, prefs, this); 269 natural_scroll_.Init(prefs::kNaturalScroll, prefs, this);
257 accessibility_enabled_.Init(prefs::kSpokenFeedbackEnabled, prefs, this); 270 accessibility_enabled_.Init(prefs::kSpokenFeedbackEnabled, prefs, this);
258 mouse_sensitivity_.Init(prefs::kMouseSensitivity, prefs, this); 271 mouse_sensitivity_.Init(prefs::kMouseSensitivity, prefs, this);
259 touchpad_sensitivity_.Init(prefs::kTouchpadSensitivity, prefs, this); 272 touchpad_sensitivity_.Init(prefs::kTouchpadSensitivity, prefs, this);
260 use_24hour_clock_.Init(prefs::kUse24HourClock, prefs, this); 273 use_24hour_clock_.Init(prefs::kUse24HourClock, prefs, this);
261 disable_gdata_.Init(prefs::kDisableGData, prefs, this); 274 disable_gdata_.Init(prefs::kDisableGData, prefs, this);
262 disable_gdata_over_cellular_.Init(prefs::kDisableGDataOverCellular, 275 disable_gdata_over_cellular_.Init(prefs::kDisableGDataOverCellular,
263 prefs, this); 276 prefs, this);
264 disable_gdata_hosted_files_.Init(prefs::kDisableGDataHostedFiles, 277 disable_gdata_hosted_files_.Init(prefs::kDisableGDataHostedFiles,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 xkb_remap_alt_key_to_.Init( 334 xkb_remap_alt_key_to_.Init(
322 prefs::kLanguageXkbRemapAltKeyTo, prefs, this); 335 prefs::kLanguageXkbRemapAltKeyTo, prefs, this);
323 xkb_auto_repeat_enabled_.Init( 336 xkb_auto_repeat_enabled_.Init(
324 prefs::kLanguageXkbAutoRepeatEnabled, prefs, this); 337 prefs::kLanguageXkbAutoRepeatEnabled, prefs, this);
325 xkb_auto_repeat_delay_pref_.Init( 338 xkb_auto_repeat_delay_pref_.Init(
326 prefs::kLanguageXkbAutoRepeatDelay, prefs, this); 339 prefs::kLanguageXkbAutoRepeatDelay, prefs, this);
327 xkb_auto_repeat_interval_pref_.Init( 340 xkb_auto_repeat_interval_pref_.Init(
328 prefs::kLanguageXkbAutoRepeatInterval, prefs, this); 341 prefs::kLanguageXkbAutoRepeatInterval, prefs, this);
329 342
330 enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, this); 343 enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, this);
344 }
345
346 void Preferences::Init(PrefService* prefs) {
347 InitUserPrefs(prefs);
331 348
332 // Initialize preferences to currently saved state. 349 // Initialize preferences to currently saved state.
333 NotifyPrefChanged(NULL); 350 NotifyPrefChanged(NULL);
334 351
335 // Initialize virtual keyboard settings to currently saved state. 352 // Initialize virtual keyboard settings to currently saved state.
336 UpdateVirturalKeyboardPreference(prefs); 353 UpdateVirturalKeyboardPreference(prefs);
337 354
338 // If a guest is logged in, initialize the prefs as if this is the first 355 // If a guest is logged in, initialize the prefs as if this is the first
339 // login. 356 // login.
340 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { 357 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) {
341 LoginUtils::Get()->SetFirstLoginPrefs(prefs); 358 LoginUtils::Get()->SetFirstLoginPrefs(prefs);
342 } 359 }
343 } 360 }
344 361
362 void Preferences::InitUserPrefsForTesting(PrefService* prefs) {
363 InitUserPrefs(prefs);
364 }
365
366 void Preferences::SetInputMethodListForTesting() {
367 SetInputMethodList();
368 }
369
345 void Preferences::Observe(int type, 370 void Preferences::Observe(int type,
346 const content::NotificationSource& source, 371 const content::NotificationSource& source,
347 const content::NotificationDetails& details) { 372 const content::NotificationDetails& details) {
348 if (type == chrome::NOTIFICATION_PREF_CHANGED) 373 if (type == chrome::NOTIFICATION_PREF_CHANGED)
349 NotifyPrefChanged(content::Details<std::string>(details).ptr()); 374 NotifyPrefChanged(content::Details<std::string>(details).ptr());
350 } 375 }
351 376
352 void Preferences::NotifyPrefChanged(const std::string* pref_name) { 377 void Preferences::NotifyPrefChanged(const std::string* pref_name) {
353 if (!pref_name || *pref_name == prefs::kTapToClickEnabled) { 378 if (!pref_name || *pref_name == prefs::kTapToClickEnabled) {
354 const bool enabled = tap_to_click_enabled_.GetValue(); 379 const bool enabled = tap_to_click_enabled_.GetValue();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 451 }
427 if (!pref_name || *pref_name == prefs::kLanguageXkbAutoRepeatEnabled) { 452 if (!pref_name || *pref_name == prefs::kLanguageXkbAutoRepeatEnabled) {
428 const bool enabled = xkb_auto_repeat_enabled_.GetValue(); 453 const bool enabled = xkb_auto_repeat_enabled_.GetValue();
429 input_method::XKeyboard::SetAutoRepeatEnabled(enabled); 454 input_method::XKeyboard::SetAutoRepeatEnabled(enabled);
430 } 455 }
431 if (!pref_name || ((*pref_name == prefs::kLanguageXkbAutoRepeatDelay) || 456 if (!pref_name || ((*pref_name == prefs::kLanguageXkbAutoRepeatDelay) ||
432 (*pref_name == prefs::kLanguageXkbAutoRepeatInterval))) { 457 (*pref_name == prefs::kLanguageXkbAutoRepeatInterval))) {
433 UpdateAutoRepeatRate(); 458 UpdateAutoRepeatRate();
434 } 459 }
435 460
436 if (!pref_name || *pref_name == prefs::kLanguagePreloadEngines) { 461 if (!pref_name) {
462 SetInputMethodList();
463 } else if (*pref_name == prefs::kLanguagePreloadEngines) {
437 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, 464 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName,
438 language_prefs::kPreloadEnginesConfigName, 465 language_prefs::kPreloadEnginesConfigName,
439 preload_engines_.GetValue()); 466 preload_engines_.GetValue());
440 } 467 }
441 468
442 // Do not check |*pref_name| for the two prefs. We're only interested in 469 // Do not check |*pref_name| of the prefs for remembering current/previous
443 // initial values of the prefs. 470 // input methods here. We're only interested in initial values of the prefs.
444 if (!pref_name) {
445 const std::string previous_input_method_id =
446 previous_input_method_.GetValue();
447 const std::string current_input_method_id =
448 current_input_method_.GetValue();
449 // NOTICE: ChangeInputMethod() has to be called AFTER the value of
450 // |preload_engines_| is sent to the InputMethodManager. Otherwise, the
451 // ChangeInputMethod request might be ignored as an invalid input method ID.
452 input_method::InputMethodManager* manager =
453 input_method::InputMethodManager::GetInstance();
454 if (!previous_input_method_id.empty())
455 manager->ChangeInputMethod(previous_input_method_id);
456 if (!current_input_method_id.empty())
457 manager->ChangeInputMethod(current_input_method_id);
458 }
459 471
460 for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { 472 for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) {
461 if (!pref_name || 473 if (!pref_name ||
462 *pref_name == language_prefs::kChewingBooleanPrefs[i].pref_name) { 474 *pref_name == language_prefs::kChewingBooleanPrefs[i].pref_name) {
463 SetLanguageConfigBoolean( 475 SetLanguageConfigBoolean(
464 language_prefs::kChewingSectionName, 476 language_prefs::kChewingSectionName,
465 language_prefs::kChewingBooleanPrefs[i].ibus_config_name, 477 language_prefs::kChewingBooleanPrefs[i].ibus_config_name,
466 chewing_boolean_prefs_[i].GetValue()); 478 chewing_boolean_prefs_[i].GetValue());
467 } 479 }
468 } 480 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 enable_screen_lock_.GetValue()); 574 enable_screen_lock_.GetValue());
563 } 575 }
564 } 576 }
565 577
566 void Preferences::SetLanguageConfigBoolean(const char* section, 578 void Preferences::SetLanguageConfigBoolean(const char* section,
567 const char* name, 579 const char* name,
568 bool value) { 580 bool value) {
569 input_method::InputMethodConfigValue config; 581 input_method::InputMethodConfigValue config;
570 config.type = input_method::InputMethodConfigValue::kValueTypeBool; 582 config.type = input_method::InputMethodConfigValue::kValueTypeBool;
571 config.bool_value = value; 583 config.bool_value = value;
572 input_method::InputMethodManager::GetInstance()-> 584 input_method_manager_->SetInputMethodConfig(section, name, config);
573 SetInputMethodConfig(section, name, config);
574 } 585 }
575 586
576 void Preferences::SetLanguageConfigInteger(const char* section, 587 void Preferences::SetLanguageConfigInteger(const char* section,
577 const char* name, 588 const char* name,
578 int value) { 589 int value) {
579 input_method::InputMethodConfigValue config; 590 input_method::InputMethodConfigValue config;
580 config.type = input_method::InputMethodConfigValue::kValueTypeInt; 591 config.type = input_method::InputMethodConfigValue::kValueTypeInt;
581 config.int_value = value; 592 config.int_value = value;
582 input_method::InputMethodManager::GetInstance()-> 593 input_method_manager_->SetInputMethodConfig(section, name, config);
583 SetInputMethodConfig(section, name, config);
584 } 594 }
585 595
586 void Preferences::SetLanguageConfigString(const char* section, 596 void Preferences::SetLanguageConfigString(const char* section,
587 const char* name, 597 const char* name,
588 const std::string& value) { 598 const std::string& value) {
589 input_method::InputMethodConfigValue config; 599 input_method::InputMethodConfigValue config;
590 config.type = input_method::InputMethodConfigValue::kValueTypeString; 600 config.type = input_method::InputMethodConfigValue::kValueTypeString;
591 config.string_value = value; 601 config.string_value = value;
592 input_method::InputMethodManager::GetInstance()-> 602 input_method_manager_->SetInputMethodConfig(section, name, config);
593 SetInputMethodConfig(section, name, config);
594 } 603 }
595 604
596 void Preferences::SetLanguageConfigStringList( 605 void Preferences::SetLanguageConfigStringList(
597 const char* section, 606 const char* section,
598 const char* name, 607 const char* name,
599 const std::vector<std::string>& values) { 608 const std::vector<std::string>& values) {
600 input_method::InputMethodConfigValue config; 609 input_method::InputMethodConfigValue config;
601 config.type = input_method::InputMethodConfigValue::kValueTypeStringList; 610 config.type = input_method::InputMethodConfigValue::kValueTypeStringList;
602 for (size_t i = 0; i < values.size(); ++i) 611 for (size_t i = 0; i < values.size(); ++i)
603 config.string_list_value.push_back(values[i]); 612 config.string_list_value.push_back(values[i]);
604 613
605 input_method::InputMethodManager::GetInstance()-> 614 input_method_manager_->SetInputMethodConfig(section, name, config);
606 SetInputMethodConfig(section, name, config);
607 } 615 }
608 616
609 void Preferences::SetLanguageConfigStringListAsCSV(const char* section, 617 void Preferences::SetLanguageConfigStringListAsCSV(const char* section,
610 const char* name, 618 const char* name,
611 const std::string& value) { 619 const std::string& value) {
612 VLOG(1) << "Setting " << name << " to '" << value << "'"; 620 VLOG(1) << "Setting " << name << " to '" << value << "'";
613 621
614 std::vector<std::string> split_values; 622 std::vector<std::string> split_values;
615 if (!value.empty()) 623 if (!value.empty())
616 base::SplitString(value, ',', &split_values); 624 base::SplitString(value, ',', &split_values);
617 625
618 // We should call the cros API even when |value| is empty, to disable default 626 // We should call the cros API even when |value| is empty, to disable default
619 // config. 627 // config.
620 SetLanguageConfigStringList(section, name, split_values); 628 SetLanguageConfigStringList(section, name, split_values);
621 } 629 }
622 630
631 void Preferences::SetInputMethodList() {
632 // When |preload_engines_| are set, InputMethodManager::ChangeInputMethod()
633 // might be called to change the current input method to the first one in the
634 // |preload_engines_| list. This also updates previous/current input method
635 // prefs. That's why GetValue() calls are placed before the
636 // SetLanguageConfigStringListAsCSV() call below.
637 const std::string previous_input_method_id =
638 previous_input_method_.GetValue();
639 const std::string current_input_method_id = current_input_method_.GetValue();
640 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName,
641 language_prefs::kPreloadEnginesConfigName,
642 preload_engines_.GetValue());
643
644 // ChangeInputMethod() has to be called AFTER the value of |preload_engines_|
645 // is sent to the InputMethodManager. Otherwise, the ChangeInputMethod request
646 // might be ignored as an invalid input method ID. The ChangeInputMethod()
647 // calls are also necessary to restore the previous/current input method prefs
648 // which could have been modified by the SetLanguageConfigStringListAsCSV call
649 // above to the original state.
650 if (!previous_input_method_id.empty())
651 input_method_manager_->ChangeInputMethod(previous_input_method_id);
652 if (!current_input_method_id.empty())
653 input_method_manager_->ChangeInputMethod(current_input_method_id);
654 }
655
623 void Preferences::UpdateModifierKeyMapping() { 656 void Preferences::UpdateModifierKeyMapping() {
624 const int search_remap = xkb_remap_search_key_to_.GetValue(); 657 const int search_remap = xkb_remap_search_key_to_.GetValue();
625 const int control_remap = xkb_remap_control_key_to_.GetValue(); 658 const int control_remap = xkb_remap_control_key_to_.GetValue();
626 const int alt_remap = xkb_remap_alt_key_to_.GetValue(); 659 const int alt_remap = xkb_remap_alt_key_to_.GetValue();
627 if ((search_remap < input_method::kNumModifierKeys) && (search_remap >= 0) && 660 if ((search_remap < input_method::kNumModifierKeys) && (search_remap >= 0) &&
628 (control_remap < input_method::kNumModifierKeys) && 661 (control_remap < input_method::kNumModifierKeys) &&
629 (control_remap >= 0) && 662 (control_remap >= 0) &&
630 (alt_remap < input_method::kNumModifierKeys) && (alt_remap >= 0)) { 663 (alt_remap < input_method::kNumModifierKeys) && (alt_remap >= 0)) {
631 input_method::ModifierMap modifier_map; 664 input_method::ModifierMap modifier_map;
632 modifier_map.push_back( 665 modifier_map.push_back(
633 input_method::ModifierKeyPair( 666 input_method::ModifierKeyPair(
634 input_method::kSearchKey, 667 input_method::kSearchKey,
635 input_method::ModifierKey(search_remap))); 668 input_method::ModifierKey(search_remap)));
636 modifier_map.push_back( 669 modifier_map.push_back(
637 input_method::ModifierKeyPair( 670 input_method::ModifierKeyPair(
638 input_method::kLeftControlKey, 671 input_method::kLeftControlKey,
639 input_method::ModifierKey(control_remap))); 672 input_method::ModifierKey(control_remap)));
640 modifier_map.push_back( 673 modifier_map.push_back(
641 input_method::ModifierKeyPair( 674 input_method::ModifierKeyPair(
642 input_method::kLeftAltKey, 675 input_method::kLeftAltKey,
643 input_method::ModifierKey(alt_remap))); 676 input_method::ModifierKey(alt_remap)));
644 input_method::InputMethodManager::GetInstance()->GetXKeyboard()-> 677 input_method_manager_->GetXKeyboard()->RemapModifierKeys(modifier_map);
645 RemapModifierKeys(modifier_map);
646 } else { 678 } else {
647 LOG(ERROR) << "Failed to remap modifier keys. Unexpected value(s): " 679 LOG(ERROR) << "Failed to remap modifier keys. Unexpected value(s): "
648 << search_remap << ", " << control_remap << ", " << alt_remap; 680 << search_remap << ", " << control_remap << ", " << alt_remap;
649 } 681 }
650 } 682 }
651 683
652 void Preferences::UpdateAutoRepeatRate() { 684 void Preferences::UpdateAutoRepeatRate() {
653 // Avoid setting repeat rate on desktop dev environment. 685 // Avoid setting repeat rate on desktop dev environment.
654 if (!base::chromeos::IsRunningOnChromeOS()) 686 if (!base::chromeos::IsRunningOnChromeOS())
655 return; 687 return;
656 688
657 input_method::AutoRepeatRate rate; 689 input_method::AutoRepeatRate rate;
658 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); 690 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue();
659 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); 691 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue();
660 DCHECK(rate.initial_delay_in_ms > 0); 692 DCHECK(rate.initial_delay_in_ms > 0);
661 DCHECK(rate.repeat_interval_in_ms > 0); 693 DCHECK(rate.repeat_interval_in_ms > 0);
662 input_method::XKeyboard::SetAutoRepeatRate(rate); 694 input_method::XKeyboard::SetAutoRepeatRate(rate);
663 } 695 }
664 696
665 void Preferences::UpdateVirturalKeyboardPreference(PrefService* prefs) { 697 void Preferences::UpdateVirturalKeyboardPreference(PrefService* prefs) {
666 const DictionaryValue* virtual_keyboard_pref = 698 const DictionaryValue* virtual_keyboard_pref =
667 prefs->GetDictionary(prefs::kLanguagePreferredVirtualKeyboard); 699 prefs->GetDictionary(prefs::kLanguagePreferredVirtualKeyboard);
668 DCHECK(virtual_keyboard_pref); 700 DCHECK(virtual_keyboard_pref);
669 701
670 input_method::InputMethodManager* input_method_manager = 702 input_method::InputMethodManager* input_method_manager =
671 input_method::InputMethodManager::GetInstance(); 703 input_method::InputMethodManager::GetInstance();
kinaba 2012/04/12 06:02:01 Just for confirmation, shouldn't this be replaced
Yusuke Sato 2012/04/12 09:21:25 good point, but actually the method is static. let
672 input_method_manager->ClearAllVirtualKeyboardPreferences(); 704 input_method_manager->ClearAllVirtualKeyboardPreferences();
673 705
674 std::string url; 706 std::string url;
675 std::vector<std::string> layouts_to_remove; 707 std::vector<std::string> layouts_to_remove;
676 for (DictionaryValue::key_iterator iter = virtual_keyboard_pref->begin_keys(); 708 for (DictionaryValue::key_iterator iter = virtual_keyboard_pref->begin_keys();
677 iter != virtual_keyboard_pref->end_keys(); 709 iter != virtual_keyboard_pref->end_keys();
678 ++iter) { 710 ++iter) {
679 const std::string& layout_id = *iter; // e.g. "us", "handwriting-vk" 711 const std::string& layout_id = *iter; // e.g. "us", "handwriting-vk"
680 if (!virtual_keyboard_pref->GetString(layout_id, &url)) 712 if (!virtual_keyboard_pref->GetString(layout_id, &url))
681 continue; 713 continue;
682 if (!input_method_manager->SetVirtualKeyboardPreference( 714 if (!input_method_manager->SetVirtualKeyboardPreference(
683 layout_id, GURL(url))) { 715 layout_id, GURL(url))) {
684 // Either |layout_id| or |url| is invalid. Remove the key from |prefs| 716 // Either |layout_id| or |url| is invalid. Remove the key from |prefs|
685 // later. 717 // later.
686 layouts_to_remove.push_back(layout_id); 718 layouts_to_remove.push_back(layout_id);
687 LOG(ERROR) << "Removing invalid virtual keyboard pref: layout=" 719 LOG(ERROR) << "Removing invalid virtual keyboard pref: layout="
688 << layout_id; 720 << layout_id;
689 } 721 }
690 } 722 }
691 723
692 // Remove invalid prefs. 724 // Remove invalid prefs.
693 DictionaryPrefUpdate updater(prefs, prefs::kLanguagePreferredVirtualKeyboard); 725 DictionaryPrefUpdate updater(prefs, prefs::kLanguagePreferredVirtualKeyboard);
694 DictionaryValue* pref_value = updater.Get(); 726 DictionaryValue* pref_value = updater.Get();
695 for (size_t i = 0; i < layouts_to_remove.size(); ++i) { 727 for (size_t i = 0; i < layouts_to_remove.size(); ++i) {
696 pref_value->RemoveWithoutPathExpansion(layouts_to_remove[i], NULL); 728 pref_value->RemoveWithoutPathExpansion(layouts_to_remove[i], NULL);
697 } 729 }
698 } 730 }
699 731
700 } // namespace chromeos 732 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698