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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 private static final String MINIMUM_SELECTION_LENGTH = "minimum_selection_le
ngth"; | 52 private static final String MINIMUM_SELECTION_LENGTH = "minimum_selection_le
ngth"; |
53 | 53 |
54 // Safety switch for disabling online-detection. Also used to disable detec
tion when running | 54 // Safety switch for disabling online-detection. Also used to disable detec
tion when running |
55 // tests. | 55 // tests. |
56 @VisibleForTesting | 56 @VisibleForTesting |
57 static final String ONLINE_DETECTION_DISABLED = "disable_online_detection"; | 57 static final String ONLINE_DETECTION_DISABLED = "disable_online_detection"; |
58 | 58 |
59 private static final String DISABLE_AMP_AS_SEPARATE_TAB = "disable_amp_as_se
parate_tab"; | 59 private static final String DISABLE_AMP_AS_SEPARATE_TAB = "disable_amp_as_se
parate_tab"; |
60 | 60 |
| 61 // Machine Learning |
| 62 private static final String ENABLE_RANKER_LOGGING = "enable_ranker_logging"; |
| 63 |
61 // Privacy-related flags | 64 // Privacy-related flags |
62 private static final String DISABLE_SEND_HOME_COUNTRY = "disable_send_home_c
ountry"; | 65 private static final String DISABLE_SEND_HOME_COUNTRY = "disable_send_home_c
ountry"; |
63 private static final String DISABLE_PAGE_CONTENT_NOTIFICATION = | 66 private static final String DISABLE_PAGE_CONTENT_NOTIFICATION = |
64 "disable_page_content_notification"; | 67 "disable_page_content_notification"; |
65 | 68 |
66 // Cached values to avoid repeated and redundant JNI operations. | 69 // Cached values to avoid repeated and redundant JNI operations. |
67 private static Boolean sEnabled; | 70 private static Boolean sEnabled; |
68 private static Boolean sDisableSearchTermResolution; | 71 private static Boolean sDisableSearchTermResolution; |
69 private static Boolean sIsMandatoryPromoEnabled; | 72 private static Boolean sIsMandatoryPromoEnabled; |
70 private static Integer sMandatoryPromoLimit; | 73 private static Integer sMandatoryPromoLimit; |
71 private static Boolean sIsPeekPromoEnabled; | 74 private static Boolean sIsPeekPromoEnabled; |
72 private static Integer sPeekPromoMaxCount; | 75 private static Integer sPeekPromoMaxCount; |
73 private static Boolean sIsTranslationDisabled; | 76 private static Boolean sIsTranslationDisabled; |
74 private static Boolean sIsEnglishTargetTranslationEnabled; | 77 private static Boolean sIsEnglishTargetTranslationEnabled; |
75 private static Integer sScreenTopSuppressionDps; | 78 private static Integer sScreenTopSuppressionDps; |
76 private static Boolean sIsBarOverlapCollectionEnabled; | 79 private static Boolean sIsBarOverlapCollectionEnabled; |
77 private static Boolean sIsBarOverlapSuppressionEnabled; | 80 private static Boolean sIsBarOverlapSuppressionEnabled; |
78 private static Integer sMinimumSelectionLength; | 81 private static Integer sMinimumSelectionLength; |
79 private static Boolean sIsOnlineDetectionDisabled; | 82 private static Boolean sIsOnlineDetectionDisabled; |
80 private static Boolean sIsAmpAsSeparateTabDisabled; | 83 private static Boolean sIsAmpAsSeparateTabDisabled; |
81 private static Boolean sContextualSearchSingleActionsEnabled; | 84 private static Boolean sContextualSearchSingleActionsEnabled; |
82 private static Boolean sIsSendHomeCountryDisabled; | 85 private static Boolean sIsSendHomeCountryDisabled; |
83 private static Boolean sIsPageContentNotificationDisabled; | 86 private static Boolean sIsPageContentNotificationDisabled; |
84 private static Boolean sContextualSearchUrlActionsEnabled; | 87 private static Boolean sContextualSearchUrlActionsEnabled; |
| 88 private static Boolean sIsRankerLoggingEnabled; |
85 | 89 |
86 /** | 90 /** |
87 * Don't instantiate. | 91 * Don't instantiate. |
88 */ | 92 */ |
89 private ContextualSearchFieldTrial() {} | 93 private ContextualSearchFieldTrial() {} |
90 | 94 |
91 /** | 95 /** |
92 * Checks the current Variations parameters associated with the active group
as well as the | 96 * Checks the current Variations parameters associated with the active group
as well as the |
93 * Chrome preference to determine if the service is enabled. | 97 * Chrome preference to determine if the service is enabled. |
94 * @return Whether Contextual Search is enabled or not. | 98 * @return Whether Contextual Search is enabled or not. |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 * @return Whether sending the page content notifications to observers (e.g.
icing for | 298 * @return Whether sending the page content notifications to observers (e.g.
icing for |
295 * conversational search) is disabled. | 299 * conversational search) is disabled. |
296 */ | 300 */ |
297 static boolean isPageContentNotificationDisabled() { | 301 static boolean isPageContentNotificationDisabled() { |
298 if (sIsPageContentNotificationDisabled == null) { | 302 if (sIsPageContentNotificationDisabled == null) { |
299 sIsPageContentNotificationDisabled = getBooleanParam(DISABLE_PAGE_CO
NTENT_NOTIFICATION); | 303 sIsPageContentNotificationDisabled = getBooleanParam(DISABLE_PAGE_CO
NTENT_NOTIFICATION); |
300 } | 304 } |
301 return sIsPageContentNotificationDisabled.booleanValue(); | 305 return sIsPageContentNotificationDisabled.booleanValue(); |
302 } | 306 } |
303 | 307 |
| 308 /** |
| 309 * @return Whether or not logging to Ranker is enabled. |
| 310 */ |
| 311 static boolean isRankerLoggingEnabled() { |
| 312 if (sIsRankerLoggingEnabled == null) { |
| 313 sIsRankerLoggingEnabled = getBooleanParam(ENABLE_RANKER_LOGGING); |
| 314 } |
| 315 |
| 316 return sIsRankerLoggingEnabled; |
| 317 } |
| 318 |
304 // --------------- | 319 // --------------- |
305 // Features. | 320 // Features. |
306 // --------------- | 321 // --------------- |
307 | 322 |
308 /** | 323 /** |
309 * @return Whether or not single actions based on Contextual Cards is enable
d. | 324 * @return Whether or not single actions based on Contextual Cards is enable
d. |
310 */ | 325 */ |
311 static boolean isContextualSearchSingleActionsEnabled() { | 326 static boolean isContextualSearchSingleActionsEnabled() { |
312 if (sContextualSearchSingleActionsEnabled == null) { | 327 if (sContextualSearchSingleActionsEnabled == null) { |
313 sContextualSearchSingleActionsEnabled = | 328 sContextualSearchSingleActionsEnabled = |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 try { | 379 try { |
365 return Integer.parseInt(value); | 380 return Integer.parseInt(value); |
366 } catch (NumberFormatException e) { | 381 } catch (NumberFormatException e) { |
367 return defaultValue; | 382 return defaultValue; |
368 } | 383 } |
369 } | 384 } |
370 | 385 |
371 return defaultValue; | 386 return defaultValue; |
372 } | 387 } |
373 } | 388 } |
OLD | NEW |