Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / base / ime / chromeos / ime_keyboard_ozone.cc
blob5436d6234369230438efb2026c7ee76a66905b7a
1 // Copyright 2014 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 "ui/base/ime/chromeos/ime_keyboard_ozone.h"
6 #include "ui/events/ozone/layout/keyboard_layout_engine.h"
7 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
10 #include "ui/ozone/public/input_controller.h"
11 #include "ui/ozone/public/ozone_platform.h"
13 namespace chromeos {
14 namespace input_method {
16 ImeKeyboardOzone::ImeKeyboardOzone(ui::InputController* input_controller)
17 : input_controller_(input_controller) {
21 ImeKeyboardOzone::~ImeKeyboardOzone() {
24 bool ImeKeyboardOzone::SetCurrentKeyboardLayoutByName(
25 const std::string& layout_name) {
26 last_layout_ = layout_name;
27 ui::KeyboardLayoutEngine* keyboard_engine = ui::KeyboardLayoutEngineManager::
28 GetKeyboardLayoutEngine();
29 keyboard_engine->SetCurrentLayoutByName(layout_name);
30 return true;
33 bool ImeKeyboardOzone::ReapplyCurrentKeyboardLayout() {
34 return SetCurrentKeyboardLayoutByName(last_layout_);
37 void ImeKeyboardOzone::SetCapsLockEnabled(bool enable_caps_lock) {
38 // Inform ImeKeyboard of caps lock state.
39 ImeKeyboard::SetCapsLockEnabled(enable_caps_lock);
40 // Inform Ozone InputController input of caps lock state.
41 input_controller_->SetCapsLockEnabled(enable_caps_lock);
44 bool ImeKeyboardOzone::CapsLockIsEnabled() {
45 return input_controller_->IsCapsLockEnabled();
48 void ImeKeyboardOzone::ReapplyCurrentModifierLockStatus() {
51 void ImeKeyboardOzone::DisableNumLock() {
52 input_controller_->SetNumLockEnabled(false);
55 bool ImeKeyboardOzone::SetAutoRepeatRate(const AutoRepeatRate& rate) {
56 input_controller_->SetAutoRepeatRate(
57 base::TimeDelta::FromMilliseconds(rate.initial_delay_in_ms),
58 base::TimeDelta::FromMilliseconds(rate.repeat_interval_in_ms));
59 return true;
62 bool ImeKeyboardOzone::SetAutoRepeatEnabled(bool enabled) {
63 input_controller_->SetAutoRepeatEnabled(enabled);
64 return true;
67 bool ImeKeyboardOzone::GetAutoRepeatEnabled() {
68 return input_controller_->IsAutoRepeatEnabled();
71 // static
72 ImeKeyboard* ImeKeyboard::Create() {
73 return new ImeKeyboardOzone(
74 ui::OzonePlatform::GetInstance()->GetInputController());
77 } // namespace input_method
78 } // namespace chromeos