Commit e89d11fb authored by Maggie Cai's avatar Maggie Cai Committed by Commit Bot

Fix the get start url logic in AppsNavigationThrottle.

Currently when there is a redirect link open on in new tab (e.g. link
from gmail, youtube sharing link), the get start URL gets empty URL
and hence didn't trigger an app query. The reason is that we were using
the SiteInstance's Site URL. This is no longer working in some cases due
to the site isolation fixes. Change it to use initiator origin from the
NavigationHandle.

BUG=1048042

Change-Id: Ib264d35c31284826dabdfc65056fbc99d5fe9014
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2055908
Commit-Queue: Maggie Cai <mxcai@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741364}
parent 2a47c1c9
...@@ -77,10 +77,10 @@ bool ShouldOverrideUrlLoading(const GURL& previous_url, ...@@ -77,10 +77,10 @@ bool ShouldOverrideUrlLoading(const GURL& previous_url,
GURL GetStartingGURL(content::NavigationHandle* navigation_handle) { GURL GetStartingGURL(content::NavigationHandle* navigation_handle) {
// This helps us determine a reference GURL for the current NavigationHandle. // This helps us determine a reference GURL for the current NavigationHandle.
// This is the order or preferrence: Referrer > LastCommittedURL > SiteURL, // This is the order or preference: Referrer > LastCommittedURL >
// GetSiteURL *should* only be used on very rare cases, e.g. when the // InitiatorOrigin. InitiatorOrigin *should* only be used on very rare cases,
// navigation goes from https: to http: on a new tab, thus losing the other // e.g. when the navigation goes from https: to http: on a new tab, thus
// potential referrers. // losing the other potential referrers.
const GURL referrer_url = navigation_handle->GetReferrer().url; const GURL referrer_url = navigation_handle->GetReferrer().url;
if (referrer_url.is_valid() && !referrer_url.is_empty()) if (referrer_url.is_valid() && !referrer_url.is_empty())
return referrer_url; return referrer_url;
...@@ -90,7 +90,8 @@ GURL GetStartingGURL(content::NavigationHandle* navigation_handle) { ...@@ -90,7 +90,8 @@ GURL GetStartingGURL(content::NavigationHandle* navigation_handle) {
if (last_committed_url.is_valid() && !last_committed_url.is_empty()) if (last_committed_url.is_valid() && !last_committed_url.is_empty())
return last_committed_url; return last_committed_url;
return navigation_handle->GetStartingSiteInstance()->GetSiteURL(); const auto& initiator_origin = navigation_handle->GetInitiatorOrigin();
return initiator_origin.has_value() ? initiator_origin->GetURL() : GURL();
} }
} // namespace } // namespace
......
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