| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/ime_adapter_android.h" | 5 #include "content/browser/renderer_host/ime_adapter_android.h" |
| 6 | 6 |
| 7 #include <android/input.h> | 7 #include <android/input.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool ImeAdapterAndroid::SendKeyEvent(JNIEnv* env, jobject, | 114 bool ImeAdapterAndroid::SendKeyEvent(JNIEnv* env, jobject, |
| 115 jobject original_key_event, | 115 jobject original_key_event, |
| 116 int action, int modifiers, | 116 int action, int modifiers, |
| 117 long time_ms, int key_code, | 117 long time_ms, int key_code, |
| 118 bool is_system_key, int unicode_char) { | 118 bool is_system_key, int unicode_char) { |
| 119 NativeWebKeyboardEvent event = NativeWebKeyboardEventFromKeyEvent( | 119 NativeWebKeyboardEvent event = NativeWebKeyboardEventFromKeyEvent( |
| 120 env, original_key_event, action, modifiers, | 120 env, original_key_event, action, modifiers, |
| 121 time_ms, key_code, is_system_key, unicode_char); | 121 time_ms, key_code, is_system_key, unicode_char); |
| 122 bool key_down_text_insertion = |
| 123 event.type == WebKit::WebInputEvent::RawKeyDown && event.text[0]; |
| 124 // If we are going to follow up with a synthetic Char event, then that's the |
| 125 // one we expect to test if it's handled or unhandled, so skip handling the |
| 126 // "real" event in the browser. |
| 127 event.skip_in_browser = key_down_text_insertion; |
| 122 rwhva_->SendKeyEvent(event); | 128 rwhva_->SendKeyEvent(event); |
| 123 if (event.type == WebKit::WebInputEvent::RawKeyDown && event.text[0]) { | 129 if (key_down_text_insertion) { |
| 124 // Send a Char event, but without an os_event since we don't want to | 130 // Send a Char event, but without an os_event since we don't want to |
| 125 // roundtrip back to java such synthetic event. | 131 // roundtrip back to java such synthetic event. |
| 126 NativeWebKeyboardEvent char_event(event); | 132 NativeWebKeyboardEvent char_event(event); |
| 127 char_event.os_event = NULL; | 133 char_event.os_event = NULL; |
| 128 event.type = WebKit::WebInputEvent::Char; | 134 char_event.type = WebKit::WebInputEvent::Char; |
| 129 rwhva_->SendKeyEvent(event); | 135 rwhva_->SendKeyEvent(char_event); |
| 130 } | 136 } |
| 131 return true; | 137 return true; |
| 132 } | 138 } |
| 133 | 139 |
| 134 void ImeAdapterAndroid::SetComposingText(JNIEnv* env, jobject, jstring text, | 140 void ImeAdapterAndroid::SetComposingText(JNIEnv* env, jobject, jstring text, |
| 135 int new_cursor_pos) { | 141 int new_cursor_pos) { |
| 136 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From( | 142 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From( |
| 137 rwhva_->GetRenderWidgetHost()); | 143 rwhva_->GetRenderWidgetHost()); |
| 138 if (!rwhi) | 144 if (!rwhi) |
| 139 return; | 145 return; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 return; | 270 return; |
| 265 | 271 |
| 266 rwhi->Paste(); | 272 rwhi->Paste(); |
| 267 } | 273 } |
| 268 | 274 |
| 269 void ImeAdapterAndroid::ResetImeAdapter(JNIEnv* env, jobject) { | 275 void ImeAdapterAndroid::ResetImeAdapter(JNIEnv* env, jobject) { |
| 270 java_ime_adapter_.reset(); | 276 java_ime_adapter_.reset(); |
| 271 } | 277 } |
| 272 | 278 |
| 273 } // namespace content | 279 } // namespace content |
| OLD | NEW |