blob: f40e9dbdfd0a90c5d7a338f3157ad5fcaa420fa5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/keyboard/webui/vk_mojo_handler.h"
#include "ui/aura/window.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_controller_proxy.h"
#include "ui/keyboard/keyboard_util.h"
#include "ui/keyboard/webui/keyboard.mojom.h"
namespace keyboard {
VKMojoHandler::VKMojoHandler(
mojo::InterfaceRequest<KeyboardUIHandlerMojo> request)
: binding_(this, request.Pass()) {
GetInputMethod()->AddObserver(this);
OnTextInputStateChanged(GetInputMethod()->GetTextInputClient());
}
VKMojoHandler::~VKMojoHandler() {
GetInputMethod()->RemoveObserver(this);
}
ui::InputMethod* VKMojoHandler::GetInputMethod() {
return KeyboardController::GetInstance()->proxy()->GetInputMethod();
}
void VKMojoHandler::SetTextInputTypeObserver(
TextInputTypeObserverPtr observer) {
text_input_type_observer_ = observer.Pass();
}
void VKMojoHandler::SendKeyEvent(const mojo::String& event_type,
int32_t char_value,
int32_t key_code,
const mojo::String& key_name,
int32_t modifiers) {
aura::Window* window =
KeyboardController::GetInstance()->GetContainerWindow();
std::string type = event_type.To<std::string>();
std::string name = key_name.To<std::string>();
keyboard::SendKeyEvent(
type, char_value, key_code, name, modifiers, window->GetHost());
}
void VKMojoHandler::HideKeyboard() {
KeyboardController::GetInstance()->HideKeyboard(
KeyboardController::HIDE_REASON_MANUAL);
}
void VKMojoHandler::OnTextInputTypeChanged(const ui::TextInputClient* client) {
}
void VKMojoHandler::OnFocus() {
}
void VKMojoHandler::OnBlur() {
}
void VKMojoHandler::OnCaretBoundsChanged(const ui::TextInputClient* client) {
}
void VKMojoHandler::OnTextInputStateChanged(
const ui::TextInputClient* text_client) {
if (!text_input_type_observer_)
return;
ui::TextInputType type =
text_client ? text_client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE;
std::string type_name = "none";
switch (type) {
case ui::TEXT_INPUT_TYPE_NONE:
type_name = "none";
break;
case ui::TEXT_INPUT_TYPE_PASSWORD:
type_name = "password";
break;
case ui::TEXT_INPUT_TYPE_EMAIL:
type_name = "email";
break;
case ui::TEXT_INPUT_TYPE_NUMBER:
type_name = "number";
break;
case ui::TEXT_INPUT_TYPE_TELEPHONE:
type_name = "tel";
break;
case ui::TEXT_INPUT_TYPE_URL:
type_name = "url";
break;
case ui::TEXT_INPUT_TYPE_DATE:
type_name = "date";
break;
case ui::TEXT_INPUT_TYPE_TEXT:
case ui::TEXT_INPUT_TYPE_SEARCH:
case ui::TEXT_INPUT_TYPE_DATE_TIME:
case ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL:
case ui::TEXT_INPUT_TYPE_MONTH:
case ui::TEXT_INPUT_TYPE_TIME:
case ui::TEXT_INPUT_TYPE_WEEK:
case ui::TEXT_INPUT_TYPE_TEXT_AREA:
case ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE:
case ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD:
type_name = "text";
break;
}
text_input_type_observer_->OnTextInputTypeChanged(type_name);
}
void VKMojoHandler::OnInputMethodDestroyed(
const ui::InputMethod* input_method) {
}
void VKMojoHandler::OnShowImeIfNeeded() {
}
} // namespace keyboard
|