| OLD | NEW |
| 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 Loading... |
| 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::StringToLowerASCII(scheme); | 109 std::string lower_scheme = base::ToLowerASCII(scheme); |
| 110 FactoryMap::iterator it = factory_map_.find(lower_scheme); | 110 FactoryMap::iterator it = factory_map_.find(lower_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_[lower_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::StringToLowerASCII(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. |
| 126 } | 126 } |
| 127 return it->second; | 127 return it->second; |
| 128 } | 128 } |
| 129 | 129 |
| 130 // static | 130 // static |
| 131 HttpAuthHandlerRegistryFactory* HttpAuthHandlerRegistryFactory::Create( | 131 HttpAuthHandlerRegistryFactory* HttpAuthHandlerRegistryFactory::Create( |
| 132 const std::vector<std::string>& supported_schemes, | 132 const std::vector<std::string>& supported_schemes, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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->scheme(); |
| 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::StringToLowerASCII(scheme); | 193 std::string lower_scheme = base::ToLowerASCII(scheme); |
| 194 FactoryMap::iterator it = factory_map_.find(lower_scheme); | 194 FactoryMap::iterator it = factory_map_.find(lower_scheme); |
| 195 if (it == factory_map_.end()) { | 195 if (it == factory_map_.end()) { |
| 196 handler->reset(); | 196 handler->reset(); |
| 197 return ERR_UNSUPPORTED_AUTH_SCHEME; | 197 return ERR_UNSUPPORTED_AUTH_SCHEME; |
| 198 } | 198 } |
| 199 DCHECK(it->second); | 199 DCHECK(it->second); |
| 200 return it->second->CreateAuthHandler(challenge, target, origin, reason, | 200 return it->second->CreateAuthHandler(challenge, target, origin, reason, |
| 201 digest_nonce_count, net_log, handler); | 201 digest_nonce_count, net_log, handler); |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace net | 204 } // namespace net |
| OLD | NEW |