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