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()) { | |
20 GetInputMethod()->AddObserver(this); | 18 GetInputMethod()->AddObserver(this); |
21 OnTextInputStateChanged(GetInputMethod()->GetTextInputClient()); | |
22 } | 19 } |
23 | 20 |
24 VKMojoHandler::~VKMojoHandler() { | 21 VKMojoHandler::~VKMojoHandler() { |
25 GetInputMethod()->RemoveObserver(this); | 22 GetInputMethod()->RemoveObserver(this); |
26 } | 23 } |
27 | 24 |
28 ui::InputMethod* VKMojoHandler::GetInputMethod() { | 25 ui::InputMethod* VKMojoHandler::GetInputMethod() { |
29 return KeyboardController::GetInstance()->proxy()->GetInputMethod(); | 26 return KeyboardController::GetInstance()->proxy()->GetInputMethod(); |
30 } | 27 } |
31 | 28 |
| 29 void VKMojoHandler::OnConnectionEstablished() { |
| 30 OnTextInputStateChanged(GetInputMethod()->GetTextInputClient()); |
| 31 } |
| 32 |
32 void VKMojoHandler::SendKeyEvent(const mojo::String& event_type, | 33 void VKMojoHandler::SendKeyEvent(const mojo::String& event_type, |
33 int32_t char_value, | 34 int32_t char_value, |
34 int32_t key_code, | 35 int32_t key_code, |
35 const mojo::String& key_name, | 36 const mojo::String& key_name, |
36 int32_t modifiers) { | 37 int32_t modifiers) { |
37 aura::Window* window = | 38 aura::Window* window = |
38 KeyboardController::GetInstance()->GetContainerWindow(); | 39 KeyboardController::GetInstance()->GetContainerWindow(); |
39 std::string type = event_type.To<std::string>(); | 40 std::string type = event_type.To<std::string>(); |
40 std::string name = key_name.To<std::string>(); | 41 std::string name = key_name.To<std::string>(); |
41 keyboard::SendKeyEvent( | 42 keyboard::SendKeyEvent( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 case ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL: | 100 case ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL: |
100 case ui::TEXT_INPUT_TYPE_MONTH: | 101 case ui::TEXT_INPUT_TYPE_MONTH: |
101 case ui::TEXT_INPUT_TYPE_TIME: | 102 case ui::TEXT_INPUT_TYPE_TIME: |
102 case ui::TEXT_INPUT_TYPE_WEEK: | 103 case ui::TEXT_INPUT_TYPE_WEEK: |
103 case ui::TEXT_INPUT_TYPE_TEXT_AREA: | 104 case ui::TEXT_INPUT_TYPE_TEXT_AREA: |
104 case ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE: | 105 case ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE: |
105 case ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD: | 106 case ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD: |
106 type_name = "text"; | 107 type_name = "text"; |
107 break; | 108 break; |
108 } | 109 } |
109 binding_.client()->OnTextInputTypeChanged(type_name); | 110 client()->OnTextInputTypeChanged(type_name); |
110 } | 111 } |
111 | 112 |
112 void VKMojoHandler::OnInputMethodDestroyed( | 113 void VKMojoHandler::OnInputMethodDestroyed( |
113 const ui::InputMethod* input_method) { | 114 const ui::InputMethod* input_method) { |
114 } | 115 } |
115 | 116 |
116 void VKMojoHandler::OnShowImeIfNeeded() { | 117 void VKMojoHandler::OnShowImeIfNeeded() { |
117 } | 118 } |
118 | 119 |
119 } // namespace keyboard | 120 } // namespace keyboard |
OLD | NEW |