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..86b1108c007af1538cdcc2b1880f4630686b14e5 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 in px. |
+ * @param y The y coordinate in px. |
*/ |
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); |
} |
} |