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

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

Issue 1712943002: [Android] Simplify "network predictions" preference to a boolean value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated TODO in prediction_options.h Created 4 years, 10 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 unified diff | Download patch
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.VisibleForTesting; 10 import org.chromium.base.VisibleForTesting;
11 import org.chromium.chrome.browser.ChromeVersionInfo; 11 import org.chromium.chrome.browser.ChromeVersionInfo;
12 import org.chromium.chrome.browser.contextualsearch.ContextualSearchSelectionCon troller.SelectionType; 12 import org.chromium.chrome.browser.contextualsearch.ContextualSearchSelectionCon troller.SelectionType;
13 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; 13 import org.chromium.chrome.browser.preferences.ChromePreferenceManager;
14 import org.chromium.chrome.browser.preferences.NetworkPredictionOptions;
15 import org.chromium.chrome.browser.preferences.PrefServiceBridge; 14 import org.chromium.chrome.browser.preferences.PrefServiceBridge;
16 import org.chromium.content.browser.ContentViewCore; 15 import org.chromium.content.browser.ContentViewCore;
17 16
18 import java.net.URL; 17 import java.net.URL;
19 import java.util.List; 18 import java.util.List;
20 import java.util.Locale; 19 import java.util.Locale;
21 import java.util.regex.Pattern; 20 import java.util.regex.Pattern;
22 21
23 import javax.annotation.Nullable; 22 import javax.annotation.Nullable;
24 23
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 boolean isTapSupported() { 91 boolean isTapSupported() {
93 if (!isUserUndecided()) return true; 92 if (!isUserUndecided()) return true;
94 return getPromoTapsRemaining() != 0; 93 return getPromoTapsRemaining() != 0;
95 } 94 }
96 95
97 /** 96 /**
98 * @return whether or not the Contextual Search Result should be preloaded b efore the user 97 * @return whether or not the Contextual Search Result should be preloaded b efore the user
99 * explicitly interacts with the feature. 98 * explicitly interacts with the feature.
100 */ 99 */
101 boolean shouldPrefetchSearchResult(boolean isTapTriggered) { 100 boolean shouldPrefetchSearchResult(boolean isTapTriggered) {
102 if (PrefServiceBridge.getInstance().getNetworkPredictionOptions() 101 if (!PrefServiceBridge.getInstance().getNetworkPredictionEnabled()) {
103 == NetworkPredictionOptions.NETWORK_PREDICTION_NEVER) {
104 return false; 102 return false;
105 } 103 }
106 104
107 // We may not be prefetching due to the resolve/prefetch limit. 105 // We may not be prefetching due to the resolve/prefetch limit.
108 if (isTapBeyondTheLimit()) return false; 106 if (isTapBeyondTheLimit()) return false;
109 107
110 // We never preload on long-press so users can cut & paste without hitti ng the servers. 108 // We never preload on long-press so users can cut & paste without hitti ng the servers.
111 return isTapTriggered; 109 return isTapTriggered;
112 } 110 }
113 111
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 } 531 }
534 532
535 private int getTapLimitForUndecided() { 533 private int getTapLimitForUndecided() {
536 if (mTapLimitForUndecided != null) { 534 if (mTapLimitForUndecided != null) {
537 return mTapLimitForUndecided.intValue(); 535 return mTapLimitForUndecided.intValue();
538 } else { 536 } else {
539 return TAP_RESOLVE_PREFETCH_LIMIT_FOR_UNDECIDED; 537 return TAP_RESOLVE_PREFETCH_LIMIT_FOR_UNDECIDED;
540 } 538 }
541 } 539 }
542 } 540 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698