Commit 6d84cfe2 authored by Scott Violet's avatar Scott Violet Committed by Chromium LUCI CQ

Revert "cct: adds extra that controls whether client data header is added"

This reverts commit ff9183ee.

Reason for revert: for various reasons this is no longer necessary. Reverting.

Original change's description:
> cct: adds extra that controls whether client data header is added
>
> Prior to this the header was always added. After this, the header
> is only added if an extra is supplied. This only changes whether
> setClientDataHeaderForNewTab() is called and does not alter
> the implementation of that function.
>
> BUG=1163158
> TEST=covered by tests
>
> Change-Id: Ic5d222d719a81c6da3d4e0c7866e18cbcee6e817
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611340
> Commit-Queue: Scott Violet <sky@chromium.org>
> Reviewed-by: Ted Choc <tedchoc@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#840370}

TBR=sky@chromium.org,tedchoc@chromium.org,chromium-scoped@luci-project-accounts.iam.gserviceaccount.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1163158
Change-Id: I97429cd16f7a2830d612f787a52b3270f05ccaa8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2615302Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841169}
parent 8565b13e
......@@ -539,13 +539,4 @@ public abstract class BrowserServicesIntentDataProvider {
public boolean shouldHideIncognitoIconOnToolbarInCct() {
return false;
}
/**
* @return Whether the cct-client-data header should be added. Note that a return value of true
* does not necessarily mean the header will be added. There are aditional checks in
* {@link setClientDataHeaderForNewTab()}. This is applicable only to cct.
*/
public boolean shouldAddCctClientDataHeader() {
return false;
}
}
......@@ -99,13 +99,6 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
public static final String BUNDLE_EXIT_ANIMATION_RESOURCE =
ANIMATION_BUNDLE_PREFIX + "animExitRes";
/**
* See {@link BrowserServicesIntentDataProvider#shouldAddCctClientDataHeader} for details on
* this.
*/
public static final String EXTRA_ADD_CCT_CLIENT_DATA_HEADER =
"org.chromium.chrome.browser.customtabs.ADD_CCT_CLIENT_DATA_HEADER";
/**
* Extra that indicates whether or not the Custom Tab is being launched by an Intent fired by
* Chrome itself.
......@@ -915,9 +908,4 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
return !IntentUtils.safeGetBooleanExtra(
mIntent, EXTRA_HIDE_OPEN_IN_CHROME_MENU_ITEM, false);
}
@Override
public boolean shouldAddCctClientDataHeader() {
return IntentUtils.safeGetBooleanExtra(mIntent, EXTRA_ADD_CCT_CLIENT_DATA_HEADER, false);
}
}
......@@ -405,7 +405,7 @@ public class CustomTabActivityTabController implements InflationObserver {
mConnection.getClientPackageNameForSession(mSession)));
// clang-format on
if (!tab.isIncognito() && mIntentDataProvider.shouldAddCctClientDataHeader()) {
if (!tab.isIncognito()) {
mConnection.setClientDataHeaderForNewTab(mSession, webContents);
}
......
......@@ -187,8 +187,9 @@ public class CustomTabActivityTabControllerUnitTest {
assertNull(env.tabProvider.getTab());
}
// Some websites replace the tab with a new one.
@Test
public void doesNotSetCctClientDataHeaderWhenIncognito() {
public void doesNotSetHeaderWhenIncognito() {
doAnswer((mock) -> {
fail("setClientDataHeaderForNewTab() should not be called for incognito tabs");
return null;
......@@ -196,38 +197,9 @@ public class CustomTabActivityTabControllerUnitTest {
.when(env.connection)
.setClientDataHeaderForNewTab(any(), any());
env.isIncognito = true;
when(env.intentDataProvider.shouldAddCctClientDataHeader()).thenReturn(true);
mTabController.onPreInflationStartup();
mTabController.finishNativeInitialization();
Tab tab = env.prepareTab();
assertTrue(tab.isIncognito());
}
@Test
public void doesNotSetCctClientDataHeaderWithoutExtra() {
doAnswer((mock) -> {
fail("setClientDataHeaderForNewTab() should not be called without extra");
return null;
})
.when(env.connection)
.setClientDataHeaderForNewTab(any(), any());
mTabController.onPreInflationStartup();
mTabController.finishNativeInitialization();
}
@Test
public void setsCctClientDataHeaderWithExtra() {
final boolean[] wasSetClientDataHeaderForNewTabCalled = new boolean[1];
doAnswer((mock) -> {
wasSetClientDataHeaderForNewTabCalled[0] = true;
return null;
})
.when(env.connection)
.setClientDataHeaderForNewTab(any(), any());
when(env.intentDataProvider.shouldAddCctClientDataHeader()).thenReturn(true);
mTabController.onPreInflationStartup();
mTabController.finishNativeInitialization();
Tab tab = env.prepareTab();
assertTrue(wasSetClientDataHeaderForNewTabCalled[0]);
}
}
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