| 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 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_FACTORY_H_ | 5 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_FACTORY_H_ |
| 6 #define NET_HTTP_HTTP_AUTH_HANDLER_FACTORY_H_ | 6 #define NET_HTTP_HTTP_AUTH_HANDLER_FACTORY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // authentication scheme such as Basic, Digest, or Negotiate. | 98 // authentication scheme such as Basic, Digest, or Negotiate. |
| 99 // The |*factory| object is assumed to be new-allocated, and its lifetime | 99 // The |*factory| object is assumed to be new-allocated, and its lifetime |
| 100 // will be managed by this HttpAuthHandlerRegistryFactory object (including | 100 // will be managed by this HttpAuthHandlerRegistryFactory object (including |
| 101 // deleting it when it is no longer used. | 101 // deleting it when it is no longer used. |
| 102 // A NULL |factory| value means that HttpAuthHandlers's will not be created | 102 // A NULL |factory| value means that HttpAuthHandlers's will not be created |
| 103 // for |scheme|. If a factory object used to exist for |scheme|, it will be | 103 // for |scheme|. If a factory object used to exist for |scheme|, it will be |
| 104 // deleted. | 104 // deleted. |
| 105 void RegisterSchemeFactory(const std::string& scheme, | 105 void RegisterSchemeFactory(const std::string& scheme, |
| 106 HttpAuthHandlerFactory* factory); | 106 HttpAuthHandlerFactory* factory); |
| 107 | 107 |
| 108 // Retrieve the factory for the specified |scheme|. If no factory exists |
| 109 // for the |scheme|, NULL is returned. The returned factory must not be |
| 110 // deleted by the caller, and it is guaranteed to be valid until either |
| 111 // a new factory is registered for the same scheme, or until this |
| 112 // registry factory is destroyed. |
| 113 HttpAuthHandlerFactory* GetSchemeFactory(const std::string& scheme) const; |
| 114 |
| 108 // Creates an auth handler by dispatching out to the registered factories | 115 // Creates an auth handler by dispatching out to the registered factories |
| 109 // based on the first token in |challenge|. | 116 // based on the first token in |challenge|. |
| 110 virtual int CreateAuthHandler(HttpAuth::ChallengeTokenizer* challenge, | 117 virtual int CreateAuthHandler(HttpAuth::ChallengeTokenizer* challenge, |
| 111 HttpAuth::Target target, | 118 HttpAuth::Target target, |
| 112 const GURL& origin, | 119 const GURL& origin, |
| 113 scoped_refptr<HttpAuthHandler>* handler); | 120 scoped_refptr<HttpAuthHandler>* handler); |
| 114 | 121 |
| 115 private: | 122 private: |
| 116 // Retrieve the factory for the specified |scheme| | |
| 117 HttpAuthHandlerFactory* GetSchemeFactory(const std::string& scheme) const; | |
| 118 | |
| 119 typedef std::map<std::string, HttpAuthHandlerFactory*> FactoryMap; | 123 typedef std::map<std::string, HttpAuthHandlerFactory*> FactoryMap; |
| 120 | 124 |
| 121 FactoryMap factory_map_; | 125 FactoryMap factory_map_; |
| 122 DISALLOW_COPY_AND_ASSIGN(HttpAuthHandlerRegistryFactory); | 126 DISALLOW_COPY_AND_ASSIGN(HttpAuthHandlerRegistryFactory); |
| 123 }; | 127 }; |
| 124 | 128 |
| 125 } // namespace net | 129 } // namespace net |
| 126 | 130 |
| 127 #endif // NET_HTTP_HTTP_AUTH_HANDLER_FACTORY_H_ | 131 #endif // NET_HTTP_HTTP_AUTH_HANDLER_FACTORY_H_ |
| OLD | NEW |