Move the NTLM check to the URLRequestContextGetter delegate

This commit is contained in:
Paul Betts 2015-10-19 12:51:01 -07:00
parent 91a62640ab
commit 0d63eaa07b
2 changed files with 46 additions and 33 deletions

View file

@ -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));