| 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/aura/mus/input_method_mus.h" | 5 #include "ui/aura/mus/input_method_mus.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "services/ui/public/interfaces/constants.mojom.h" | 10 #include "services/ui/public/interfaces/constants.mojom.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 InputMethodMus::~InputMethodMus() { | 34 InputMethodMus::~InputMethodMus() { |
| 35 // Mus won't dispatch the next key event until the existing one is acked. We | 35 // Mus won't dispatch the next key event until the existing one is acked. We |
| 36 // may have KeyEvents sent to IME and awaiting the result, we need to ack | 36 // may have KeyEvents sent to IME and awaiting the result, we need to ack |
| 37 // them otherwise mus won't process the next event until it times out. | 37 // them otherwise mus won't process the next event until it times out. |
| 38 AckPendingCallbacksUnhandled(); | 38 AckPendingCallbacksUnhandled(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void InputMethodMus::Init(service_manager::Connector* connector) { | 41 void InputMethodMus::Init(service_manager::Connector* connector) { |
| 42 if (connector) | 42 if (connector) |
| 43 connector->BindInterface(ui::mojom::kServiceName, &ime_server_); | 43 connector->BindInterface(ui::mojom::kServiceName, &ime_driver_); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void InputMethodMus::DispatchKeyEvent( | 46 void InputMethodMus::DispatchKeyEvent( |
| 47 ui::KeyEvent* event, | 47 ui::KeyEvent* event, |
| 48 std::unique_ptr<EventResultCallback> ack_callback) { | 48 std::unique_ptr<EventResultCallback> ack_callback) { |
| 49 DCHECK(event->type() == ui::ET_KEY_PRESSED || | 49 DCHECK(event->type() == ui::ET_KEY_PRESSED || |
| 50 event->type() == ui::ET_KEY_RELEASED); | 50 event->type() == ui::ET_KEY_RELEASED); |
| 51 | 51 |
| 52 // If no text input client, do nothing. | 52 // If no text input client, do nothing. |
| 53 if (!GetTextInputClient()) { | 53 if (!GetTextInputClient()) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if (!focused) | 149 if (!focused) |
| 150 return; | 150 return; |
| 151 | 151 |
| 152 text_input_client_ = base::MakeUnique<TextInputClientImpl>(focused); | 152 text_input_client_ = base::MakeUnique<TextInputClientImpl>(focused); |
| 153 | 153 |
| 154 // We are about to close the pipe with pending callbacks. Closing the pipe | 154 // We are about to close the pipe with pending callbacks. Closing the pipe |
| 155 // results in none of the callbacks being run. We have to run the callbacks | 155 // results in none of the callbacks being run. We have to run the callbacks |
| 156 // else mus won't process the next event immediately. | 156 // else mus won't process the next event immediately. |
| 157 AckPendingCallbacksUnhandled(); | 157 AckPendingCallbacksUnhandled(); |
| 158 | 158 |
| 159 if (ime_server_) { | 159 if (ime_driver_) { |
| 160 ui::mojom::StartSessionDetailsPtr details = | 160 ui::mojom::StartSessionDetailsPtr details = |
| 161 ui::mojom::StartSessionDetails::New(); | 161 ui::mojom::StartSessionDetails::New(); |
| 162 details->client = text_input_client_->CreateInterfacePtrAndBind(); | 162 details->client = text_input_client_->CreateInterfacePtrAndBind(); |
| 163 details->input_method_request = MakeRequest(&input_method_ptr_); | 163 details->input_method_request = MakeRequest(&input_method_ptr_); |
| 164 input_method_ = input_method_ptr_.get(); | 164 input_method_ = input_method_ptr_.get(); |
| 165 details->text_input_type = focused->GetTextInputType(); | 165 details->text_input_type = focused->GetTextInputType(); |
| 166 details->text_input_mode = focused->GetTextInputMode(); | 166 details->text_input_mode = focused->GetTextInputMode(); |
| 167 details->text_direction = focused->GetTextDirection(); | 167 details->text_direction = focused->GetTextDirection(); |
| 168 details->text_input_flags = focused->GetTextInputFlags(); | 168 details->text_input_flags = focused->GetTextInputFlags(); |
| 169 details->caret_bounds = focused->GetCaretBounds(); | 169 details->caret_bounds = focused->GetCaretBounds(); |
| 170 ime_server_->StartSession(std::move(details)); | 170 ime_driver_->StartSession(std::move(details)); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 void InputMethodMus::UpdateTextInputType() { | 174 void InputMethodMus::UpdateTextInputType() { |
| 175 ui::TextInputType type = GetTextInputType(); | 175 ui::TextInputType type = GetTextInputType(); |
| 176 mojo::TextInputStatePtr state = mojo::TextInputState::New(); | 176 mojo::TextInputStatePtr state = mojo::TextInputState::New(); |
| 177 state->type = mojo::ConvertTo<mojo::TextInputType>(type); | 177 state->type = mojo::ConvertTo<mojo::TextInputType>(type); |
| 178 if (window_) { | 178 if (window_) { |
| 179 WindowPortMus* window_impl_mus = WindowPortMus::Get(window_); | 179 WindowPortMus* window_impl_mus = WindowPortMus::Get(window_); |
| 180 if (type != ui::TEXT_INPUT_TYPE_NONE) | 180 if (type != ui::TEXT_INPUT_TYPE_NONE) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 event_result = EventResult::HANDLED; | 214 event_result = EventResult::HANDLED; |
| 215 } | 215 } |
| 216 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is | 216 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is |
| 217 // called instead of the version which provides a callback. In mus+ash we | 217 // called instead of the version which provides a callback. In mus+ash we |
| 218 // use the version with callback, but some unittests use the standard form. | 218 // use the version with callback, but some unittests use the standard form. |
| 219 if (ack_callback) | 219 if (ack_callback) |
| 220 ack_callback->Run(event_result); | 220 ack_callback->Run(event_result); |
| 221 } | 221 } |
| 222 | 222 |
| 223 } // namespace aura | 223 } // namespace aura |
| OLD | NEW |