| 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.customtabs; | 5 package org.chromium.chrome.browser.customtabs; |
| 6 | 6 |
| 7 import android.app.ActivityManager; | 7 import android.app.ActivityManager; |
| 8 import android.app.Application; | 8 import android.app.Application; |
| 9 import android.app.PendingIntent; | 9 import android.app.PendingIntent; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| (...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 @VisibleForTesting | 945 @VisibleForTesting |
| 946 void cleanUpSession(final CustomTabsSessionToken session) { | 946 void cleanUpSession(final CustomTabsSessionToken session) { |
| 947 ThreadUtils.runOnUiThread(new Runnable() { | 947 ThreadUtils.runOnUiThread(new Runnable() { |
| 948 @Override | 948 @Override |
| 949 public void run() { | 949 public void run() { |
| 950 mClientManager.cleanupSession(session); | 950 mClientManager.cleanupSession(session); |
| 951 } | 951 } |
| 952 }); | 952 }); |
| 953 } | 953 } |
| 954 | 954 |
| 955 private boolean maySpeculate(CustomTabsSessionToken session) { | 955 @VisibleForTesting |
| 956 boolean maySpeculate(CustomTabsSessionToken session) { |
| 956 if (!DeviceClassManager.enablePrerendering()) return false; | 957 if (!DeviceClassManager.enablePrerendering()) return false; |
| 958 PrefServiceBridge prefs = PrefServiceBridge.getInstance(); |
| 959 if (prefs.isBlockThirdPartyCookiesEnabled()) return false; |
| 957 // TODO(yusufo): The check for prerender in PrivacyManager now checks fo
r the network | 960 // TODO(yusufo): The check for prerender in PrivacyManager now checks fo
r the network |
| 958 // connection type as well, we should either change that or add another
check for custom | 961 // connection type as well, we should either change that or add another
check for custom |
| 959 // tabs. Then PrivacyManager should be used to make the below check. | 962 // tabs. Then PrivacyManager should be used to make the below check. |
| 960 if (!PrefServiceBridge.getInstance().getNetworkPredictionEnabled()) retu
rn false; | 963 if (!prefs.getNetworkPredictionEnabled()) return false; |
| 961 if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled
()) return false; | 964 if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled
()) return false; |
| 962 ConnectivityManager cm = | 965 ConnectivityManager cm = |
| 963 (ConnectivityManager) mApplication.getApplicationContext().getSy
stemService( | 966 (ConnectivityManager) mApplication.getApplicationContext().getSy
stemService( |
| 964 Context.CONNECTIVITY_SERVICE); | 967 Context.CONNECTIVITY_SERVICE); |
| 965 return !cm.isActiveNetworkMetered() || shouldPrerenderOnCellularForSessi
on(session); | 968 return !cm.isActiveNetworkMetered() || shouldPrerenderOnCellularForSessi
on(session); |
| 966 } | 969 } |
| 967 | 970 |
| 968 /** Cancels the speculation for a given session, or any session if null. */ | 971 /** Cancels the speculation for a given session, or any session if null. */ |
| 969 void cancelSpeculation(CustomTabsSessionToken session) { | 972 void cancelSpeculation(CustomTabsSessionToken session) { |
| 970 ThreadUtils.assertOnUiThread(); | 973 ThreadUtils.assertOnUiThread(); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 */ | 1139 */ |
| 1137 String getReferrer(CustomTabsSessionToken session, Intent intent) { | 1140 String getReferrer(CustomTabsSessionToken session, Intent intent) { |
| 1138 String referrer = IntentHandler.getReferrerUrlIncludingExtraHeaders(inte
nt); | 1141 String referrer = IntentHandler.getReferrerUrlIncludingExtraHeaders(inte
nt); |
| 1139 if (referrer == null && getReferrerForSession(session) != null) { | 1142 if (referrer == null && getReferrerForSession(session) != null) { |
| 1140 referrer = getReferrerForSession(session).getUrl(); | 1143 referrer = getReferrerForSession(session).getUrl(); |
| 1141 } | 1144 } |
| 1142 if (referrer == null) referrer = ""; | 1145 if (referrer == null) referrer = ""; |
| 1143 return referrer; | 1146 return referrer; |
| 1144 } | 1147 } |
| 1145 } | 1148 } |
| OLD | NEW |