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

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: 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..04e94252ea7f5a05d479aa8c2b928627222008de 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,8 @@ class ContextualSearchPolicy {
* @return Whether the tap resolve/prefetch limit has been exceeded.
*/
private boolean isTapBeyondTheLimit() {
- return getTapCount() > getTapLimit();
+ return getTapCount() - mPreferenceManager.getContextualSearchTapQuickAnswerCount()
twellington 2016/06/27 18:46:40 Do we need to do something like this in the other
Donn Denman 2016/06/27 20:43:00 Yes, thanks for reminding me. We can land this an
pedro (no code reviews) 2016/06/27 21:11:10 Put an explanation here to clarify why we are subt
+ > getTapLimit();
}
/**

Powered by Google App Engine
This is Rietveld 408576698