Commit 257cdc8f authored by Benoît Lizé's avatar Benoît Lizé Committed by Commit Bot

customtabs: Allow detached requests before native is fully initialized.

Relax the restriction on parallel requests.
Most of the changes are in tests:
- Don't always initialize the browser in tests
- Detached requests are tried before and after native is loaded.

Bug: 901835
Change-Id: Iecd16e976eb3bdea44871097528ef799b9678051
Reviewed-on: https://chromium-review.googlesource.com/c/1350891Reviewed-by: default avatarAlexandr Ilin <alexilin@chromium.org>
Commit-Queue: Benoit L <lizeb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611085}
parent 1d7e84e1
...@@ -846,7 +846,8 @@ public class CustomTabsConnection { ...@@ -846,7 +846,8 @@ public class CustomTabsConnection {
*/ */
public void onHandledIntent(CustomTabsSessionToken session, String url, Intent intent) { public void onHandledIntent(CustomTabsSessionToken session, String url, Intent intent) {
if (mLogRequests) { if (mLogRequests) {
Log.w(TAG, "onHandledIntent, URL: %s, extras:", bundleToJson(intent.getExtras())); Log.w(TAG, "onHandledIntent, URL: %s, extras: %s", url,
bundleToJson(intent.getExtras()));
} }
// If we still have pending warmup tasks, don't continue as they would only delay intent // If we still have pending warmup tasks, don't continue as they would only delay intent
...@@ -1001,14 +1002,7 @@ public class CustomTabsConnection { ...@@ -1001,14 +1002,7 @@ public class CustomTabsConnection {
@VisibleForTesting @VisibleForTesting
boolean canDoParallelRequest(CustomTabsSessionToken session, Uri referrer) { boolean canDoParallelRequest(CustomTabsSessionToken session, Uri referrer) {
ThreadUtils.assertOnUiThread(); ThreadUtils.assertOnUiThread();
// The restrictions are: return mClientManager.isFirstPartyOriginForSession(session, new Origin(referrer));
// - Native initialization: Required to get the profile, and the feature state.
// - The referrer's origin is allowed.
//
// TODO(lizeb): Relax the restrictions.
return ChromeBrowserInitializer.getInstance(ContextUtils.getApplicationContext())
.hasNativeInitializationCompleted()
&& mClientManager.isFirstPartyOriginForSession(session, new Origin(referrer));
} }
/** See {@link ClientManager#getReferrerForSession(CustomTabsSessionToken)} */ /** See {@link ClientManager#getReferrerForSession(CustomTabsSessionToken)} */
......
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