OLD | NEW |
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.CommandLine; | 9 import org.chromium.base.CommandLine; |
10 import org.chromium.base.SysUtils; | 10 import org.chromium.base.SysUtils; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 private static final String CHINESE_LANGUAGE_CODE = "zh"; | 45 private static final String CHINESE_LANGUAGE_CODE = "zh"; |
46 private static final String JAPANESE_LANGUAGE_CODE = "ja"; | 46 private static final String JAPANESE_LANGUAGE_CODE = "ja"; |
47 private static final String KOREAN_LANGUAGE_CODE = "ko"; | 47 private static final String KOREAN_LANGUAGE_CODE = "ko"; |
48 private static final String[] CJK_LANGUAGE_CODES = {CHINESE_LANGUAGE_CODE, | 48 private static final String[] CJK_LANGUAGE_CODES = {CHINESE_LANGUAGE_CODE, |
49 JAPANESE_LANGUAGE_CODE, KOREAN_LANGUAGE_CODE}; | 49 JAPANESE_LANGUAGE_CODE, KOREAN_LANGUAGE_CODE}; |
50 | 50 |
51 // The default navigation-detection-delay in milliseconds. | 51 // The default navigation-detection-delay in milliseconds. |
52 private static final int DEFAULT_TAP_NAVIGATION_DETECTION_DELAY = 16; | 52 private static final int DEFAULT_TAP_NAVIGATION_DETECTION_DELAY = 16; |
53 private static final String NAVIGATION_DETECTION_DELAY = "tap_navigation_det
ection_delay"; | 53 private static final String NAVIGATION_DETECTION_DELAY = "tap_navigation_det
ection_delay"; |
54 | 54 |
| 55 // Quick Answers. |
| 56 private static final String QUICK_ANSWERS_ENABLED = "quick_answers_enabled"; |
| 57 |
| 58 // Tap handling. |
55 private static final int UNLIMITED_TAPS = -1; | 59 private static final int UNLIMITED_TAPS = -1; |
56 private static final int DEFAULT_TAP_RESOLVE_LIMIT_FOR_DECIDED = UNLIMITED_T
APS; | 60 private static final int DEFAULT_TAP_RESOLVE_LIMIT_FOR_DECIDED = UNLIMITED_T
APS; |
57 private static final int DEFAULT_TAP_PREFETCH_LIMIT_FOR_DECIDED = UNLIMITED_
TAPS; | 61 private static final int DEFAULT_TAP_PREFETCH_LIMIT_FOR_DECIDED = UNLIMITED_
TAPS; |
58 private static final int DEFAULT_TAP_RESOLVE_LIMIT_FOR_UNDECIDED = 100; | 62 private static final int DEFAULT_TAP_RESOLVE_LIMIT_FOR_UNDECIDED = 100; |
59 private static final int DEFAULT_TAP_PREFETCH_LIMIT_FOR_UNDECIDED = 10; | 63 private static final int DEFAULT_TAP_PREFETCH_LIMIT_FOR_UNDECIDED = 10; |
60 | 64 |
61 // Cached values to avoid repeated and redundant JNI operations. | 65 // Cached values to avoid repeated and redundant JNI operations. |
62 private static Boolean sEnabled; | 66 private static Boolean sEnabled; |
63 private static Boolean sIsPeekPromoEnabled; | 67 private static Boolean sIsPeekPromoEnabled; |
64 private static Integer sPeekPromoMaxCount; | 68 private static Integer sPeekPromoMaxCount; |
| 69 private static Boolean sIsQuickAnswersEnabled; |
65 | 70 |
66 /** | 71 /** |
67 * Don't instantiate. | 72 * Don't instantiate. |
68 */ | 73 */ |
69 private ContextualSearchFieldTrial() {} | 74 private ContextualSearchFieldTrial() {} |
70 | 75 |
71 /** | 76 /** |
72 * Checks the current Variations parameters associated with the active group
as well as the | 77 * Checks the current Variations parameters associated with the active group
as well as the |
73 * Chrome preference to determine if the service is enabled. | 78 * Chrome preference to determine if the service is enabled. |
74 * @return Whether Contextual Search is enabled or not. | 79 * @return Whether Contextual Search is enabled or not. |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 */ | 261 */ |
257 static int getPeekPromoMaxShowCount() { | 262 static int getPeekPromoMaxShowCount() { |
258 if (sPeekPromoMaxCount == null) { | 263 if (sPeekPromoMaxCount == null) { |
259 sPeekPromoMaxCount = getIntParamValueOrDefault( | 264 sPeekPromoMaxCount = getIntParamValueOrDefault( |
260 PEEK_PROMO_MAX_SHOW_COUNT, | 265 PEEK_PROMO_MAX_SHOW_COUNT, |
261 PEEK_PROMO_DEFAULT_MAX_SHOW_COUNT); | 266 PEEK_PROMO_DEFAULT_MAX_SHOW_COUNT); |
262 } | 267 } |
263 return sPeekPromoMaxCount.intValue(); | 268 return sPeekPromoMaxCount.intValue(); |
264 } | 269 } |
265 | 270 |
| 271 /** |
| 272 * @return Whether showing "quick answers" in the Bar is enabled. |
| 273 */ |
| 274 static boolean isQuickAnswersEnabled() { |
| 275 if (sIsQuickAnswersEnabled == null) { |
| 276 sIsQuickAnswersEnabled = getBooleanParam(QUICK_ANSWERS_ENABLED); |
| 277 } |
| 278 return sIsQuickAnswersEnabled.booleanValue(); |
| 279 } |
| 280 |
266 // -------------------------------------------------------------------------
------------------- | 281 // -------------------------------------------------------------------------
------------------- |
267 // Helpers. | 282 // Helpers. |
268 // -------------------------------------------------------------------------
------------------- | 283 // -------------------------------------------------------------------------
------------------- |
269 | 284 |
270 /** | 285 /** |
271 * Gets a boolean Finch parameter, assuming the <paramName>="true" format.
Also checks for a | 286 * Gets a boolean Finch parameter, assuming the <paramName>="true" format.
Also checks for a |
272 * command-line switch with the same name, for easy local testing. | 287 * command-line switch with the same name, for easy local testing. |
273 * @param paramName The name of the Finch parameter (or command-line switch)
to get a value for. | 288 * @param paramName The name of the Finch parameter (or command-line switch)
to get a value for. |
274 * @return Whether the Finch param is defined with a value "true", if there'
s a command-line | 289 * @return Whether the Finch param is defined with a value "true", if there'
s a command-line |
275 * flag present with any value. | 290 * flag present with any value. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 * @param paramName The name of the Finch parameter (or command-line switch)
to get a value for. | 325 * @param paramName The name of the Finch parameter (or command-line switch)
to get a value for. |
311 * @return The command-line value, if present, or the finch parameter value. | 326 * @return The command-line value, if present, or the finch parameter value. |
312 */ | 327 */ |
313 private static String getStringParam(String paramName) { | 328 private static String getStringParam(String paramName) { |
314 if (CommandLine.getInstance().hasSwitch(paramName)) { | 329 if (CommandLine.getInstance().hasSwitch(paramName)) { |
315 return CommandLine.getInstance().getSwitchValue(paramName); | 330 return CommandLine.getInstance().getSwitchValue(paramName); |
316 } | 331 } |
317 return VariationsAssociatedData.getVariationParamValue(FIELD_TRIAL_NAME,
paramName); | 332 return VariationsAssociatedData.getVariationParamValue(FIELD_TRIAL_NAME,
paramName); |
318 } | 333 } |
319 } | 334 } |
OLD | NEW |