OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_mock.h" | 5 #include "net/http/http_auth_handler_mock.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 | 95 |
96 bool HttpAuthHandlerMock::AllowsDefaultCredentials() { | 96 bool HttpAuthHandlerMock::AllowsDefaultCredentials() { |
97 return allows_default_credentials_; | 97 return allows_default_credentials_; |
98 } | 98 } |
99 | 99 |
100 bool HttpAuthHandlerMock::AllowsExplicitCredentials() { | 100 bool HttpAuthHandlerMock::AllowsExplicitCredentials() { |
101 return allows_explicit_credentials_; | 101 return allows_explicit_credentials_; |
102 } | 102 } |
103 | 103 |
104 bool HttpAuthHandlerMock::Init(HttpAuthChallengeTokenizer* challenge) { | 104 bool HttpAuthHandlerMock::Init(HttpAuthChallengeTokenizer* challenge, |
| 105 const HttpResponseInfo& response_info) { |
105 auth_scheme_ = HttpAuth::AUTH_SCHEME_MOCK; | 106 auth_scheme_ = HttpAuth::AUTH_SCHEME_MOCK; |
106 score_ = 1; | 107 score_ = 1; |
107 properties_ = connection_based_ ? IS_CONNECTION_BASED : 0; | 108 properties_ = connection_based_ ? IS_CONNECTION_BASED : 0; |
108 return true; | 109 return true; |
109 } | 110 } |
110 | 111 |
111 int HttpAuthHandlerMock::GenerateAuthTokenImpl( | 112 int HttpAuthHandlerMock::GenerateAuthTokenImpl( |
112 const AuthCredentials* credentials, | 113 const AuthCredentials* credentials, |
113 const HttpRequestInfo* request, | 114 const HttpRequestInfo* request, |
114 const CompletionCallback& callback, | 115 const CompletionCallback& callback, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 161 } |
161 | 162 |
162 void HttpAuthHandlerMock::Factory::AddMockHandler( | 163 void HttpAuthHandlerMock::Factory::AddMockHandler( |
163 HttpAuthHandler* handler, HttpAuth::Target target) { | 164 HttpAuthHandler* handler, HttpAuth::Target target) { |
164 handlers_[target].push_back(make_scoped_ptr(handler)); | 165 handlers_[target].push_back(make_scoped_ptr(handler)); |
165 } | 166 } |
166 | 167 |
167 int HttpAuthHandlerMock::Factory::CreateAuthHandler( | 168 int HttpAuthHandlerMock::Factory::CreateAuthHandler( |
168 HttpAuthChallengeTokenizer* challenge, | 169 HttpAuthChallengeTokenizer* challenge, |
169 HttpAuth::Target target, | 170 HttpAuth::Target target, |
| 171 const HttpResponseInfo& response_info, |
170 const GURL& origin, | 172 const GURL& origin, |
171 CreateReason reason, | 173 CreateReason reason, |
172 int nonce_count, | 174 int nonce_count, |
173 const BoundNetLog& net_log, | 175 const BoundNetLog& net_log, |
174 scoped_ptr<HttpAuthHandler>* handler) { | 176 scoped_ptr<HttpAuthHandler>* handler) { |
175 if (handlers_[target].empty()) | 177 if (handlers_[target].empty()) |
176 return ERR_UNEXPECTED; | 178 return ERR_UNEXPECTED; |
177 scoped_ptr<HttpAuthHandler> tmp_handler = std::move(handlers_[target][0]); | 179 scoped_ptr<HttpAuthHandler> tmp_handler = std::move(handlers_[target][0]); |
178 std::vector<scoped_ptr<HttpAuthHandler>>& handlers = handlers_[target]; | 180 std::vector<scoped_ptr<HttpAuthHandler>>& handlers = handlers_[target]; |
179 handlers.erase(handlers.begin()); | 181 handlers.erase(handlers.begin()); |
180 if (do_init_from_challenge_ && | 182 if (do_init_from_challenge_ && |
181 !tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) | 183 !tmp_handler->InitFromChallenge(challenge, target, response_info, origin, |
| 184 net_log)) |
182 return ERR_INVALID_RESPONSE; | 185 return ERR_INVALID_RESPONSE; |
183 handler->swap(tmp_handler); | 186 handler->swap(tmp_handler); |
184 return OK; | 187 return OK; |
185 } | 188 } |
186 | 189 |
187 } // namespace net | 190 } // namespace net |
OLD | NEW |