OLD | NEW |
---|---|
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 11 matching lines...) Expand all Loading... | |
22 import android.view.MenuInflater; | 22 import android.view.MenuInflater; |
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.factory.ContentClassFactory; | |
32 import org.chromium.content.browser.input.FloatingPastePopupMenu; | 33 import org.chromium.content.browser.input.FloatingPastePopupMenu; |
33 import org.chromium.content.browser.input.ImeAdapter; | 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; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 private boolean mHasSelection; | 109 private boolean mHasSelection; |
109 | 110 |
110 // Lazily created paste popup menu, triggered either via long press in an | 111 // Lazily created paste popup menu, triggered either via long press in an |
111 // editable region or from tapping the insertion handle. | 112 // editable region or from tapping the insertion handle. |
112 private PastePopupMenu mPastePopupMenu; | 113 private PastePopupMenu mPastePopupMenu; |
113 private boolean mWasPastePopupShowingOnInsertionDragStart; | 114 private boolean mWasPastePopupShowingOnInsertionDragStart; |
114 | 115 |
115 // The client that implements Contextual Search functionality, or null if no ne exists. | 116 // The client that implements Contextual Search functionality, or null if no ne exists. |
116 private ContextualSearchClient mContextualSearchClient; | 117 private ContextualSearchClient mContextualSearchClient; |
117 | 118 |
119 private ContextSelectionProvider mContextSelector; | |
Tima Vaisburd
2017/03/03 03:10:58
Now I think that having both mContextualSearchClie
| |
120 | |
118 /** | 121 /** |
119 * Create {@link SelectionPopupController} instance. | 122 * Create {@link SelectionPopupController} instance. |
120 * @param context Context for action mode. | 123 * @param context Context for action mode. |
121 * @param window WindowAndroid instance. | 124 * @param window WindowAndroid instance. |
122 * @param webContents WebContents instance. | 125 * @param webContents WebContents instance. |
123 * @param view Container view. | 126 * @param view Container view. |
124 * @param renderCoordinates Coordinates info used to position elements. | 127 * @param renderCoordinates Coordinates info used to position elements. |
125 * @param imeAdapter ImeAdapter instance to handle cursor position. | 128 * @param imeAdapter ImeAdapter instance to handle cursor position. |
126 */ | 129 */ |
127 public SelectionPopupController(Context context, WindowAndroid window, WebCo ntents webContents, | 130 public SelectionPopupController(Context context, WindowAndroid window, WebCo ntents webContents, |
(...skipping 10 matching lines...) Expand all Loading... | |
138 mRepeatingHideRunnable = new Runnable() { | 141 mRepeatingHideRunnable = new Runnable() { |
139 @Override | 142 @Override |
140 public void run() { | 143 public void run() { |
141 assert mHidden; | 144 assert mHidden; |
142 final long hideDuration = getDefaultHideDuration(); | 145 final long hideDuration = getDefaultHideDuration(); |
143 // Ensure the next hide call occurs before the ActionMode reappe ars. | 146 // Ensure the next hide call occurs before the ActionMode reappe ars. |
144 mView.postDelayed(mRepeatingHideRunnable, hideDuration - 1); | 147 mView.postDelayed(mRepeatingHideRunnable, hideDuration - 1); |
145 hideActionModeTemporarily(hideDuration); | 148 hideActionModeTemporarily(hideDuration); |
146 } | 149 } |
147 }; | 150 }; |
151 | |
152 if (ContentClassFactory.get() != null) { | |
153 mContextSelector = ContentClassFactory.get().createContextSelectionP rovider( | |
154 null, webContents, window); | |
155 } | |
148 } | 156 } |
149 | 157 |
150 /** | 158 /** |
151 * Update the container view. | 159 * Update the container view. |
152 */ | 160 */ |
153 void setContainerView(View view) { | 161 void setContainerView(View view) { |
154 assert view != null; | 162 assert view != null; |
155 | 163 |
156 // Cleans up action mode before switching to a new container view. | 164 // Cleans up action mode before switching to a new container view. |
157 if (isActionModeValid()) finishActionMode(); | 165 if (isActionModeValid()) finishActionMode(); |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
914 mIsInsertion = insertion; | 922 mIsInsertion = insertion; |
915 } | 923 } |
916 | 924 |
917 private boolean isShareAvailable() { | 925 private boolean isShareAvailable() { |
918 Intent intent = new Intent(Intent.ACTION_SEND); | 926 Intent intent = new Intent(Intent.ACTION_SEND); |
919 intent.setType("text/plain"); | 927 intent.setType("text/plain"); |
920 return mContext.getPackageManager().queryIntentActivities(intent, | 928 return mContext.getPackageManager().queryIntentActivities(intent, |
921 PackageManager.MATCH_DEFAULT_ONLY).size() > 0; | 929 PackageManager.MATCH_DEFAULT_ONLY).size() > 0; |
922 } | 930 } |
923 } | 931 } |
OLD | NEW |