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/ash/ime_controller_chromeos.h" | 5 #include "chrome/browser/ui/ash/ime_controller_chromeos.h" |
6 | 6 |
7 #include "ui/base/accelerators/accelerator.h" | 7 #include "ui/base/accelerators/accelerator.h" |
8 #include "ui/base/ime/chromeos/input_method_manager.h" | 8 #include "ui/base/ime/chromeos/input_method_manager.h" |
9 | 9 |
10 bool ImeController::CanCycleIme() { | 10 bool ImeController::CanCycleIme() { |
(...skipping 18 matching lines...) Expand all Loading... |
29 chromeos::input_method::InputMethodManager* manager = | 29 chromeos::input_method::InputMethodManager* manager = |
30 chromeos::input_method::InputMethodManager::Get(); | 30 chromeos::input_method::InputMethodManager::Get(); |
31 return manager->GetActiveIMEState()->CanSwitchInputMethod(accelerator); | 31 return manager->GetActiveIMEState()->CanSwitchInputMethod(accelerator); |
32 } | 32 } |
33 | 33 |
34 void ImeController::HandleSwitchIme(const ui::Accelerator& accelerator) { | 34 void ImeController::HandleSwitchIme(const ui::Accelerator& accelerator) { |
35 chromeos::input_method::InputMethodManager* manager = | 35 chromeos::input_method::InputMethodManager* manager = |
36 chromeos::input_method::InputMethodManager::Get(); | 36 chromeos::input_method::InputMethodManager::Get(); |
37 manager->GetActiveIMEState()->SwitchInputMethod(accelerator); | 37 manager->GetActiveIMEState()->SwitchInputMethod(accelerator); |
38 } | 38 } |
39 | |
40 ui::Accelerator ImeController::RemapAccelerator( | |
41 const ui::Accelerator& accelerator) { | |
42 ui::KeyboardCode key = accelerator.key_code(); | |
43 // On French keyboards the user needs to press a number key in conjunction | |
44 // with the shift key. To get the right accelerator from our static table | |
45 // we modify the received accelerator to match this. See | |
46 // http://crbug.com/129017 for more details. | |
47 if (key < ui::VKEY_0 || key > ui::VKEY_9 || !UsingFrenchInputMethod()) | |
48 return accelerator; | |
49 | |
50 // We toggle the shift key to get the correct accelerator from our table. | |
51 int remapped_modifiers = accelerator.modifiers() ^ ui::EF_SHIFT_DOWN; | |
52 | |
53 ui::Accelerator remapped_accelerator(key, remapped_modifiers); | |
54 remapped_accelerator.set_type(accelerator.type()); | |
55 remapped_accelerator.set_is_repeat(accelerator.IsRepeat()); | |
56 return remapped_accelerator; | |
57 } | |
58 | |
59 bool ImeController::UsingFrenchInputMethod() const { | |
60 chromeos::input_method::InputMethodManager* manager = | |
61 chromeos::input_method::InputMethodManager::Get(); | |
62 const chromeos::input_method::InputMethodManager::State* state = | |
63 manager->GetActiveIMEState().get(); | |
64 | |
65 // KeyEvent can come before default user profile is initialized, so IM is | |
66 // still in global default state "en_US". | |
67 if (!state) | |
68 return false; | |
69 | |
70 const chromeos::input_method::InputMethodDescriptor& descriptor = | |
71 state->GetCurrentInputMethod(); | |
72 const std::string& layout = descriptor.id(); | |
73 return (layout == "xkb:fr::fra" || layout == "xkb:be::fra"); | |
74 } | |
OLD | NEW |