Add type annotations to video_player.js.
[chromium-blink-merge.git] / ui / keyboard / webui / vk_mojo_handler.cc
blob5efe763eedfec2d0466635e4dc85eff0234304fb
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/keyboard/webui/vk_mojo_handler.h"
7 #include "ui/aura/window.h"
8 #include "ui/base/ime/input_method.h"
9 #include "ui/base/ime/text_input_client.h"
10 #include "ui/keyboard/keyboard_controller.h"
11 #include "ui/keyboard/keyboard_controller_proxy.h"
12 #include "ui/keyboard/keyboard_util.h"
13 #include "ui/keyboard/webui/keyboard.mojom.h"
15 namespace keyboard {
17 VKMojoHandler::VKMojoHandler(
18 mojo::InterfaceRequest<KeyboardUIHandlerMojo> request)
19 : binding_(this, request.Pass()) {
20 GetInputMethod()->AddObserver(this);
21 OnTextInputStateChanged(GetInputMethod()->GetTextInputClient());
24 VKMojoHandler::~VKMojoHandler() {
25 GetInputMethod()->RemoveObserver(this);
28 ui::InputMethod* VKMojoHandler::GetInputMethod() {
29 return KeyboardController::GetInstance()->proxy()->GetInputMethod();
32 void VKMojoHandler::SendKeyEvent(const mojo::String& event_type,
33 int32_t char_value,
34 int32_t key_code,
35 const mojo::String& key_name,
36 int32_t modifiers) {
37 aura::Window* window =
38 KeyboardController::GetInstance()->GetContainerWindow();
39 std::string type = event_type.To<std::string>();
40 std::string name = key_name.To<std::string>();
41 keyboard::SendKeyEvent(
42 type, char_value, key_code, name, modifiers, window->GetHost());
45 void VKMojoHandler::HideKeyboard() {
46 KeyboardController::GetInstance()->HideKeyboard(
47 KeyboardController::HIDE_REASON_MANUAL);
50 void VKMojoHandler::OnTextInputTypeChanged(const ui::TextInputClient* client) {
53 void VKMojoHandler::OnFocus() {
56 void VKMojoHandler::OnBlur() {
59 void VKMojoHandler::OnCaretBoundsChanged(const ui::TextInputClient* client) {
62 void VKMojoHandler::OnTextInputStateChanged(
63 const ui::TextInputClient* text_client) {
64 ui::TextInputType type =
65 text_client ? text_client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE;
66 std::string type_name = "none";
67 switch (type) {
68 case ui::TEXT_INPUT_TYPE_NONE:
69 type_name = "none";
70 break;
72 case ui::TEXT_INPUT_TYPE_PASSWORD:
73 type_name = "password";
74 break;
76 case ui::TEXT_INPUT_TYPE_EMAIL:
77 type_name = "email";
78 break;
80 case ui::TEXT_INPUT_TYPE_NUMBER:
81 type_name = "number";
82 break;
84 case ui::TEXT_INPUT_TYPE_TELEPHONE:
85 type_name = "tel";
86 break;
88 case ui::TEXT_INPUT_TYPE_URL:
89 type_name = "url";
90 break;
92 case ui::TEXT_INPUT_TYPE_DATE:
93 type_name = "date";
94 break;
96 case ui::TEXT_INPUT_TYPE_TEXT:
97 case ui::TEXT_INPUT_TYPE_SEARCH:
98 case ui::TEXT_INPUT_TYPE_DATE_TIME:
99 case ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL:
100 case ui::TEXT_INPUT_TYPE_MONTH:
101 case ui::TEXT_INPUT_TYPE_TIME:
102 case ui::TEXT_INPUT_TYPE_WEEK:
103 case ui::TEXT_INPUT_TYPE_TEXT_AREA:
104 case ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE:
105 case ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD:
106 type_name = "text";
107 break;
109 binding_.client()->OnTextInputTypeChanged(type_name);
112 void VKMojoHandler::OnInputMethodDestroyed(
113 const ui::InputMethod* input_method) {
116 void VKMojoHandler::OnShowImeIfNeeded() {
119 } // namespace keyboard