summaryrefslogtreecommitdiffstats
path: root/src/core/net
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-01-22 10:55:57 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-01-25 15:41:53 +0100
commitcde72003881c6b5680ac8ac0fe6d6971bb43e0d5 (patch)
treefcb50002765c1cb179dd6f62054380c3fed85e80 /src/core/net
parent3fb215dab139fd7b61473ce3fe1058b87a6b4fe3 (diff)
parent75d061bbc68875c08b3dc243e464e32a80da71df (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Including update to 87-based Change-Id: I36b6054e00de97ab055d0bc800cff08d0408fac6
Diffstat (limited to 'src/core/net')
-rw-r--r--src/core/net/client_cert_override.cpp6
-rw-r--r--src/core/net/cookie_monster_delegate_qt.cpp9
-rw-r--r--src/core/net/cookie_monster_delegate_qt.h2
-rw-r--r--src/core/net/custom_url_loader_factory.cpp29
-rw-r--r--src/core/net/custom_url_loader_factory.h4
-rw-r--r--src/core/net/proxying_restricted_cookie_manager_qt.cpp2
-rw-r--r--src/core/net/proxying_url_loader_factory_qt.cpp13
-rw-r--r--src/core/net/system_network_context_manager.cpp37
-rw-r--r--src/core/net/system_network_context_manager.h4
9 files changed, 51 insertions, 55 deletions
diff --git a/src/core/net/client_cert_override.cpp b/src/core/net/client_cert_override.cpp
index f33515f63..d768092e8 100644
--- a/src/core/net/client_cert_override.cpp
+++ b/src/core/net/client_cert_override.cpp
@@ -65,7 +65,7 @@
#include "net/ssl/client_cert_store_win.h"
#endif
-#if defined(OS_MACOSX)
+#if defined(OS_MAC)
#include "net/ssl/client_cert_store_mac.h"
#endif
@@ -83,7 +83,7 @@ public:
std::move(private_key_callback).Run(m_key);
}
-#if defined(OS_MACOSX)
+#if defined(OS_MAC)
SecIdentityRef sec_identity_ref() const override
{
return nullptr;
@@ -167,7 +167,7 @@ std::unique_ptr<net::ClientCertStore> ClientCertOverrideStore::createNativeStore
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS(net::ClientCertStoreNSS::PasswordDelegateFactory()));
#elif defined(OS_WIN)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreWin());
-#elif defined(OS_MACOSX)
+#elif defined(OS_MAC)
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreMac());
#else
return nullptr;
diff --git a/src/core/net/cookie_monster_delegate_qt.cpp b/src/core/net/cookie_monster_delegate_qt.cpp
index a7a3a9348..792d34373 100644
--- a/src/core/net/cookie_monster_delegate_qt.cpp
+++ b/src/core/net/cookie_monster_delegate_qt.cpp
@@ -143,7 +143,7 @@ void CookieMonsterDelegateQt::setCookie(quint64 callbackId, const QNetworkCookie
if (callbackId != CallbackDirectory::NoCallbackId)
callback = base::BindOnce(&CookieMonsterDelegateQt::SetCookieCallbackOnUIThread, this, callbackId);
- net::CanonicalCookie::CookieInclusionStatus inclusion;
+ net::CookieInclusionStatus inclusion;
auto canonCookie = net::CanonicalCookie::Create(gurl, cookie_line, base::Time::Now(), base::nullopt, &inclusion);
if (!inclusion.IsInclude()) {
LOG(WARNING) << "QWebEngineCookieStore::setCookie() - Tried to set invalid cookie";
@@ -151,7 +151,8 @@ void CookieMonsterDelegateQt::setCookie(quint64 callbackId, const QNetworkCookie
}
net::CookieOptions options;
options.set_include_httponly();
- m_mojoCookieManager->SetCanonicalCookie(*canonCookie.get(), gurl.scheme(), options, std::move(callback));
+ options.set_same_site_cookie_context(net::CookieOptions::SameSiteCookieContext::MakeInclusiveForSet());
+ m_mojoCookieManager->SetCanonicalCookie(*canonCookie.get(), gurl, options, std::move(callback));
}
void CookieMonsterDelegateQt::deleteCookie(const QNetworkCookie &cookie, const QUrl &origin)
@@ -272,10 +273,10 @@ void CookieMonsterDelegateQt::GetAllCookiesCallbackOnUIThread(qint64 callbackId,
m_client->d_func()->onGetAllCallbackResult(callbackId, rawCookies);
}
-void CookieMonsterDelegateQt::SetCookieCallbackOnUIThread(qint64 callbackId, net::CanonicalCookie::CookieInclusionStatus status)
+void CookieMonsterDelegateQt::SetCookieCallbackOnUIThread(qint64 callbackId, net::CookieAccessResult status)
{
if (m_client)
- m_client->d_func()->onSetCallbackResult(callbackId, status.IsInclude());
+ m_client->d_func()->onSetCallbackResult(callbackId, status.status.IsInclude());
}
void CookieMonsterDelegateQt::DeleteCookiesCallbackOnUIThread(qint64 callbackId, uint numCookies)
diff --git a/src/core/net/cookie_monster_delegate_qt.h b/src/core/net/cookie_monster_delegate_qt.h
index a8432e125..9078bcd58 100644
--- a/src/core/net/cookie_monster_delegate_qt.h
+++ b/src/core/net/cookie_monster_delegate_qt.h
@@ -114,7 +114,7 @@ public:
private:
void GetAllCookiesCallbackOnUIThread(qint64 callbackId, const net::CookieList &cookies);
- void SetCookieCallbackOnUIThread(qint64 callbackId, net::CanonicalCookie::CookieInclusionStatus status);
+ void SetCookieCallbackOnUIThread(qint64 callbackId, net::CookieAccessResult status);
void DeleteCookiesCallbackOnUIThread(qint64 callbackId, uint numCookies);
};
diff --git a/src/core/net/custom_url_loader_factory.cpp b/src/core/net/custom_url_loader_factory.cpp
index 709e4451b..10b4a9e0f 100644
--- a/src/core/net/custom_url_loader_factory.cpp
+++ b/src/core/net/custom_url_loader_factory.cpp
@@ -91,6 +91,7 @@ public:
// network::mojom::URLLoader:
void FollowRedirect(const std::vector<std::string> &removed_headers,
const net::HttpRequestHeaders &modified_headers,
+ const net::HttpRequestHeaders &modified_cors_exempt_headers, // FIXME: do something with this?
const base::Optional<GURL> &new_url) override
{
// We can be asked for follow our own redirect
@@ -287,9 +288,9 @@ private:
if (!m_redirect.is_empty()) {
m_head->content_length = m_head->encoded_body_length = -1;
- net::URLRequest::FirstPartyURLPolicy first_party_url_policy =
- m_request.update_first_party_url_on_redirect ? net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT
- : net::URLRequest::NEVER_CHANGE_FIRST_PARTY_URL;
+ net::RedirectInfo::FirstPartyURLPolicy first_party_url_policy =
+ m_request.update_first_party_url_on_redirect ? net::RedirectInfo::FirstPartyURLPolicy::UPDATE_URL_ON_REDIRECT
+ : net::RedirectInfo::FirstPartyURLPolicy::NEVER_CHANGE_URL;
net::RedirectInfo redirectInfo = net::RedirectInfo::ComputeRedirectInfo(
m_request.method, m_request.url,
m_request.site_for_cookies,
@@ -457,10 +458,13 @@ private:
class CustomURLLoaderFactory : public network::mojom::URLLoaderFactory {
public:
- CustomURLLoaderFactory(ProfileAdapter *profileAdapter)
+ CustomURLLoaderFactory(ProfileAdapter *profileAdapter, mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver)
: m_taskRunner(base::CreateSequencedTaskRunner({ content::BrowserThread::IO }))
, m_profileAdapter(profileAdapter)
{
+ m_receivers.set_disconnect_handler(base::BindRepeating(
+ &CustomURLLoaderFactory::OnDisconnect, base::Unretained(this)));
+ m_receivers.Add(this, std::move(receiver));
}
~CustomURLLoaderFactory() override = default;
@@ -491,6 +495,19 @@ public:
m_receivers.Add(this, std::move(receiver));
}
+ void OnDisconnect()
+ {
+ if (m_receivers.empty())
+ delete this;
+ }
+
+ static mojo::PendingRemote<network::mojom::URLLoaderFactory> Create(ProfileAdapter *profileAdapter)
+ {
+ mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_remote;
+ new CustomURLLoaderFactory(profileAdapter, pending_remote.InitWithNewPipeAndPassReceiver());
+ return pending_remote;
+ }
+
const scoped_refptr<base::SequencedTaskRunner> m_taskRunner;
mojo::ReceiverSet<network::mojom::URLLoaderFactory> m_receivers;
QPointer<ProfileAdapter> m_profileAdapter;
@@ -499,9 +516,9 @@ public:
} // namespace
-std::unique_ptr<network::mojom::URLLoaderFactory> CreateCustomURLLoaderFactory(ProfileAdapter *profileAdapter)
+mojo::PendingRemote<network::mojom::URLLoaderFactory> CreateCustomURLLoaderFactory(ProfileAdapter *profileAdapter)
{
- return std::make_unique<CustomURLLoaderFactory>(profileAdapter);
+ return CustomURLLoaderFactory::Create(profileAdapter);
}
} // namespace QtWebEngineCore
diff --git a/src/core/net/custom_url_loader_factory.h b/src/core/net/custom_url_loader_factory.h
index 58adf4b79..a9eecbd1c 100644
--- a/src/core/net/custom_url_loader_factory.h
+++ b/src/core/net/custom_url_loader_factory.h
@@ -51,7 +51,7 @@
#ifndef CUSTOM_URL_LOADER_FACTORY_H_
#define CUSTOM_URL_LOADER_FACTORY_H_
-#include <memory>
+#include "mojo/public/cpp/bindings/pending_remote.h"
namespace network {
namespace mojom {
@@ -62,7 +62,7 @@ class URLLoaderFactory;
namespace QtWebEngineCore {
class ProfileAdapter;
-std::unique_ptr<network::mojom::URLLoaderFactory> CreateCustomURLLoaderFactory(ProfileAdapter *profileAdapter);
+mojo::PendingRemote<network::mojom::URLLoaderFactory> CreateCustomURLLoaderFactory(ProfileAdapter *profileAdapter);
} // namespace QtWebEngineCore
diff --git a/src/core/net/proxying_restricted_cookie_manager_qt.cpp b/src/core/net/proxying_restricted_cookie_manager_qt.cpp
index b0b46c817..b0d3787de 100644
--- a/src/core/net/proxying_restricted_cookie_manager_qt.cpp
+++ b/src/core/net/proxying_restricted_cookie_manager_qt.cpp
@@ -126,7 +126,7 @@ void ProxyingRestrictedCookieManagerQt::GetAllForUrl(const GURL &url,
if (allowCookies(url, site_for_cookies)) {
underlying_restricted_cookie_manager_->GetAllForUrl(url, site_for_cookies, top_frame_origin, std::move(options), std::move(callback));
} else {
- std::move(callback).Run(std::vector<net::CanonicalCookie>());
+ std::move(callback).Run(std::vector<net::CookieWithAccessResult>());
}
}
diff --git a/src/core/net/proxying_url_loader_factory_qt.cpp b/src/core/net/proxying_url_loader_factory_qt.cpp
index 2b1472e88..f174df46c 100644
--- a/src/core/net/proxying_url_loader_factory_qt.cpp
+++ b/src/core/net/proxying_url_loader_factory_qt.cpp
@@ -137,7 +137,9 @@ public:
// network::mojom::URLLoader
void FollowRedirect(const std::vector<std::string> &removed_headers,
- const net::HttpRequestHeaders &modified_headers, const base::Optional<GURL> &new_url) override;
+ const net::HttpRequestHeaders &modified_headers,
+ const net::HttpRequestHeaders &modified_cors_exempt_headers,
+ const base::Optional<GURL> &new_url) override;
void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override;
void PauseReadingBodyFromNet() override;
void ResumeReadingBodyFromNet() override;
@@ -285,9 +287,9 @@ void InterceptedRequest::ContinueAfterIntercept()
}
if (info.shouldRedirectRequest) {
- net::URLRequest::FirstPartyURLPolicy first_party_url_policy =
- request_.update_first_party_url_on_redirect ? net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT
- : net::URLRequest::NEVER_CHANGE_FIRST_PARTY_URL;
+ net::RedirectInfo::FirstPartyURLPolicy first_party_url_policy =
+ request_.update_first_party_url_on_redirect ? net::RedirectInfo::FirstPartyURLPolicy::UPDATE_URL_ON_REDIRECT
+ : net::RedirectInfo::FirstPartyURLPolicy::NEVER_CHANGE_URL;
net::RedirectInfo redirectInfo = net::RedirectInfo::ComputeRedirectInfo(
request_.method, request_.url, request_.site_for_cookies,
first_party_url_policy, request_.referrer_policy, request_.referrer.spec(),
@@ -369,10 +371,11 @@ void InterceptedRequest::OnComplete(const network::URLLoaderCompletionStatus &st
void InterceptedRequest::FollowRedirect(const std::vector<std::string> &removed_headers,
const net::HttpRequestHeaders &modified_headers,
+ const net::HttpRequestHeaders &modified_cors_exempt_headers,
const base::Optional<GURL> &new_url)
{
if (target_loader_)
- target_loader_->FollowRedirect(removed_headers, modified_headers, new_url);
+ target_loader_->FollowRedirect(removed_headers, modified_headers, modified_cors_exempt_headers, new_url);
// If |OnURLLoaderClientError| was called then we're just waiting for the
// connection error handler of |proxied_loader_binding_|. Don't restart the
diff --git a/src/core/net/system_network_context_manager.cpp b/src/core/net/system_network_context_manager.cpp
index 611b5eafa..99a207c0e 100644
--- a/src/core/net/system_network_context_manager.cpp
+++ b/src/core/net/system_network_context_manager.cpp
@@ -64,7 +64,6 @@
#include "components/network_session_configurator/common/network_switches.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/cors_exempt_headers.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
@@ -102,7 +101,7 @@ network::mojom::HttpAuthDynamicParamsPtr CreateHttpAuthDynamicParams()
network::mojom::HttpAuthDynamicParamsPtr auth_dynamic_params = network::mojom::HttpAuthDynamicParams::New();
auto *command_line = base::CommandLine::ForCurrentProcess();
- auth_dynamic_params->server_allowlist = command_line->GetSwitchValueASCII(switches::kAuthServerWhitelist);
+ auth_dynamic_params->server_allowlist = command_line->GetSwitchValueASCII(switches::kAuthServerAllowlist);
// auth_dynamic_params->delegate_allowlist = command_line->GetSwitchValueASCII(switches::kAuthNegotiateDelegateWhitelist);
// auth_dynamic_params->enable_negotiate_port = command_line->HasSwitch(switches::kEnableAuthNegotiatePort);
@@ -241,8 +240,7 @@ void SystemNetworkContextManager::OnNetworkServiceCreated(network::mojom::Networ
network_service->SetUpHttpAuth(CreateHttpAuthStaticParams());
network_service->ConfigureHttpAuthPrefs(CreateHttpAuthDynamicParams());
- // The system NetworkContext must be created first, since it sets
- // |primary_network_context| to true.
+ // The system NetworkContext is created first
network_service_network_context_.reset();
network_service->CreateNetworkContext(
network_service_network_context_.BindNewPipeAndPassReceiver(),
@@ -263,41 +261,21 @@ void SystemNetworkContextManager::AddSSLConfigToNetworkContextParams(network::mo
network_context_params->initial_ssl_config->symantec_enforcement_disabled = true;
}
-network::mojom::NetworkContextParamsPtr SystemNetworkContextManager::CreateDefaultNetworkContextParams()
+void SystemNetworkContextManager::ConfigureDefaultNetworkContextParams(network::mojom::NetworkContextParams *network_context_params)
{
- network::mojom::NetworkContextParamsPtr network_context_params = network::mojom::NetworkContextParams::New();
- content::UpdateCorsExemptHeader(network_context_params.get());
-
network_context_params->enable_brotli = true;
- // network_context_params->user_agent = GetUserAgent();
-
// Disable referrers by default. Any consumer that enables referrers should
// respect prefs::kEnableReferrers from the appropriate pref store.
network_context_params->enable_referrers = false;
- // const base::CommandLine& command_line =
- // *base::CommandLine::ForCurrentProcess();
-
- // // TODO(eroman): Figure out why this doesn't work in single-process mode,
- // // or if it does work, now.
- // // Should be possible now that a private isolate is used.
- // // http://crbug.com/474654
- // if (!command_line.HasSwitch(switches::kWinHttpProxyResolver)) {
- // if (command_line.HasSwitch(switches::kSingleProcess)) {
- // LOG(ERROR) << "Cannot use V8 Proxy resolver in single process mode.";
- // } else {
network_context_params->proxy_resolver_factory = ChromeMojoProxyResolverFactory::CreateWithSelfOwnedReceiver();
- // }
- // }
-
- // network_context_params->pac_quick_check_enabled = local_state_->GetBoolean(prefs::kQuickCheckEnabled);
// Use the SystemNetworkContextManager to populate and update SSL
// configuration. The SystemNetworkContextManager is owned by the
// BrowserProcess itself, so will only be destroyed on shutdown, at which
// point, all NetworkContexts will be destroyed as well.
- AddSSLConfigToNetworkContextParams(network_context_params.get());
+ AddSSLConfigToNetworkContextParams(network_context_params);
// CT is only enabled on Desktop platforms for now.
network_context_params->enforce_chrome_ct_policy = true;
@@ -308,14 +286,13 @@ network::mojom::NetworkContextParamsPtr SystemNetworkContextManager::CreateDefau
log_info->name = ct_log.log_name;
network_context_params->ct_logs.push_back(std::move(log_info));
}
-
- return network_context_params;
}
network::mojom::NetworkContextParamsPtr SystemNetworkContextManager::CreateNetworkContextParams()
{
// TODO(mmenke): Set up parameters here (in memory cookie store, etc).
- network::mojom::NetworkContextParamsPtr network_context_params = CreateDefaultNetworkContextParams();
+ network::mojom::NetworkContextParamsPtr network_context_params = network::mojom::NetworkContextParams::New();
+ ConfigureDefaultNetworkContextParams(network_context_params.get());
network_context_params->context_name = std::string("system");
@@ -328,8 +305,6 @@ network::mojom::NetworkContextParamsPtr SystemNetworkContextManager::CreateNetwo
network_context_params->enable_ftp_url_support = true;
#endif
- network_context_params->primary_network_context = false;
-
proxy_config_monitor_.AddToNetworkContextParams(network_context_params.get());
return network_context_params;
diff --git a/src/core/net/system_network_context_manager.h b/src/core/net/system_network_context_manager.h
index 0dd503ce1..bd12fe217 100644
--- a/src/core/net/system_network_context_manager.h
+++ b/src/core/net/system_network_context_manager.h
@@ -130,8 +130,8 @@ public:
// SSL configuration updates.
void AddSSLConfigToNetworkContextParams(network::mojom::NetworkContextParams *network_context_params);
- // Returns default set of parameters for configuring the network service.
- network::mojom::NetworkContextParamsPtr CreateDefaultNetworkContextParams();
+ // Configures the default set of parameters for the network context.
+ void ConfigureDefaultNetworkContextParams(network::mojom::NetworkContextParams *);
private:
class URLLoaderFactoryForSystem;