Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc

Issue 1420053005: Move code in components/safe_browsing_db and chrome/browser/s_b/ under the safe_browsing namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@02_components_move
Patch Set: Bring back anon namespace. Remove safe_browsing:: wherever not needed. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // This test creates a fake safebrowsing service, where we can inject known- 5 // This test creates a fake safebrowsing service, where we can inject known-
6 // threat urls. It then uses a real browser to go to these urls, and sends 6 // threat urls. It then uses a real browser to go to these urls, and sends
7 // "goback" or "proceed" commands and verifies they work. 7 // "goback" or "proceed" commands and verifies they work.
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "content/public/test/test_browser_thread.h" 45 #include "content/public/test/test_browser_thread.h"
46 #include "content/public/test/test_utils.h" 46 #include "content/public/test/test_utils.h"
47 #include "net/test/url_request/url_request_mock_http_job.h" 47 #include "net/test/url_request/url_request_mock_http_job.h"
48 48
49 using chrome_browser_interstitials::SecurityInterstitialIDNTest; 49 using chrome_browser_interstitials::SecurityInterstitialIDNTest;
50 using content::BrowserThread; 50 using content::BrowserThread;
51 using content::InterstitialPage; 51 using content::InterstitialPage;
52 using content::NavigationController; 52 using content::NavigationController;
53 using content::WebContents; 53 using content::WebContents;
54 54
55 namespace safe_browsing {
56
55 namespace { 57 namespace {
56 58
57 const char kEmptyPage[] = "empty.html"; 59 const char kEmptyPage[] = "empty.html";
58 const char kMalwarePage[] = "safe_browsing/malware.html"; 60 const char kMalwarePage[] = "safe_browsing/malware.html";
59 const char kMalwareIframe[] = "safe_browsing/malware_iframe.html"; 61 const char kMalwareIframe[] = "safe_browsing/malware_iframe.html";
60 const char kUnrelatedUrl[] = "https://www.google.com"; 62 const char kUnrelatedUrl[] = "https://www.google.com";
61 63
62 // A SafeBrowsingDatabaseManager class that allows us to inject the malicious 64 // A SafeBrowsingDatabaseManager class that allows us to inject the malicious
63 // URLs. 65 // URLs.
64 class FakeSafeBrowsingDatabaseManager : public TestSafeBrowsingDatabaseManager { 66 class FakeSafeBrowsingDatabaseManager : public TestSafeBrowsingDatabaseManager {
(...skipping 20 matching lines...) Expand all
85 std::vector<SBThreatType> expected_threats; 87 std::vector<SBThreatType> expected_threats;
86 // TODO(nparker): Remove ref to LocalSafeBrowsingDatabase by calling 88 // TODO(nparker): Remove ref to LocalSafeBrowsingDatabase by calling
87 // client->OnCheckBrowseUrlResult(..) directly. 89 // client->OnCheckBrowseUrlResult(..) directly.
88 expected_threats.push_back(SB_THREAT_TYPE_URL_MALWARE); 90 expected_threats.push_back(SB_THREAT_TYPE_URL_MALWARE);
89 expected_threats.push_back(SB_THREAT_TYPE_URL_PHISHING); 91 expected_threats.push_back(SB_THREAT_TYPE_URL_PHISHING);
90 expected_threats.push_back(SB_THREAT_TYPE_URL_UNWANTED); 92 expected_threats.push_back(SB_THREAT_TYPE_URL_UNWANTED);
91 LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck sb_check( 93 LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck sb_check(
92 std::vector<GURL>(1, gurl), 94 std::vector<GURL>(1, gurl),
93 std::vector<SBFullHash>(), 95 std::vector<SBFullHash>(),
94 client, 96 client,
95 safe_browsing::MALWARE, 97 MALWARE,
96 expected_threats); 98 expected_threats);
97 sb_check.url_results[0] = badurls[gurl.spec()]; 99 sb_check.url_results[0] = badurls[gurl.spec()];
98 sb_check.OnSafeBrowsingResult(); 100 sb_check.OnSafeBrowsingResult();
99 } 101 }
100 102
101 void SetURLThreatType(const GURL& url, SBThreatType threat_type) { 103 void SetURLThreatType(const GURL& url, SBThreatType threat_type) {
102 badurls[url.spec()] = threat_type; 104 badurls[url.spec()] = threat_type;
103 } 105 }
104 106
105 // These are called when checking URLs, so we implement them. 107 // These are called when checking URLs, so we implement them.
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 AssertNoInterstitial(true); // Assert the interstitial is gone 739 AssertNoInterstitial(true); // Assert the interstitial is gone
738 740
739 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( 741 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(
740 prefs::kSafeBrowsingExtendedReportingEnabled)); 742 prefs::kSafeBrowsingExtendedReportingEnabled));
741 EXPECT_EQ(url, 743 EXPECT_EQ(url,
742 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 744 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
743 745
744 if (expect_malware_details) { 746 if (expect_malware_details) {
745 malware_report_sent_runner->Run(); 747 malware_report_sent_runner->Run();
746 std::string serialized = GetReportSent(); 748 std::string serialized = GetReportSent();
747 safe_browsing::ClientMalwareReportRequest report; 749 ClientMalwareReportRequest report;
748 ASSERT_TRUE(report.ParseFromString(serialized)); 750 ASSERT_TRUE(report.ParseFromString(serialized));
749 // Verify the report is complete. 751 // Verify the report is complete.
750 EXPECT_TRUE(report.complete()); 752 EXPECT_TRUE(report.complete());
751 } 753 }
752 } 754 }
753 755
754 // Verifies that the "proceed anyway" link isn't available when it is disabled 756 // Verifies that the "proceed anyway" link isn't available when it is disabled
755 // by the corresponding policy. Also verifies that sending the "proceed" 757 // by the corresponding policy. Also verifies that sending the "proceed"
756 // command anyway doesn't advance to the unsafe site. 758 // command anyway doesn't advance to the unsafe site.
757 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, ProceedDisabled) { 759 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, ProceedDisabled) {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest, 1018 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest,
1017 SafeBrowsingBlockingPageDecodesIDN) { 1019 SafeBrowsingBlockingPageDecodesIDN) {
1018 EXPECT_TRUE(VerifyIDNDecoded()); 1020 EXPECT_TRUE(VerifyIDNDecoded());
1019 } 1021 }
1020 1022
1021 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageIDNTestWithThreatType, 1023 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageIDNTestWithThreatType,
1022 SafeBrowsingBlockingPageIDNTest, 1024 SafeBrowsingBlockingPageIDNTest,
1023 testing::Values(SB_THREAT_TYPE_URL_MALWARE, 1025 testing::Values(SB_THREAT_TYPE_URL_MALWARE,
1024 SB_THREAT_TYPE_URL_PHISHING, 1026 SB_THREAT_TYPE_URL_PHISHING,
1025 SB_THREAT_TYPE_URL_UNWANTED)); 1027 SB_THREAT_TYPE_URL_UNWANTED));
1028
1029 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698