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.chrome.browser.contextualsearch; | 5 package org.chromium.chrome.browser.contextualsearch; |
6 | 6 |
7 import android.os.Handler; | 7 import android.os.Handler; |
8 | 8 |
9 import org.chromium.base.VisibleForTesting; | 9 import org.chromium.base.VisibleForTesting; |
10 import org.chromium.chrome.browser.ChromeActivity; | 10 import org.chromium.chrome.browser.ChromeActivity; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 } | 287 } |
288 | 288 |
289 /** | 289 /** |
290 * Expands the current selection by the specified amounts. | 290 * Expands the current selection by the specified amounts. |
291 * @param selectionStartAdjust The start offset adjustment of the selection
to use to highlight | 291 * @param selectionStartAdjust The start offset adjustment of the selection
to use to highlight |
292 * the search term. | 292 * the search term. |
293 * @param selectionEndAdjust The end offset adjustment of the selection to u
se to highlight | 293 * @param selectionEndAdjust The end offset adjustment of the selection to u
se to highlight |
294 * the search term. | 294 * the search term. |
295 */ | 295 */ |
296 void adjustSelection(int selectionStartAdjust, int selectionEndAdjust) { | 296 void adjustSelection(int selectionStartAdjust, int selectionEndAdjust) { |
| 297 if (ContextualSearchFieldTrial.isSelectionExpansionDisabled()) return; |
| 298 |
297 // TODO(donnd): add code to verify that the selection is still valid bef
ore changing it. | 299 // TODO(donnd): add code to verify that the selection is still valid bef
ore changing it. |
298 // crbug.com/508354 | 300 // crbug.com/508354 |
299 | 301 |
300 if (selectionStartAdjust == 0 && selectionEndAdjust == 0) return; | 302 if (selectionStartAdjust == 0 && selectionEndAdjust == 0) return; |
301 ContentViewCore basePageContentView = getBaseContentView(); | 303 ContentViewCore basePageContentView = getBaseContentView(); |
302 if (basePageContentView != null && basePageContentView.getWebContents()
!= null) { | 304 if (basePageContentView != null && basePageContentView.getWebContents()
!= null) { |
303 mDidExpandSelection = true; | 305 mDidExpandSelection = true; |
304 basePageContentView.getWebContents().adjustSelectionByCharacterOffse
t( | 306 basePageContentView.getWebContents().adjustSelectionByCharacterOffse
t( |
305 selectionStartAdjust, selectionEndAdjust); | 307 selectionStartAdjust, selectionEndAdjust); |
306 } | 308 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 /** | 382 /** |
381 * Determines if the given selection contains a word or not. | 383 * Determines if the given selection contains a word or not. |
382 * @param selection The the selection to check for a word. | 384 * @param selection The the selection to check for a word. |
383 * @return Whether the selection contains a word anywhere within it or not. | 385 * @return Whether the selection contains a word anywhere within it or not. |
384 */ | 386 */ |
385 @VisibleForTesting | 387 @VisibleForTesting |
386 public boolean doesContainAWord(String selection) { | 388 public boolean doesContainAWord(String selection) { |
387 return mContainsWordPattern.matcher(selection).find(); | 389 return mContainsWordPattern.matcher(selection).find(); |
388 } | 390 } |
389 } | 391 } |
OLD | NEW |