Index: content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java |
diff --git a/content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java b/content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java |
index 0012b5b1b0150d4da1713f251df91ffd5c2177a9..8a8cc8ef08cfe4ae922c58bfafc8fa0cb91751fa 100644 |
--- a/content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java |
+++ b/content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java |
@@ -844,7 +844,15 @@ public class SelectionPopupController extends ActionModeCallbackHelper { |
mSelectionRect.set(left, top, right, bottom); |
mHasSelection = true; |
mUnselectAllOnDismiss = true; |
- if (mSelectionClient == null || !mSelectionClient.sendsSelectionPopupUpdates()) { |
+ // When this event comes as the result of SelectAll, SelectionClient should not |
+ // change the selection range (http://crbug.com/714106). We assume that two or |
+ // more selected words means SelectAll. |
+ // TODO(amaralp): Find a better way to know that SELECTION_HANDLES_SHOWN was |
+ // caused by SelectAll. |
+ boolean oneWordSelected = |
+ !getSelectedText().isEmpty() && !getSelectedText().matches(".*\\s+.*"); |
+ if (!oneWordSelected || mSelectionClient == null |
+ || !mSelectionClient.sendsSelectionPopupUpdates()) { |
showActionModeOrClearOnFailure(); |
} else { |
// Rely on |mSelectionClient| sending a classification request and the request |