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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java

Issue 2080173006: customtabs: Allowing prerendering on cellular also disables throttling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a test. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java
index 01e9ff142c75b0063ed8f3d0f104853e01c11cd4..1c03b3acfaee2196c6a276ccc9a23f62bc53177d 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java
@@ -508,6 +508,11 @@ public class CustomTabsConnection {
return mClientManager.getIgnoreFragmentsForSession(session);
}
+ @VisibleForTesting
+ void setShouldPrerenderOnCellularForSession(CustomTabsSessionToken session, boolean value) {
+ mClientManager.setPrerenderCellularForSession(session, value);
+ }
+
/**
* Extracts the creator package name from the intent.
* @param intent The intent to get the package name from.
@@ -699,7 +704,8 @@ public class CustomTabsConnection {
// Last one wins and cancels the previous prerender.
cancelPrerender(null);
if (TextUtils.isEmpty(url)) return false;
- if (!mClientManager.isPrerenderingAllowed(uid)) return false;
+ boolean throttle = !shouldPrerenderOnCellularForSession(session);
+ if (throttle && !mClientManager.isPrerenderingAllowed(uid)) return false;
// A prerender will be requested. Time to destroy the spare WebContents.
destroySpareWebContents();
@@ -721,7 +727,7 @@ public class CustomTabsConnection {
Profile.getLastUsedProfile(), url, referrer, contentSize.x, contentSize.y,
shouldPrerenderOnCellularForSession(session));
if (webContents == null) return false;
- mClientManager.registerPrerenderRequest(uid, url);
+ if (throttle) mClientManager.registerPrerenderRequest(uid, url);
mPrerender = new PrerenderedUrlParams(session, webContents, url, referrer, extras);
return true;
}
@@ -759,4 +765,9 @@ public class CustomTabsConnection {
void resetThrottling(Context context, int uid) {
mClientManager.resetThrottling(uid);
}
+
+ @VisibleForTesting
+ void ban(Context context, int uid) {
+ mClientManager.ban(uid);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698