| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/ui/ash/ime_driver_ash.h" | 5 #include "chrome/browser/ui/ash/ime_driver_ash.h" |
| 6 | 6 |
| 7 #include "services/ui/public/interfaces/ime.mojom.h" | 7 #include "services/ui/public/interfaces/ime/ime.mojom.h" |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| 11 class InputMethod : public ui::mojom::InputMethod { | 11 class InputMethod : public ui::mojom::InputMethod { |
| 12 public: | 12 public: |
| 13 explicit InputMethod(ui::mojom::TextInputClientPtr client) | 13 explicit InputMethod(ui::mojom::TextInputClientPtr client) |
| 14 : client_(std::move(client)) {} | 14 : client_(std::move(client)) {} |
| 15 ~InputMethod() override {} | 15 ~InputMethod() override {} |
| 16 | 16 |
| 17 private: | 17 private: |
| 18 // ui::mojom::InputMethod: | 18 // ui::mojom::InputMethod: |
| 19 void OnTextInputModeChanged( | 19 void OnTextInputModeChanged( |
| 20 ui::mojom::TextInputMode text_input_mode) override {} | 20 ui::mojom::TextInputMode text_input_mode) override {} |
| 21 void OnTextInputTypeChanged( | 21 void OnTextInputTypeChanged( |
| 22 ui::mojom::TextInputType text_input_type) override {} | 22 ui::mojom::TextInputType text_input_type) override {} |
| 23 void OnCaretBoundsChanged(const gfx::Rect& caret_bounds) override {} | 23 void OnCaretBoundsChanged(const gfx::Rect& caret_bounds) override {} |
| 24 void ProcessKeyEvent(std::unique_ptr<ui::Event> key_event, | 24 void ProcessKeyEvent(std::unique_ptr<ui::Event> key_event, |
| 25 const ProcessKeyEventCallback& callback) override { | 25 const ProcessKeyEventCallback& callback) override { |
| 26 DCHECK(key_event->IsKeyEvent()); | 26 DCHECK(key_event->IsKeyEvent()); |
| 27 | 27 |
| 28 if (key_event->AsKeyEvent()->is_char()) { | 28 if (key_event->AsKeyEvent()->is_char()) { |
| 29 ui::mojom::CompositionEventPtr composition_event = | 29 client_->InsertChar(std::move(key_event)); |
| 30 ui::mojom::CompositionEvent::New(); | |
| 31 composition_event->type = ui::mojom::CompositionEventType::INSERT_CHAR; | |
| 32 composition_event->key_event = std::move(key_event); | |
| 33 client_->OnCompositionEvent(std::move(composition_event)); | |
| 34 callback.Run(true); | 30 callback.Run(true); |
| 35 } else { | 31 } else { |
| 36 callback.Run(false); | 32 callback.Run(false); |
| 37 } | 33 } |
| 38 } | 34 } |
| 39 void CancelComposition() override {} | 35 void CancelComposition() override {} |
| 40 | 36 |
| 41 ui::mojom::TextInputClientPtr client_; | 37 ui::mojom::TextInputClientPtr client_; |
| 42 | 38 |
| 43 DISALLOW_COPY_AND_ASSIGN(InputMethod); | 39 DISALLOW_COPY_AND_ASSIGN(InputMethod); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 54 ui::mojom::TextInputClientPtr client, | 50 ui::mojom::TextInputClientPtr client, |
| 55 ui::mojom::InputMethodRequest input_method_request) { | 51 ui::mojom::InputMethodRequest input_method_request) { |
| 56 input_method_bindings_[session_id] = | 52 input_method_bindings_[session_id] = |
| 57 base::MakeUnique<mojo::Binding<ui::mojom::InputMethod>>( | 53 base::MakeUnique<mojo::Binding<ui::mojom::InputMethod>>( |
| 58 new InputMethod(std::move(client)), std::move(input_method_request)); | 54 new InputMethod(std::move(client)), std::move(input_method_request)); |
| 59 } | 55 } |
| 60 | 56 |
| 61 void IMEDriver::CancelSession(int32_t session_id) { | 57 void IMEDriver::CancelSession(int32_t session_id) { |
| 62 input_method_bindings_.erase(session_id); | 58 input_method_bindings_.erase(session_id); |
| 63 } | 59 } |
| OLD | NEW |