From bba302d0ced354b71853bbf3582f4034ea825b9b Mon Sep 17 00:00:00 2001 From: aberent Date: Thu, 3 Dec 2015 02:20:19 -0800 Subject: Allow dynamic updating of authentication policies This allows a number of the authentication policies to be updated dynamically after the IO thread has been created. BUG=545534 Review URL: https://codereview.chromium.org/1414313002 Cr-Commit-Position: refs/heads/master@{#362940} --- google_apis/gcm/tools/mcs_probe.cc | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'google_apis') diff --git a/google_apis/gcm/tools/mcs_probe.cc b/google_apis/gcm/tools/mcs_probe.cc index b2acc19..2e2c593 100644 --- a/google_apis/gcm/tools/mcs_probe.cc +++ b/google_apis/gcm/tools/mcs_probe.cc @@ -38,6 +38,8 @@ #include "net/cert/cert_verifier.h" #include "net/dns/host_resolver.h" #include "net/http/http_auth_handler_factory.h" +#include "net/http/http_auth_preferences.h" +#include "net/http/http_auth_scheme.h" #include "net/http/http_network_session.h" #include "net/http/http_server_properties_impl.h" #include "net/http/transport_security_state.h" @@ -183,6 +185,27 @@ class MyTestCertVerifier : public net::CertVerifier { } }; +class MCSProbeAuthPreferences : public net::HttpAuthPreferences { + public: + MCSProbeAuthPreferences() + : HttpAuthPreferences(std::vector() +#if defined(OS_POSIX) && !defined(OS_ANDROID) + , + std::string() +#endif + ) { + } + bool IsSupportedScheme(const std::string& scheme) const override { + return scheme == std::string(net::kBasicAuthScheme); + } + bool NegotiateDisableCnameLookup() const override { return false; } + bool NegotiateEnablePort() const override { return false; } + bool CanUseDefaultCredentials(const GURL& auth_origin) const override { + return false; + } + bool CanDelegate(const GURL& auth_origin) const override { return false; } +}; + class MCSProbe { public: MCSProbe( @@ -225,7 +248,7 @@ class MCSProbe { scoped_ptr cert_verifier_; scoped_ptr system_channel_id_service_; scoped_ptr transport_security_state_; - scoped_ptr url_security_manager_; + MCSProbeAuthPreferences http_auth_preferences_; scoped_ptr http_auth_handler_factory_; scoped_ptr http_server_properties_; scoped_ptr host_mapping_rules_; @@ -376,10 +399,10 @@ void MCSProbe::InitializeNetworkState() { base::WorkerPool::GetTaskRunner(true))); transport_security_state_.reset(new net::TransportSecurityState()); - url_security_manager_.reset(net::URLSecurityManager::Create(NULL, NULL)); - http_auth_handler_factory_.reset(net::HttpAuthHandlerRegistryFactory::Create( - std::vector(1, "basic"), url_security_manager_.get(), - host_resolver_.get(), std::string(), std::string(), false, false)); + http_auth_handler_factory_ = + net::HttpAuthHandlerRegistryFactory::Create(&http_auth_preferences_, + host_resolver_.get()) + .Pass(); http_server_properties_.reset(new net::HttpServerPropertiesImpl()); host_mapping_rules_.reset(new net::HostMappingRules()); proxy_service_ = net::ProxyService::CreateDirectWithNetLog(&net_log_); -- cgit v1.1