| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <android/input.h> | 8 #include <android/input.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 void ImeAdapterAndroid::FinishComposingText(JNIEnv* env, jobject) { | 210 void ImeAdapterAndroid::FinishComposingText(JNIEnv* env, jobject) { |
| 211 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); | 211 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); |
| 212 if (!rwhi) | 212 if (!rwhi) |
| 213 return; | 213 return; |
| 214 | 214 |
| 215 rwhi->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), | 215 rwhi->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), |
| 216 true); | 216 true); |
| 217 } | 217 } |
| 218 | 218 |
| 219 |
| 220 bool ImeAdapterAndroid::RequestCursorUpdates(JNIEnv* env, |
| 221 jobject obj, |
| 222 int cursorUpdateMode) { |
| 223 if (!rwhva_) |
| 224 return false; |
| 225 return rwhva_->RequestCursorUpdates(static_cast<uint32>(cursorUpdateMode)); |
| 226 } |
| 227 |
| 219 void ImeAdapterAndroid::AttachImeAdapter(JNIEnv* env, jobject java_object) { | 228 void ImeAdapterAndroid::AttachImeAdapter(JNIEnv* env, jobject java_object) { |
| 220 java_ime_adapter_ = JavaObjectWeakGlobalRef(env, java_object); | 229 java_ime_adapter_ = JavaObjectWeakGlobalRef(env, java_object); |
| 221 } | 230 } |
| 222 | 231 |
| 223 void ImeAdapterAndroid::CancelComposition() { | 232 void ImeAdapterAndroid::CancelComposition() { |
| 224 base::android::ScopedJavaLocalRef<jobject> obj = | 233 base::android::ScopedJavaLocalRef<jobject> obj = |
| 225 java_ime_adapter_.get(AttachCurrentThread()); | 234 java_ime_adapter_.get(AttachCurrentThread()); |
| 226 if (!obj.is_null()) | 235 if (!obj.is_null()) |
| 227 Java_ImeAdapter_cancelComposition(AttachCurrentThread(), obj.obj()); | 236 Java_ImeAdapter_cancelComposition(AttachCurrentThread(), obj.obj()); |
| 228 } | 237 } |
| 229 | 238 |
| 230 void ImeAdapterAndroid::FocusedNodeChanged(bool is_editable_node) { | 239 void ImeAdapterAndroid::FocusedNodeChanged(bool is_editable_node) { |
| 231 base::android::ScopedJavaLocalRef<jobject> obj = | 240 base::android::ScopedJavaLocalRef<jobject> obj = |
| 232 java_ime_adapter_.get(AttachCurrentThread()); | 241 java_ime_adapter_.get(AttachCurrentThread()); |
| 233 if (!obj.is_null()) { | 242 if (!obj.is_null()) { |
| 234 Java_ImeAdapter_focusedNodeChanged(AttachCurrentThread(), | 243 Java_ImeAdapter_focusedNodeChanged(AttachCurrentThread(), |
| 235 obj.obj(), | 244 obj.obj(), |
| 236 is_editable_node); | 245 is_editable_node); |
| 237 } | 246 } |
| 238 } | 247 } |
| 239 | 248 |
| 249 void ImeAdapterAndroid::UpdateCursorAnchorInfo( |
| 250 const base::android::ScopedJavaLocalRef<jobject>& cursor_anchor_info) { |
| 251 base::android::ScopedJavaLocalRef<jobject> obj = |
| 252 java_ime_adapter_.get(AttachCurrentThread()); |
| 253 if (!obj.is_null()) { |
| 254 Java_ImeAdapter_updateCursorAnchorInfo(AttachCurrentThread(), |
| 255 obj.obj(), |
| 256 cursor_anchor_info.obj()); |
| 257 } |
| 258 } |
| 259 |
| 240 void ImeAdapterAndroid::SetEditableSelectionOffsets(JNIEnv*, jobject, | 260 void ImeAdapterAndroid::SetEditableSelectionOffsets(JNIEnv*, jobject, |
| 241 int start, int end) { | 261 int start, int end) { |
| 242 RenderFrameHost* rfh = GetFocusedFrame(); | 262 RenderFrameHost* rfh = GetFocusedFrame(); |
| 243 if (!rfh) | 263 if (!rfh) |
| 244 return; | 264 return; |
| 245 | 265 |
| 246 rfh->Send(new FrameMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(), | 266 rfh->Send(new FrameMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(), |
| 247 start, end)); | 267 start, end)); |
| 248 } | 268 } |
| 249 | 269 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 WebContents* ImeAdapterAndroid::GetWebContents() { | 351 WebContents* ImeAdapterAndroid::GetWebContents() { |
| 332 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); | 352 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); |
| 333 if (!rwh) | 353 if (!rwh) |
| 334 return NULL; | 354 return NULL; |
| 335 if (!rwh->IsRenderView()) | 355 if (!rwh->IsRenderView()) |
| 336 return NULL; | 356 return NULL; |
| 337 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); | 357 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); |
| 338 } | 358 } |
| 339 | 359 |
| 340 } // namespace content | 360 } // namespace content |
| OLD | NEW |