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(); |
} |
/** |