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

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

Issue 1157333005: [net/http auth] Use strings to identify authentication schemes. Base URL: https://chromium.googlesource.com/chromium/src.git@master
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"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 const std::string& scheme, 99 const std::string& scheme,
100 URLSecurityManager* security_manager) { 100 URLSecurityManager* security_manager) {
101 HttpAuthHandlerFactory* factory = GetSchemeFactory(scheme); 101 HttpAuthHandlerFactory* factory = GetSchemeFactory(scheme);
102 if (factory) 102 if (factory)
103 factory->set_url_security_manager(security_manager); 103 factory->set_url_security_manager(security_manager);
104 } 104 }
105 105
106 void HttpAuthHandlerRegistryFactory::RegisterSchemeFactory( 106 void HttpAuthHandlerRegistryFactory::RegisterSchemeFactory(
107 const std::string& scheme, 107 const std::string& scheme,
108 HttpAuthHandlerFactory* factory) { 108 HttpAuthHandlerFactory* factory) {
109 std::string lower_scheme = base::ToLowerASCII(scheme); 109 DCHECK(HttpAuth::IsValidNormalizedScheme(scheme));
110 FactoryMap::iterator it = factory_map_.find(lower_scheme); 110 FactoryMap::iterator it = factory_map_.find(scheme);
111 if (it != factory_map_.end()) { 111 if (it != factory_map_.end()) {
112 delete it->second; 112 delete it->second;
113 } 113 }
114 if (factory) 114 if (factory)
115 factory_map_[lower_scheme] = factory; 115 factory_map_[scheme] = factory;
116 else 116 else
117 factory_map_.erase(it); 117 factory_map_.erase(it);
118 } 118 }
119 119
120 HttpAuthHandlerFactory* HttpAuthHandlerRegistryFactory::GetSchemeFactory( 120 HttpAuthHandlerFactory* HttpAuthHandlerRegistryFactory::GetSchemeFactory(
121 const std::string& scheme) const { 121 const std::string& scheme) const {
122 std::string lower_scheme = base::ToLowerASCII(scheme); 122 std::string lower_scheme = base::ToLowerASCII(scheme);
123 FactoryMap::const_iterator it = factory_map_.find(lower_scheme); 123 FactoryMap::const_iterator it = factory_map_.find(lower_scheme);
124 if (it == factory_map_.end()) { 124 if (it == factory_map_.end()) {
125 return NULL; // |scheme| is not registered. 125 return NULL; // |scheme| is not registered.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 178 }
179 179
180 int HttpAuthHandlerRegistryFactory::CreateAuthHandler( 180 int HttpAuthHandlerRegistryFactory::CreateAuthHandler(
181 HttpAuthChallengeTokenizer* challenge, 181 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->scheme(); 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 std::string lower_scheme = base::ToLowerASCII(scheme); 193 FactoryMap::iterator it = factory_map_.find(scheme);
194 FactoryMap::iterator it = factory_map_.find(lower_scheme);
195 if (it == factory_map_.end()) { 194 if (it == factory_map_.end()) {
196 handler->reset(); 195 handler->reset();
197 return ERR_UNSUPPORTED_AUTH_SCHEME; 196 return ERR_UNSUPPORTED_AUTH_SCHEME;
198 } 197 }
199 DCHECK(it->second); 198 DCHECK(it->second);
200 return it->second->CreateAuthHandler(challenge, target, origin, reason, 199 return it->second->CreateAuthHandler(challenge, target, origin, reason,
201 digest_nonce_count, net_log, handler); 200 digest_nonce_count, net_log, handler);
202 } 201 }
203 202
204 } // 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