Chromium Code Reviews| Index: chrome/browser/ui/views/ash/ime_controller_chromeos.cc |
| diff --git a/chrome/browser/ui/views/ash/ime_controller_chromeos.cc b/chrome/browser/ui/views/ash/ime_controller_chromeos.cc |
| index 1934357e90140bc62cc7e8ea681e6ab6cc68b498..06803b9a98b2f6e771edfe8dbe5fb16e71b96307 100644 |
| --- a/chrome/browser/ui/views/ash/ime_controller_chromeos.cc |
| +++ b/chrome/browser/ui/views/ash/ime_controller_chromeos.cc |
| @@ -4,8 +4,14 @@ |
| #include "chrome/browser/ui/views/ash/ime_controller_chromeos.h" |
| +#include "base/string_util.h" |
| #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
|
mazda
2012/05/29 17:08:06
nit: unnecessary empty line
|
| +#include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/prefs/pref_service.h" |
| +#include "chrome/browser/chromeos/language_preferences.h" |
|
mazda
2012/05/29 17:08:06
nit: alphabetical order
|
| +#include "ui/base/accelerators/accelerator.h" |
| + |
| bool ImeController::HandleNextIme() { |
| chromeos::input_method::InputMethodManager* manager = |
| chromeos::input_method::InputMethodManager::GetInstance(); |
| @@ -23,3 +29,35 @@ bool ImeController::HandleSwitchIme(const ui::Accelerator& accelerator) { |
| chromeos::input_method::InputMethodManager::GetInstance(); |
| return manager->SwitchInputMethod(accelerator); |
| } |
| + |
| +bool ImeController::IsFrenchKeyboard() { |
| + // First check the settings. |
| + std::string layout = g_browser_process->local_state()->GetString( |
| + chromeos::language_prefs::kPreferredKeyboardLayout); |
| + if (layout == "") { |
|
mazda
2012/05/29 17:08:06
nit: layout.empty()
|
| + // If it is unset we check the hardware. |
| + chromeos::input_method::InputMethodManager* manager = |
| + chromeos::input_method::InputMethodManager::GetInstance(); |
| + const chromeos::input_method::InputMethodDescriptor& descriptor = |
| + manager->GetCurrentInputMethod(); |
| + layout = descriptor.id(); |
| + } |
| + return (layout == "xkb:fr::fra" || layout == "xkb:be::fra"); |
| +} |
| + |
| +ui::Accelerator ImeController::RemapAccelerator( |
| + const ui::Accelerator& accelerator) { |
| + ui::KeyboardCode key = accelerator.key_code(); |
| + int modifiers = accelerator.modifiers(); |
| + // On French keyboards the user needs to press a number key in conjunction |
| + // with the shift key. To get the right accelerator from our static table |
| + // we modify the received accelerator to match this. |
| + if (key >= ui::VKEY_0 && key <= ui::VKEY_9) { |
| + // A keyboard layout can get changed by the user, so we need to dynamically |
| + // check if a modification is required. |
| + if (IsFrenchKeyboard()) |
| + // We toggle the shift key to get the correct accelerator from our table. |
| + modifiers ^= ui::EF_SHIFT_DOWN; |
|
mazda
2012/05/29 17:08:06
Do we need to toggle the shift key when the shift
|
| + } |
| + return ui::Accelerator(key, modifiers); |
| +} |