crazy linker: Fix failure to cleanly unload libraries.
[chromium-blink-merge.git] / ui / keyboard / webui / vk_mojo_handler.cc
blob48e6dccd51eee190cdd763bfec6799b02812cc40
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 GetInputMethod()->AddObserver(this);
21 VKMojoHandler::~VKMojoHandler() {
22 GetInputMethod()->RemoveObserver(this);
25 ui::InputMethod* VKMojoHandler::GetInputMethod() {
26 return KeyboardController::GetInstance()->proxy()->GetInputMethod();
29 void VKMojoHandler::OnConnectionEstablished() {
30 OnTextInputStateChanged(GetInputMethod()->GetTextInputClient());
33 void VKMojoHandler::SendKeyEvent(const mojo::String& event_type,
34 int32_t char_value,
35 int32_t key_code,
36 const mojo::String& key_name,
37 int32_t modifiers) {
38 aura::Window* window =
39 KeyboardController::GetInstance()->GetContainerWindow();
40 std::string type = event_type.To<std::string>();
41 std::string name = key_name.To<std::string>();
42 keyboard::SendKeyEvent(
43 type, char_value, key_code, name, modifiers, window->GetHost());
46 void VKMojoHandler::HideKeyboard() {
47 KeyboardController::GetInstance()->HideKeyboard(
48 KeyboardController::HIDE_REASON_MANUAL);
51 void VKMojoHandler::OnTextInputTypeChanged(const ui::TextInputClient* client) {
54 void VKMojoHandler::OnFocus() {
57 void VKMojoHandler::OnBlur() {
60 void VKMojoHandler::OnCaretBoundsChanged(const ui::TextInputClient* client) {
63 void VKMojoHandler::OnTextInputStateChanged(
64 const ui::TextInputClient* text_client) {
65 ui::TextInputType type =
66 text_client ? text_client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE;
67 std::string type_name = "none";
68 switch (type) {
69 case ui::TEXT_INPUT_TYPE_NONE:
70 type_name = "none";
71 break;
73 case ui::TEXT_INPUT_TYPE_PASSWORD:
74 type_name = "password";
75 break;
77 case ui::TEXT_INPUT_TYPE_EMAIL:
78 type_name = "email";
79 break;
81 case ui::TEXT_INPUT_TYPE_NUMBER:
82 type_name = "number";
83 break;
85 case ui::TEXT_INPUT_TYPE_TELEPHONE:
86 type_name = "tel";
87 break;
89 case ui::TEXT_INPUT_TYPE_URL:
90 type_name = "url";
91 break;
93 case ui::TEXT_INPUT_TYPE_DATE:
94 type_name = "date";
95 break;
97 case ui::TEXT_INPUT_TYPE_TEXT:
98 case ui::TEXT_INPUT_TYPE_SEARCH:
99 case ui::TEXT_INPUT_TYPE_DATE_TIME:
100 case ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL:
101 case ui::TEXT_INPUT_TYPE_MONTH:
102 case ui::TEXT_INPUT_TYPE_TIME:
103 case ui::TEXT_INPUT_TYPE_WEEK:
104 case ui::TEXT_INPUT_TYPE_TEXT_AREA:
105 case ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE:
106 case ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD:
107 type_name = "text";
108 break;
110 client()->OnTextInputTypeChanged(type_name);
113 void VKMojoHandler::OnInputMethodDestroyed(
114 const ui::InputMethod* input_method) {
117 void VKMojoHandler::OnShowImeIfNeeded() {
120 } // namespace keyboard