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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java

Issue 2099753003: [TTS] Update Tap counters to compensate for Quick Answers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Just added a comment. Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java
index c767ef34f3da6094670dce091260568e00f97027..3848c9dcfe3a3e05f61bd3e3b37916590d59058e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java
@@ -259,6 +259,7 @@ class ContextualSearchPolicy {
// Always completely reset the tap counter, since it just counts taps
// since the last open.
mPreferenceManager.setContextualSearchTapCount(0);
+ mPreferenceManager.setContextualSearchTapQuickAnswerCount(0);
// Disable the "promo tap" counter, but only if we're using the Opt-out onboarding.
// For Opt-in, we never disable the promo tap counter.
@@ -273,6 +274,20 @@ class ContextualSearchPolicy {
}
/**
+ * Updates Tap counters to account for a quick-answer caption shown on the panel.
+ * @param wasActivatedByTap Whether the triggering gesture was a Tap or not.
+ * @param doesAnswer Whether the caption is considered an answer rather than just
+ * informative.
+ */
+ void updateCountersForQuickAnswer(boolean wasActivatedByTap, boolean doesAnswer) {
+ if (wasActivatedByTap && doesAnswer) {
+ int tapsWithAnswerSinceOpen =
+ mPreferenceManager.getContextualSearchTapQuickAnswerCount();
+ mPreferenceManager.setContextualSearchTapQuickAnswerCount(++tapsWithAnswerSinceOpen);
+ }
+ }
+
+ /**
* @return Whether a verbatim request should be made for the given base page, assuming there
* is no exiting request.
*/
@@ -527,7 +542,9 @@ class ContextualSearchPolicy {
* @return Whether the tap resolve/prefetch limit has been exceeded.
*/
private boolean isTapBeyondTheLimit() {
- return getTapCount() > getTapLimit();
+ // Discount taps that caused a Quick Answer since the tap may not have been totally ignored.
+ return getTapCount() - mPreferenceManager.getContextualSearchTapQuickAnswerCount()
+ > getTapLimit();
}
/**

Powered by Google App Engine
This is Rietveld 408576698