OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <map> | 5 #include <map> |
6 #include <memory> | 6 #include <memory> |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 net::URLRequestJob* | 478 net::URLRequestJob* |
479 URLRequestMockCaptivePortalJobFactory::Interceptor::MaybeInterceptRequest( | 479 URLRequestMockCaptivePortalJobFactory::Interceptor::MaybeInterceptRequest( |
480 net::URLRequest* request, | 480 net::URLRequest* request, |
481 net::NetworkDelegate* network_delegate) const { | 481 net::NetworkDelegate* network_delegate) const { |
482 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 482 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
483 | 483 |
484 // The PathService is threadsafe. | 484 // The PathService is threadsafe. |
485 base::FilePath root_http; | 485 base::FilePath root_http; |
486 PathService::Get(chrome::DIR_TEST_DATA, &root_http); | 486 PathService::Get(chrome::DIR_TEST_DATA, &root_http); |
487 | 487 |
488 if (request->url() == GURL(kMockHttpsUrl) || | 488 if (request->url() == kMockHttpsUrl || |
489 request->url() == GURL(kMockHttpsUrl2)) { | 489 request->url() == kMockHttpsUrl2) { |
490 if (behind_captive_portal_) | 490 if (behind_captive_portal_) |
491 return new URLRequestTimeoutOnDemandJob(request, network_delegate); | 491 return new URLRequestTimeoutOnDemandJob(request, network_delegate); |
492 // Once logged in to the portal, HTTPS requests return the page that was | 492 // Once logged in to the portal, HTTPS requests return the page that was |
493 // actually requested. | 493 // actually requested. |
494 return new URLRequestMockHTTPJob( | 494 return new URLRequestMockHTTPJob( |
495 request, | 495 request, |
496 network_delegate, | 496 network_delegate, |
497 root_http.Append(FILE_PATH_LITERAL("title2.html")), | 497 root_http.Append(FILE_PATH_LITERAL("title2.html")), |
498 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 498 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( |
499 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 499 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
500 } else if (request->url() == GURL(kMockHttpsQuickTimeoutUrl)) { | 500 } else if (request->url() == kMockHttpsQuickTimeoutUrl) { |
501 if (behind_captive_portal_) | 501 if (behind_captive_portal_) |
502 return new URLRequestFailedJob( | 502 return new URLRequestFailedJob( |
503 request, network_delegate, net::ERR_CONNECTION_TIMED_OUT); | 503 request, network_delegate, net::ERR_CONNECTION_TIMED_OUT); |
504 // Once logged in to the portal, HTTPS requests return the page that was | 504 // Once logged in to the portal, HTTPS requests return the page that was |
505 // actually requested. | 505 // actually requested. |
506 return new URLRequestMockHTTPJob( | 506 return new URLRequestMockHTTPJob( |
507 request, | 507 request, |
508 network_delegate, | 508 network_delegate, |
509 root_http.Append(FILE_PATH_LITERAL("title2.html")), | 509 root_http.Append(FILE_PATH_LITERAL("title2.html")), |
510 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 510 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( |
511 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 511 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
512 } else { | 512 } else { |
513 // The URL should be the captive portal test URL. | 513 // The URL should be the captive portal test URL. |
514 EXPECT_TRUE(GURL(kMockCaptivePortalTestUrl) == request->url() || | 514 EXPECT_TRUE(request->url() == kMockCaptivePortalTestUrl || |
515 GURL(kMockCaptivePortal511Url) == request->url()); | 515 request->url() == kMockCaptivePortal511Url); |
516 | 516 |
517 if (behind_captive_portal_) { | 517 if (behind_captive_portal_) { |
518 // Prior to logging in to the portal, the HTTP test URLs are intercepted | 518 // Prior to logging in to the portal, the HTTP test URLs are intercepted |
519 // by the captive portal. | 519 // by the captive portal. |
520 if (GURL(kMockCaptivePortal511Url) == request->url()) { | 520 if (request->url() == kMockCaptivePortal511Url) { |
521 return new URLRequestMockHTTPJob( | 521 return new URLRequestMockHTTPJob( |
522 request, | 522 request, |
523 network_delegate, | 523 network_delegate, |
524 root_http.Append(FILE_PATH_LITERAL("captive_portal/page511.html")), | 524 root_http.Append(FILE_PATH_LITERAL("captive_portal/page511.html")), |
525 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 525 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( |
526 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 526 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
527 } | 527 } |
528 return new URLRequestMockHTTPJob( | 528 return new URLRequestMockHTTPJob( |
529 request, | 529 request, |
530 network_delegate, | 530 network_delegate, |
(...skipping 2307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2838 | 2838 |
2839 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, | 2839 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, |
2840 GetStateOfTabReloaderAt(browser(), broken_tab_index)); | 2840 GetStateOfTabReloaderAt(browser(), broken_tab_index)); |
2841 | 2841 |
2842 WaitForInterstitialAttach(broken_tab_contents); | 2842 WaitForInterstitialAttach(broken_tab_contents); |
2843 portal_observer.WaitForResults(1); | 2843 portal_observer.WaitForResults(1); |
2844 | 2844 |
2845 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, | 2845 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, |
2846 GetInterstitialType(broken_tab_contents)); | 2846 GetInterstitialType(broken_tab_contents)); |
2847 } | 2847 } |
OLD | NEW |