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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionFactory.java

Issue 1278593004: Introduce ThreadedInputConnection behind a switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: switched to delayed onCreateInputConnection approach (tedchoc@'s other comments not resolved yet) Created 4 years, 10 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.content.browser.input;
6
7 import android.os.Handler;
8 import android.os.HandlerThread;
9 import android.view.View;
10 import android.view.inputmethod.EditorInfo;
11
12 import org.chromium.base.Log;
13 import org.chromium.base.ThreadUtils;
14 import org.chromium.content.browser.input.ChromiumBaseInputConnection.ThreadMana ger;
15
16 /**
17 * Default factory for ChromiumBaseInputConnection classes.
18 */
19 public class ThreadedInputConnectionFactory implements ChromiumBaseInputConnecti on.Factory {
20 private static final String TAG = "cr_Ime";
21 private static final boolean DEBUG_LOGS = false;
22
23 private ThreadedInputConnection mThreadedInputConnection;
24 private final Handler mHandler;
25 private final ThreadedInputConnection.ThreadManager mThreadManager;
26 private final InputMethodManagerWrapper mInputMethodManagerWrapper;
27 private ThreadedInputConnectionProxyView mProxyView;
28
29 ThreadedInputConnectionFactory(InputMethodManagerWrapper inputMethodManagerW rapper) {
30 HandlerThread thread =
31 new HandlerThread("InputConnectionHandlerThread", HandlerThread. NORM_PRIORITY);
32 thread.start();
33 mHandler = new Handler(thread.getLooper());
34 mThreadManager = new ThreadManager(mHandler);
35 mInputMethodManagerWrapper = inputMethodManagerWrapper;
36 }
37
38 @Override
39 public ChromiumBaseInputConnection initializeAndGet(View view, ImeAdapter im eAdapter,
40 int inputType, int inputFlags, EditorInfo outAttrs) {
41 if (ThreadUtils.runningOnUiThread()) {
aelias_OOO_until_Jul13 2016/02/08 23:17:14 Is there a way to avoid this thread-based branchin
Changwan Ryu 2016/02/11 16:21:08 Some WebView users (app developers) may override o
aelias_OOO_until_Jul13 2016/02/11 23:13:15 Subclassing WebView is very rare in the first plac
Changwan Ryu 2016/02/12 00:36:03 Unfortunately, there are apps that override webvie
42 if (DEBUG_LOGS) Log.w(TAG, "initializeAndGet: running on ui thread") ;
43 if (mThreadedInputConnection != null) {
44 mThreadedInputConnection.finishComposingTextOnUiThread();
45 }
46 triggerDelayedOnCreateInputConnection(view);
47 return null;
aelias_OOO_until_Jul13 2016/02/08 23:17:14 What if instead of returning a null InputConnectio
Changwan Ryu 2016/02/11 16:21:08 That's something we could consider if this doesn't
aelias_OOO_until_Jul13 2016/02/11 23:13:15 OK, if immediately calling showSoftInput always pr
aelias_OOO_until_Jul13 2016/02/11 23:13:15 OK, if immediately calling showSoftInput always pr
Changwan Ryu 2016/02/12 00:36:03 Hmm... I think nullity of input connection is not
48 }
49 if (DEBUG_LOGS) Log.w(TAG, "initializeAndGet: running on IME thread");
50 if (mThreadedInputConnection == null) {
51 if (DEBUG_LOGS) Log.w(TAG, "Creating ThreadedInputConnection...");
52 mThreadedInputConnection = new ThreadedInputConnection(imeAdapter, m ThreadManager);
53 }
54 mThreadedInputConnection.initializeOutAttrs(inputType, inputFlags, outAt trs);
55 return mThreadedInputConnection;
56 }
57
58 private void triggerDelayedOnCreateInputConnection(final View view) {
59 if (DEBUG_LOGS) Log.w(TAG, "triggerDelayedOnCreateInputConnection");
60 mProxyView = new ThreadedInputConnectionProxyView(
aelias_OOO_until_Jul13 2016/02/08 23:17:14 This ThreadedInputConnectionProxyView class is not
Changwan Ryu 2016/02/11 16:21:08 Added now.
61 view.getContext(), mHandler, view);
62 mProxyView.requestFocus();
63 view.getHandler().post(new Runnable() {
64 @Override
65 public void run() {
66 mProxyView.onWindowFocusChanged(true);
67 mInputMethodManagerWrapper.isActive(mProxyView);
68 }
69 });
70 }
71
72 @Override
73 public ThreadManager getThreadManager() {
74 return mThreadManager;
75 }
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698