Commit d9b19c66 authored by mattcary's avatar mattcary Committed by Commit bot

Finch kill switch feature for background tab.

Adds the CCTBackgroundTab (ChromeFeatureList::CCT_BACKGROUND_TAB) feature
which is enabled by default.

BUG=708173

Review-Url: https://codereview.chromium.org/2837873002
Cr-Commit-Position: refs/heads/master@{#467281}
parent 136356dc
......@@ -146,6 +146,7 @@ public abstract class ChromeFeatureList {
public static final String ANDROID_PAY_INTEGRATION_V2 = "AndroidPayIntegrationV2";
public static final String ANDROID_PAYMENT_APPS = "AndroidPaymentApps";
public static final String AUTOFILL_SCAN_CARDHOLDER_NAME = "AutofillScanCardholderName";
public static final String CCT_BACKGROUND_TAB = "CCTBackgroundTab";
public static final String CCT_EXTERNAL_LINK_HANDLING = "CCTExternalLinkHandling";
public static final String CCT_POST_MESSAGE_API = "CCTPostMessageAPI";
public static final String CHROME_HOME = "ChromeHome";
......
......@@ -987,6 +987,10 @@ public class CustomTabsConnection {
WarmupManager warmupManager = WarmupManager.getInstance();
Profile profile = Profile.getLastUsedProfile();
boolean preconnect = true, createSpareWebContents = true;
if (speculationMode == SpeculationParams.HIDDEN_TAB
&& !ChromeFeatureList.isEnabled(ChromeFeatureList.CCT_BACKGROUND_TAB)) {
speculationMode = SpeculationParams.PRERENDER;
}
switch (speculationMode) {
case SpeculationParams.PREFETCH:
boolean didPrefetch = new ResourcePrefetchPredictor(profile).startPrefetching(url);
......
......@@ -57,6 +57,7 @@ import org.chromium.base.test.util.Restriction;
import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.IntentHandler;
......@@ -1810,14 +1811,33 @@ public class CustomTabActivityTest extends CustomTabActivityTestBase {
testSpeculateCorrectUrl(CustomTabsConnection.SpeculationParams.HIDDEN_TAB);
}
/**
* Test that a hidden tab speculation is executed as a prerender if the |CCT_BACKGROUND_TAB|
* feature is disabled.
**/
@SmallTest
@Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
@RetryOnFailure
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
"disable-features=" + ChromeFeatureList.CCT_BACKGROUND_TAB})
public void testHiddenTabDisabled() throws Exception {
testSpeculateCorrectUrl(CustomTabsConnection.SpeculationParams.HIDDEN_TAB,
CustomTabsConnection.SpeculationParams.PRERENDER);
}
private void testSpeculateCorrectUrl(int speculationMode) throws Exception {
testSpeculateCorrectUrl(speculationMode, speculationMode);
}
private void testSpeculateCorrectUrl(int requestedSpeculationMode, int usedSpeculationMode)
throws Exception {
Context context = getInstrumentation().getTargetContext().getApplicationContext();
final CustomTabsConnection connection = warmUpAndWait();
CustomTabsSessionToken token = CustomTabsSessionToken.createDummySessionTokenForTesting();
connection.newSession(token);
connection.setSpeculationModeForSession(token, speculationMode);
connection.setSpeculationModeForSession(token, requestedSpeculationMode);
assertTrue(connection.mayLaunchUrl(token, Uri.parse(mTestPage), null, null));
ensureCompletedSpeculationForUrl(connection, mTestPage, speculationMode);
ensureCompletedSpeculationForUrl(connection, mTestPage, usedSpeculationMode);
try {
startCustomTabActivityWithIntent(CustomTabsTestUtils.createMinimalCustomTabIntent(
......
......@@ -48,6 +48,7 @@ const base::Feature* kFeaturesExposedToJava[] = {
&kAndroidPayIntegrationV1,
&kAndroidPayIntegrationV2,
&kAndroidPaymentApps,
&kCCTBackgroundTab,
&kCCTExternalLinkHandling,
&kCCTPostMessageAPI,
&kChromeHomeFeature,
......@@ -111,6 +112,9 @@ const base::Feature kAndroidPayIntegrationV2{"AndroidPayIntegrationV2",
const base::Feature kAndroidPaymentApps{"AndroidPaymentApps",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kCCTBackgroundTab{"CCTBackgroundTab",
base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kCCTExternalLinkHandling{"CCTExternalLinkHandling",
base::FEATURE_ENABLED_BY_DEFAULT};
......
......@@ -16,6 +16,7 @@ namespace android {
extern const base::Feature kAndroidPayIntegrationV1;
extern const base::Feature kAndroidPayIntegrationV2;
extern const base::Feature kAndroidPaymentApps;
extern const base::Feature kCCTBackgroundTab;
extern const base::Feature kCCTExternalLinkHandling;
extern const base::Feature kCCTPostMessageAPI;
extern const base::Feature kChromeHomeFeature;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment