Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Side by Side Diff: content/browser/renderer_host/ime_adapter_android.cc

Issue 1771223002: Migrate *-ime-thread switches to feature API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: plumb imeadapter instead and fixed nits Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "base/android/jni_android.h" 11 #include "base/android/jni_android.h"
12 #include "base/android/jni_string.h" 12 #include "base/android/jni_string.h"
13 #include "base/android/scoped_java_ref.h" 13 #include "base/android/scoped_java_ref.h"
14 #include "base/feature_list.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "content/browser/frame_host/frame_tree.h" 17 #include "content/browser/frame_host/frame_tree.h"
17 #include "content/browser/frame_host/frame_tree_node.h" 18 #include "content/browser/frame_host/frame_tree_node.h"
18 #include "content/browser/frame_host/render_frame_host_impl.h" 19 #include "content/browser/frame_host/render_frame_host_impl.h"
19 #include "content/browser/renderer_host/render_view_host_delegate.h" 20 #include "content/browser/renderer_host/render_view_host_delegate.h"
20 #include "content/browser/renderer_host/render_view_host_impl.h" 21 #include "content/browser/renderer_host/render_view_host_impl.h"
21 #include "content/browser/renderer_host/render_widget_host_impl.h" 22 #include "content/browser/renderer_host/render_widget_host_impl.h"
22 #include "content/browser/renderer_host/render_widget_host_view_android.h" 23 #include "content/browser/renderer_host/render_widget_host_view_android.h"
23 #include "content/common/frame_messages.h" 24 #include "content/common/frame_messages.h"
24 #include "content/common/input_messages.h" 25 #include "content/common/input_messages.h"
25 #include "content/common/view_messages.h" 26 #include "content/common/view_messages.h"
26 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/native_web_keyboard_event.h" 28 #include "content/public/browser/native_web_keyboard_event.h"
28 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
30 #include "content/public/common/content_features.h"
29 #include "jni/ImeAdapter_jni.h" 31 #include "jni/ImeAdapter_jni.h"
30 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 32 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
31 #include "third_party/WebKit/public/web/WebInputEvent.h" 33 #include "third_party/WebKit/public/web/WebInputEvent.h"
32 #include "third_party/WebKit/public/web/WebTextInputType.h" 34 #include "third_party/WebKit/public/web/WebTextInputType.h"
33 35
34 using base::android::AttachCurrentThread; 36 using base::android::AttachCurrentThread;
35 using base::android::ConvertJavaStringToUTF16; 37 using base::android::ConvertJavaStringToUTF16;
36 38
37 namespace content { 39 namespace content {
38 namespace { 40 namespace {
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 bool ImeAdapterAndroid::RequestTextInputStateUpdate( 295 bool ImeAdapterAndroid::RequestTextInputStateUpdate(
294 JNIEnv* env, 296 JNIEnv* env,
295 const JavaParamRef<jobject>&) { 297 const JavaParamRef<jobject>&) {
296 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl(); 298 RenderWidgetHostImpl* rwhi = GetRenderWidgetHostImpl();
297 if (!rwhi) 299 if (!rwhi)
298 return false; 300 return false;
299 rwhi->Send(new InputMsg_RequestTextInputStateUpdate(rwhi->GetRoutingID())); 301 rwhi->Send(new InputMsg_RequestTextInputStateUpdate(rwhi->GetRoutingID()));
300 return true; 302 return true;
301 } 303 }
302 304
305 bool ImeAdapterAndroid::IsImeThreadEnabled(
306 JNIEnv* env,
307 const base::android::JavaParamRef<jobject>&) {
308 return base::FeatureList::IsEnabled(features::kImeThread);
309 }
310
303 void ImeAdapterAndroid::ResetImeAdapter(JNIEnv* env, 311 void ImeAdapterAndroid::ResetImeAdapter(JNIEnv* env,
304 const JavaParamRef<jobject>&) { 312 const JavaParamRef<jobject>&) {
305 java_ime_adapter_.reset(); 313 java_ime_adapter_.reset();
306 } 314 }
307 315
308 RenderWidgetHostImpl* ImeAdapterAndroid::GetRenderWidgetHostImpl() { 316 RenderWidgetHostImpl* ImeAdapterAndroid::GetRenderWidgetHostImpl() {
309 DCHECK_CURRENTLY_ON(BrowserThread::UI); 317 DCHECK_CURRENTLY_ON(BrowserThread::UI);
310 DCHECK(rwhva_); 318 DCHECK(rwhva_);
311 RenderWidgetHost* rwh = rwhva_->GetRenderWidgetHost(); 319 RenderWidgetHost* rwh = rwhva_->GetRenderWidgetHost();
312 if (!rwh) 320 if (!rwh)
(...skipping 18 matching lines...) Expand all
331 } 339 }
332 340
333 WebContents* ImeAdapterAndroid::GetWebContents() { 341 WebContents* ImeAdapterAndroid::GetWebContents() {
334 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); 342 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
335 if (!rwh) 343 if (!rwh)
336 return nullptr; 344 return nullptr;
337 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); 345 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh));
338 } 346 }
339 347
340 } // namespace content 348 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698