Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionController.java

Issue 1230933005: Add a finch flag to disable ContextualSearch selection expansion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add JavaDoc Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchFieldTrial.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchFieldTrial.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698