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

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

Powered by Google App Engine
This is Rietveld 408576698