Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: chrome/browser/ui/ash/ime_controller_chromeos.cc

Issue 419293002: IME refactoring: ChromeOS introduce input methods State. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit test fixed. Re-sorted methods of StateImpl and IMM. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chromeos/ime/input_method_manager.h" 7 #include "chromeos/ime/input_method_manager.h"
8 #include "ui/base/accelerators/accelerator.h" 8 #include "ui/base/accelerators/accelerator.h"
9 9
10 void ImeController::HandleNextIme() { 10 void ImeController::HandleNextIme() {
11 chromeos::input_method::InputMethodManager* manager = 11 chromeos::input_method::InputMethodManager* manager =
12 chromeos::input_method::InputMethodManager::Get(); 12 chromeos::input_method::InputMethodManager::Get();
13 manager->SwitchToNextInputMethod(); 13 manager->GetActiveIMEState()->SwitchToNextInputMethod();
14 } 14 }
15 15
16 bool ImeController::HandlePreviousIme(const ui::Accelerator& accelerator) { 16 bool ImeController::HandlePreviousIme(const ui::Accelerator& accelerator) {
17 chromeos::input_method::InputMethodManager* manager = 17 chromeos::input_method::InputMethodManager* manager =
18 chromeos::input_method::InputMethodManager::Get(); 18 chromeos::input_method::InputMethodManager::Get();
19 return manager->SwitchToPreviousInputMethod(accelerator); 19 return manager->GetActiveIMEState()->SwitchToPreviousInputMethod(accelerator);
20 } 20 }
21 21
22 bool ImeController::HandleSwitchIme(const ui::Accelerator& accelerator) { 22 bool ImeController::HandleSwitchIme(const ui::Accelerator& accelerator) {
23 chromeos::input_method::InputMethodManager* manager = 23 chromeos::input_method::InputMethodManager* manager =
24 chromeos::input_method::InputMethodManager::Get(); 24 chromeos::input_method::InputMethodManager::Get();
25 return manager->SwitchInputMethod(accelerator); 25 return manager->GetActiveIMEState()->SwitchInputMethod(accelerator);
26 } 26 }
27 27
28 ui::Accelerator ImeController::RemapAccelerator( 28 ui::Accelerator ImeController::RemapAccelerator(
29 const ui::Accelerator& accelerator) { 29 const ui::Accelerator& accelerator) {
30 ui::KeyboardCode key = accelerator.key_code(); 30 ui::KeyboardCode key = accelerator.key_code();
31 int modifiers = accelerator.modifiers(); 31 int modifiers = accelerator.modifiers();
32 // On French keyboards the user needs to press a number key in conjunction 32 // On French keyboards the user needs to press a number key in conjunction
33 // with the shift key. To get the right accelerator from our static table 33 // with the shift key. To get the right accelerator from our static table
34 // we modify the received accelerator to match this. 34 // we modify the received accelerator to match this.
35 if (key >= ui::VKEY_0 && key <= ui::VKEY_9) { 35 if (key >= ui::VKEY_0 && key <= ui::VKEY_9) {
36 // A keyboard layout can get changed by the user, so we perform quickly 36 // A keyboard layout can get changed by the user, so we perform quickly
37 // this cheap layout test. 37 // this cheap layout test.
38 // See http://crbug.com/129017 for more details. 38 // See http://crbug.com/129017 for more details.
39 if (UsingFrenchInputMethod()) { 39 if (UsingFrenchInputMethod()) {
40 // We toggle the shift key to get the correct accelerator from our table. 40 // We toggle the shift key to get the correct accelerator from our table.
41 modifiers ^= ui::EF_SHIFT_DOWN; 41 modifiers ^= ui::EF_SHIFT_DOWN;
42 } 42 }
43 } 43 }
44 ui::Accelerator remapped_accelerator(key, modifiers); 44 ui::Accelerator remapped_accelerator(key, modifiers);
45 remapped_accelerator.set_type(accelerator.type()); 45 remapped_accelerator.set_type(accelerator.type());
46 return remapped_accelerator; 46 return remapped_accelerator;
47 } 47 }
48 48
49 bool ImeController::UsingFrenchInputMethod() const { 49 bool ImeController::UsingFrenchInputMethod() const {
50 chromeos::input_method::InputMethodManager* manager = 50 chromeos::input_method::InputMethodManager* manager =
51 chromeos::input_method::InputMethodManager::Get(); 51 chromeos::input_method::InputMethodManager::Get();
52 const chromeos::input_method::InputMethodDescriptor& descriptor = 52 const chromeos::input_method::InputMethodDescriptor& descriptor =
53 manager->GetCurrentInputMethod(); 53 manager->GetActiveIMEState()->GetCurrentInputMethod();
54 const std::string& layout = descriptor.id(); 54 const std::string& layout = descriptor.id();
55 return (layout == "xkb:fr::fra" || layout == "xkb:be::fra"); 55 return (layout == "xkb:fr::fra" || layout == "xkb:be::fra");
56 } 56 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.cc ('k') | chrome/browser/ui/ash/system_tray_delegate_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698