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

Side by Side Diff: ui/keyboard/webui/vk_mojo_handler.cc

Issue 946623002: [Code cleanup]Remove webui keyboard mojo binding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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
« no previous file with comments | « ui/keyboard/webui/vk_mojo_handler.h ('k') | ui/keyboard/webui/vk_webui_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "ui/keyboard/webui/vk_mojo_handler.h"
6
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"
14
15 namespace keyboard {
16
17 VKMojoHandler::VKMojoHandler(
18 mojo::InterfaceRequest<KeyboardUIHandlerMojo> request)
19 : binding_(this, request.Pass()) {
20 GetInputMethod()->AddObserver(this);
21 OnTextInputStateChanged(GetInputMethod()->GetTextInputClient());
22 }
23
24 VKMojoHandler::~VKMojoHandler() {
25 GetInputMethod()->RemoveObserver(this);
26 }
27
28 ui::InputMethod* VKMojoHandler::GetInputMethod() {
29 return KeyboardController::GetInstance()->proxy()->GetInputMethod();
30 }
31
32 void VKMojoHandler::SetTextInputTypeObserver(
33 TextInputTypeObserverPtr observer) {
34 text_input_type_observer_ = observer.Pass();
35 }
36
37 void VKMojoHandler::SendKeyEvent(const mojo::String& event_type,
38 int32_t char_value,
39 int32_t key_code,
40 const mojo::String& key_name,
41 int32_t modifiers) {
42 aura::Window* window =
43 KeyboardController::GetInstance()->GetContainerWindow();
44 std::string type = event_type.To<std::string>();
45 std::string name = key_name.To<std::string>();
46 keyboard::SendKeyEvent(
47 type, char_value, key_code, name, modifiers, window->GetHost());
48 }
49
50 void VKMojoHandler::HideKeyboard() {
51 KeyboardController::GetInstance()->HideKeyboard(
52 KeyboardController::HIDE_REASON_MANUAL);
53 }
54
55 void VKMojoHandler::OnTextInputTypeChanged(const ui::TextInputClient* client) {
56 }
57
58 void VKMojoHandler::OnFocus() {
59 }
60
61 void VKMojoHandler::OnBlur() {
62 }
63
64 void VKMojoHandler::OnCaretBoundsChanged(const ui::TextInputClient* client) {
65 }
66
67 void VKMojoHandler::OnTextInputStateChanged(
68 const ui::TextInputClient* text_client) {
69 if (!text_input_type_observer_)
70 return;
71
72 ui::TextInputType type =
73 text_client ? text_client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE;
74 std::string type_name = "none";
75 switch (type) {
76 case ui::TEXT_INPUT_TYPE_NONE:
77 type_name = "none";
78 break;
79
80 case ui::TEXT_INPUT_TYPE_PASSWORD:
81 type_name = "password";
82 break;
83
84 case ui::TEXT_INPUT_TYPE_EMAIL:
85 type_name = "email";
86 break;
87
88 case ui::TEXT_INPUT_TYPE_NUMBER:
89 type_name = "number";
90 break;
91
92 case ui::TEXT_INPUT_TYPE_TELEPHONE:
93 type_name = "tel";
94 break;
95
96 case ui::TEXT_INPUT_TYPE_URL:
97 type_name = "url";
98 break;
99
100 case ui::TEXT_INPUT_TYPE_DATE:
101 type_name = "date";
102 break;
103
104 case ui::TEXT_INPUT_TYPE_TEXT:
105 case ui::TEXT_INPUT_TYPE_SEARCH:
106 case ui::TEXT_INPUT_TYPE_DATE_TIME:
107 case ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL:
108 case ui::TEXT_INPUT_TYPE_MONTH:
109 case ui::TEXT_INPUT_TYPE_TIME:
110 case ui::TEXT_INPUT_TYPE_WEEK:
111 case ui::TEXT_INPUT_TYPE_TEXT_AREA:
112 case ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE:
113 case ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD:
114 type_name = "text";
115 break;
116 }
117 text_input_type_observer_->OnTextInputTypeChanged(type_name);
118 }
119
120 void VKMojoHandler::OnInputMethodDestroyed(
121 const ui::InputMethod* input_method) {
122 }
123
124 void VKMojoHandler::OnShowImeIfNeeded() {
125 }
126
127 } // namespace keyboard
OLDNEW
« no previous file with comments | « ui/keyboard/webui/vk_mojo_handler.h ('k') | ui/keyboard/webui/vk_webui_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698