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_H_ | 5 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_H_ |
6 #define NET_HTTP_HTTP_AUTH_HANDLER_H_ | 6 #define NET_HTTP_HTTP_AUTH_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
| 11 #include "base/string16.h" |
11 #include "base/time.h" | 12 #include "base/time.h" |
12 #include "net/base/completion_callback.h" | 13 #include "net/base/completion_callback.h" |
13 #include "net/base/net_log.h" | 14 #include "net/base/net_log.h" |
14 #include "net/http/http_auth.h" | 15 #include "net/http/http_auth.h" |
15 | 16 |
16 class Histogram; | 17 class Histogram; |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 | 20 |
20 class HostResolver; | 21 class HostResolver; |
(...skipping 29 matching lines...) Expand all Loading... |
50 // The return value is a net error code. | 51 // The return value is a net error code. |
51 // If |OK| is returned, |*auth_token| is filled in with an authentication | 52 // If |OK| is returned, |*auth_token| is filled in with an authentication |
52 // token which can be inserted in the HTTP request. | 53 // token which can be inserted in the HTTP request. |
53 // If |ERR_IO_PENDING| is returned, |*auth_token| will be filled in | 54 // If |ERR_IO_PENDING| is returned, |*auth_token| will be filled in |
54 // asynchronously and |callback| will be invoked. The lifetime of | 55 // asynchronously and |callback| will be invoked. The lifetime of |
55 // |request|, |callback|, and |auth_token| must last until |callback| is | 56 // |request|, |callback|, and |auth_token| must last until |callback| is |
56 // invoked, but |username| and |password| are only used during the initial | 57 // invoked, but |username| and |password| are only used during the initial |
57 // call. | 58 // call. |
58 // Otherwise, there was a problem generating a token synchronously, and the | 59 // Otherwise, there was a problem generating a token synchronously, and the |
59 // value of |*auth_token| is unspecified. | 60 // value of |*auth_token| is unspecified. |
60 int GenerateAuthToken(const std::wstring* username, | 61 int GenerateAuthToken(const string16* username, |
61 const std::wstring* password, | 62 const string16* password, |
62 const HttpRequestInfo* request, | 63 const HttpRequestInfo* request, |
63 CompletionCallback* callback, | 64 CompletionCallback* callback, |
64 std::string* auth_token); | 65 std::string* auth_token); |
65 | 66 |
66 // Lowercase name of the auth scheme | 67 // Lowercase name of the auth scheme |
67 const std::string& scheme() const { | 68 const std::string& scheme() const { |
68 return scheme_; | 69 return scheme_; |
69 } | 70 } |
70 | 71 |
71 // The realm value that was parsed during Init(). | 72 // The realm value that was parsed during Init(). |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // |challenge| must be non-NULL and have already tokenized the | 131 // |challenge| must be non-NULL and have already tokenized the |
131 // authentication scheme, but none of the tokens occuring after the | 132 // authentication scheme, but none of the tokens occuring after the |
132 // authentication scheme. | 133 // authentication scheme. |
133 // Implementations are expcted to initialize the following members: | 134 // Implementations are expcted to initialize the following members: |
134 // scheme_, realm_, score_, properties_ | 135 // scheme_, realm_, score_, properties_ |
135 virtual bool Init(HttpAuth::ChallengeTokenizer* challenge) = 0; | 136 virtual bool Init(HttpAuth::ChallengeTokenizer* challenge) = 0; |
136 | 137 |
137 // |GenerateAuthTokenImpl()} is the auth-scheme specific implementation | 138 // |GenerateAuthTokenImpl()} is the auth-scheme specific implementation |
138 // of generating the next auth token. Callers sohuld use |GenerateAuthToken()| | 139 // of generating the next auth token. Callers sohuld use |GenerateAuthToken()| |
139 // which will in turn call |GenerateAuthTokenImpl()| | 140 // which will in turn call |GenerateAuthTokenImpl()| |
140 virtual int GenerateAuthTokenImpl(const std::wstring* username, | 141 virtual int GenerateAuthTokenImpl(const string16* username, |
141 const std::wstring* password, | 142 const string16* password, |
142 const HttpRequestInfo* request, | 143 const HttpRequestInfo* request, |
143 CompletionCallback* callback, | 144 CompletionCallback* callback, |
144 std::string* auth_token) = 0; | 145 std::string* auth_token) = 0; |
145 | 146 |
146 // The lowercase auth-scheme {"basic", "digest", "ntlm", "negotiate"} | 147 // The lowercase auth-scheme {"basic", "digest", "ntlm", "negotiate"} |
147 std::string scheme_; | 148 std::string scheme_; |
148 | 149 |
149 // The realm. Used by "basic" and "digest". | 150 // The realm. Used by "basic" and "digest". |
150 std::string realm_; | 151 std::string realm_; |
151 | 152 |
(...skipping 24 matching lines...) Expand all Loading... |
176 CompletionCallback* original_callback_; | 177 CompletionCallback* original_callback_; |
177 CompletionCallbackImpl<HttpAuthHandler> wrapper_callback_; | 178 CompletionCallbackImpl<HttpAuthHandler> wrapper_callback_; |
178 // When GenerateAuthToken was called. | 179 // When GenerateAuthToken was called. |
179 base::TimeTicks generate_auth_token_start_; | 180 base::TimeTicks generate_auth_token_start_; |
180 scoped_refptr<Histogram> histogram_; | 181 scoped_refptr<Histogram> histogram_; |
181 }; | 182 }; |
182 | 183 |
183 } // namespace net | 184 } // namespace net |
184 | 185 |
185 #endif // NET_HTTP_HTTP_AUTH_HANDLER_H_ | 186 #endif // NET_HTTP_HTTP_AUTH_HANDLER_H_ |
OLD | NEW |