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

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

Issue 2752113005: Let ImeAdapterAndroid have the same lifecycle as its Java peer (Closed)
Patch Set: fix tests Created 3 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.app.Activity; 8 import android.app.Activity;
9 import android.app.SearchManager; 9 import android.app.SearchManager;
10 import android.content.ClipboardManager; 10 import android.content.ClipboardManager;
(...skipping 13 matching lines...) Expand all
24 import android.view.View; 24 import android.view.View;
25 import android.view.ViewConfiguration; 25 import android.view.ViewConfiguration;
26 import android.view.WindowManager; 26 import android.view.WindowManager;
27 27
28 import org.chromium.base.BuildInfo; 28 import org.chromium.base.BuildInfo;
29 import org.chromium.base.Log; 29 import org.chromium.base.Log;
30 import org.chromium.base.VisibleForTesting; 30 import org.chromium.base.VisibleForTesting;
31 import org.chromium.base.metrics.RecordUserAction; 31 import org.chromium.base.metrics.RecordUserAction;
32 import org.chromium.content.R; 32 import org.chromium.content.R;
33 import org.chromium.content.browser.input.FloatingPastePopupMenu; 33 import org.chromium.content.browser.input.FloatingPastePopupMenu;
34 import org.chromium.content.browser.input.ImeAdapter;
35 import org.chromium.content.browser.input.LGEmailActionModeWorkaround; 34 import org.chromium.content.browser.input.LGEmailActionModeWorkaround;
36 import org.chromium.content.browser.input.LegacyPastePopupMenu; 35 import org.chromium.content.browser.input.LegacyPastePopupMenu;
37 import org.chromium.content.browser.input.PastePopupMenu; 36 import org.chromium.content.browser.input.PastePopupMenu;
38 import org.chromium.content.browser.input.PastePopupMenu.PastePopupMenuDelegate; 37 import org.chromium.content.browser.input.PastePopupMenu.PastePopupMenuDelegate;
39 import org.chromium.content_public.browser.ActionModeCallbackHelper; 38 import org.chromium.content_public.browser.ActionModeCallbackHelper;
40 import org.chromium.content_public.browser.WebContents; 39 import org.chromium.content_public.browser.WebContents;
41 import org.chromium.ui.base.DeviceFormFactor; 40 import org.chromium.ui.base.DeviceFormFactor;
42 import org.chromium.ui.base.WindowAndroid; 41 import org.chromium.ui.base.WindowAndroid;
43 import org.chromium.ui.touch_selection.SelectionEventType; 42 import org.chromium.ui.touch_selection.SelectionEventType;
44 43
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // XML template. 75 // XML template.
77 // TODO(timav): remove this constant and use show/hide for Assist item inste ad 76 // TODO(timav): remove this constant and use show/hide for Assist item inste ad
78 // of adding and removing it once we switch to Android O SDK. The show/hide method 77 // of adding and removing it once we switch to Android O SDK. The show/hide method
79 // does not require ordering information. 78 // does not require ordering information.
80 private static final int MENU_ITEM_ORDER_TEXT_PROCESS_START = 100; 79 private static final int MENU_ITEM_ORDER_TEXT_PROCESS_START = 100;
81 80
82 private final Context mContext; 81 private final Context mContext;
83 private final WindowAndroid mWindowAndroid; 82 private final WindowAndroid mWindowAndroid;
84 private final WebContents mWebContents; 83 private final WebContents mWebContents;
85 private final RenderCoordinates mRenderCoordinates; 84 private final RenderCoordinates mRenderCoordinates;
86 private final ImeAdapter mImeAdapter;
87 private ActionMode.Callback mCallback; 85 private ActionMode.Callback mCallback;
88 86
89 // Selection rectangle in DIP. 87 // Selection rectangle in DIP.
90 private final Rect mSelectionRect = new Rect(); 88 private final Rect mSelectionRect = new Rect();
91 89
92 // Self-repeating task that repeatedly hides the ActionMode. This is 90 // Self-repeating task that repeatedly hides the ActionMode. This is
93 // required because ActionMode only exposes a temporary hide routine. 91 // required because ActionMode only exposes a temporary hide routine.
94 private final Runnable mRepeatingHideRunnable; 92 private final Runnable mRepeatingHideRunnable;
95 93
96 private View mView; 94 private View mView;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // arrives or till the selection is adjusted based on the classification res ult. 129 // arrives or till the selection is adjusted based on the classification res ult.
132 private boolean mPendingShowActionMode; 130 private boolean mPendingShowActionMode;
133 131
134 /** 132 /**
135 * Create {@link SelectionPopupController} instance. 133 * Create {@link SelectionPopupController} instance.
136 * @param context Context for action mode. 134 * @param context Context for action mode.
137 * @param window WindowAndroid instance. 135 * @param window WindowAndroid instance.
138 * @param webContents WebContents instance. 136 * @param webContents WebContents instance.
139 * @param view Container view. 137 * @param view Container view.
140 * @param renderCoordinates Coordinates info used to position elements. 138 * @param renderCoordinates Coordinates info used to position elements.
141 * @param imeAdapter ImeAdapter instance to handle cursor position.
142 */ 139 */
143 public SelectionPopupController(Context context, WindowAndroid window, WebCo ntents webContents, 140 public SelectionPopupController(Context context, WindowAndroid window, WebCo ntents webContents,
144 View view, RenderCoordinates renderCoordinates, ImeAdapter imeAdapte r) { 141 View view, RenderCoordinates renderCoordinates) {
145 mContext = context; 142 mContext = context;
146 mWindowAndroid = window; 143 mWindowAndroid = window;
147 mWebContents = webContents; 144 mWebContents = webContents;
148 mView = view; 145 mView = view;
149 mRenderCoordinates = renderCoordinates; 146 mRenderCoordinates = renderCoordinates;
150 mImeAdapter = imeAdapter;
151 147
152 // The menu items are allowed by default. 148 // The menu items are allowed by default.
153 mAllowedMenuItems = MENU_ITEM_SHARE | MENU_ITEM_WEB_SEARCH | MENU_ITEM_P ROCESS_TEXT; 149 mAllowedMenuItems = MENU_ITEM_SHARE | MENU_ITEM_WEB_SEARCH | MENU_ITEM_P ROCESS_TEXT;
154 mRepeatingHideRunnable = new Runnable() { 150 mRepeatingHideRunnable = new Runnable() {
155 @Override 151 @Override
156 public void run() { 152 public void run() {
157 assert mHidden; 153 assert mHidden;
158 final long hideDuration = getDefaultHideDuration(); 154 final long hideDuration = getDefaultHideDuration();
159 // Ensure the next hide call occurs before the ActionMode reappe ars. 155 // Ensure the next hide call occurs before the ActionMode reappe ars.
160 mView.postDelayed(mRepeatingHideRunnable, hideDuration - 1); 156 mView.postDelayed(mRepeatingHideRunnable, hideDuration - 1);
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 998
1003 // Remain pending until SELECTION_HANDLES_MOVED arrives. 999 // Remain pending until SELECTION_HANDLES_MOVED arrives.
1004 if (mPendingShowActionMode) return; 1000 if (mPendingShowActionMode) return;
1005 } 1001 }
1006 1002
1007 // Rely on this method to clear |mHidden| and unhide the action mode . 1003 // Rely on this method to clear |mHidden| and unhide the action mode .
1008 showActionModeOrClearOnFailure(); 1004 showActionModeOrClearOnFailure();
1009 } 1005 }
1010 }; 1006 };
1011 } 1007 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698