OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/base/ime/input_method_auralinux.h" | 5 #include "ui/base/ime/input_method_auralinux.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/environment.h" | 8 #include "base/environment.h" |
9 #include "ui/base/ime/ime_bridge.h" | 9 #include "ui/base/ime/ime_bridge.h" |
10 #include "ui/base/ime/ime_engine_handler_interface.h" | 10 #include "ui/base/ime/ime_engine_handler_interface.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // If there's an active IME extension is listening to the key event, and the | 97 // If there's an active IME extension is listening to the key event, and the |
98 // current text input client is not password input client, the key event | 98 // current text input client is not password input client, the key event |
99 // should be dispatched to the extension engine in the two conditions: | 99 // should be dispatched to the extension engine in the two conditions: |
100 // 1) |filtered| == false: the ET_KEY_PRESSED event of non-character key, | 100 // 1) |filtered| == false: the ET_KEY_PRESSED event of non-character key, |
101 // or the ET_KEY_RELEASED event of all key. | 101 // or the ET_KEY_RELEASED event of all key. |
102 // 2) |filtered| == true && NeedInsertChar(): the ET_KEY_PRESSED event of | 102 // 2) |filtered| == true && NeedInsertChar(): the ET_KEY_PRESSED event of |
103 // character key. | 103 // character key. |
104 if (text_input_type_ != TEXT_INPUT_TYPE_PASSWORD && | 104 if (text_input_type_ != TEXT_INPUT_TYPE_PASSWORD && |
105 GetEngine() && GetEngine()->IsInterestedInKeyEvent() && | 105 GetEngine() && GetEngine()->IsInterestedInKeyEvent() && |
106 (!filtered || NeedInsertChar())) { | 106 (!filtered || NeedInsertChar())) { |
107 ui::IMEEngineHandlerInterface::KeyEventDoneCallback callback = | 107 ui::IMEEngineHandlerInterface::KeyEventDoneCallback callback = base::Bind( |
108 base::Bind(&InputMethodAuraLinux::ProcessKeyEventDone, | 108 &InputMethodAuraLinux::ProcessKeyEventByEngineDone, |
109 weak_ptr_factory_.GetWeakPtr(), | 109 weak_ptr_factory_.GetWeakPtr(), base::Owned(new ui::KeyEvent(*event)), |
110 base::Owned(new ui::KeyEvent(*event)), filtered); | 110 filtered, composition_changed_, |
| 111 base::Owned(new ui::CompositionText(composition_)), |
| 112 base::Owned(new base::string16(result_text_))); |
111 GetEngine()->ProcessKeyEvent(*event, callback); | 113 GetEngine()->ProcessKeyEvent(*event, callback); |
112 } else { | 114 } else { |
113 ProcessKeyEventDone(event, filtered, false); | 115 ProcessKeyEventDone(event, filtered, false); |
114 } | 116 } |
115 } | 117 } |
116 | 118 |
| 119 void InputMethodAuraLinux::ProcessKeyEventByEngineDone( |
| 120 ui::KeyEvent* event, |
| 121 bool filtered, |
| 122 bool composition_changed, |
| 123 ui::CompositionText* composition, |
| 124 base::string16* result_text, |
| 125 bool is_handled) { |
| 126 composition_changed_ = composition_changed; |
| 127 composition_.CopyFrom(*composition); |
| 128 result_text_ = *result_text; |
| 129 ProcessKeyEventDone(event, filtered, is_handled); |
| 130 } |
| 131 |
117 void InputMethodAuraLinux::ProcessKeyEventDone(ui::KeyEvent* event, | 132 void InputMethodAuraLinux::ProcessKeyEventDone(ui::KeyEvent* event, |
118 bool filtered, | 133 bool filtered, |
119 bool is_handled) { | 134 bool is_handled) { |
120 DCHECK(event); | 135 DCHECK(event); |
121 if (is_handled) | 136 if (is_handled) |
122 return; | 137 return; |
123 | 138 |
124 // If the IME extension has not handled the key event, passes the keyevent | 139 // If the IME extension has not handled the key event, passes the keyevent |
125 // back to the previous processing flow. Preconditions for this situation: | 140 // back to the previous processing flow. Preconditions for this situation: |
126 // 1) |filtered| == false | 141 // 1) |filtered| == false |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 client->ConfirmCompositionText(); | 447 client->ConfirmCompositionText(); |
433 | 448 |
434 if (GetEngine()) | 449 if (GetEngine()) |
435 GetEngine()->Reset(); | 450 GetEngine()->Reset(); |
436 } | 451 } |
437 | 452 |
438 ResetContext(); | 453 ResetContext(); |
439 } | 454 } |
440 | 455 |
441 } // namespace ui | 456 } // namespace ui |
OLD | NEW |