diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index bc42f8e460..08149a471a 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -84,22 +84,24 @@ const char kProxyPacUrl[] = "proxy-pac-url"; } // namespace -ExplicitURLSecurityManager::ExplicitURLSecurityManager() : - allow_default_creds_(false), + +URLRequestContextGetter::DelegateURLSecurityManager::DelegateURLSecurityManager + (URLRequestContextGetter::Delegate* delegate) : + delegate_(delegate) {} + +bool URLRequestContextGetter::DelegateURLSecurityManager::CanUseDefaultCredentials + (const GURL& auth_origin) const { + return delegate_->AllowNTLMCredentialsForDomain(auth_origin); +} + +bool URLRequestContextGetter::DelegateURLSecurityManager::CanDelegate + (const GURL& auth_origin) const { + return delegate_->CanDelegateURLSecurity(auth_origin); +} + +URLRequestContextGetter::Delegate::Delegate() : orig_url_sec_mgr_(net::URLSecurityManager::Create(NULL, NULL)) {} -bool ExplicitURLSecurityManager::CanUseDefaultCredentials(const GURL& auth_origin) const { - if (allow_default_creds_) { - return true; - } - - return orig_url_sec_mgr_->CanUseDefaultCredentials(auth_origin); -} - -bool ExplicitURLSecurityManager::CanDelegate(const GURL& auth_origin) const { - return orig_url_sec_mgr_->CanDelegate(auth_origin); -} - std::string URLRequestContextGetter::Delegate::GetUserAgent() { return base::EmptyString(); } @@ -144,6 +146,15 @@ net::SSLConfigService* URLRequestContextGetter::Delegate::CreateSSLConfigService return new net::SSLConfigServiceDefaults; } +bool URLRequestContextGetter::Delegate::AllowNTLMCredentialsForDomain(const GURL& auth_origin) { + return orig_url_sec_mgr_->CanUseDefaultCredentials(auth_origin); +} + +bool URLRequestContextGetter::Delegate::CanDelegateURLSecurity(const GURL& auth_origin) { + return orig_url_sec_mgr_->CanDelegate(auth_origin); +} + + URLRequestContextGetter::URLRequestContextGetter( Delegate* delegate, DevToolsNetworkController* controller, @@ -161,7 +172,7 @@ URLRequestContextGetter::URLRequestContextGetter( in_memory_(in_memory), io_loop_(io_loop), file_loop_(file_loop), - url_sec_mgr_(new ExplicitURLSecurityManager()), + url_sec_mgr_(new URLRequestContextGetter::DelegateURLSecurityManager(delegate)), protocol_interceptors_(protocol_interceptors.Pass()) { // Must first be created on the UI thread. DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); diff --git a/brightray/browser/url_request_context_getter.h b/brightray/browser/url_request_context_getter.h index 78dc5c4eb8..ed142d4790 100644 --- a/brightray/browser/url_request_context_getter.h +++ b/brightray/browser/url_request_context_getter.h @@ -30,27 +30,11 @@ namespace brightray { class DevToolsNetworkController; class NetLog; -class ExplicitURLSecurityManager : public net::URLSecurityManager { - public: - ExplicitURLSecurityManager(); - - bool CanUseDefaultCredentials(const GURL& auth_origin) const override; - bool CanDelegate(const GURL& auth_origin) const override; - - void AllowNTLMCredentialsForAllDomains(bool should_allow) { allow_default_creds_ = should_allow; } - - private: - bool allow_default_creds_; - scoped_ptr orig_url_sec_mgr_; - - DISALLOW_COPY_AND_ASSIGN(ExplicitURLSecurityManager); -}; - class URLRequestContextGetter : public net::URLRequestContextGetter { public: class Delegate { public: - Delegate() {} + Delegate(); virtual ~Delegate() {} virtual net::NetworkDelegate* CreateNetworkDelegate() { return NULL; } @@ -61,6 +45,24 @@ class URLRequestContextGetter : public net::URLRequestContextGetter { virtual net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory( const base::FilePath& base_path); virtual net::SSLConfigService* CreateSSLConfigService(); + virtual bool AllowNTLMCredentialsForDomain(const GURL& auth_origin); + virtual bool CanDelegateURLSecurity(const GURL& auth_origin); + + private: + scoped_ptr orig_url_sec_mgr_; + }; + + class DelegateURLSecurityManager : public net::URLSecurityManager { + public: + DelegateURLSecurityManager(URLRequestContextGetter::Delegate* delegate); + + bool CanUseDefaultCredentials(const GURL& auth_origin) const override; + bool CanDelegate(const GURL& auth_origin) const override; + + private: + URLRequestContextGetter::Delegate* delegate_; + + DISALLOW_COPY_AND_ASSIGN(DelegateURLSecurityManager); }; URLRequestContextGetter( @@ -98,7 +100,7 @@ class URLRequestContextGetter : public net::URLRequestContextGetter { scoped_ptr storage_; scoped_ptr url_request_context_; scoped_ptr host_mapping_rules_; - scoped_ptr url_sec_mgr_; + scoped_ptr url_sec_mgr_; content::ProtocolHandlerMap protocol_handlers_; content::URLRequestInterceptorScopedVector protocol_interceptors_;