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

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

Issue 2785543003: 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 12 matching lines...) Expand all
23 import android.view.MenuItem; 23 import android.view.MenuItem;
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.Log; 28 import org.chromium.base.Log;
29 import org.chromium.base.VisibleForTesting; 29 import org.chromium.base.VisibleForTesting;
30 import org.chromium.base.metrics.RecordUserAction; 30 import org.chromium.base.metrics.RecordUserAction;
31 import org.chromium.content.R; 31 import org.chromium.content.R;
32 import org.chromium.content.browser.input.FloatingPastePopupMenu; 32 import org.chromium.content.browser.input.FloatingPastePopupMenu;
33 import org.chromium.content.browser.input.ImeAdapter;
33 import org.chromium.content.browser.input.LGEmailActionModeWorkaround; 34 import org.chromium.content.browser.input.LGEmailActionModeWorkaround;
34 import org.chromium.content.browser.input.LegacyPastePopupMenu; 35 import org.chromium.content.browser.input.LegacyPastePopupMenu;
35 import org.chromium.content.browser.input.PastePopupMenu; 36 import org.chromium.content.browser.input.PastePopupMenu;
36 import org.chromium.content.browser.input.PastePopupMenu.PastePopupMenuDelegate; 37 import org.chromium.content.browser.input.PastePopupMenu.PastePopupMenuDelegate;
37 import org.chromium.content_public.browser.ActionModeCallbackHelper; 38 import org.chromium.content_public.browser.ActionModeCallbackHelper;
38 import org.chromium.content_public.browser.WebContents; 39 import org.chromium.content_public.browser.WebContents;
39 import org.chromium.ui.base.DeviceFormFactor; 40 import org.chromium.ui.base.DeviceFormFactor;
40 import org.chromium.ui.base.WindowAndroid; 41 import org.chromium.ui.base.WindowAndroid;
41 import org.chromium.ui.touch_selection.SelectionEventType; 42 import org.chromium.ui.touch_selection.SelectionEventType;
42 43
(...skipping 23 matching lines...) Expand all
66 // invalidations after the ActionMode is shown. For example, after the user 67 // invalidations after the ActionMode is shown. For example, after the user
67 // stops dragging a selection handle, in turn showing the ActionMode, the 68 // stops dragging a selection handle, in turn showing the ActionMode, the
68 // selection change response will be asynchronous. 300ms should accomodate 69 // selection change response will be asynchronous. 300ms should accomodate
69 // most such trailing, async delays. 70 // most such trailing, async delays.
70 private static final int SHOW_DELAY_MS = 300; 71 private static final int SHOW_DELAY_MS = 300;
71 72
72 private final Context mContext; 73 private final Context mContext;
73 private final WindowAndroid mWindowAndroid; 74 private final WindowAndroid mWindowAndroid;
74 private final WebContents mWebContents; 75 private final WebContents mWebContents;
75 private final RenderCoordinates mRenderCoordinates; 76 private final RenderCoordinates mRenderCoordinates;
77 private final ImeAdapter mImeAdapter;
76 private ActionMode.Callback mCallback; 78 private ActionMode.Callback mCallback;
77 79
78 // Selection rectangle in DIP. 80 // Selection rectangle in DIP.
79 private final Rect mSelectionRect = new Rect(); 81 private final Rect mSelectionRect = new Rect();
80 82
81 // Self-repeating task that repeatedly hides the ActionMode. This is 83 // Self-repeating task that repeatedly hides the ActionMode. This is
82 // required because ActionMode only exposes a temporary hide routine. 84 // required because ActionMode only exposes a temporary hide routine.
83 private final Runnable mRepeatingHideRunnable; 85 private final Runnable mRepeatingHideRunnable;
84 86
85 private View mView; 87 private View mView;
(...skipping 27 matching lines...) Expand all
113 // The client that processes textual selection, or null if none exists. 115 // The client that processes textual selection, or null if none exists.
114 private SelectionClient mSelectionClient; 116 private SelectionClient mSelectionClient;
115 117
116 /** 118 /**
117 * Create {@link SelectionPopupController} instance. 119 * Create {@link SelectionPopupController} instance.
118 * @param context Context for action mode. 120 * @param context Context for action mode.
119 * @param window WindowAndroid instance. 121 * @param window WindowAndroid instance.
120 * @param webContents WebContents instance. 122 * @param webContents WebContents instance.
121 * @param view Container view. 123 * @param view Container view.
122 * @param renderCoordinates Coordinates info used to position elements. 124 * @param renderCoordinates Coordinates info used to position elements.
125 * @param imeAdapter ImeAdapter instance to handle cursor position.
123 */ 126 */
124 public SelectionPopupController(Context context, WindowAndroid window, WebCo ntents webContents, 127 public SelectionPopupController(Context context, WindowAndroid window, WebCo ntents webContents,
125 View view, RenderCoordinates renderCoordinates) { 128 View view, RenderCoordinates renderCoordinates, ImeAdapter imeAdapte r) {
126 mContext = context; 129 mContext = context;
127 mWindowAndroid = window; 130 mWindowAndroid = window;
128 mWebContents = webContents; 131 mWebContents = webContents;
129 mView = view; 132 mView = view;
130 mRenderCoordinates = renderCoordinates; 133 mRenderCoordinates = renderCoordinates;
134 mImeAdapter = imeAdapter;
131 135
132 // The menu items are allowed by default. 136 // The menu items are allowed by default.
133 mAllowedMenuItems = MENU_ITEM_SHARE | MENU_ITEM_WEB_SEARCH | MENU_ITEM_P ROCESS_TEXT; 137 mAllowedMenuItems = MENU_ITEM_SHARE | MENU_ITEM_WEB_SEARCH | MENU_ITEM_P ROCESS_TEXT;
134 mRepeatingHideRunnable = new Runnable() { 138 mRepeatingHideRunnable = new Runnable() {
135 @Override 139 @Override
136 public void run() { 140 public void run() {
137 assert mHidden; 141 assert mHidden;
138 final long hideDuration = getDefaultHideDuration(); 142 final long hideDuration = getDefaultHideDuration();
139 // Ensure the next hide call occurs before the ActionMode reappe ars. 143 // Ensure the next hide call occurs before the ActionMode reappe ars.
140 mView.postDelayed(mRepeatingHideRunnable, hideDuration - 1); 144 mView.postDelayed(mRepeatingHideRunnable, hideDuration - 1);
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 mIsInsertion = insertion; 877 mIsInsertion = insertion;
874 } 878 }
875 879
876 private boolean isShareAvailable() { 880 private boolean isShareAvailable() {
877 Intent intent = new Intent(Intent.ACTION_SEND); 881 Intent intent = new Intent(Intent.ACTION_SEND);
878 intent.setType("text/plain"); 882 intent.setType("text/plain");
879 return mContext.getPackageManager().queryIntentActivities(intent, 883 return mContext.getPackageManager().queryIntentActivities(intent,
880 PackageManager.MATCH_DEFAULT_ONLY).size() > 0; 884 PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
881 } 885 }
882 } 886 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698