| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 void ImeAdapterAndroid::FocusedNodeChanged(bool is_editable_node) { | 244 void ImeAdapterAndroid::FocusedNodeChanged(bool is_editable_node) { |
| 245 base::android::ScopedJavaLocalRef<jobject> obj = | 245 base::android::ScopedJavaLocalRef<jobject> obj = |
| 246 java_ime_adapter_.get(AttachCurrentThread()); | 246 java_ime_adapter_.get(AttachCurrentThread()); |
| 247 if (!obj.is_null()) { | 247 if (!obj.is_null()) { |
| 248 Java_ImeAdapter_focusedNodeChanged(AttachCurrentThread(), | 248 Java_ImeAdapter_focusedNodeChanged(AttachCurrentThread(), |
| 249 obj.obj(), | 249 obj.obj(), |
| 250 is_editable_node); | 250 is_editable_node); |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 | 253 |
| 254 void ImeAdapterAndroid::Unblock() { |
| 255 base::android::ScopedJavaLocalRef<jobject> obj = |
| 256 java_ime_adapter_.get(AttachCurrentThread()); |
| 257 if (!obj.is_null()) { |
| 258 Java_ImeAdapter_unblock(AttachCurrentThread(), |
| 259 obj.obj()); |
| 260 } |
| 261 } |
| 262 |
| 254 void ImeAdapterAndroid::SetEditableSelectionOffsets( | 263 void ImeAdapterAndroid::SetEditableSelectionOffsets( |
| 255 JNIEnv*, | 264 JNIEnv*, |
| 256 const JavaParamRef<jobject>&, | 265 const JavaParamRef<jobject>&, |
| 257 int start, | 266 int start, |
| 258 int end) { | 267 int end) { |
| 259 RenderFrameHost* rfh = GetFocusedFrame(); | 268 RenderFrameHost* rfh = GetFocusedFrame(); |
| 260 if (!rfh) | 269 if (!rfh) |
| 261 return; | 270 return; |
| 262 | 271 |
| 263 rfh->Send(new FrameMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(), | 272 rfh->Send(new FrameMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 283 void ImeAdapterAndroid::DeleteSurroundingText(JNIEnv*, | 292 void ImeAdapterAndroid::DeleteSurroundingText(JNIEnv*, |
| 284 const JavaParamRef<jobject>&, | 293 const JavaParamRef<jobject>&, |
| 285 int before, | 294 int before, |
| 286 int after) { | 295 int after) { |
| 287 RenderFrameHostImpl* rfh = | 296 RenderFrameHostImpl* rfh = |
| 288 static_cast<RenderFrameHostImpl*>(GetFocusedFrame()); | 297 static_cast<RenderFrameHostImpl*>(GetFocusedFrame()); |
| 289 if (rfh) | 298 if (rfh) |
| 290 rfh->ExtendSelectionAndDelete(before, after); | 299 rfh->ExtendSelectionAndDelete(before, after); |
| 291 } | 300 } |
| 292 | 301 |
| 302 bool ImeAdapterAndroid::RequestTextInputStateUpdate( |
| 303 JNIEnv* env, |
| 304 const JavaParamRef<jobject>&) { |
| 305 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); |
| 306 if (!rwhi) |
| 307 return false; |
| 308 rwhi->Send(new InputMsg_RequestTextInputStateUpdate(rwhi->GetRoutingID())); |
| 309 return true; |
| 310 } |
| 311 |
| 293 void ImeAdapterAndroid::ResetImeAdapter(JNIEnv* env, | 312 void ImeAdapterAndroid::ResetImeAdapter(JNIEnv* env, |
| 294 const JavaParamRef<jobject>&) { | 313 const JavaParamRef<jobject>&) { |
| 295 java_ime_adapter_.reset(); | 314 java_ime_adapter_.reset(); |
| 296 } | 315 } |
| 297 | 316 |
| 298 RenderWidgetHostImpl* ImeAdapterAndroid::GetRenderWidgetHostImpl() { | 317 RenderWidgetHostImpl* ImeAdapterAndroid::GetRenderWidgetHostImpl() { |
| 299 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 318 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 300 DCHECK(rwhva_); | 319 DCHECK(rwhva_); |
| 301 RenderWidgetHost* rwh = rwhva_->GetRenderWidgetHost(); | 320 RenderWidgetHost* rwh = rwhva_->GetRenderWidgetHost(); |
| 302 if (!rwh) | 321 if (!rwh) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 321 } | 340 } |
| 322 | 341 |
| 323 WebContents* ImeAdapterAndroid::GetWebContents() { | 342 WebContents* ImeAdapterAndroid::GetWebContents() { |
| 324 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); | 343 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); |
| 325 if (!rwh) | 344 if (!rwh) |
| 326 return nullptr; | 345 return nullptr; |
| 327 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); | 346 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); |
| 328 } | 347 } |
| 329 | 348 |
| 330 } // namespace content | 349 } // namespace content |
| OLD | NEW |