| 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 30 matching lines...) Expand all Loading... |
| 41 static final String DISABLE_TRANSLATION = "disable_translation"; | 41 static final String DISABLE_TRANSLATION = "disable_translation"; |
| 42 // Enables usage of English as the target language even when it's the primar
y UI language. | 42 // Enables usage of English as the target language even when it's the primar
y UI language. |
| 43 @VisibleForTesting | 43 @VisibleForTesting |
| 44 static final String ENABLE_ENGLISH_TARGET_TRANSLATION = | 44 static final String ENABLE_ENGLISH_TARGET_TRANSLATION = |
| 45 "enable_english_target_translation"; | 45 "enable_english_target_translation"; |
| 46 | 46 |
| 47 // TODO(donnd): remove all supporting code once short-lived data collection
is done. | 47 // TODO(donnd): remove all supporting code once short-lived data collection
is done. |
| 48 private static final String SCREEN_TOP_SUPPRESSION_DPS = "screen_top_suppres
sion_dps"; | 48 private static final String SCREEN_TOP_SUPPRESSION_DPS = "screen_top_suppres
sion_dps"; |
| 49 private static final String ENABLE_BAR_OVERLAP_COLLECTION = "enable_bar_over
lap_collection"; | 49 private static final String ENABLE_BAR_OVERLAP_COLLECTION = "enable_bar_over
lap_collection"; |
| 50 private static final String BAR_OVERLAP_SUPPRESSION_ENABLED = "enable_bar_ov
erlap_suppression"; | 50 private static final String BAR_OVERLAP_SUPPRESSION_ENABLED = "enable_bar_ov
erlap_suppression"; |
| 51 private static final String WORD_EDGE_SUPPRESSION_ENABLED = "enable_word_edg
e_suppression"; |
| 52 private static final String SHORT_WORD_SUPPRESSION_ENABLED = "enable_short_w
ord_suppression"; |
| 53 private static final String WORD_NOT_LONG_ENOUGH_SUPPRESSION_ENABLED = |
| 54 "enable_word_not_long_enough_suppression"; |
| 51 | 55 |
| 52 private static final String MINIMUM_SELECTION_LENGTH = "minimum_selection_le
ngth"; | 56 private static final String MINIMUM_SELECTION_LENGTH = "minimum_selection_le
ngth"; |
| 53 | 57 |
| 54 // Safety switch for disabling online-detection. Also used to disable detec
tion when running | 58 // Safety switch for disabling online-detection. Also used to disable detec
tion when running |
| 55 // tests. | 59 // tests. |
| 56 @VisibleForTesting | 60 @VisibleForTesting |
| 57 static final String ONLINE_DETECTION_DISABLED = "disable_online_detection"; | 61 static final String ONLINE_DETECTION_DISABLED = "disable_online_detection"; |
| 58 | 62 |
| 59 private static final String DISABLE_AMP_AS_SEPARATE_TAB = "disable_amp_as_se
parate_tab"; | 63 private static final String DISABLE_AMP_AS_SEPARATE_TAB = "disable_amp_as_se
parate_tab"; |
| 60 | 64 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 71 private static Boolean sDisableSearchTermResolution; | 75 private static Boolean sDisableSearchTermResolution; |
| 72 private static Boolean sIsMandatoryPromoEnabled; | 76 private static Boolean sIsMandatoryPromoEnabled; |
| 73 private static Integer sMandatoryPromoLimit; | 77 private static Integer sMandatoryPromoLimit; |
| 74 private static Boolean sIsPeekPromoEnabled; | 78 private static Boolean sIsPeekPromoEnabled; |
| 75 private static Integer sPeekPromoMaxCount; | 79 private static Integer sPeekPromoMaxCount; |
| 76 private static Boolean sIsTranslationDisabled; | 80 private static Boolean sIsTranslationDisabled; |
| 77 private static Boolean sIsEnglishTargetTranslationEnabled; | 81 private static Boolean sIsEnglishTargetTranslationEnabled; |
| 78 private static Integer sScreenTopSuppressionDps; | 82 private static Integer sScreenTopSuppressionDps; |
| 79 private static Boolean sIsBarOverlapCollectionEnabled; | 83 private static Boolean sIsBarOverlapCollectionEnabled; |
| 80 private static Boolean sIsBarOverlapSuppressionEnabled; | 84 private static Boolean sIsBarOverlapSuppressionEnabled; |
| 85 private static Boolean sIsWordEdgeSuppressionEnabled; |
| 86 private static Boolean sIsShortWordSuppressionEnabled; |
| 87 private static Boolean sIsWordNotLongEnoughSuppressionEnabled; |
| 81 private static Integer sMinimumSelectionLength; | 88 private static Integer sMinimumSelectionLength; |
| 82 private static Boolean sIsOnlineDetectionDisabled; | 89 private static Boolean sIsOnlineDetectionDisabled; |
| 83 private static Boolean sIsAmpAsSeparateTabDisabled; | 90 private static Boolean sIsAmpAsSeparateTabDisabled; |
| 84 private static Boolean sContextualSearchSingleActionsEnabled; | 91 private static Boolean sContextualSearchSingleActionsEnabled; |
| 85 private static Boolean sIsSendHomeCountryDisabled; | 92 private static Boolean sIsSendHomeCountryDisabled; |
| 86 private static Boolean sIsPageContentNotificationDisabled; | 93 private static Boolean sIsPageContentNotificationDisabled; |
| 87 private static Boolean sContextualSearchUrlActionsEnabled; | 94 private static Boolean sContextualSearchUrlActionsEnabled; |
| 88 private static Boolean sIsRankerLoggingEnabled; | 95 private static Boolean sIsRankerLoggingEnabled; |
| 89 | 96 |
| 90 /** | 97 /** |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 * Bar peeking location. | 254 * Bar peeking location. |
| 248 */ | 255 */ |
| 249 static boolean isBarOverlapSuppressionEnabled() { | 256 static boolean isBarOverlapSuppressionEnabled() { |
| 250 if (sIsBarOverlapSuppressionEnabled == null) { | 257 if (sIsBarOverlapSuppressionEnabled == null) { |
| 251 sIsBarOverlapSuppressionEnabled = getBooleanParam(BAR_OVERLAP_SUPPRE
SSION_ENABLED); | 258 sIsBarOverlapSuppressionEnabled = getBooleanParam(BAR_OVERLAP_SUPPRE
SSION_ENABLED); |
| 252 } | 259 } |
| 253 return sIsBarOverlapSuppressionEnabled.booleanValue(); | 260 return sIsBarOverlapSuppressionEnabled.booleanValue(); |
| 254 } | 261 } |
| 255 | 262 |
| 256 /** | 263 /** |
| 264 * @return Whether triggering is suppressed by a tap that's near the edge of
a word. |
| 265 */ |
| 266 static boolean isWordEdgeSuppressionEnabled() { |
| 267 if (sIsWordEdgeSuppressionEnabled == null) { |
| 268 sIsWordEdgeSuppressionEnabled = getBooleanParam(WORD_EDGE_SUPPRESSIO
N_ENABLED); |
| 269 } |
| 270 return sIsWordEdgeSuppressionEnabled.booleanValue(); |
| 271 } |
| 272 |
| 273 /** |
| 274 * @return Whether triggering is suppressed by a tap that's in a short word. |
| 275 */ |
| 276 static boolean isShortWordSuppressionEnabled() { |
| 277 if (sIsShortWordSuppressionEnabled == null) { |
| 278 sIsShortWordSuppressionEnabled = getBooleanParam(SHORT_WORD_SUPPRESS
ION_ENABLED); |
| 279 } |
| 280 return sIsShortWordSuppressionEnabled.booleanValue(); |
| 281 } |
| 282 |
| 283 /** |
| 284 * @return Whether triggering is suppressed by a tap that's in a word that's
considered not |
| 285 * long enough. |
| 286 */ |
| 287 static boolean isWordNotLongEnoughSuppressionEnabled() { |
| 288 if (sIsWordNotLongEnoughSuppressionEnabled == null) { |
| 289 sIsWordNotLongEnoughSuppressionEnabled = |
| 290 getBooleanParam(WORD_NOT_LONG_ENOUGH_SUPPRESSION_ENABLED); |
| 291 } |
| 292 return sIsWordNotLongEnoughSuppressionEnabled.booleanValue(); |
| 293 } |
| 294 |
| 295 /** |
| 257 * @return The minimum valid selection length. | 296 * @return The minimum valid selection length. |
| 258 */ | 297 */ |
| 259 static int getMinimumSelectionLength() { | 298 static int getMinimumSelectionLength() { |
| 260 if (sMinimumSelectionLength == null) { | 299 if (sMinimumSelectionLength == null) { |
| 261 sMinimumSelectionLength = getIntParamValueOrDefault(MINIMUM_SELECTIO
N_LENGTH, 0); | 300 sMinimumSelectionLength = getIntParamValueOrDefault(MINIMUM_SELECTIO
N_LENGTH, 0); |
| 262 } | 301 } |
| 263 return sMinimumSelectionLength.intValue(); | 302 return sMinimumSelectionLength.intValue(); |
| 264 } | 303 } |
| 265 | 304 |
| 266 /** | 305 /** |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 try { | 418 try { |
| 380 return Integer.parseInt(value); | 419 return Integer.parseInt(value); |
| 381 } catch (NumberFormatException e) { | 420 } catch (NumberFormatException e) { |
| 382 return defaultValue; | 421 return defaultValue; |
| 383 } | 422 } |
| 384 } | 423 } |
| 385 | 424 |
| 386 return defaultValue; | 425 return defaultValue; |
| 387 } | 426 } |
| 388 } | 427 } |
| OLD | NEW |