OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/views/ime_driver/input_method_bridge_chromeos.h" |
| 6 |
| 7 #include "chrome/browser/ui/views/ime_driver/remote_text_input_client.h" |
| 8 |
| 9 InputMethodBridge::InputMethodBridge(ui::mojom::TextInputClientPtr client) |
| 10 : client_(base::MakeUnique<RemoteTextInputClient>(std::move(client))), |
| 11 input_method_chromeos_( |
| 12 base::MakeUnique<ui::InputMethodChromeOS>(nullptr)) { |
| 13 input_method_chromeos_->SetFocusedTextInputClient(client_.get()); |
| 14 } |
| 15 |
| 16 InputMethodBridge::~InputMethodBridge() {} |
| 17 |
| 18 void InputMethodBridge::OnTextInputModeChanged( |
| 19 ui::mojom::TextInputMode text_input_mode) { |
| 20 // TODO(moshayedi): crbug.com/631527. Consider removing this, as |
| 21 // ui::InputMethodChromeOS doesn't have this. |
| 22 } |
| 23 |
| 24 void InputMethodBridge::OnTextInputTypeChanged( |
| 25 ui::mojom::TextInputType text_input_type) { |
| 26 input_method_chromeos_->OnTextInputTypeChanged(client_.get()); |
| 27 } |
| 28 |
| 29 void InputMethodBridge::OnCaretBoundsChanged(const gfx::Rect& caret_bounds) { |
| 30 input_method_chromeos_->OnCaretBoundsChanged(client_.get()); |
| 31 } |
| 32 |
| 33 void InputMethodBridge::ProcessKeyEvent( |
| 34 std::unique_ptr<ui::Event> event, |
| 35 const ProcessKeyEventCallback& callback) { |
| 36 DCHECK(event->IsKeyEvent()); |
| 37 ui::KeyEvent* key_event = event->AsKeyEvent(); |
| 38 if (!key_event->is_char()) { |
| 39 input_method_chromeos_->DispatchKeyEvent( |
| 40 key_event, base::MakeUnique<base::Callback<void(bool)>>(callback)); |
| 41 } else { |
| 42 callback.Run(false); |
| 43 } |
| 44 } |
| 45 |
| 46 void InputMethodBridge::CancelComposition() { |
| 47 input_method_chromeos_->CancelComposition(client_.get()); |
| 48 } |
OLD | NEW |