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

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

Issue 2791603002: Revert of Let ImeAdapterAndroid have the same lifecycle as its Java peer (Closed)
Patch Set: 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;
34 import org.chromium.content.browser.input.LGEmailActionModeWorkaround; 35 import org.chromium.content.browser.input.LGEmailActionModeWorkaround;
35 import org.chromium.content.browser.input.LegacyPastePopupMenu; 36 import org.chromium.content.browser.input.LegacyPastePopupMenu;
36 import org.chromium.content.browser.input.PastePopupMenu; 37 import org.chromium.content.browser.input.PastePopupMenu;
37 import org.chromium.content.browser.input.PastePopupMenu.PastePopupMenuDelegate; 38 import org.chromium.content.browser.input.PastePopupMenu.PastePopupMenuDelegate;
38 import org.chromium.content_public.browser.ActionModeCallbackHelper; 39 import org.chromium.content_public.browser.ActionModeCallbackHelper;
39 import org.chromium.content_public.browser.WebContents; 40 import org.chromium.content_public.browser.WebContents;
40 import org.chromium.ui.base.DeviceFormFactor; 41 import org.chromium.ui.base.DeviceFormFactor;
41 import org.chromium.ui.base.WindowAndroid; 42 import org.chromium.ui.base.WindowAndroid;
42 import org.chromium.ui.touch_selection.SelectionEventType; 43 import org.chromium.ui.touch_selection.SelectionEventType;
43 44
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // XML template. 76 // XML template.
76 // TODO(timav): remove this constant and use show/hide for Assist item inste ad 77 // TODO(timav): remove this constant and use show/hide for Assist item inste ad
77 // of adding and removing it once we switch to Android O SDK. The show/hide method 78 // of adding and removing it once we switch to Android O SDK. The show/hide method
78 // does not require ordering information. 79 // does not require ordering information.
79 private static final int MENU_ITEM_ORDER_TEXT_PROCESS_START = 100; 80 private static final int MENU_ITEM_ORDER_TEXT_PROCESS_START = 100;
80 81
81 private final Context mContext; 82 private final Context mContext;
82 private final WindowAndroid mWindowAndroid; 83 private final WindowAndroid mWindowAndroid;
83 private final WebContents mWebContents; 84 private final WebContents mWebContents;
84 private final RenderCoordinates mRenderCoordinates; 85 private final RenderCoordinates mRenderCoordinates;
86 private final ImeAdapter mImeAdapter;
85 private ActionMode.Callback mCallback; 87 private ActionMode.Callback mCallback;
86 88
87 // Selection rectangle in DIP. 89 // Selection rectangle in DIP.
88 private final Rect mSelectionRect = new Rect(); 90 private final Rect mSelectionRect = new Rect();
89 91
90 // Self-repeating task that repeatedly hides the ActionMode. This is 92 // Self-repeating task that repeatedly hides the ActionMode. This is
91 // required because ActionMode only exposes a temporary hide routine. 93 // required because ActionMode only exposes a temporary hide routine.
92 private final Runnable mRepeatingHideRunnable; 94 private final Runnable mRepeatingHideRunnable;
93 95
94 private View mView; 96 private View mView;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // This variable is set to true when the classification request is in progre ss. 130 // This variable is set to true when the classification request is in progre ss.
129 private boolean mPendingClassificationRequest; 131 private boolean mPendingClassificationRequest;
130 132
131 /** 133 /**
132 * Create {@link SelectionPopupController} instance. 134 * Create {@link SelectionPopupController} instance.
133 * @param context Context for action mode. 135 * @param context Context for action mode.
134 * @param window WindowAndroid instance. 136 * @param window WindowAndroid instance.
135 * @param webContents WebContents instance. 137 * @param webContents WebContents instance.
136 * @param view Container view. 138 * @param view Container view.
137 * @param renderCoordinates Coordinates info used to position elements. 139 * @param renderCoordinates Coordinates info used to position elements.
140 * @param imeAdapter ImeAdapter instance to handle cursor position.
138 */ 141 */
139 public SelectionPopupController(Context context, WindowAndroid window, WebCo ntents webContents, 142 public SelectionPopupController(Context context, WindowAndroid window, WebCo ntents webContents,
140 View view, RenderCoordinates renderCoordinates) { 143 View view, RenderCoordinates renderCoordinates, ImeAdapter imeAdapte r) {
141 mContext = context; 144 mContext = context;
142 mWindowAndroid = window; 145 mWindowAndroid = window;
143 mWebContents = webContents; 146 mWebContents = webContents;
144 mView = view; 147 mView = view;
145 mRenderCoordinates = renderCoordinates; 148 mRenderCoordinates = renderCoordinates;
149 mImeAdapter = imeAdapter;
146 150
147 // The menu items are allowed by default. 151 // The menu items are allowed by default.
148 mAllowedMenuItems = MENU_ITEM_SHARE | MENU_ITEM_WEB_SEARCH | MENU_ITEM_P ROCESS_TEXT; 152 mAllowedMenuItems = MENU_ITEM_SHARE | MENU_ITEM_WEB_SEARCH | MENU_ITEM_P ROCESS_TEXT;
149 mRepeatingHideRunnable = new Runnable() { 153 mRepeatingHideRunnable = new Runnable() {
150 @Override 154 @Override
151 public void run() { 155 public void run() {
152 assert mHidden; 156 assert mHidden;
153 final long hideDuration = getDefaultHideDuration(); 157 final long hideDuration = getDefaultHideDuration();
154 // Ensure the next hide call occurs before the ActionMode reappe ars. 158 // Ensure the next hide call occurs before the ActionMode reappe ars.
155 mView.postDelayed(mRepeatingHideRunnable, hideDuration - 1); 159 mView.postDelayed(mRepeatingHideRunnable, hideDuration - 1);
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 if (!(result.startAdjust == 0 && result.endAdjust == 0)) { 997 if (!(result.startAdjust == 0 && result.endAdjust == 0)) {
994 // This call causes SELECTION_HANDLES_MOVED event 998 // This call causes SELECTION_HANDLES_MOVED event
995 mWebContents.adjustSelectionByCharacterOffset(result.startAdjust , result.endAdjust); 999 mWebContents.adjustSelectionByCharacterOffset(result.startAdjust , result.endAdjust);
996 } 1000 }
997 1001
998 // Rely on this method to clear |mHidden| and unhide the action mode . 1002 // Rely on this method to clear |mHidden| and unhide the action mode .
999 showActionModeOrClearOnFailure(); 1003 showActionModeOrClearOnFailure();
1000 } 1004 }
1001 }; 1005 };
1002 } 1006 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698