| 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 // This test creates a fake safebrowsing service, where we can inject | 5 // This test creates a fake safebrowsing service, where we can inject |
| 6 // malware and phishing urls. It then uses a real browser to go to | 6 // malware and phishing urls. It then uses a real browser to go to |
| 7 // these urls, and sends "goback" or "proceed" commands and verifies | 7 // these urls, and sends "goback" or "proceed" commands and verifies |
| 8 // they work. | 8 // they work. |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 return true; | 61 return true; |
| 62 | 62 |
| 63 BrowserThread::PostTask( | 63 BrowserThread::PostTask( |
| 64 BrowserThread::IO, FROM_HERE, | 64 BrowserThread::IO, FROM_HERE, |
| 65 base::Bind(&FakeSafeBrowsingDatabaseManager::OnCheckBrowseURLDone, | 65 base::Bind(&FakeSafeBrowsingDatabaseManager::OnCheckBrowseURLDone, |
| 66 this, gurl, client)); | 66 this, gurl, client)); |
| 67 return false; | 67 return false; |
| 68 } | 68 } |
| 69 | 69 |
| 70 void OnCheckBrowseURLDone(const GURL& gurl, Client* client) { | 70 void OnCheckBrowseURLDone(const GURL& gurl, Client* client) { |
| 71 SafeBrowsingDatabaseManager::SafeBrowsingCheck check; | 71 SafeBrowsingDatabaseManager::SafeBrowsingCheck check( |
| 72 safe_browsing_util::MALWARE); |
| 72 check.urls.push_back(gurl); | 73 check.urls.push_back(gurl); |
| 73 check.client = client; | 74 check.client = client; |
| 74 check.threat_type = badurls[gurl.spec()]; | 75 check.url_threats[gurl] = badurls[gurl.spec()]; |
| 75 client->OnSafeBrowsingResult(check); | 76 client->OnSafeBrowsingResult(check); |
| 76 } | 77 } |
| 77 | 78 |
| 78 void SetURLThreatType(const GURL& url, SBThreatType threat_type) { | 79 void SetURLThreatType(const GURL& url, SBThreatType threat_type) { |
| 79 badurls[url.spec()] = threat_type; | 80 badurls[url.spec()] = threat_type; |
| 80 } | 81 } |
| 81 | 82 |
| 82 private: | 83 private: |
| 83 virtual ~FakeSafeBrowsingDatabaseManager() {} | 84 virtual ~FakeSafeBrowsingDatabaseManager() {} |
| 84 | 85 |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); | 781 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); |
| 781 | 782 |
| 782 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); | 783 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); |
| 783 AssertNoInterstitial(false); // Assert the interstitial is gone | 784 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 784 | 785 |
| 785 // We are in the help page. | 786 // We are in the help page. |
| 786 EXPECT_EQ( | 787 EXPECT_EQ( |
| 787 "/goodtoknow/online-safety/phishing/", | 788 "/goodtoknow/online-safety/phishing/", |
| 788 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); | 789 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); |
| 789 } | 790 } |
| OLD | NEW |