| 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 class RenderWidgetHostViewAndroid; | 12 class RenderWidgetHostViewAndroid; |
| 13 struct NativeWebKeyboardEvent; | 13 struct NativeWebKeyboardEvent; |
| 14 | 14 |
| 15 // This class is in charge of dispatching key events from the java side | 15 // This class is in charge of dispatching key events from the java side |
| 16 // and forward to renderer along with input method results via | 16 // and forward to renderer along with input method results via |
| 17 // corresponding host view. | 17 // corresponding host view. |
| 18 class ImeAdapterAndroid { | 18 class ImeAdapterAndroid { |
| 19 public: | 19 public: |
| 20 explicit ImeAdapterAndroid(RenderWidgetHostViewAndroid* rwhva); | 20 explicit ImeAdapterAndroid(RenderWidgetHostViewAndroid* rwhva); |
| 21 ~ImeAdapterAndroid(); | 21 ~ImeAdapterAndroid(); |
| 22 | 22 |
| 23 static bool RegisterImeAdapter(JNIEnv* env); | |
| 24 | |
| 25 // Called from java -> native | 23 // Called from java -> native |
| 26 // The java side is responsible to translate android KeyEvent various enums | 24 // The java side is responsible to translate android KeyEvent various enums |
| 27 // and values into the corresponding WebKit::WebInputEvent. | 25 // and values into the corresponding WebKit::WebInputEvent. |
| 26 bool SendKeyEvent(JNIEnv* env, jobject, |
| 27 jobject original_key_event, |
| 28 int action, int meta_state, |
| 29 long event_time, int key_code, |
| 30 bool is_system_key, int unicode_text); |
| 31 // |event_type| is a value of WebInputEvent::Type. |
| 32 bool SendSyntheticKeyEvent(JNIEnv*, |
| 33 jobject, |
| 34 int event_type, |
| 35 long timestamp_ms, |
| 36 int native_key_code, |
| 37 int unicode_char); |
| 38 void SetComposingText(JNIEnv*, jobject, jstring text, int new_cursor_pos); |
| 39 void CommitText(JNIEnv*, jobject, jstring text); |
| 40 void AttachImeAdapter(JNIEnv*, jobject java_object); |
| 41 void ReplaceText(JNIEnv*, jobject, jstring text); |
| 42 void ClearFocus(JNIEnv*, jobject); |
| 43 void SetEditableSelectionOffsets(JNIEnv*, jobject, int start, int end); |
| 44 void SetComposingRegion(JNIEnv*, jobject, int start, int end); |
| 45 void DeleteSurroundingText(JNIEnv*, jobject, int before, int after); |
| 28 void Unselect(JNIEnv*, jobject); | 46 void Unselect(JNIEnv*, jobject); |
| 29 void SelectAll(JNIEnv*, jobject); | 47 void SelectAll(JNIEnv*, jobject); |
| 30 void Cut(JNIEnv*, jobject); | 48 void Cut(JNIEnv*, jobject); |
| 31 void Copy(JNIEnv*, jobject); | 49 void Copy(JNIEnv*, jobject); |
| 32 void Paste(JNIEnv*, jobject); | 50 void Paste(JNIEnv*, jobject); |
| 33 | 51 |
| 52 // Called from native -> java |
| 53 void CancelComposition(); |
| 54 |
| 34 private: | 55 private: |
| 35 RenderWidgetHostViewAndroid* rwhva_; | 56 RenderWidgetHostViewAndroid* rwhva_; |
| 36 jobject java_ime_adapter_; | 57 jobject java_ime_adapter_; |
| 37 }; | 58 }; |
| 38 | 59 |
| 60 bool RegisterImeAdapter(JNIEnv* env); |
| 61 |
| 39 } // namespace content | 62 } // namespace content |
| 40 | 63 |
| 41 #endif // CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_ | 64 #endif // CONTENT_BROWSER_RENDERER_HOST_IME_ADAPTER_ANDROID_H_ |
| OLD | NEW |