diff options
author | Tamas Zakor <ztamas@inf.u-szeged.hu> | 2018-11-20 14:15:55 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-09-04 14:31:26 +0200 |
commit | 9f8245969705819bac796ba9ab95e533907f9d7a (patch) | |
tree | bcaa7a0bb32737f3f144779f8cf89653d1124fc3 | |
parent | aca7f5c2021fb020b4b35a1177fdc557ec05f628 (diff) | |
download | qtwebengine-chromium-9f8245969705819bac796ba9ab95e533907f9d7a.tar.gz |
Add net::URLRequest::first_party_url()
Returns the top level frame URL. Used instead of site_for_cookies()
in case of cross-origin iframe navigations.
Task-number: QTBUG-70790
Change-Id: Icec4beddd70b20120d53e17a35385d83d1276ac2
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
8 files changed, 55 insertions, 0 deletions
diff --git a/chromium/content/browser/frame_host/navigation_request.cc b/chromium/content/browser/frame_host/navigation_request.cc index 4bb7b470e7f..c6e16615f42 100644 --- a/chromium/content/browser/frame_host/navigation_request.cc +++ b/chromium/content/browser/frame_host/navigation_request.cc @@ -1704,9 +1704,18 @@ void NavigationRequest::OnStartChecksComplete( // Mark the fetch_start (Navigation Timing API). commit_params_.navigation_timing.fetch_start = base::TimeTicks::Now(); +#if defined(TOOLKIT_QT) + const GURL& top_document_url = + frame_tree_node_->frame_tree()->root()->current_url(); + const GURL& first_party_url = + frame_tree_node_->IsMainFrame() ? common_params_.url + : top_document_url; +#endif + GURL site_for_cookies = frame_tree_node_->current_frame_host() ->ComputeSiteForCookiesForNavigation(common_params_.url); + bool parent_is_main_frame = !frame_tree_node_->parent() ? false : frame_tree_node_->parent()->IsMainFrame(); @@ -1750,6 +1759,9 @@ void NavigationRequest::OnStartChecksComplete( browser_context, browser_context->GetResourceContext(), partition, std::make_unique<NavigationRequestInfo>( common_params_, begin_params_.Clone(), site_for_cookies, +#if defined(TOOLKIT_QT) + first_party_url, +#endif net::NetworkIsolationKey(top_frame_origin, frame_origin), frame_tree_node_->IsMainFrame(), parent_is_main_frame, IsSecureFrame(frame_tree_node_->parent()), diff --git a/chromium/content/browser/frame_host/navigation_request_info.cc b/chromium/content/browser/frame_host/navigation_request_info.cc index e4491f8f5dd..f726e9e9ab1 100644 --- a/chromium/content/browser/frame_host/navigation_request_info.cc +++ b/chromium/content/browser/frame_host/navigation_request_info.cc @@ -10,6 +10,9 @@ NavigationRequestInfo::NavigationRequestInfo( const CommonNavigationParams& common_params, mojom::BeginNavigationParamsPtr begin_params, const GURL& site_for_cookies, +#if defined(TOOLKIT_QT) + const GURL& first_party_url, +#endif const net::NetworkIsolationKey& network_isolation_key, bool is_main_frame, bool parent_is_main_frame, @@ -26,6 +29,9 @@ NavigationRequestInfo::NavigationRequestInfo( : common_params(common_params), begin_params(std::move(begin_params)), site_for_cookies(site_for_cookies), +#if defined(TOOLKIT_QT) + first_party_url(first_party_url), +#endif network_isolation_key(network_isolation_key), is_main_frame(is_main_frame), parent_is_main_frame(parent_is_main_frame), diff --git a/chromium/content/browser/frame_host/navigation_request_info.h b/chromium/content/browser/frame_host/navigation_request_info.h index 78dd2a219d2..e0c5bf3ce0f 100644 --- a/chromium/content/browser/frame_host/navigation_request_info.h +++ b/chromium/content/browser/frame_host/navigation_request_info.h @@ -26,6 +26,9 @@ struct CONTENT_EXPORT NavigationRequestInfo { NavigationRequestInfo(const CommonNavigationParams& common_params, mojom::BeginNavigationParamsPtr begin_params, const GURL& site_for_cookies, +#if defined(TOOLKIT_QT) + const GURL& first_party_url, +#endif const net::NetworkIsolationKey& network_isolation_key, bool is_main_frame, bool parent_is_main_frame, @@ -49,6 +52,10 @@ struct CONTENT_EXPORT NavigationRequestInfo { // checked by the third-party cookie blocking policy. const GURL site_for_cookies; +#if defined(TOOLKIT_QT) + // The top level frame URL + const GURL first_party_url; +#endif // Navigation resource requests will be keyed using |network_isolation_key| // for accessing shared network resources like the http cache. const net::NetworkIsolationKey network_isolation_key; diff --git a/chromium/content/browser/loader/navigation_url_loader_impl.cc b/chromium/content/browser/loader/navigation_url_loader_impl.cc index 8a550243054..9d30595c9f5 100644 --- a/chromium/content/browser/loader/navigation_url_loader_impl.cc +++ b/chromium/content/browser/loader/navigation_url_loader_impl.cc @@ -187,6 +187,9 @@ std::unique_ptr<network::ResourceRequest> CreateResourceRequest( new_request->method = request_info->common_params.method; new_request->url = request_info->common_params.url; new_request->site_for_cookies = request_info->site_for_cookies; +#if defined(TOOLKIT_QT) + new_request->first_party_url = request_info->first_party_url; +#endif new_request->trusted_network_isolation_key = request_info->network_isolation_key; @@ -277,6 +280,9 @@ std::unique_ptr<NavigationRequestInfo> CreateNavigationRequestInfoForRedirect( return std::make_unique<NavigationRequestInfo>( std::move(new_common_params), std::move(new_begin_params), updated_resource_request.site_for_cookies, +#if defined(TOOLKIT_QT) + previous_request_info.first_party_url, +#endif updated_resource_request.trusted_network_isolation_key, previous_request_info.is_main_frame, previous_request_info.parent_is_main_frame, diff --git a/chromium/content/browser/loader/resource_dispatcher_host_impl.cc b/chromium/content/browser/loader/resource_dispatcher_host_impl.cc index 76bcf34f58e..3a050e7913b 100644 --- a/chromium/content/browser/loader/resource_dispatcher_host_impl.cc +++ b/chromium/content/browser/loader/resource_dispatcher_host_impl.cc @@ -1438,6 +1438,9 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest( new_request->set_method(info.common_params.method); new_request->set_site_for_cookies(info.site_for_cookies); +#if defined(TOOLKIT_QT) + new_request->set_first_party_url(info.first_party_url); +#endif new_request->set_network_isolation_key(info.network_isolation_key); new_request->set_initiator(info.common_params.initiator_origin); new_request->set_upgrade_if_insecure(info.upgrade_if_insecure); diff --git a/chromium/net/url_request/url_request.cc b/chromium/net/url_request/url_request.cc index 736dddbe7d6..126ef036aef 100644 --- a/chromium/net/url_request/url_request.cc +++ b/chromium/net/url_request/url_request.cc @@ -481,6 +481,12 @@ void URLRequest::set_site_for_cookies(const GURL& site_for_cookies) { DCHECK(!is_pending_); site_for_cookies_ = site_for_cookies; } +#if defined(TOOLKIT_QT) +void URLRequest::set_first_party_url(const GURL& first_party_url) { + DCHECK(!is_pending_); + first_party_url_ = first_party_url; +} +#endif void URLRequest::set_first_party_url_policy( FirstPartyURLPolicy first_party_url_policy) { diff --git a/chromium/net/url_request/url_request.h b/chromium/net/url_request/url_request.h index 2a0950079cb..3585ac4021a 100644 --- a/chromium/net/url_request/url_request.h +++ b/chromium/net/url_request/url_request.h @@ -288,6 +288,12 @@ class NET_EXPORT URLRequest : public base::SupportsUserData { // This method may only be called before Start(). void set_site_for_cookies(const GURL& site_for_cookies); +#if defined(TOOLKIT_QT) + // The top-level frame URL. + const GURL& first_party_url() const { return first_party_url_; } + void set_first_party_url(const GURL& first_party_url); +#endif + // The origin of the top frame of the page making the request (where // applicable). Note that this is experimental and may not always be set. // DEPRECATED: This was introduced for the cache key and will be removed once @@ -900,6 +906,9 @@ class NET_EXPORT URLRequest : public base::SupportsUserData { std::vector<GURL> url_chain_; GURL site_for_cookies_; +#if defined(TOOLKIT_QT) + GURL first_party_url_; +#endif // DEPRECATED: See comment on the getter function. base::Optional<url::Origin> top_frame_origin_; diff --git a/chromium/services/network/public/cpp/resource_request.h b/chromium/services/network/public/cpp/resource_request.h index 2c27d661011..cdf5f69adc0 100644 --- a/chromium/services/network/public/cpp/resource_request.h +++ b/chromium/services/network/public/cpp/resource_request.h @@ -40,6 +40,12 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE) ResourceRequest { std::string method = "GET"; GURL url; GURL site_for_cookies; + +#if defined(TOOLKIT_QT) + // The top-level frame URL. + GURL first_party_url; +#endif + base::Optional<url::Origin> top_frame_origin; net::NetworkIsolationKey trusted_network_isolation_key; mojom::UpdateNetworkIsolationKeyOnRedirect |