Commit 6ca2f09f authored by Ella Ge's avatar Ella Ge Committed by Commit Bot

Revert "🛃 Move Client Data header out of ClientManager."

This reverts commit fd191139.

Reason for revert: [Sheriff] compile failure https://ci.chromium.org/p/chrome/builders/ci/android_arm64-builder-perf/157215

Original change's description:
> 🛃 Move Client Data header out of ClientManager.
> 
> Bug: 1040143
> Change-Id: Ife79cfe1f0c5963bf4c6c7bee0c810e936b0a9a0
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2062208
> Commit-Queue: Peter Conn <peconn@chromium.org>
> Reviewed-by: Michael van Ouwerkerk <mvanouwerkerk@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#743100}

TBR=mvanouwerkerk@chromium.org,peconn@chromium.org

Change-Id: I372b18ffaf679ba933129ce5f3ac65bf0ee8b661
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1040143
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2067717Reviewed-by: default avatarElla Ge <eirage@chromium.org>
Commit-Queue: Ella Ge <eirage@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743280}
parent a11361ad
...@@ -188,6 +188,7 @@ class ClientManager { ...@@ -188,6 +188,7 @@ class ClientManager {
private boolean mAllowResourcePrefetch; private boolean mAllowResourcePrefetch;
private boolean mShouldGetPageLoadMetrics; private boolean mShouldGetPageLoadMetrics;
private boolean mShouldHideTopBar; private boolean mShouldHideTopBar;
private String mCustomTabsClientDataHeaderValue;
public SessionParams(Context context, int uid, CustomTabsCallback customTabsCallback, public SessionParams(Context context, int uid, CustomTabsCallback customTabsCallback,
DisconnectCallback callback, PostMessageHandler postMessageHandler, DisconnectCallback callback, PostMessageHandler postMessageHandler,
...@@ -582,6 +583,25 @@ class ClientManager { ...@@ -582,6 +583,25 @@ class ClientManager {
if (params != null) params.mShouldSendBottomBarScrollState = send; if (params != null) params.mShouldSendBottomBarScrollState = send;
} }
/**
* Sets the value of the X-CCT-Client-Data header that will be sent on some Custom Tabs
* requests.
*/
public synchronized void setClientDataHeaderValue(
CustomTabsSessionToken session, String headerValue) {
SessionParams params = mSessionParams.get(session);
if (params != null) params.mCustomTabsClientDataHeaderValue = headerValue;
}
/**
* Gets the value previously set by {@link #setClientDataHeaderValue}.
*/
public synchronized String getClientDataHeaderValue(CustomTabsSessionToken session) {
SessionParams params = mSessionParams.get(session);
if (params == null) return null;
return params.mCustomTabsClientDataHeaderValue;
}
/** /**
* @return Whether navigation info should be recorded and shared for the session. * @return Whether navigation info should be recorded and shared for the session.
*/ */
...@@ -718,14 +738,6 @@ class ClientManager { ...@@ -718,14 +738,6 @@ class ClientManager {
return params != null ? params.mShouldGetPageLoadMetrics : false; return params != null ? params.mShouldGetPageLoadMetrics : false;
} }
/**
* Returns the uid associated with the session, {@code -1} if there is no matching session.
*/
public synchronized int getUidForSession(CustomTabsSessionToken session) {
SessionParams params = mSessionParams.get(session);
return params != null ? params.uid : -1;
}
/** /**
* Returns whether an origin is first-party with respect to a session, that is if the * Returns whether an origin is first-party with respect to a session, that is if the
* application linked to the session has a relation with the provided origin. This does not * application linked to the session has a relation with the provided origin. This does not
......
...@@ -818,12 +818,11 @@ public class CustomTabsConnection { ...@@ -818,12 +818,11 @@ public class CustomTabsConnection {
* @param webContents the WebContents of the new tab. * @param webContents the WebContents of the new tab.
*/ */
public void setClientDataHeaderForNewTab( public void setClientDataHeaderForNewTab(
CustomTabsSessionToken session, WebContents webContents) {} CustomTabsSessionToken session, WebContents webContents) {
String header = getClientDataHeaderValueForSession(session);
protected void setClientDataHeader(WebContents webContents, String header) { if (!TextUtils.isEmpty(header)) {
if (TextUtils.isEmpty(header)) return; CustomTabsConnectionJni.get().setClientDataHeader(webContents, header);
}
CustomTabsConnectionJni.get().setClientDataHeader(webContents, header);
} }
private void maybePreconnectToRedirectEndpoint( private void maybePreconnectToRedirectEndpoint(
...@@ -1044,6 +1043,13 @@ public class CustomTabsConnection { ...@@ -1044,6 +1043,13 @@ public class CustomTabsConnection {
mClientManager.setSendNavigationInfoForSession(session, send); mClientManager.setSendNavigationInfoForSession(session, send);
} }
/**
* See {@link ClientManager#setClientDataHeaderValue}.
*/
String getClientDataHeaderValueForSession(CustomTabsSessionToken session) {
return mClientManager.getClientDataHeaderValue(session);
}
/** /**
* Extracts the creator package name from the intent. * Extracts the creator package name from the intent.
* @param intent The intent to get the package name from. * @param intent The intent to get the package name from.
......
...@@ -170,6 +170,20 @@ public class ClientManagerTest { ...@@ -170,6 +170,20 @@ public class ClientManagerTest {
mClientManager.getPredictionOutcome(mSession, URL + "#fragment")); mClientManager.getPredictionOutcome(mSession, URL + "#fragment"));
} }
@Test
@SmallTest
public void testClientDataHeader() {
Assert.assertTrue(mClientManager.newSession(mSession, mUid, null, null, null));
String headerValue = "header value";
mClientManager.setClientDataHeaderValue(mSession, headerValue);
Assert.assertEquals(headerValue, mClientManager.getClientDataHeaderValue(mSession));
mClientManager.setClientDataHeaderValue(mSession, null);
Assert.assertNull(mClientManager.getClientDataHeaderValue(mSession));
}
@Test @Test
@SmallTest @SmallTest
public void testPostMessageOriginVerification() { public void testPostMessageOriginVerification() {
......
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