Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java |
| index 161f3171719cfee20881e3144c3e89c404c2afe7..d14ff3ff4e7f67ea5c4cd148bf7829824888c7ba 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java |
| @@ -15,6 +15,7 @@ import org.chromium.chrome.browser.preferences.ChromePreferenceManager; |
| import org.chromium.chrome.browser.tab.Tab; |
| import org.chromium.content.browser.ContentViewCore; |
| import org.chromium.content_public.browser.GestureStateListener; |
| +import org.chromium.content_public.browser.WebContents; |
| import org.chromium.ui.touch_selection.SelectionEventType; |
| import java.util.regex.Matcher; |
| @@ -355,10 +356,11 @@ public class ContextualSearchSelectionController { |
| /** |
| * Handles an unhandled tap gesture. |
| + * @param x The x coordinate. |
|
Theresa
2017/03/09 22:46:37
nit: The x coordinate in px?
Donn Denman
2017/03/10 01:29:43
Done.
|
| + * @param y The y coordinate. |
| */ |
| void handleShowUnhandledTapUIIfNeeded(int x, int y) { |
| mWasTapGestureDetected = false; |
| - // TODO(donnd): shouldn't we check == TAP here instead of LONG_PRESS? |
| // TODO(donnd): refactor to avoid needing a new handler API method as suggested by Pedro. |
| if (mSelectionType != SelectionType.LONG_PRESS) { |
| mWasTapGestureDetected = true; |
| @@ -403,14 +405,25 @@ public class ContextualSearchSelectionController { |
| } |
| /** |
| + * Gets the base page ContentViewCore. |
| + * Deprecated, use getBaseWebContents instead. |
| * @return The Base Page's {@link ContentViewCore}, or {@code null} if there is no current tab. |
| */ |
| + @Deprecated |
| ContentViewCore getBaseContentView() { |
| Tab currentTab = mActivity.getActivityTab(); |
| return currentTab != null ? currentTab.getContentViewCore() : null; |
| } |
| /** |
| + * @return The Base Page's {@link WebContents}, or {@code null} if there is no current tab. |
| + */ |
| + WebContents getBaseWebContents() { |
| + Tab currentTab = mActivity.getActivityTab(); |
| + return currentTab != null ? currentTab.getContentViewCore().getWebContents() : null; |
| + } |
| + |
| + /** |
| * Expands the current selection by the specified amounts. |
| * @param selectionStartAdjust The start offset adjustment of the selection to use to highlight |
| * the search term. |
| @@ -422,10 +435,10 @@ public class ContextualSearchSelectionController { |
| // crbug.com/508354 |
| if (selectionStartAdjust == 0 && selectionEndAdjust == 0) return; |
| - ContentViewCore basePageContentView = getBaseContentView(); |
| - if (basePageContentView != null && basePageContentView.getWebContents() != null) { |
| + WebContents basePageWebContents = getBaseWebContents(); |
| + if (basePageWebContents != null) { |
| mDidExpandSelection = true; |
| - basePageContentView.getWebContents().adjustSelectionByCharacterOffset( |
| + basePageWebContents.adjustSelectionByCharacterOffset( |
| selectionStartAdjust, selectionEndAdjust); |
| } |
| } |