Chromium Code Reviews| 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/ui/views/ash/ime_controller_chromeos.h" | 5 #include "chrome/browser/ui/views/ash/ime_controller_chromeos.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 7 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 8 #include "ui/base/accelerators/accelerator.h" | |
| 8 | 9 |
| 9 bool ImeController::HandleNextIme() { | 10 bool ImeController::HandleNextIme() { |
| 10 chromeos::input_method::InputMethodManager* manager = | 11 chromeos::input_method::InputMethodManager* manager = |
| 11 chromeos::input_method::InputMethodManager::GetInstance(); | 12 chromeos::input_method::InputMethodManager::GetInstance(); |
| 12 return manager->SwitchToNextInputMethod(); | 13 return manager->SwitchToNextInputMethod(); |
| 13 } | 14 } |
| 14 | 15 |
| 15 bool ImeController::HandlePreviousIme() { | 16 bool ImeController::HandlePreviousIme() { |
| 16 chromeos::input_method::InputMethodManager* manager = | 17 chromeos::input_method::InputMethodManager* manager = |
| 17 chromeos::input_method::InputMethodManager::GetInstance(); | 18 chromeos::input_method::InputMethodManager::GetInstance(); |
| 18 return manager->SwitchToPreviousInputMethod(); | 19 return manager->SwitchToPreviousInputMethod(); |
| 19 } | 20 } |
| 20 | 21 |
| 21 bool ImeController::HandleSwitchIme(const ui::Accelerator& accelerator) { | 22 bool ImeController::HandleSwitchIme(const ui::Accelerator& accelerator) { |
| 22 chromeos::input_method::InputMethodManager* manager = | 23 chromeos::input_method::InputMethodManager* manager = |
| 23 chromeos::input_method::InputMethodManager::GetInstance(); | 24 chromeos::input_method::InputMethodManager::GetInstance(); |
| 24 return manager->SwitchInputMethod(accelerator); | 25 return manager->SwitchInputMethod(accelerator); |
| 25 } | 26 } |
| 27 | |
| 28 bool ImeController::IsFrenchKeyboard() { | |
|
Daniel Erat
2012/05/30 15:58:27
nit: move this down so it matches the declaration
Mr4D (OOO till 08-26)
2012/05/30 16:21:31
Done.
| |
| 29 chromeos::input_method::InputMethodManager* manager = | |
| 30 chromeos::input_method::InputMethodManager::GetInstance(); | |
| 31 const chromeos::input_method::InputMethodDescriptor& descriptor = | |
| 32 manager->GetCurrentInputMethod(); | |
| 33 const std::string& layout = descriptor.id(); | |
| 34 return (layout == "xkb:fr::fra" || layout == "xkb:be::fra"); | |
| 35 } | |
| 36 | |
| 37 ui::Accelerator ImeController::RemapAccelerator( | |
| 38 const ui::Accelerator& accelerator) { | |
| 39 ui::KeyboardCode key = accelerator.key_code(); | |
| 40 int modifiers = accelerator.modifiers(); | |
| 41 // On French keyboards the user needs to press a number key in conjunction | |
| 42 // with the shift key. To get the right accelerator from our static table | |
|
Daniel Erat
2012/05/30 15:58:27
nit: link to http://crbug.com/129017 here so it's
Mr4D (OOO till 08-26)
2012/05/30 16:21:31
Done.
| |
| 43 // we modify the received accelerator to match this. | |
| 44 if (key >= ui::VKEY_0 && key <= ui::VKEY_9) { | |
| 45 // A keyboard layout can get changed by the user, so we need to dynamically | |
|
Daniel Erat
2012/05/30 15:58:27
will HandleSwitchIme() get called when this happen
Mr4D (OOO till 08-26)
2012/05/30 16:21:31
This is only done for number keys. Even more: I am
Daniel Erat
2012/05/30 16:54:06
Just change the comment to "This is cheap; check i
Mr4D (OOO till 08-26)
2012/05/30 17:37:17
Had the comment already changed, but changed it on
| |
| 46 // check if a modification is required. | |
| 47 if (IsFrenchKeyboard()) | |
| 48 // We toggle the shift key to get the correct accelerator from our table. | |
| 49 modifiers ^= ui::EF_SHIFT_DOWN; | |
| 50 } | |
| 51 return ui::Accelerator(key, modifiers); | |
| 52 } | |
| OLD | NEW |