Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / ui / ash / ime_controller_chromeos.cc
blob07f10196c4586144ea5f7033ef9f78639de25dd5
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/ash/ime_controller_chromeos.h"
7 #include "ui/base/accelerators/accelerator.h"
8 #include "ui/base/ime/chromeos/input_method_manager.h"
10 bool ImeController::CanCycleIme() {
11 chromeos::input_method::InputMethodManager* manager =
12 chromeos::input_method::InputMethodManager::Get();
13 return manager->GetActiveIMEState()->CanCycleInputMethod();
16 void ImeController::HandleNextIme() {
17 chromeos::input_method::InputMethodManager* manager =
18 chromeos::input_method::InputMethodManager::Get();
19 manager->GetActiveIMEState()->SwitchToNextInputMethod();
22 void ImeController::HandlePreviousIme() {
23 chromeos::input_method::InputMethodManager* manager =
24 chromeos::input_method::InputMethodManager::Get();
25 manager->GetActiveIMEState()->SwitchToPreviousInputMethod();
28 bool ImeController::CanSwitchIme(const ui::Accelerator& accelerator) {
29 chromeos::input_method::InputMethodManager* manager =
30 chromeos::input_method::InputMethodManager::Get();
31 return manager->GetActiveIMEState()->CanSwitchInputMethod(accelerator);
34 void ImeController::HandleSwitchIme(const ui::Accelerator& accelerator) {
35 chromeos::input_method::InputMethodManager* manager =
36 chromeos::input_method::InputMethodManager::Get();
37 manager->GetActiveIMEState()->SwitchInputMethod(accelerator);
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;
50 // We toggle the shift key to get the correct accelerator from our table.
51 int remapped_modifiers = accelerator.modifiers() ^ ui::EF_SHIFT_DOWN;
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;
59 bool ImeController::UsingFrenchInputMethod() const {
60 chromeos::input_method::InputMethodManager* manager =
61 chromeos::input_method::InputMethodManager::Get();
62 const chromeos::input_method::InputMethodDescriptor& descriptor =
63 manager->GetActiveIMEState()->GetCurrentInputMethod();
64 const std::string& layout = descriptor.id();
65 return (layout == "xkb:fr::fra" || layout == "xkb:be::fra");