| 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/views/ime_driver/input_method_bridge_chromeos.h" | 5 #include "chrome/browser/ui/views/ime_driver/input_method_bridge_chromeos.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/ui/views/ime_driver/remote_text_input_client.h" | 8 #include "chrome/browser/ui/views/ime_driver/remote_text_input_client.h" |
| 9 | 9 |
| 10 InputMethodBridge::InputMethodBridge(ui::mojom::TextInputClientPtr client) | 10 InputMethodBridge::InputMethodBridge(ui::mojom::TextInputClientPtr client) |
| 11 : client_(base::MakeUnique<RemoteTextInputClient>(std::move(client))), | 11 : client_(base::MakeUnique<RemoteTextInputClient>(std::move(client))), |
| 12 input_method_chromeos_( | 12 input_method_chromeos_( |
| 13 base::MakeUnique<ui::InputMethodChromeOS>(nullptr)) { | 13 base::MakeUnique<ui::InputMethodChromeOS>(nullptr)) { |
| 14 input_method_chromeos_->SetFocusedTextInputClient(client_.get()); | 14 input_method_chromeos_->SetFocusedTextInputClient(client_.get()); |
| 15 } | 15 } |
| 16 | 16 |
| 17 InputMethodBridge::~InputMethodBridge() {} | 17 InputMethodBridge::~InputMethodBridge() {} |
| 18 | 18 |
| 19 void InputMethodBridge::OnTextInputModeChanged( | 19 void InputMethodBridge::OnTextInputModeChanged( |
| 20 ui::mojom::TextInputMode text_input_mode) { | 20 ui::TextInputMode text_input_mode) { |
| 21 // TODO(moshayedi): crbug.com/631527. Consider removing this, as | 21 // TODO(moshayedi): crbug.com/631527. Consider removing this, as |
| 22 // ui::InputMethodChromeOS doesn't have this. | 22 // ui::InputMethodChromeOS doesn't have this. |
| 23 } | 23 } |
| 24 | 24 |
| 25 void InputMethodBridge::OnTextInputTypeChanged( | 25 void InputMethodBridge::OnTextInputTypeChanged( |
| 26 ui::mojom::TextInputType text_input_type) { | 26 ui::TextInputType text_input_type) { |
| 27 input_method_chromeos_->OnTextInputTypeChanged(client_.get()); | 27 input_method_chromeos_->OnTextInputTypeChanged(client_.get()); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void InputMethodBridge::OnCaretBoundsChanged(const gfx::Rect& caret_bounds) { | 30 void InputMethodBridge::OnCaretBoundsChanged(const gfx::Rect& caret_bounds) { |
| 31 input_method_chromeos_->OnCaretBoundsChanged(client_.get()); | 31 input_method_chromeos_->OnCaretBoundsChanged(client_.get()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void InputMethodBridge::ProcessKeyEvent( | 34 void InputMethodBridge::ProcessKeyEvent( |
| 35 std::unique_ptr<ui::Event> event, | 35 std::unique_ptr<ui::Event> event, |
| 36 const ProcessKeyEventCallback& callback) { | 36 const ProcessKeyEventCallback& callback) { |
| 37 DCHECK(event->IsKeyEvent()); | 37 DCHECK(event->IsKeyEvent()); |
| 38 ui::KeyEvent* key_event = event->AsKeyEvent(); | 38 ui::KeyEvent* key_event = event->AsKeyEvent(); |
| 39 if (!key_event->is_char()) { | 39 if (!key_event->is_char()) { |
| 40 input_method_chromeos_->DispatchKeyEvent( | 40 input_method_chromeos_->DispatchKeyEvent( |
| 41 key_event, base::MakeUnique<base::Callback<void(bool)>>(callback)); | 41 key_event, base::MakeUnique<base::Callback<void(bool)>>(callback)); |
| 42 } else { | 42 } else { |
| 43 // On Linux (include ChromeOS), the mus emulates the WM_CHAR generation | 43 // On Linux (include ChromeOS), the mus emulates the WM_CHAR generation |
| 44 // behaviour of Windows. But for ChromeOS, we don't expect those char | 44 // behaviour of Windows. But for ChromeOS, we don't expect those char |
| 45 // events, so we filter them out. | 45 // events, so we filter them out. |
| 46 const bool handled = true; | 46 const bool handled = true; |
| 47 callback.Run(handled); | 47 callback.Run(handled); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 void InputMethodBridge::CancelComposition() { | 51 void InputMethodBridge::CancelComposition() { |
| 52 input_method_chromeos_->CancelComposition(client_.get()); | 52 input_method_chromeos_->CancelComposition(client_.get()); |
| 53 } | 53 } |
| OLD | NEW |