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> |
11 | 11 |
12 #include "base/base_switches.h" | 12 #include "base/base_switches.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
21 #include "base/threading/sequenced_worker_pool.h" | 21 #include "base/task_scheduler/post_task.h" |
22 #include "base/values.h" | 22 #include "base/values.h" |
23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
24 #include "chrome/browser/captive_portal/captive_portal_service.h" | 24 #include "chrome/browser/captive_portal/captive_portal_service.h" |
25 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | 25 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" |
26 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 26 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
27 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" | 27 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" |
28 #include "chrome/browser/chrome_notification_types.h" | 28 #include "chrome/browser/chrome_notification_types.h" |
29 #include "chrome/browser/net/url_request_mock_util.h" | 29 #include "chrome/browser/net/url_request_mock_util.h" |
30 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
31 #include "chrome/browser/ssl/captive_portal_blocking_page.h" | 31 #include "chrome/browser/ssl/captive_portal_blocking_page.h" |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 base::FilePath root_http; | 486 base::FilePath root_http; |
487 PathService::Get(chrome::DIR_TEST_DATA, &root_http); | 487 PathService::Get(chrome::DIR_TEST_DATA, &root_http); |
488 | 488 |
489 if (request->url() == kMockHttpsUrl || | 489 if (request->url() == kMockHttpsUrl || |
490 request->url() == kMockHttpsUrl2) { | 490 request->url() == kMockHttpsUrl2) { |
491 if (behind_captive_portal_) | 491 if (behind_captive_portal_) |
492 return new URLRequestTimeoutOnDemandJob(request, network_delegate); | 492 return new URLRequestTimeoutOnDemandJob(request, network_delegate); |
493 // Once logged in to the portal, HTTPS requests return the page that was | 493 // Once logged in to the portal, HTTPS requests return the page that was |
494 // actually requested. | 494 // actually requested. |
495 return new URLRequestMockHTTPJob( | 495 return new URLRequestMockHTTPJob( |
496 request, | 496 request, network_delegate, |
497 network_delegate, | |
498 root_http.Append(FILE_PATH_LITERAL("title2.html")), | 497 root_http.Append(FILE_PATH_LITERAL("title2.html")), |
499 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 498 base::CreateTaskRunnerWithTraits( |
500 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 499 base::TaskTraits() |
500 .MayBlock() | |
501 .WithPriority(base::TaskPriority::BACKGROUND) | |
502 .WithShutdownBehavior( | |
503 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN))); | |
mmenke
2017/04/25 15:55:10
Do we really need all this stuff? I'd think that
fdoray
2017/04/27 13:05:43
Done.
| |
501 } else if (request->url() == kMockHttpsQuickTimeoutUrl) { | 504 } else if (request->url() == kMockHttpsQuickTimeoutUrl) { |
502 if (behind_captive_portal_) | 505 if (behind_captive_portal_) |
503 return new URLRequestFailedJob( | 506 return new URLRequestFailedJob( |
504 request, network_delegate, net::ERR_CONNECTION_TIMED_OUT); | 507 request, network_delegate, net::ERR_CONNECTION_TIMED_OUT); |
505 // Once logged in to the portal, HTTPS requests return the page that was | 508 // Once logged in to the portal, HTTPS requests return the page that was |
506 // actually requested. | 509 // actually requested. |
507 return new URLRequestMockHTTPJob( | 510 return new URLRequestMockHTTPJob( |
508 request, | 511 request, network_delegate, |
509 network_delegate, | |
510 root_http.Append(FILE_PATH_LITERAL("title2.html")), | 512 root_http.Append(FILE_PATH_LITERAL("title2.html")), |
511 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 513 base::CreateTaskRunnerWithTraits( |
512 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 514 base::TaskTraits() |
515 .MayBlock() | |
516 .WithPriority(base::TaskPriority::BACKGROUND) | |
517 .WithShutdownBehavior( | |
518 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN))); | |
513 } else { | 519 } else { |
514 // The URL should be the captive portal test URL. | 520 // The URL should be the captive portal test URL. |
515 EXPECT_TRUE(request->url() == kMockCaptivePortalTestUrl || | 521 EXPECT_TRUE(request->url() == kMockCaptivePortalTestUrl || |
516 request->url() == kMockCaptivePortal511Url); | 522 request->url() == kMockCaptivePortal511Url); |
517 | 523 |
518 if (behind_captive_portal_) { | 524 if (behind_captive_portal_) { |
519 // Prior to logging in to the portal, the HTTP test URLs are intercepted | 525 // Prior to logging in to the portal, the HTTP test URLs are intercepted |
520 // by the captive portal. | 526 // by the captive portal. |
521 if (request->url() == kMockCaptivePortal511Url) { | 527 if (request->url() == kMockCaptivePortal511Url) { |
522 return new URLRequestMockHTTPJob( | 528 return new URLRequestMockHTTPJob( |
523 request, | 529 request, network_delegate, |
524 network_delegate, | |
525 root_http.Append(FILE_PATH_LITERAL("captive_portal/page511.html")), | 530 root_http.Append(FILE_PATH_LITERAL("captive_portal/page511.html")), |
526 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 531 base::CreateTaskRunnerWithTraits( |
527 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 532 base::TaskTraits() |
533 .MayBlock() | |
534 .WithPriority(base::TaskPriority::BACKGROUND) | |
535 .WithShutdownBehavior( | |
536 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN))); | |
528 } | 537 } |
529 return new URLRequestMockHTTPJob( | 538 return new URLRequestMockHTTPJob( |
530 request, | 539 request, network_delegate, |
531 network_delegate, | |
532 root_http.Append(FILE_PATH_LITERAL("captive_portal/login.html")), | 540 root_http.Append(FILE_PATH_LITERAL("captive_portal/login.html")), |
533 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 541 base::CreateTaskRunnerWithTraits( |
534 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 542 base::TaskTraits() |
543 .MayBlock() | |
544 .WithPriority(base::TaskPriority::BACKGROUND) | |
545 .WithShutdownBehavior( | |
546 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN))); | |
535 } | 547 } |
536 | 548 |
537 // After logging in to the portal, the test URLs return a 204 response. | 549 // After logging in to the portal, the test URLs return a 204 response. |
538 return new URLRequestMockHTTPJob( | 550 return new URLRequestMockHTTPJob( |
539 request, | 551 request, network_delegate, |
540 network_delegate, | |
541 root_http.Append(FILE_PATH_LITERAL("captive_portal/page204.html")), | 552 root_http.Append(FILE_PATH_LITERAL("captive_portal/page204.html")), |
542 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 553 base::CreateTaskRunnerWithTraits( |
543 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 554 base::TaskTraits() |
555 .MayBlock() | |
556 .WithPriority(base::TaskPriority::BACKGROUND) | |
557 .WithShutdownBehavior( | |
558 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN))); | |
544 } | 559 } |
545 } | 560 } |
546 | 561 |
547 // Creates a server-side redirect for use with the TestServer. | 562 // Creates a server-side redirect for use with the TestServer. |
548 std::string CreateServerRedirect(const std::string& dest_url) { | 563 std::string CreateServerRedirect(const std::string& dest_url) { |
549 const char* const kServerRedirectBase = "/server-redirect?"; | 564 const char* const kServerRedirectBase = "/server-redirect?"; |
550 return kServerRedirectBase + dest_url; | 565 return kServerRedirectBase + dest_url; |
551 } | 566 } |
552 | 567 |
553 // Returns the total number of loading tabs across all Browsers, for all | 568 // Returns the total number of loading tabs across all Browsers, for all |
(...skipping 2289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2843 | 2858 |
2844 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, | 2859 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, |
2845 GetStateOfTabReloaderAt(browser(), broken_tab_index)); | 2860 GetStateOfTabReloaderAt(browser(), broken_tab_index)); |
2846 | 2861 |
2847 WaitForInterstitialAttach(broken_tab_contents); | 2862 WaitForInterstitialAttach(broken_tab_contents); |
2848 portal_observer.WaitForResults(1); | 2863 portal_observer.WaitForResults(1); |
2849 | 2864 |
2850 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, | 2865 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, |
2851 GetInterstitialType(broken_tab_contents)); | 2866 GetInterstitialType(broken_tab_contents)); |
2852 } | 2867 } |
OLD | NEW |