| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/views/mus/input_method_mus.h" | 5 #include "ui/views/mus/input_method_mus.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "services/ui/public/cpp/window.h" | 9 #include "services/ui/public/cpp/window.h" |
| 10 #include "services/ui/public/interfaces/constants.mojom.h" |
| 10 #include "services/ui/public/interfaces/ime.mojom.h" | 11 #include "services/ui/public/interfaces/ime.mojom.h" |
| 11 #include "ui/base/ime/text_input_client.h" | 12 #include "ui/base/ime/text_input_client.h" |
| 12 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
| 13 #include "ui/platform_window/mojo/ime_type_converters.h" | 14 #include "ui/platform_window/mojo/ime_type_converters.h" |
| 14 #include "ui/platform_window/mojo/text_input_state.mojom.h" | 15 #include "ui/platform_window/mojo/text_input_state.mojom.h" |
| 15 #include "ui/views/mus/text_input_client_impl.h" | 16 #include "ui/views/mus/text_input_client_impl.h" |
| 16 | 17 |
| 17 using ui::mojom::EventResult; | 18 using ui::mojom::EventResult; |
| 18 | 19 |
| 19 namespace views { | 20 namespace views { |
| 20 | 21 |
| 21 //////////////////////////////////////////////////////////////////////////////// | 22 //////////////////////////////////////////////////////////////////////////////// |
| 22 // InputMethodMus, public: | 23 // InputMethodMus, public: |
| 23 | 24 |
| 24 InputMethodMus::InputMethodMus(ui::internal::InputMethodDelegate* delegate, | 25 InputMethodMus::InputMethodMus(ui::internal::InputMethodDelegate* delegate, |
| 25 ui::Window* window) | 26 ui::Window* window) |
| 26 : window_(window) { | 27 : window_(window) { |
| 27 SetDelegate(delegate); | 28 SetDelegate(delegate); |
| 28 } | 29 } |
| 29 | 30 |
| 30 InputMethodMus::~InputMethodMus() {} | 31 InputMethodMus::~InputMethodMus() {} |
| 31 | 32 |
| 32 void InputMethodMus::Init(service_manager::Connector* connector) { | 33 void InputMethodMus::Init(service_manager::Connector* connector) { |
| 33 connector->ConnectToInterface("ui", &ime_server_); | 34 connector->ConnectToInterface(ui::mojom::kServiceName, &ime_server_); |
| 34 } | 35 } |
| 35 | 36 |
| 36 void InputMethodMus::DispatchKeyEvent( | 37 void InputMethodMus::DispatchKeyEvent( |
| 37 ui::KeyEvent* event, | 38 ui::KeyEvent* event, |
| 38 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback) { | 39 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback) { |
| 39 DCHECK(event->type() == ui::ET_KEY_PRESSED || | 40 DCHECK(event->type() == ui::ET_KEY_PRESSED || |
| 40 event->type() == ui::ET_KEY_RELEASED); | 41 event->type() == ui::ET_KEY_RELEASED); |
| 41 | 42 |
| 42 // If no text input client, do nothing. | 43 // If no text input client, do nothing. |
| 43 if (!GetTextInputClient()) { | 44 if (!GetTextInputClient()) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 event_result = EventResult::HANDLED; | 155 event_result = EventResult::HANDLED; |
| 155 } | 156 } |
| 156 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is | 157 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is |
| 157 // called instead of the version which provides a callback. In mus+ash we | 158 // called instead of the version which provides a callback. In mus+ash we |
| 158 // use the version with callback, but some unittests use the standard form. | 159 // use the version with callback, but some unittests use the standard form. |
| 159 if (ack_callback) | 160 if (ack_callback) |
| 160 ack_callback->Run(event_result); | 161 ack_callback->Run(event_result); |
| 161 } | 162 } |
| 162 | 163 |
| 163 } // namespace views | 164 } // namespace views |
| OLD | NEW |