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 "chrome/browser/safe_browsing/download_protection_service.h" | 5 #include "chrome/browser/safe_browsing/download_protection_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 // Set sample rate to 0 to prevent sampling. | 655 // Set sample rate to 0 to prevent sampling. |
656 SetWhitelistedDownloadSampleRate(0); | 656 SetWhitelistedDownloadSampleRate(0); |
657 download_service_->CheckClientDownload( | 657 download_service_->CheckClientDownload( |
658 &item, | 658 &item, |
659 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 659 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
660 base::Unretained(this))); | 660 base::Unretained(this))); |
661 MessageLoop::current()->Run(); | 661 MessageLoop::current()->Run(); |
662 | 662 |
663 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); | 663 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); |
664 EXPECT_TRUE(HasClientDownloadRequest()); | 664 EXPECT_TRUE(HasClientDownloadRequest()); |
| 665 EXPECT_FALSE(GetClientDownloadRequest()->skipped_url_whitelist()); |
| 666 EXPECT_FALSE(GetClientDownloadRequest()->skipped_certificate_whitelist()); |
665 ClearClientDownloadRequest(); | 667 ClearClientDownloadRequest(); |
666 | 668 |
667 // Check that the referrer is not matched against the whitelist. | 669 // Check that the referrer is not matched against the whitelist. |
668 referrer_ = GURL("http://www.google.com/"); | 670 referrer_ = GURL("http://www.google.com/"); |
669 download_service_->CheckClientDownload( | 671 download_service_->CheckClientDownload( |
670 &item, | 672 &item, |
671 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 673 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
672 base::Unretained(this))); | 674 base::Unretained(this))); |
673 MessageLoop::current()->Run(); | 675 MessageLoop::current()->Run(); |
674 | 676 |
675 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); | 677 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); |
676 EXPECT_TRUE(HasClientDownloadRequest()); | 678 EXPECT_TRUE(HasClientDownloadRequest()); |
| 679 EXPECT_FALSE(GetClientDownloadRequest()->skipped_url_whitelist()); |
| 680 EXPECT_FALSE(GetClientDownloadRequest()->skipped_certificate_whitelist()); |
677 ClearClientDownloadRequest(); | 681 ClearClientDownloadRequest(); |
678 | 682 |
679 // Redirect from a site shouldn't be checked either. | 683 // Redirect from a site shouldn't be checked either. |
680 url_chain_.insert(url_chain_.begin(), GURL("http://www.google.com/redirect")); | 684 url_chain_.insert(url_chain_.begin(), GURL("http://www.google.com/redirect")); |
681 download_service_->CheckClientDownload( | 685 download_service_->CheckClientDownload( |
682 &item, | 686 &item, |
683 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 687 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
684 base::Unretained(this))); | 688 base::Unretained(this))); |
685 MessageLoop::current()->Run(); | 689 MessageLoop::current()->Run(); |
686 | 690 |
687 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); | 691 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); |
688 EXPECT_TRUE(HasClientDownloadRequest()); | 692 EXPECT_TRUE(HasClientDownloadRequest()); |
| 693 EXPECT_FALSE(GetClientDownloadRequest()->skipped_url_whitelist()); |
| 694 EXPECT_FALSE(GetClientDownloadRequest()->skipped_certificate_whitelist()); |
689 ClearClientDownloadRequest(); | 695 ClearClientDownloadRequest(); |
690 | 696 |
691 // Only if the final url is whitelisted should it be SAFE. | 697 // Only if the final url is whitelisted should it be SAFE. |
692 url_chain_.push_back(GURL("http://www.google.com/a.exe")); | 698 url_chain_.push_back(GURL("http://www.google.com/a.exe")); |
693 download_service_->CheckClientDownload( | 699 download_service_->CheckClientDownload( |
694 &item, | 700 &item, |
695 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 701 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
696 base::Unretained(this))); | 702 base::Unretained(this))); |
697 MessageLoop::current()->Run(); | 703 MessageLoop::current()->Run(); |
698 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); | 704 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); |
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 1913 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
1908 base::Unretained(this))); | 1914 base::Unretained(this))); |
1909 MessageLoop::current()->Run(); | 1915 MessageLoop::current()->Run(); |
1910 | 1916 |
1911 EXPECT_FALSE(HasClientDownloadRequest()); | 1917 EXPECT_FALSE(HasClientDownloadRequest()); |
1912 // Overriden by flag: | 1918 // Overriden by flag: |
1913 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); | 1919 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); |
1914 } | 1920 } |
1915 | 1921 |
1916 } // namespace safe_browsing | 1922 } // namespace safe_browsing |
OLD | NEW |