Skip to content

Commit

Permalink
customtabs: Always call CustomTabsConnection.onHandledIntent().
Browse files Browse the repository at this point in the history
Previously, only new intents going to the current active session would go
through CustomTabsConnection.onHandledIntent(), which is not the
intended behavior, as this is used to trigger preconnection to redirect
endpoints.

Bug: 739165
Change-Id: Ie9da5dcf4e25f4d0ca2044cba20956a316f7a253
Reviewed-on: https://chromium-review.googlesource.com/581110
Commit-Queue: Benoit L <lizeb@chromium.org>
Reviewed-by: Yusuf Ozuysal <yusufo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488952}
  • Loading branch information
Benoit Lize authored and Commit Bot committed Jul 24, 2017
1 parent 4cdb77d commit 67e17f3
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,24 +225,26 @@ public static void setActiveContentHandler(CustomTabContentHandler contentHandle
}

/**
* Used to check whether an incoming intent can be handled by the
* current {@link CustomTabContentHandler}.
* Called when a CustomTabs intent is handled.
*
* Used to check whether an incoming intent can be handled by the current
* {@link CustomTabContentHandler}, and to perform action on new Intent.
*
* @return Whether the active {@link CustomTabContentHandler} has handled the intent.
*/
public static boolean handleInActiveContentIfNeeded(Intent intent) {
if (sActiveContentHandler == null) return false;

if (sActiveContentHandler.shouldIgnoreIntent(intent)) {
Log.w(TAG, "Incoming intent to Custom Tab was ignored.");
return false;
}

CustomTabsSessionToken session = CustomTabsSessionToken.getSessionTokenFromIntent(intent);
if (session == null || !session.equals(sActiveContentHandler.getSession())) return false;

String url = IntentHandler.getUrlFromIntent(intent);
if (TextUtils.isEmpty(url)) return false;
CustomTabsConnection.getInstance().onHandledIntent(session, url, intent);

if (sActiveContentHandler == null) return false;
if (session == null || !session.equals(sActiveContentHandler.getSession())) return false;
if (sActiveContentHandler.shouldIgnoreIntent(intent)) {
Log.w(TAG, "Incoming intent to Custom Tab was ignored.");
return false;
}
sActiveContentHandler.loadUrlAndTrackFromTimestamp(new LoadUrlParams(url),
IntentHandler.getTimestampFromIntent(intent));
return true;
Expand Down

0 comments on commit 67e17f3

Please sign in to comment.