Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 "ui/base/ime/input_method_android.h" | |
| 6 | |
| 7 #include "ui/base/ime/text_input_client.h" | |
| 8 #include "ui/events/event.h" | |
| 9 | |
| 10 // TODO(bshe): This is currently very similar to InputMethodMUS. Consider unify | |
| 11 // them in the furture if the two have reasonable similarity. | |
| 12 | |
| 13 namespace ui { | |
| 14 | |
| 15 //////////////////////////////////////////////////////////////////////////////// | |
| 16 // InputMethodAndroid, public: | |
| 17 | |
| 18 InputMethodAndroid::InputMethodAndroid( | |
| 19 internal::InputMethodDelegate* delegate) { | |
| 20 SetDelegate(delegate); | |
| 21 } | |
| 22 | |
| 23 InputMethodAndroid::~InputMethodAndroid() {} | |
| 24 | |
| 25 bool InputMethodAndroid::OnUntranslatedIMEMessage( | |
| 26 const base::NativeEvent& event, | |
| 27 NativeEventResult* result) { | |
| 28 return false; | |
| 29 } | |
| 30 | |
| 31 void InputMethodAndroid::DispatchKeyEvent(ui::KeyEvent* event) { | |
| 32 DCHECK(event->type() == ui::ET_KEY_PRESSED || | |
| 33 event->type() == ui::ET_KEY_RELEASED); | |
| 34 | |
| 35 // If no text input client, do nothing. | |
| 36 if (!GetTextInputClient()) { | |
| 37 ignore_result(DispatchKeyEventPostIME(event)); | |
| 38 return; | |
| 39 } | |
| 40 | |
| 41 // Here is where we change the differ from our base class's logic. Instead of | |
| 42 // always dispatching a key down event, and then sending a synthesized | |
| 43 // character event, we instead check to see if this is a character event and | |
| 44 // send out the key if it is. (We fallback to normal dispatch if it isn't.) | |
| 45 if (event->is_char()) { | |
|
Shu Chen
2015/10/21 01:54:23
Are you sure this is the case for Android? I suppo
bshe
2015/10/21 14:20:25
This is basically a copy of InputMethodMUS. In aur
| |
| 46 GetTextInputClient()->InsertChar(*event); | |
| 47 event->StopPropagation(); | |
| 48 return; | |
| 49 } | |
| 50 | |
| 51 ignore_result(DispatchKeyEventPostIME(event)); | |
| 52 } | |
| 53 | |
| 54 void InputMethodAndroid::OnCaretBoundsChanged( | |
| 55 const ui::TextInputClient* client) { | |
| 56 } | |
| 57 | |
| 58 void InputMethodAndroid::CancelComposition( | |
| 59 const ui::TextInputClient* client) { | |
| 60 } | |
| 61 | |
| 62 void InputMethodAndroid::OnInputLocaleChanged() {} | |
| 63 | |
| 64 std::string InputMethodAndroid::GetInputLocale() { | |
| 65 return ""; | |
| 66 } | |
| 67 | |
| 68 bool InputMethodAndroid::IsCandidatePopupOpen() const { | |
| 69 return false; | |
| 70 } | |
| 71 | |
| 72 } // namespace ui | |
| OLD | NEW |