| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 229 |
| 230 void ImeAdapterAndroid::FinishComposingText(JNIEnv* env, jobject) { | 230 void ImeAdapterAndroid::FinishComposingText(JNIEnv* env, jobject) { |
| 231 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); | 231 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); |
| 232 if (!rwhi) | 232 if (!rwhi) |
| 233 return; | 233 return; |
| 234 | 234 |
| 235 rwhi->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), | 235 rwhi->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), |
| 236 true); | 236 true); |
| 237 } | 237 } |
| 238 | 238 |
| 239 |
| 240 bool ImeAdapterAndroid::RequestCursorUpdates(JNIEnv* env, |
| 241 jobject obj, |
| 242 int cursorUpdateMode) { |
| 243 if (!rwhva_) |
| 244 return false; |
| 245 return rwhva_->RequestCursorUpdates(static_cast<uint32>(cursorUpdateMode)); |
| 246 } |
| 247 |
| 239 void ImeAdapterAndroid::AttachImeAdapter(JNIEnv* env, jobject java_object) { | 248 void ImeAdapterAndroid::AttachImeAdapter(JNIEnv* env, jobject java_object) { |
| 240 java_ime_adapter_ = JavaObjectWeakGlobalRef(env, java_object); | 249 java_ime_adapter_ = JavaObjectWeakGlobalRef(env, java_object); |
| 241 } | 250 } |
| 242 | 251 |
| 243 void ImeAdapterAndroid::CancelComposition() { | 252 void ImeAdapterAndroid::CancelComposition() { |
| 244 base::android::ScopedJavaLocalRef<jobject> obj = | 253 base::android::ScopedJavaLocalRef<jobject> obj = |
| 245 java_ime_adapter_.get(AttachCurrentThread()); | 254 java_ime_adapter_.get(AttachCurrentThread()); |
| 246 if (!obj.is_null()) | 255 if (!obj.is_null()) |
| 247 Java_ImeAdapter_cancelComposition(AttachCurrentThread(), obj.obj()); | 256 Java_ImeAdapter_cancelComposition(AttachCurrentThread(), obj.obj()); |
| 248 } | 257 } |
| 249 | 258 |
| 250 void ImeAdapterAndroid::FocusedNodeChanged(bool is_editable_node) { | 259 void ImeAdapterAndroid::FocusedNodeChanged(bool is_editable_node) { |
| 251 base::android::ScopedJavaLocalRef<jobject> obj = | 260 base::android::ScopedJavaLocalRef<jobject> obj = |
| 252 java_ime_adapter_.get(AttachCurrentThread()); | 261 java_ime_adapter_.get(AttachCurrentThread()); |
| 253 if (!obj.is_null()) { | 262 if (!obj.is_null()) { |
| 254 Java_ImeAdapter_focusedNodeChanged(AttachCurrentThread(), | 263 Java_ImeAdapter_focusedNodeChanged(AttachCurrentThread(), |
| 255 obj.obj(), | 264 obj.obj(), |
| 256 is_editable_node); | 265 is_editable_node); |
| 257 } | 266 } |
| 258 } | 267 } |
| 259 | 268 |
| 269 void ImeAdapterAndroid::UpdateCursorAnchorInfo( |
| 270 const base::android::ScopedJavaLocalRef<jobject>& cursor_anchor_info) { |
| 271 base::android::ScopedJavaLocalRef<jobject> obj = |
| 272 java_ime_adapter_.get(AttachCurrentThread()); |
| 273 if (!obj.is_null()) { |
| 274 Java_ImeAdapter_updateCursorAnchorInfo(AttachCurrentThread(), |
| 275 obj.obj(), |
| 276 cursor_anchor_info.obj()); |
| 277 } |
| 278 } |
| 279 |
| 260 void ImeAdapterAndroid::SetEditableSelectionOffsets(JNIEnv*, jobject, | 280 void ImeAdapterAndroid::SetEditableSelectionOffsets(JNIEnv*, jobject, |
| 261 int start, int end) { | 281 int start, int end) { |
| 262 RenderFrameHost* rfh = GetFocusedFrame(); | 282 RenderFrameHost* rfh = GetFocusedFrame(); |
| 263 if (!rfh) | 283 if (!rfh) |
| 264 return; | 284 return; |
| 265 | 285 |
| 266 rfh->Send(new FrameMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(), | 286 rfh->Send(new FrameMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(), |
| 267 start, end)); | 287 start, end)); |
| 268 } | 288 } |
| 269 | 289 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 WebContents* ImeAdapterAndroid::GetWebContents() { | 371 WebContents* ImeAdapterAndroid::GetWebContents() { |
| 352 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); | 372 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); |
| 353 if (!rwh) | 373 if (!rwh) |
| 354 return NULL; | 374 return NULL; |
| 355 if (!rwh->IsRenderView()) | 375 if (!rwh->IsRenderView()) |
| 356 return NULL; | 376 return NULL; |
| 357 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); | 377 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); |
| 358 } | 378 } |
| 359 | 379 |
| 360 } // namespace content | 380 } // namespace content |
| OLD | NEW |