Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: net/http/http_auth_handler_factory.cc

Issue 1383613002: [net/http auth] Cleanup. Method names, and constness. Base URL: https://chromium.googlesource.com/chromium/src.git@mock-auth-handler-generalization
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_auth_handler_factory.h ('k') | net/http/http_auth_handler_factory_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_auth_handler_factory.h" 5 #include "net/http/http_auth_handler_factory.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/http/http_auth_challenge_tokenizer.h" 10 #include "net/http/http_auth_challenge_tokenizer.h"
11 #include "net/http/http_auth_filter.h" 11 #include "net/http/http_auth_filter.h"
12 #include "net/http/http_auth_handler_basic.h" 12 #include "net/http/http_auth_handler_basic.h"
13 #include "net/http/http_auth_handler_digest.h" 13 #include "net/http/http_auth_handler_digest.h"
14 #include "net/http/http_auth_handler_ntlm.h" 14 #include "net/http/http_auth_handler_ntlm.h"
15 15
16 #if defined(USE_KERBEROS) 16 #if defined(USE_KERBEROS)
17 #include "net/http/http_auth_handler_negotiate.h" 17 #include "net/http/http_auth_handler_negotiate.h"
18 #endif 18 #endif
19 19
20 namespace net { 20 namespace net {
21 21
22 int HttpAuthHandlerFactory::CreateAuthHandlerFromString( 22 int HttpAuthHandlerFactory::CreateAuthHandlerFromString(
23 const std::string& challenge, 23 const std::string& challenge,
24 HttpAuth::Target target, 24 HttpAuth::Target target,
25 const GURL& origin, 25 const GURL& origin,
26 const BoundNetLog& net_log, 26 const BoundNetLog& net_log,
27 scoped_ptr<HttpAuthHandler>* handler) { 27 scoped_ptr<HttpAuthHandler>* handler) {
28 HttpAuthChallengeTokenizer props(challenge.begin(), challenge.end()); 28 HttpAuthChallengeTokenizer props(challenge.begin(), challenge.end());
29 return CreateAuthHandler(&props, target, origin, CREATE_CHALLENGE, 1, 29 return CreateAuthHandler(props, target, origin, CREATE_CHALLENGE, 1, net_log,
30 net_log, handler); 30 handler);
31 } 31 }
32 32
33 int HttpAuthHandlerFactory::CreatePreemptiveAuthHandlerFromString( 33 int HttpAuthHandlerFactory::CreatePreemptiveAuthHandlerFromString(
34 const std::string& challenge, 34 const std::string& challenge,
35 HttpAuth::Target target, 35 HttpAuth::Target target,
36 const GURL& origin, 36 const GURL& origin,
37 int digest_nonce_count, 37 int digest_nonce_count,
38 const BoundNetLog& net_log, 38 const BoundNetLog& net_log,
39 scoped_ptr<HttpAuthHandler>* handler) { 39 scoped_ptr<HttpAuthHandler>* handler) {
40 HttpAuthChallengeTokenizer props(challenge.begin(), challenge.end()); 40 HttpAuthChallengeTokenizer props(challenge.begin(), challenge.end());
41 return CreateAuthHandler(&props, target, origin, CREATE_PREEMPTIVE, 41 return CreateAuthHandler(props, target, origin, CREATE_PREEMPTIVE,
42 digest_nonce_count, net_log, handler); 42 digest_nonce_count, net_log, handler);
43 } 43 }
44 44
45 // static 45 // static
46 scoped_ptr<HttpAuthHandlerRegistryFactory> 46 scoped_ptr<HttpAuthHandlerRegistryFactory>
47 HttpAuthHandlerFactory::CreateDefault(HostResolver* host_resolver) { 47 HttpAuthHandlerFactory::CreateDefault(HostResolver* host_resolver) {
48 DCHECK(host_resolver); 48 DCHECK(host_resolver);
49 scoped_ptr<HttpAuthHandlerRegistryFactory> registry_factory = 49 scoped_ptr<HttpAuthHandlerRegistryFactory> registry_factory =
50 make_scoped_ptr(new HttpAuthHandlerRegistryFactory()); 50 make_scoped_ptr(new HttpAuthHandlerRegistryFactory());
51 registry_factory->RegisterSchemeFactory( 51 registry_factory->RegisterSchemeFactory(
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 negotiate_factory->set_disable_cname_lookup(negotiate_disable_cname_lookup); 171 negotiate_factory->set_disable_cname_lookup(negotiate_disable_cname_lookup);
172 negotiate_factory->set_use_port(negotiate_enable_port); 172 negotiate_factory->set_use_port(negotiate_enable_port);
173 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); 173 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory);
174 } 174 }
175 #endif // defined(USE_KERBEROS) 175 #endif // defined(USE_KERBEROS)
176 176
177 return registry_factory; 177 return registry_factory;
178 } 178 }
179 179
180 int HttpAuthHandlerRegistryFactory::CreateAuthHandler( 180 int HttpAuthHandlerRegistryFactory::CreateAuthHandler(
181 HttpAuthChallengeTokenizer* challenge, 181 const HttpAuthChallengeTokenizer& challenge,
182 HttpAuth::Target target, 182 HttpAuth::Target target,
183 const GURL& origin, 183 const GURL& origin,
184 CreateReason reason, 184 CreateReason reason,
185 int digest_nonce_count, 185 int digest_nonce_count,
186 const BoundNetLog& net_log, 186 const BoundNetLog& net_log,
187 scoped_ptr<HttpAuthHandler>* handler) { 187 scoped_ptr<HttpAuthHandler>* handler) {
188 std::string scheme = challenge->NormalizedScheme(); 188 std::string scheme = challenge.NormalizedScheme();
189 if (scheme.empty()) { 189 if (scheme.empty()) {
190 handler->reset(); 190 handler->reset();
191 return ERR_INVALID_RESPONSE; 191 return ERR_INVALID_RESPONSE;
192 } 192 }
193 FactoryMap::iterator it = factory_map_.find(scheme); 193 FactoryMap::iterator it = factory_map_.find(scheme);
194 if (it == factory_map_.end()) { 194 if (it == factory_map_.end()) {
195 handler->reset(); 195 handler->reset();
196 return ERR_UNSUPPORTED_AUTH_SCHEME; 196 return ERR_UNSUPPORTED_AUTH_SCHEME;
197 } 197 }
198 DCHECK(it->second); 198 DCHECK(it->second);
199 return it->second->CreateAuthHandler(challenge, target, origin, reason, 199 return it->second->CreateAuthHandler(challenge, target, origin, reason,
200 digest_nonce_count, net_log, handler); 200 digest_nonce_count, net_log, handler);
201 } 201 }
202 202
203 } // namespace net 203 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler_factory.h ('k') | net/http/http_auth_handler_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698