summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/chrome_url_request_context.cc
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-15 14:25:50 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-15 14:25:50 +0000
commitfa55e1931013409ddbce59ed39f8b12a351fd0c4 (patch)
tree1ff77c48d22f36173c1fa63ae8acb1faf896aa0d /chrome/browser/net/chrome_url_request_context.cc
parente8da0a0066695284dbf698c9900617b3b159f33b (diff)
downloadchromium_src-fa55e1931013409ddbce59ed39f8b12a351fd0c4.zip
chromium_src-fa55e1931013409ddbce59ed39f8b12a351fd0c4.tar.gz
chromium_src-fa55e1931013409ddbce59ed39f8b12a351fd0c4.tar.bz2
Added factories for HttpAuthHandler.
The driving rationale for this change was to prevent choosing an AuthHandler when it is not supported on the system due to a missing runtime component (such as not being able to locate a gssapi shared library when seeing a Negotiate scheme). It also has the advantage (currently unused) of determining some per-auth-scheme properties only the first time that a challenge for that scheme is seen (such as maximum token length for the SSPI implementation of NTLM). Finally, it may make unit tests easier to generate since the factory can be easily mocked. BUG=34795 TEST=New unit test for HttpAuthHandlerDispatchFactory. Review URL: http://codereview.chromium.org/582007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39065 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/chrome_url_request_context.cc')
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc29
1 files changed, 26 insertions, 3 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 2afff1d..79a94cd 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -142,6 +142,8 @@ ChromeURLRequestContext* FactoryForOriginal::Create() {
// Global host resolver for the context.
context->set_host_resolver(io_thread()->globals()->host_resolver);
+ context->set_http_auth_handler_factory(
+ io_thread()->globals()->http_auth_handler_factory.get());
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
@@ -157,6 +159,7 @@ ChromeURLRequestContext* FactoryForOriginal::Create() {
context->host_resolver(),
context->proxy_service(),
context->ssl_config_service(),
+ context->http_auth_handler_factory(),
disk_cache_path_, cache_size_);
if (command_line.HasSwitch(switches::kDisableByteRangeSupport))
@@ -230,6 +233,9 @@ ChromeURLRequestContext* FactoryForExtensions::Create() {
const char* schemes[] = {chrome::kExtensionScheme};
cookie_monster->SetCookieableSchemes(schemes, 1);
context->set_cookie_store(cookie_monster);
+ // TODO(cbentzel): How should extensions handle HTTP Authentication?
+ context->set_http_auth_handler_factory(
+ io_thread()->globals()->http_auth_handler_factory.get());
return context;
}
@@ -257,14 +263,20 @@ ChromeURLRequestContext* FactoryForOffTheRecord::Create() {
ChromeURLRequestContext* original_context =
original_context_getter_->GetIOContext();
- // Share the same proxy service and host resolver as the original profile.
+ // Share the same proxy service, host resolver, and http_auth_handler_factory
+ // as the original profile.
context->set_host_resolver(original_context->host_resolver());
context->set_proxy_service(original_context->proxy_service());
+ context->set_http_auth_handler_factory(
+ original_context->http_auth_handler_factory());
net::HttpCache* cache =
new net::HttpCache(io_thread()->globals()->network_change_notifier.get(),
- context->host_resolver(), context->proxy_service(),
- context->ssl_config_service(), 0);
+ context->host_resolver(),
+ context->proxy_service(),
+ context->ssl_config_service(),
+ context->http_auth_handler_factory(),
+ 0);
context->set_cookie_store(new net::CookieMonster(NULL));
context->set_cookie_policy(
new ChromeCookiePolicy(host_content_settings_map_));
@@ -319,6 +331,9 @@ ChromeURLRequestContext* FactoryForMedia::Create() {
// Share the same proxy service of the common profile.
context->set_proxy_service(main_context->proxy_service());
+ context->set_http_auth_handler_factory(
+ main_context->http_auth_handler_factory());
+
// Also share the cookie store of the common profile.
context->set_cookie_store(main_context->cookie_store());
context->set_cookie_policy(
@@ -350,6 +365,7 @@ ChromeURLRequestContext* FactoryForMedia::Create() {
main_context->host_resolver(),
main_context->proxy_service(),
main_context->ssl_config_service(),
+ main_context->http_auth_handler_factory(),
disk_cache_path_, cache_size_);
}
@@ -747,6 +763,13 @@ ChromeURLRequestContext::ChromeURLRequestContext(
accept_language_ = other->accept_language_;
accept_charset_ = other->accept_charset_;
referrer_charset_ = other->referrer_charset_;
+ // NOTE(cbentzel): Sharing the http_auth_handler_factory_ is potentially
+ // dangerous because it is a raw pointer. However, the current implementation
+ // creates and destroys the pointed-to-object in the io_thread and it is
+ // valid for the lifetime of all ChromeURLRequestContext objects.
+ // If this is no longer the case, HttpAuthHandlerFactory will need to be
+ // ref-counted or cloneable.
+ http_auth_handler_factory_ = other->http_auth_handler_factory_;
// Set ChromeURLRequestContext members
extension_info_ = other->extension_info_;