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

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

Issue 1423723006: Hard-code tap resolve and prefetch limits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tap_promo
Patch Set: Add @VisibleForTesting annotation Created 5 years, 1 month 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 | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java » ('j') | 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.content.Context; 7 import android.content.Context;
8 import android.text.TextUtils; 8 import android.text.TextUtils;
9 9
10 import org.chromium.base.CommandLine; 10 import org.chromium.base.CommandLine;
11 import org.chromium.base.SysUtils; 11 import org.chromium.base.SysUtils;
12 import org.chromium.base.VisibleForTesting; 12 import org.chromium.base.VisibleForTesting;
13 import org.chromium.chrome.browser.ChromeSwitches; 13 import org.chromium.chrome.browser.ChromeSwitches;
14 import org.chromium.chrome.browser.ChromeVersionInfo; 14 import org.chromium.chrome.browser.ChromeVersionInfo;
15 import org.chromium.components.variations.VariationsAssociatedData; 15 import org.chromium.components.variations.VariationsAssociatedData;
16 import org.chromium.ui.base.DeviceFormFactor; 16 import org.chromium.ui.base.DeviceFormFactor;
17 17
18 /** 18 /**
19 * Provides Field Trial support for the Contextual Search application within Chr ome for Android. 19 * Provides Field Trial support for the Contextual Search application within Chr ome for Android.
20 */ 20 */
21 public class ContextualSearchFieldTrial { 21 public class ContextualSearchFieldTrial {
22 private static final String FIELD_TRIAL_NAME = "ContextualSearch"; 22 private static final String FIELD_TRIAL_NAME = "ContextualSearch";
23 private static final String ENABLED_PARAM = "enabled"; 23 private static final String ENABLED_PARAM = "enabled";
24 private static final String ENABLED_VALUE = "true"; 24 private static final String ENABLED_VALUE = "true";
25 25
26 static final String PROMO_ON_LIMITED_TAPS = "promo_on_limited_taps"; 26 static final String PROMO_ON_LIMITED_TAPS = "promo_on_limited_taps";
27 static final String TAP_TRIGGERED_PROMO_LIMIT = "tap_triggered_promo_limit"; 27 static final String TAP_TRIGGERED_PROMO_LIMIT = "tap_triggered_promo_limit";
28 static final String TAP_RESOLVE_LIMIT_FOR_DECIDED = "tap_resolve_limit_for_d ecided";
29 static final String TAP_PREFETCH_LIMIT_FOR_DECIDED = "tap_prefetch_limit_for _decided";
30 static final String TAP_RESOLVE_LIMIT_FOR_UNDECIDED = "tap_resolve_limit_for _undecided";
31 static final String TAP_PREFETCH_LIMIT_FOR_UNDECIDED = "tap_prefetch_limit_f or_undecided";
32
33 static final String PEEK_PROMO_FORCED = "peek_promo_forced"; 28 static final String PEEK_PROMO_FORCED = "peek_promo_forced";
34 static final String PEEK_PROMO_ENABLED = "peek_promo_enabled"; 29 static final String PEEK_PROMO_ENABLED = "peek_promo_enabled";
35 static final String PEEK_PROMO_MAX_SHOW_COUNT = "peek_promo_max_show_count"; 30 static final String PEEK_PROMO_MAX_SHOW_COUNT = "peek_promo_max_show_count";
36 static final int PEEK_PROMO_DEFAULT_MAX_SHOW_COUNT = 10; 31 static final int PEEK_PROMO_DEFAULT_MAX_SHOW_COUNT = 10;
37 32
38 static final String DISABLE_EXTRA_SEARCH_BAR_ANIMATIONS = "disable_extra_sea rch_bar_animations"; 33 static final String DISABLE_EXTRA_SEARCH_BAR_ANIMATIONS = "disable_extra_sea rch_bar_animations";
39 34
40 // Translation. 35 // Translation.
41 @VisibleForTesting 36 @VisibleForTesting
42 static final String TRANSLATION_ONEBOX_ENABLED = "translation_onebox_enabled "; 37 static final String TRANSLATION_ONEBOX_ENABLED = "translation_onebox_enabled ";
43 38
44 // Tap handling. 39 // Tap handling.
45 private static final int UNLIMITED_TAPS = -1; 40 private static final int UNLIMITED_TAPS = -1;
46 private static final int DEFAULT_TAP_RESOLVE_LIMIT_FOR_DECIDED = UNLIMITED_T APS;
47 private static final int DEFAULT_TAP_PREFETCH_LIMIT_FOR_DECIDED = UNLIMITED_ TAPS;
48 private static final int DEFAULT_TAP_RESOLVE_LIMIT_FOR_UNDECIDED = 100;
49 private static final int DEFAULT_TAP_PREFETCH_LIMIT_FOR_UNDECIDED = 10;
50 41
51 // Cached values to avoid repeated and redundant JNI operations. 42 // Cached values to avoid repeated and redundant JNI operations.
52 private static Boolean sEnabled; 43 private static Boolean sEnabled;
53 private static Boolean sIsPeekPromoEnabled; 44 private static Boolean sIsPeekPromoEnabled;
54 private static Integer sPeekPromoMaxCount; 45 private static Integer sPeekPromoMaxCount;
55 private static Boolean sIsTranslationOneboxEnabled; 46 private static Boolean sIsTranslationOneboxEnabled;
56 47
57 /** 48 /**
58 * Don't instantiate. 49 * Don't instantiate.
59 */ 50 */
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 /** 105 /**
115 * @return The maximum number of times the promo can be triggered by a tap, or 106 * @return The maximum number of times the promo can be triggered by a tap, or
116 * {@code ContextualSearchUma#PROMO_TAPS_REMAINING_INVALID} if no value is p resent in the finch 107 * {@code ContextualSearchUma#PROMO_TAPS_REMAINING_INVALID} if no value is p resent in the finch
117 * configuration. 108 * configuration.
118 */ 109 */
119 static int getPromoTapTriggeredLimit() { 110 static int getPromoTapTriggeredLimit() {
120 return getIntParamValueOrDefault(TAP_TRIGGERED_PROMO_LIMIT, UNLIMITED_TA PS); 111 return getIntParamValueOrDefault(TAP_TRIGGERED_PROMO_LIMIT, UNLIMITED_TA PS);
121 } 112 }
122 113
123 /** 114 /**
124 * @return Whether Search Term Resolution in response to a Tap gesture is li mited for decided
125 * users.
126 */
127 static boolean isTapResolveLimitedForDecided() {
128 return getTapResolveLimitForDecided() != ContextualSearchFieldTrial.UNLI MITED_TAPS;
129 }
130
131 /**
132 * @return Whether prefetch in response to a Tap gesture is limited for deci ded users.
133 */
134 static boolean isTapPrefetchLimitedForDecided() {
135 return getTapPrefetchLimitForDecided() != ContextualSearchFieldTrial.UNL IMITED_TAPS;
136 }
137
138 /**
139 * @return Whether Search Term Resolution in response to a Tap gesture is li mited for undecided
140 * users.
141 */
142 static boolean isTapResolveLimitedForUndecided() {
143 return getTapResolveLimitForUndecided() != ContextualSearchFieldTrial.UN LIMITED_TAPS;
144 }
145
146 /**
147 * @return Whether prefetch in response to a Tap gesture is limited for unde cided users.
148 */
149 static boolean isTapPrefetchLimitedForUndecided() {
150 return getTapPrefetchLimitForUndecided() != ContextualSearchFieldTrial.U NLIMITED_TAPS;
151 }
152 /**
153 * @return The limit on the number of taps to resolve for decided users, or the default if no
154 * value is present in the Finch configuration.
155 */
156 static int getTapResolveLimitForDecided() {
157 return getIntParamValueOrDefault(TAP_RESOLVE_LIMIT_FOR_DECIDED,
158 DEFAULT_TAP_RESOLVE_LIMIT_FOR_DECIDED);
159 }
160
161 /**
162 * @return The limit on the number of prefetches to issue for decided users, or the default
163 * if no value is present.
164 */
165 static int getTapPrefetchLimitForDecided() {
166 return getIntParamValueOrDefault(TAP_PREFETCH_LIMIT_FOR_DECIDED,
167 DEFAULT_TAP_PREFETCH_LIMIT_FOR_DECIDED);
168 }
169
170 /**
171 * @return The limit on the number of taps to resolve for undecided users, o r the default if no
172 * value is present in the Finch configuration.
173 */
174 static int getTapResolveLimitForUndecided() {
175 return getIntParamValueOrDefault(TAP_RESOLVE_LIMIT_FOR_UNDECIDED,
176 DEFAULT_TAP_RESOLVE_LIMIT_FOR_UNDECIDED);
177 }
178
179 /**
180 * @return The limit on the number of prefetches to issue for undecided user s, or the default
181 * if no value is present.
182 */
183 static int getTapPrefetchLimitForUndecided() {
184 return getIntParamValueOrDefault(TAP_PREFETCH_LIMIT_FOR_UNDECIDED,
185 DEFAULT_TAP_PREFETCH_LIMIT_FOR_UNDECIDED);
186 }
187
188 /**
189 * @return Whether the Peek Promo is forcibly enabled (used for testing). 115 * @return Whether the Peek Promo is forcibly enabled (used for testing).
190 */ 116 */
191 static boolean isPeekPromoForced() { 117 static boolean isPeekPromoForced() {
192 return CommandLine.getInstance().hasSwitch(PEEK_PROMO_FORCED); 118 return CommandLine.getInstance().hasSwitch(PEEK_PROMO_FORCED);
193 } 119 }
194 120
195 /** 121 /**
196 * @return Whether the Peek Promo is enabled. 122 * @return Whether the Peek Promo is enabled.
197 */ 123 */
198 static boolean isPeekPromoEnabled() { 124 static boolean isPeekPromoEnabled() {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 try { 192 try {
267 return Integer.parseInt(value); 193 return Integer.parseInt(value);
268 } catch (NumberFormatException e) { 194 } catch (NumberFormatException e) {
269 return defaultValue; 195 return defaultValue;
270 } 196 }
271 } 197 }
272 198
273 return defaultValue; 199 return defaultValue;
274 } 200 }
275 } 201 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698