OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/loader/resource_loader.h" | 5 #include "content/browser/loader/resource_loader.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "content/browser/browser_thread_impl.h" | 8 #include "content/browser/browser_thread_impl.h" |
9 #include "content/browser/loader/resource_loader_delegate.h" | 9 #include "content/browser/loader/resource_loader_delegate.h" |
10 #include "content/public/browser/resource_request_info.h" | 10 #include "content/public/browser/resource_request_info.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 ResourceLoader loader(request.Pass(), resource_handler.Pass(), this, | 223 ResourceLoader loader(request.Pass(), resource_handler.Pass(), this, |
224 test_store.PassAs<net::ClientCertStore>()); | 224 test_store.PassAs<net::ClientCertStore>()); |
225 | 225 |
226 // Prepare a dummy certificate request. | 226 // Prepare a dummy certificate request. |
227 scoped_refptr<net::SSLCertRequestInfo> cert_request_info( | 227 scoped_refptr<net::SSLCertRequestInfo> cert_request_info( |
228 new net::SSLCertRequestInfo()); | 228 new net::SSLCertRequestInfo()); |
229 std::vector<std::string> dummy_authority(1, "dummy"); | 229 std::vector<std::string> dummy_authority(1, "dummy"); |
230 cert_request_info->cert_authorities = dummy_authority; | 230 cert_request_info->cert_authorities = dummy_authority; |
231 | 231 |
232 // Plug in test content browser client. | 232 // Plug in test content browser client. |
233 ContentBrowserClient* old_client = GetContentClient()->browser(); | |
234 SelectCertificateBrowserClient test_client; | 233 SelectCertificateBrowserClient test_client; |
235 GetContentClient()->set_browser_for_testing(&test_client); | 234 ContentBrowserClient* old_client = SetBrowserClientForTesting(&test_client); |
236 | 235 |
237 // Everything is set up. Trigger the resource loader certificate request event | 236 // Everything is set up. Trigger the resource loader certificate request event |
238 // and run the message loop. | 237 // and run the message loop. |
239 loader.OnCertificateRequested(raw_ptr_to_request, cert_request_info.get()); | 238 loader.OnCertificateRequested(raw_ptr_to_request, cert_request_info.get()); |
240 message_loop_->RunUntilIdle(); | 239 message_loop_->RunUntilIdle(); |
241 | 240 |
242 // Restore the original content browser client. | 241 // Restore the original content browser client. |
243 GetContentClient()->set_browser_for_testing(old_client); | 242 SetBrowserClientForTesting(old_client); |
244 | 243 |
245 // Check if the test store was queried against correct |cert_authorities|. | 244 // Check if the test store was queried against correct |cert_authorities|. |
246 EXPECT_EQ(1, raw_ptr_to_store->request_count()); | 245 EXPECT_EQ(1, raw_ptr_to_store->request_count()); |
247 EXPECT_EQ(dummy_authority, raw_ptr_to_store->requested_authorities()); | 246 EXPECT_EQ(dummy_authority, raw_ptr_to_store->requested_authorities()); |
248 | 247 |
249 // Check if the retrieved certificates were passed to the content browser | 248 // Check if the retrieved certificates were passed to the content browser |
250 // client. | 249 // client. |
251 EXPECT_EQ(1, test_client.call_count()); | 250 EXPECT_EQ(1, test_client.call_count()); |
252 EXPECT_EQ(dummy_certs, test_client.passed_certs()); | 251 EXPECT_EQ(dummy_certs, test_client.passed_certs()); |
253 } | 252 } |
254 #endif // !defined(OPENSSL) | 253 #endif // !defined(OPENSSL) |
255 | 254 |
256 } // namespace content | 255 } // namespace content |
OLD | NEW |