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 "base/string_util.h" | |
|
Yusuke Sato
2012/05/30 01:05:56
remove?
Mr4D (OOO till 08-26)
2012/05/30 15:46:03
Done.
| |
| 7 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 8 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 8 | 9 |
| 10 #include "chrome/browser/browser_process.h" | |
|
Yusuke Sato
2012/05/30 01:05:56
remove line 10-12?
Mr4D (OOO till 08-26)
2012/05/30 15:46:03
Done.
| |
| 11 #include "chrome/browser/prefs/pref_service.h" | |
| 12 #include "chrome/browser/chromeos/language_preferences.h" | |
| 13 #include "ui/base/accelerators/accelerator.h" | |
| 14 | |
| 9 bool ImeController::HandleNextIme() { | 15 bool ImeController::HandleNextIme() { |
| 10 chromeos::input_method::InputMethodManager* manager = | 16 chromeos::input_method::InputMethodManager* manager = |
| 11 chromeos::input_method::InputMethodManager::GetInstance(); | 17 chromeos::input_method::InputMethodManager::GetInstance(); |
| 12 return manager->SwitchToNextInputMethod(); | 18 return manager->SwitchToNextInputMethod(); |
| 13 } | 19 } |
| 14 | 20 |
| 15 bool ImeController::HandlePreviousIme() { | 21 bool ImeController::HandlePreviousIme() { |
| 16 chromeos::input_method::InputMethodManager* manager = | 22 chromeos::input_method::InputMethodManager* manager = |
| 17 chromeos::input_method::InputMethodManager::GetInstance(); | 23 chromeos::input_method::InputMethodManager::GetInstance(); |
| 18 return manager->SwitchToPreviousInputMethod(); | 24 return manager->SwitchToPreviousInputMethod(); |
| 19 } | 25 } |
| 20 | 26 |
| 21 bool ImeController::HandleSwitchIme(const ui::Accelerator& accelerator) { | 27 bool ImeController::HandleSwitchIme(const ui::Accelerator& accelerator) { |
| 22 chromeos::input_method::InputMethodManager* manager = | 28 chromeos::input_method::InputMethodManager* manager = |
| 23 chromeos::input_method::InputMethodManager::GetInstance(); | 29 chromeos::input_method::InputMethodManager::GetInstance(); |
| 24 return manager->SwitchInputMethod(accelerator); | 30 return manager->SwitchInputMethod(accelerator); |
| 25 } | 31 } |
| 32 | |
| 33 bool ImeController::IsFrenchKeyboard() { | |
| 34 chromeos::input_method::InputMethodManager* manager = | |
| 35 chromeos::input_method::InputMethodManager::GetInstance(); | |
| 36 const chromeos::input_method::InputMethodDescriptor& descriptor = | |
| 37 manager->GetCurrentInputMethod(); | |
| 38 std::string layout = descriptor.id(); | |
|
Yusuke Sato
2012/05/30 01:05:56
nit: const std::string&
Mr4D (OOO till 08-26)
2012/05/30 15:46:03
Done.
| |
| 39 return (layout == "xkb:fr::fra" || layout == "xkb:be::fra"); | |
| 40 } | |
| 41 | |
| 42 ui::Accelerator ImeController::RemapAccelerator( | |
| 43 const ui::Accelerator& accelerator) { | |
| 44 ui::KeyboardCode key = accelerator.key_code(); | |
| 45 int modifiers = accelerator.modifiers(); | |
| 46 // On French keyboards the user needs to press a number key in conjunction | |
| 47 // with the shift key. To get the right accelerator from our static table | |
| 48 // we modify the received accelerator to match this. | |
| 49 if (key >= ui::VKEY_0 && key <= ui::VKEY_9) { | |
| 50 // A keyboard layout can get changed by the user, so we need to dynamically | |
| 51 // check if a modification is required. | |
| 52 if (IsFrenchKeyboard()) | |
| 53 // We toggle the shift key to get the correct accelerator from our table. | |
| 54 modifiers ^= ui::EF_SHIFT_DOWN; | |
| 55 } | |
| 56 return ui::Accelerator(key, modifiers); | |
| 57 } | |
| OLD | NEW |