summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamas Zakor <ztamas@inf.u-szeged.hu>2018-11-20 14:15:55 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-06-03 11:30:05 +0200
commitea7437acf1fd22a1c73d7185ac2c9b1df3a100e5 (patch)
treeb6d8b12287ba18abd669fc39e0acccc9c364feb4
parent431695b48926d897018cf5d5a6729428bf2d9250 (diff)
downloadqtwebengine-chromium-ea7437acf1fd22a1c73d7185ac2c9b1df3a100e5.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>
-rw-r--r--chromium/content/browser/frame_host/navigation_request.cc9
-rw-r--r--chromium/content/browser/frame_host/navigation_request_info.cc9
-rw-r--r--chromium/content/browser/frame_host/navigation_request_info.h7
-rw-r--r--chromium/content/browser/loader/navigation_url_loader_impl.cc6
-rw-r--r--chromium/content/browser/loader/resource_dispatcher_host_impl.cc3
-rw-r--r--chromium/net/url_request/url_request.cc6
-rw-r--r--chromium/net/url_request/url_request.h9
-rw-r--r--chromium/services/network/public/cpp/resource_request.h6
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 05336f93301..14bacff2f63 100644
--- a/chromium/content/browser/frame_host/navigation_request.cc
+++ b/chromium/content/browser/frame_host/navigation_request.cc
@@ -1597,6 +1597,12 @@ void NavigationRequest::OnStartChecksComplete(
current = current->parent();
}
+#if defined(TOOLKIT_QT)
+ const GURL& first_party_url =
+ frame_tree_node_->IsMainFrame() ? common_params_.url
+ : top_document_url;
+#endif
+
const GURL& site_for_cookies =
(ancestors_are_same_site || !base_url.is_empty())
? (frame_tree_node_->IsMainFrame() ? common_params_.url
@@ -1640,6 +1646,9 @@ void NavigationRequest::OnStartChecksComplete(
browser_context->GetResourceContext(), partition,
std::make_unique<NavigationRequestInfo>(
common_params_, begin_params_.Clone(), site_for_cookies,
+#if defined(TOOLKIT_QT)
+ first_party_url,
+#endif
top_frame_origin, frame_tree_node_->IsMainFrame(),
parent_is_main_frame, IsSecureFrame(frame_tree_node_->parent()),
frame_tree_node_->frame_tree_node_id(), is_for_guests_only,
diff --git a/chromium/content/browser/frame_host/navigation_request_info.cc b/chromium/content/browser/frame_host/navigation_request_info.cc
index b0ab6cdf70d..0002c03fd45 100644
--- a/chromium/content/browser/frame_host/navigation_request_info.cc
+++ b/chromium/content/browser/frame_host/navigation_request_info.cc
@@ -11,6 +11,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 base::Optional<url::Origin>& top_frame_origin,
bool is_main_frame,
bool parent_is_main_frame,
@@ -27,6 +30,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
top_frame_origin(top_frame_origin),
is_main_frame(is_main_frame),
parent_is_main_frame(parent_is_main_frame),
@@ -44,6 +50,9 @@ NavigationRequestInfo::NavigationRequestInfo(const NavigationRequestInfo& other)
: common_params(other.common_params),
begin_params(other.begin_params.Clone()),
site_for_cookies(other.site_for_cookies),
+#if defined(TOOLKIT_QT)
+ first_party_url(other.first_party_url),
+#endif
top_frame_origin(other.top_frame_origin),
is_main_frame(other.is_main_frame),
parent_is_main_frame(other.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 e0d59153bf2..f5897cc4484 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 base::Optional<url::Origin>& top_frame_origin,
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
// The origin of the navigation if top frame, else the origin of the top
// frame.
// TODO(crbug.com/910716) Make this required. I believe we just need to add
diff --git a/chromium/content/browser/loader/navigation_url_loader_impl.cc b/chromium/content/browser/loader/navigation_url_loader_impl.cc
index 0010982ecf2..95a54003ea3 100644
--- a/chromium/content/browser/loader/navigation_url_loader_impl.cc
+++ b/chromium/content/browser/loader/navigation_url_loader_impl.cc
@@ -195,6 +195,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->top_frame_origin = request_info->top_frame_origin;
net::RequestPriority net_priority = net::HIGHEST;
@@ -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.top_frame_origin,
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 289e7d0e40d..37baa96168c 100644
--- a/chromium/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/chromium/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -1526,6 +1526,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_top_frame_origin(info.top_frame_origin);
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 f7ee1c6c32d..93925c28d4a 100644
--- a/chromium/net/url_request/url_request.cc
+++ b/chromium/net/url_request/url_request.cc
@@ -466,6 +466,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 b264ca045f2..841f10e903e 100644
--- a/chromium/net/url_request/url_request.h
+++ b/chromium/net/url_request/url_request.h
@@ -286,6 +286,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.
const base::Optional<url::Origin>& top_frame_origin() const {
@@ -861,6 +867,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
base::Optional<url::Origin> top_frame_origin_;
bool attach_same_site_cookies_;
diff --git a/chromium/services/network/public/cpp/resource_request.h b/chromium/services/network/public/cpp/resource_request.h
index eff0e4279e3..32bf9bfc439 100644
--- a/chromium/services/network/public/cpp/resource_request.h
+++ b/chromium/services/network/public/cpp/resource_request.h
@@ -38,6 +38,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;
bool attach_same_site_cookies = false;
bool update_first_party_url_on_redirect = false;