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 0d565dd629af4e9ab233e95e6389566ac1199181..f03d6558fb19ae52bc75947522fb55a3624f1562 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 |
| @@ -55,6 +55,7 @@ public class ContextualSearchSelectionController { |
| private boolean mWasLastTapValid; |
| private boolean mIsWaitingForInvalidTapDetection; |
| private boolean mShouldHandleSelectionModification; |
| + private boolean mDidExpandSelection; |
| private float mX; |
| private float mY; |
| @@ -149,6 +150,11 @@ public class ContextualSearchSelectionController { |
| * @param selection The selection portion of the context. |
| */ |
| void handleSelectionChanged(String selection) { |
| + if (mDidExpandSelection) { |
| + mDidExpandSelection = false; |
| + return; |
| + } |
| + |
| if (selection == null || selection.isEmpty()) { |
| scheduleInvalidTapNotification(); |
| // When the user taps on the page it will place the caret in that position, which |
| @@ -281,6 +287,25 @@ public class ContextualSearchSelectionController { |
| } |
| /** |
| + * Expands the current selection by the specified amounts. |
| + * @param selectionStartAdjust The start offset adjustment of the selection to use to highlight |
| + * the search term. |
| + * @param selectionEndAdjust The end offset adjustment of the selection to use to highlight |
| + * the search term. |
| + */ |
| + void expandSelection(int selectionStartAdjust, int selectionEndAdjust) { |
| + // TODO(donnd): add code to verify that the selection is still valid before changing it! |
|
palmer
2015/07/07 18:39:59
Add a bug link to this comment.
|
| + |
| + if (selectionStartAdjust == 0 && selectionEndAdjust == 0) return; |
| + ContentViewCore basePageContentView = getBaseContentView(); |
| + if (basePageContentView != null && basePageContentView.getWebContents() != null) { |
| + mDidExpandSelection = true; |
| + basePageContentView.getWebContents().expandSelectionByCharacterOffset( |
| + selectionStartAdjust, selectionEndAdjust); |
| + } |
| + } |
| + |
| + /** |
| * @return whether a tap at the given coordinates should be handled or not. |
| */ |
| private boolean shouldHandleTap(int x, int y) { |