Move the NTLM check to the URLRequestContextGetter delegate
This commit is contained in:
parent
91a62640ab
commit
0d63eaa07b
2 changed files with 46 additions and 33 deletions
|
@ -84,22 +84,24 @@ const char kProxyPacUrl[] = "proxy-pac-url";
|
||||||
|
|
||||||
} // namespace
|
} // 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)) {}
|
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() {
|
std::string URLRequestContextGetter::Delegate::GetUserAgent() {
|
||||||
return base::EmptyString();
|
return base::EmptyString();
|
||||||
}
|
}
|
||||||
|
@ -144,6 +146,15 @@ net::SSLConfigService* URLRequestContextGetter::Delegate::CreateSSLConfigService
|
||||||
return new net::SSLConfigServiceDefaults;
|
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(
|
URLRequestContextGetter::URLRequestContextGetter(
|
||||||
Delegate* delegate,
|
Delegate* delegate,
|
||||||
DevToolsNetworkController* controller,
|
DevToolsNetworkController* controller,
|
||||||
|
@ -161,7 +172,7 @@ URLRequestContextGetter::URLRequestContextGetter(
|
||||||
in_memory_(in_memory),
|
in_memory_(in_memory),
|
||||||
io_loop_(io_loop),
|
io_loop_(io_loop),
|
||||||
file_loop_(file_loop),
|
file_loop_(file_loop),
|
||||||
url_sec_mgr_(new ExplicitURLSecurityManager()),
|
url_sec_mgr_(new URLRequestContextGetter::DelegateURLSecurityManager(delegate)),
|
||||||
protocol_interceptors_(protocol_interceptors.Pass()) {
|
protocol_interceptors_(protocol_interceptors.Pass()) {
|
||||||
// Must first be created on the UI thread.
|
// Must first be created on the UI thread.
|
||||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||||
|
|
|
@ -30,27 +30,11 @@ namespace brightray {
|
||||||
class DevToolsNetworkController;
|
class DevToolsNetworkController;
|
||||||
class NetLog;
|
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<net::URLSecurityManager> orig_url_sec_mgr_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ExplicitURLSecurityManager);
|
|
||||||
};
|
|
||||||
|
|
||||||
class URLRequestContextGetter : public net::URLRequestContextGetter {
|
class URLRequestContextGetter : public net::URLRequestContextGetter {
|
||||||
public:
|
public:
|
||||||
class Delegate {
|
class Delegate {
|
||||||
public:
|
public:
|
||||||
Delegate() {}
|
Delegate();
|
||||||
virtual ~Delegate() {}
|
virtual ~Delegate() {}
|
||||||
|
|
||||||
virtual net::NetworkDelegate* CreateNetworkDelegate() { return NULL; }
|
virtual net::NetworkDelegate* CreateNetworkDelegate() { return NULL; }
|
||||||
|
@ -61,6 +45,24 @@ class URLRequestContextGetter : public net::URLRequestContextGetter {
|
||||||
virtual net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory(
|
virtual net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory(
|
||||||
const base::FilePath& base_path);
|
const base::FilePath& base_path);
|
||||||
virtual net::SSLConfigService* CreateSSLConfigService();
|
virtual net::SSLConfigService* CreateSSLConfigService();
|
||||||
|
virtual bool AllowNTLMCredentialsForDomain(const GURL& auth_origin);
|
||||||
|
virtual bool CanDelegateURLSecurity(const GURL& auth_origin);
|
||||||
|
|
||||||
|
private:
|
||||||
|
scoped_ptr<net::URLSecurityManager> 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(
|
URLRequestContextGetter(
|
||||||
|
@ -98,7 +100,7 @@ class URLRequestContextGetter : public net::URLRequestContextGetter {
|
||||||
scoped_ptr<net::URLRequestContextStorage> storage_;
|
scoped_ptr<net::URLRequestContextStorage> storage_;
|
||||||
scoped_ptr<net::URLRequestContext> url_request_context_;
|
scoped_ptr<net::URLRequestContext> url_request_context_;
|
||||||
scoped_ptr<net::HostMappingRules> host_mapping_rules_;
|
scoped_ptr<net::HostMappingRules> host_mapping_rules_;
|
||||||
scoped_ptr<ExplicitURLSecurityManager> url_sec_mgr_;
|
scoped_ptr<net::URLSecurityManager> url_sec_mgr_;
|
||||||
content::ProtocolHandlerMap protocol_handlers_;
|
content::ProtocolHandlerMap protocol_handlers_;
|
||||||
content::URLRequestInterceptorScopedVector protocol_interceptors_;
|
content::URLRequestInterceptorScopedVector protocol_interceptors_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue