| OLD | NEW |
| 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 language_prefs::kMozcBooleanPrefs[i].pref_name, prefs, this); | 324 language_prefs::kMozcBooleanPrefs[i].pref_name, prefs, this); |
| 325 } | 325 } |
| 326 for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { | 326 for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { |
| 327 mozc_multiple_choice_prefs_[i].Init( | 327 mozc_multiple_choice_prefs_[i].Init( |
| 328 language_prefs::kMozcMultipleChoicePrefs[i].pref_name, prefs, this); | 328 language_prefs::kMozcMultipleChoicePrefs[i].pref_name, prefs, this); |
| 329 } | 329 } |
| 330 for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { | 330 for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { |
| 331 mozc_integer_prefs_[i].Init( | 331 mozc_integer_prefs_[i].Init( |
| 332 language_prefs::kMozcIntegerPrefs[i].pref_name, prefs, this); | 332 language_prefs::kMozcIntegerPrefs[i].pref_name, prefs, this); |
| 333 } | 333 } |
| 334 xkb_remap_search_key_to_.Init( | |
| 335 prefs::kLanguageXkbRemapSearchKeyTo, prefs, this); | |
| 336 xkb_remap_control_key_to_.Init( | |
| 337 prefs::kLanguageXkbRemapControlKeyTo, prefs, this); | |
| 338 xkb_remap_alt_key_to_.Init( | |
| 339 prefs::kLanguageXkbRemapAltKeyTo, prefs, this); | |
| 340 xkb_auto_repeat_enabled_.Init( | 334 xkb_auto_repeat_enabled_.Init( |
| 341 prefs::kLanguageXkbAutoRepeatEnabled, prefs, this); | 335 prefs::kLanguageXkbAutoRepeatEnabled, prefs, this); |
| 342 xkb_auto_repeat_delay_pref_.Init( | 336 xkb_auto_repeat_delay_pref_.Init( |
| 343 prefs::kLanguageXkbAutoRepeatDelay, prefs, this); | 337 prefs::kLanguageXkbAutoRepeatDelay, prefs, this); |
| 344 xkb_auto_repeat_interval_pref_.Init( | 338 xkb_auto_repeat_interval_pref_.Init( |
| 345 prefs::kLanguageXkbAutoRepeatInterval, prefs, this); | 339 prefs::kLanguageXkbAutoRepeatInterval, prefs, this); |
| 346 | 340 |
| 347 enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, this); | 341 enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, this); |
| 348 | 342 |
| 349 enable_drm_.Init(prefs::kEnableCrosDRM, prefs, this); | 343 enable_drm_.Init(prefs::kEnableCrosDRM, prefs, this); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 UMA_HISTOGRAM_BOOLEAN("Mouse.PrimaryButtonRight.Changed", right); | 425 UMA_HISTOGRAM_BOOLEAN("Mouse.PrimaryButtonRight.Changed", right); |
| 432 else | 426 else |
| 433 UMA_HISTOGRAM_BOOLEAN("Mouse.PrimaryButtonRight.Started", right); | 427 UMA_HISTOGRAM_BOOLEAN("Mouse.PrimaryButtonRight.Started", right); |
| 434 } | 428 } |
| 435 | 429 |
| 436 if (!pref_name || *pref_name == prefs::kLanguagePreferredLanguages) { | 430 if (!pref_name || *pref_name == prefs::kLanguagePreferredLanguages) { |
| 437 // Unlike kLanguagePreloadEngines and some other input method | 431 // Unlike kLanguagePreloadEngines and some other input method |
| 438 // preferencs, we don't need to send this to ibus-daemon. | 432 // preferencs, we don't need to send this to ibus-daemon. |
| 439 } | 433 } |
| 440 | 434 |
| 441 // Here, we set up the the modifier key mapping. This has to be done | |
| 442 // before changing the current keyboard layout, so that the modifier key | |
| 443 // preference is properly preserved. For this reason, we should do this | |
| 444 // before setting preload engines, that could change the current | |
| 445 // keyboard layout as needed. | |
| 446 if (!pref_name || (*pref_name == prefs::kLanguageXkbRemapSearchKeyTo || | |
| 447 *pref_name == prefs::kLanguageXkbRemapControlKeyTo || | |
| 448 *pref_name == prefs::kLanguageXkbRemapAltKeyTo)) { | |
| 449 UpdateModifierKeyMapping(); | |
| 450 } | |
| 451 if (!pref_name || *pref_name == prefs::kLanguageXkbAutoRepeatEnabled) { | 435 if (!pref_name || *pref_name == prefs::kLanguageXkbAutoRepeatEnabled) { |
| 452 const bool enabled = xkb_auto_repeat_enabled_.GetValue(); | 436 const bool enabled = xkb_auto_repeat_enabled_.GetValue(); |
| 453 input_method::XKeyboard::SetAutoRepeatEnabled(enabled); | 437 input_method::XKeyboard::SetAutoRepeatEnabled(enabled); |
| 454 } | 438 } |
| 455 if (!pref_name || ((*pref_name == prefs::kLanguageXkbAutoRepeatDelay) || | 439 if (!pref_name || ((*pref_name == prefs::kLanguageXkbAutoRepeatDelay) || |
| 456 (*pref_name == prefs::kLanguageXkbAutoRepeatInterval))) { | 440 (*pref_name == prefs::kLanguageXkbAutoRepeatInterval))) { |
| 457 UpdateAutoRepeatRate(); | 441 UpdateAutoRepeatRate(); |
| 458 } | 442 } |
| 459 | 443 |
| 460 if (!pref_name) { | 444 if (!pref_name) { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 // might be ignored as an invalid input method ID. The ChangeInputMethod() | 640 // might be ignored as an invalid input method ID. The ChangeInputMethod() |
| 657 // calls are also necessary to restore the previous/current input method prefs | 641 // calls are also necessary to restore the previous/current input method prefs |
| 658 // which could have been modified by the SetLanguageConfigStringListAsCSV call | 642 // which could have been modified by the SetLanguageConfigStringListAsCSV call |
| 659 // above to the original state. | 643 // above to the original state. |
| 660 if (!previous_input_method_id.empty()) | 644 if (!previous_input_method_id.empty()) |
| 661 input_method_manager_->ChangeInputMethod(previous_input_method_id); | 645 input_method_manager_->ChangeInputMethod(previous_input_method_id); |
| 662 if (!current_input_method_id.empty()) | 646 if (!current_input_method_id.empty()) |
| 663 input_method_manager_->ChangeInputMethod(current_input_method_id); | 647 input_method_manager_->ChangeInputMethod(current_input_method_id); |
| 664 } | 648 } |
| 665 | 649 |
| 666 void Preferences::UpdateModifierKeyMapping() { | |
| 667 const int search_remap = xkb_remap_search_key_to_.GetValue(); | |
| 668 const int control_remap = xkb_remap_control_key_to_.GetValue(); | |
| 669 const int alt_remap = xkb_remap_alt_key_to_.GetValue(); | |
| 670 if ((search_remap < input_method::kNumModifierKeys) && (search_remap >= 0) && | |
| 671 (control_remap < input_method::kNumModifierKeys) && | |
| 672 (control_remap >= 0) && | |
| 673 (alt_remap < input_method::kNumModifierKeys) && (alt_remap >= 0)) { | |
| 674 input_method::ModifierMap modifier_map; | |
| 675 modifier_map.push_back( | |
| 676 input_method::ModifierKeyPair( | |
| 677 input_method::kSearchKey, | |
| 678 input_method::ModifierKey(search_remap))); | |
| 679 modifier_map.push_back( | |
| 680 input_method::ModifierKeyPair( | |
| 681 input_method::kControlKey, | |
| 682 input_method::ModifierKey(control_remap))); | |
| 683 modifier_map.push_back( | |
| 684 input_method::ModifierKeyPair( | |
| 685 input_method::kAltKey, | |
| 686 input_method::ModifierKey(alt_remap))); | |
| 687 input_method_manager_->GetXKeyboard()->RemapModifierKeys(modifier_map); | |
| 688 } else { | |
| 689 LOG(ERROR) << "Failed to remap modifier keys. Unexpected value(s): " | |
| 690 << search_remap << ", " << control_remap << ", " << alt_remap; | |
| 691 } | |
| 692 } | |
| 693 | |
| 694 void Preferences::UpdateAutoRepeatRate() { | 650 void Preferences::UpdateAutoRepeatRate() { |
| 695 // Avoid setting repeat rate on desktop dev environment. | 651 // Avoid setting repeat rate on desktop dev environment. |
| 696 if (!base::chromeos::IsRunningOnChromeOS()) | 652 if (!base::chromeos::IsRunningOnChromeOS()) |
| 697 return; | 653 return; |
| 698 | 654 |
| 699 input_method::AutoRepeatRate rate; | 655 input_method::AutoRepeatRate rate; |
| 700 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); | 656 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); |
| 701 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); | 657 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); |
| 702 DCHECK(rate.initial_delay_in_ms > 0); | 658 DCHECK(rate.initial_delay_in_ms > 0); |
| 703 DCHECK(rate.repeat_interval_in_ms > 0); | 659 DCHECK(rate.repeat_interval_in_ms > 0); |
| 704 input_method::XKeyboard::SetAutoRepeatRate(rate); | 660 input_method::XKeyboard::SetAutoRepeatRate(rate); |
| 705 } | 661 } |
| 706 | 662 |
| 707 } // namespace chromeos | 663 } // namespace chromeos |
| OLD | NEW |