summaryrefslogtreecommitdiff
path: root/chromium
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>2018-12-20 13:50:54 +0100
commit918d18d514dea175d8102642628cf4e011991fa7 (patch)
treeb7c472a8dddf58b97ddc6951f23d8fd13d550bbf /chromium
parent9542eabb114d0c44cc20e75fdc6704ed1950c6b5 (diff)
downloadqtwebengine-chromium-918d18d514dea175d8102642628cf4e011991fa7.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>
Diffstat (limited to 'chromium')
-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.h5
8 files changed, 54 insertions, 0 deletions
diff --git a/chromium/content/browser/frame_host/navigation_request.cc b/chromium/content/browser/frame_host/navigation_request.cc
index 3687817b179..eb8964478f1 100644
--- a/chromium/content/browser/frame_host/navigation_request.cc
+++ b/chromium/content/browser/frame_host/navigation_request.cc
@@ -1381,6 +1381,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
@@ -1409,6 +1415,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
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 f02f9a18f6a..71ce841a4d7 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
bool is_main_frame,
bool parent_is_main_frame,
bool are_ancestors_secure,
@@ -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
is_main_frame(is_main_frame),
parent_is_main_frame(parent_is_main_frame),
are_ancestors_secure(are_ancestors_secure),
@@ -42,6 +48,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
is_main_frame(other.is_main_frame),
parent_is_main_frame(other.parent_is_main_frame),
are_ancestors_secure(other.are_ancestors_secure),
diff --git a/chromium/content/browser/frame_host/navigation_request_info.h b/chromium/content/browser/frame_host/navigation_request_info.h
index 8b6a81c92d9..0ed4d5630a7 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
bool is_main_frame,
bool parent_is_main_frame,
bool are_ancestors_secure,
@@ -48,6 +51,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
const bool is_main_frame;
const bool parent_is_main_frame;
diff --git a/chromium/content/browser/loader/navigation_url_loader_impl.cc b/chromium/content/browser/loader/navigation_url_loader_impl.cc
index 257cbf5c165..5f77125e8f6 100644
--- a/chromium/content/browser/loader/navigation_url_loader_impl.cc
+++ b/chromium/content/browser/loader/navigation_url_loader_impl.cc
@@ -206,6 +206,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
net::RequestPriority net_priority = net::HIGHEST;
if (!request_info->is_main_frame &&
@@ -294,6 +297,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
previous_request_info.is_main_frame,
previous_request_info.parent_is_main_frame,
previous_request_info.are_ancestors_secure,
diff --git a/chromium/content/browser/loader/resource_dispatcher_host_impl.cc b/chromium/content/browser/loader/resource_dispatcher_host_impl.cc
index 8f33f39eb1d..ff33e260910 100644
--- a/chromium/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/chromium/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -1505,6 +1505,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_initiator(info.begin_params->initiator_origin);
new_request->set_upgrade_if_insecure(info.upgrade_if_insecure);
if (info.is_main_frame) {
diff --git a/chromium/net/url_request/url_request.cc b/chromium/net/url_request/url_request.cc
index ef2c226d7e4..f8dcb203f0a 100644
--- a/chromium/net/url_request/url_request.cc
+++ b/chromium/net/url_request/url_request.cc
@@ -470,6 +470,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 e6efafc6a97..81a4a7e7357 100644
--- a/chromium/net/url_request/url_request.h
+++ b/chromium/net/url_request/url_request.h
@@ -287,6 +287,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
+
// Indicate whether SameSite cookies should be attached even though the
// request is cross-site.
bool attach_same_site_cookies() const { return attach_same_site_cookies_; }
@@ -847,6 +853,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
bool attach_same_site_cookies_;
base::Optional<url::Origin> initiator_;
GURL delegate_redirect_url_;
diff --git a/chromium/services/network/public/cpp/resource_request.h b/chromium/services/network/public/cpp/resource_request.h
index 8481b5d6faa..f747cb3c1dd 100644
--- a/chromium/services/network/public/cpp/resource_request.h
+++ b/chromium/services/network/public/cpp/resource_request.h
@@ -43,6 +43,11 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE) ResourceRequest {
// done if there really is no way to determine the correct value.
GURL site_for_cookies;
+#if defined(TOOLKIT_QT)
+ // The top-level frame URL.
+ GURL first_party_url;
+#endif
+
// Boolean indicating whether SameSite cookies are allowed to be attached
// to the request. It should be used as additional input to network side
// checks.