OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/keyboard/webui/vk_mojo_handler.h" | 5 #include "ui/keyboard/webui/vk_mojo_handler.h" |
6 | 6 |
7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
8 #include "ui/base/ime/input_method.h" | 8 #include "ui/base/ime/input_method.h" |
9 #include "ui/base/ime/text_input_client.h" | 9 #include "ui/base/ime/text_input_client.h" |
10 #include "ui/keyboard/keyboard_controller.h" | 10 #include "ui/keyboard/keyboard_controller.h" |
11 #include "ui/keyboard/keyboard_controller_proxy.h" | 11 #include "ui/keyboard/keyboard_controller_proxy.h" |
12 #include "ui/keyboard/keyboard_util.h" | 12 #include "ui/keyboard/keyboard_util.h" |
13 #include "ui/keyboard/webui/keyboard.mojom.h" | 13 #include "ui/keyboard/webui/keyboard.mojom.h" |
14 | 14 |
15 namespace keyboard { | 15 namespace keyboard { |
16 | 16 |
17 VKMojoHandler::VKMojoHandler() { | 17 VKMojoHandler::VKMojoHandler( |
| 18 mojo::InterfaceRequest<KeyboardUIHandlerMojo> request) |
| 19 : binding_(this, request.Pass()) { |
18 GetInputMethod()->AddObserver(this); | 20 GetInputMethod()->AddObserver(this); |
| 21 OnTextInputStateChanged(GetInputMethod()->GetTextInputClient()); |
19 } | 22 } |
20 | 23 |
21 VKMojoHandler::~VKMojoHandler() { | 24 VKMojoHandler::~VKMojoHandler() { |
22 GetInputMethod()->RemoveObserver(this); | 25 GetInputMethod()->RemoveObserver(this); |
23 } | 26 } |
24 | 27 |
25 ui::InputMethod* VKMojoHandler::GetInputMethod() { | 28 ui::InputMethod* VKMojoHandler::GetInputMethod() { |
26 return KeyboardController::GetInstance()->proxy()->GetInputMethod(); | 29 return KeyboardController::GetInstance()->proxy()->GetInputMethod(); |
27 } | 30 } |
28 | 31 |
29 void VKMojoHandler::OnConnectionEstablished() { | |
30 OnTextInputStateChanged(GetInputMethod()->GetTextInputClient()); | |
31 } | |
32 | |
33 void VKMojoHandler::SendKeyEvent(const mojo::String& event_type, | 32 void VKMojoHandler::SendKeyEvent(const mojo::String& event_type, |
34 int32_t char_value, | 33 int32_t char_value, |
35 int32_t key_code, | 34 int32_t key_code, |
36 const mojo::String& key_name, | 35 const mojo::String& key_name, |
37 int32_t modifiers) { | 36 int32_t modifiers) { |
38 aura::Window* window = | 37 aura::Window* window = |
39 KeyboardController::GetInstance()->GetContainerWindow(); | 38 KeyboardController::GetInstance()->GetContainerWindow(); |
40 std::string type = event_type.To<std::string>(); | 39 std::string type = event_type.To<std::string>(); |
41 std::string name = key_name.To<std::string>(); | 40 std::string name = key_name.To<std::string>(); |
42 keyboard::SendKeyEvent( | 41 keyboard::SendKeyEvent( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 case ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL: | 99 case ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL: |
101 case ui::TEXT_INPUT_TYPE_MONTH: | 100 case ui::TEXT_INPUT_TYPE_MONTH: |
102 case ui::TEXT_INPUT_TYPE_TIME: | 101 case ui::TEXT_INPUT_TYPE_TIME: |
103 case ui::TEXT_INPUT_TYPE_WEEK: | 102 case ui::TEXT_INPUT_TYPE_WEEK: |
104 case ui::TEXT_INPUT_TYPE_TEXT_AREA: | 103 case ui::TEXT_INPUT_TYPE_TEXT_AREA: |
105 case ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE: | 104 case ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE: |
106 case ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD: | 105 case ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD: |
107 type_name = "text"; | 106 type_name = "text"; |
108 break; | 107 break; |
109 } | 108 } |
110 client()->OnTextInputTypeChanged(type_name); | 109 binding_.client()->OnTextInputTypeChanged(type_name); |
111 } | 110 } |
112 | 111 |
113 void VKMojoHandler::OnInputMethodDestroyed( | 112 void VKMojoHandler::OnInputMethodDestroyed( |
114 const ui::InputMethod* input_method) { | 113 const ui::InputMethod* input_method) { |
115 } | 114 } |
116 | 115 |
117 void VKMojoHandler::OnShowImeIfNeeded() { | 116 void VKMojoHandler::OnShowImeIfNeeded() { |
118 } | 117 } |
119 | 118 |
120 } // namespace keyboard | 119 } // namespace keyboard |
OLD | NEW |