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

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

Issue 2906763002: [TTS] Add some initial signals for Tap in content. (Closed)
Patch Set: Created 3 years, 6 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
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.text.TextUtils; 7 import android.text.TextUtils;
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 198 }
199 199
200 /** 200 /**
201 * Clears the selection. 201 * Clears the selection.
202 */ 202 */
203 void clearSelection() { 203 void clearSelection() {
204 ContentViewCore baseContentView = getBaseContentView(); 204 ContentViewCore baseContentView = getBaseContentView();
205 if (baseContentView != null) { 205 if (baseContentView != null) {
206 baseContentView.clearSelection(); 206 baseContentView.clearSelection();
207 } 207 }
208 resetAllStates(); 208 resetSelectionStates();
Donn Denman 2017/05/25 19:56:47 This looks like a bug that encountered when doing
209 } 209 }
210 210
211 /** 211 /**
212 * Handles a change in the current Selection. 212 * Handles a change in the current Selection.
213 * @param selection The selection portion of the context. 213 * @param selection The selection portion of the context.
214 */ 214 */
215 void handleSelectionChanged(String selection) { 215 void handleSelectionChanged(String selection) {
216 if (mDidExpandSelection) { 216 if (mDidExpandSelection) {
217 mSelectedText = selection; 217 mSelectedText = selection;
218 mDidExpandSelection = false; 218 mDidExpandSelection = false;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 mHandler.handleInvalidTap(); 345 mHandler.handleInvalidTap();
346 } 346 }
347 } 347 }
348 348
349 /** 349 /**
350 * Handles Tap suppression by making a callback to either the handler's #han dleSuppressedTap() 350 * Handles Tap suppression by making a callback to either the handler's #han dleSuppressedTap()
351 * or #handleNonSuppressedTap() after a possible delay. 351 * or #handleNonSuppressedTap() after a possible delay.
352 * This should be called when the context is fully built (by gathering surro unding text 352 * This should be called when the context is fully built (by gathering surro unding text
353 * if needed, etc) but before showing any UX. 353 * if needed, etc) but before showing any UX.
354 */ 354 */
355 void handleShouldSuppressTap() { 355 void handleShouldSuppressTap(ContextualSearchContext contextualSearchContext ) {
356 int x = (int) mX; 356 int x = (int) mX;
357 int y = (int) mY; 357 int y = (int) mY;
358 358
359 // TODO(donnd): add a policy method to get adjusted tap count. 359 // TODO(donnd): add a policy method to get adjusted tap count.
360 ChromePreferenceManager prefs = ChromePreferenceManager.getInstance(); 360 ChromePreferenceManager prefs = ChromePreferenceManager.getInstance();
361 int adjustedTapsSinceOpen = prefs.getContextualSearchTapCount() 361 int adjustedTapsSinceOpen = prefs.getContextualSearchTapCount()
362 - prefs.getContextualSearchTapQuickAnswerCount(); 362 - prefs.getContextualSearchTapQuickAnswerCount();
363 TapSuppressionHeuristics tapHeuristics = 363 TapSuppressionHeuristics tapHeuristics = new TapSuppressionHeuristics(
364 new TapSuppressionHeuristics(this, mLastTapState, x, y, adjusted TapsSinceOpen); 364 this, mLastTapState, x, y, adjustedTapsSinceOpen, contextualSear chContext);
365 // TODO(donnd): Move to be called when the panel closes to work with sta tes that change. 365 // TODO(donnd): Move to be called when the panel closes to work with sta tes that change.
366 tapHeuristics.logConditionState(); 366 tapHeuristics.logConditionState();
367 // Tell the manager what it needs in order to log metrics on whether the tap would have 367 // Tell the manager what it needs in order to log metrics on whether the tap would have
368 // been suppressed if each of the heuristics were satisfied. 368 // been suppressed if each of the heuristics were satisfied.
369 mHandler.handleMetricsForWouldSuppressTap(tapHeuristics); 369 mHandler.handleMetricsForWouldSuppressTap(tapHeuristics);
370 370
371 boolean shouldSuppressTap = tapHeuristics.shouldSuppressTap(); 371 boolean shouldSuppressTap = tapHeuristics.shouldSuppressTap();
372 if (mTapTimeNanoseconds != 0) { 372 if (mTapTimeNanoseconds != 0) {
373 // Remember the tap state for subsequent tap evaluation. 373 // Remember the tap state for subsequent tap evaluation.
374 mLastTapState = 374 mLastTapState =
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 // Starts are inclusive and ends are non-inclusive for both GSAContext & matcher. 552 // Starts are inclusive and ends are non-inclusive for both GSAContext & matcher.
553 while (matcher.find()) { 553 while (matcher.find()) {
554 if (startOffset >= matcher.start() && endOffset <= matcher.end()) { 554 if (startOffset >= matcher.start() && endOffset <= matcher.end()) {
555 return true; 555 return true;
556 } 556 }
557 } 557 }
558 558
559 return false; 559 return false;
560 } 560 }
561 } 561 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698