| 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 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 <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } // namespace | 204 } // namespace |
| 205 | 205 |
| 206 class TestThreatDetailsFactory : public ThreatDetailsFactory { | 206 class TestThreatDetailsFactory : public ThreatDetailsFactory { |
| 207 public: | 207 public: |
| 208 TestThreatDetailsFactory() : details_() {} | 208 TestThreatDetailsFactory() : details_() {} |
| 209 ~TestThreatDetailsFactory() override {} | 209 ~TestThreatDetailsFactory() override {} |
| 210 | 210 |
| 211 ThreatDetails* CreateThreatDetails( | 211 ThreatDetails* CreateThreatDetails( |
| 212 SafeBrowsingUIManager* delegate, | 212 SafeBrowsingUIManager* delegate, |
| 213 WebContents* web_contents, | 213 WebContents* web_contents, |
| 214 const SafeBrowsingUIManager::UnsafeResource& unsafe_resource) override { | 214 const security_interstitials::UnsafeResource& unsafe_resource) override { |
| 215 details_ = new ThreatDetails(delegate, web_contents, unsafe_resource); | 215 details_ = new ThreatDetails(delegate, web_contents, unsafe_resource); |
| 216 return details_; | 216 return details_; |
| 217 } | 217 } |
| 218 | 218 |
| 219 ThreatDetails* get_details() { return details_; } | 219 ThreatDetails* get_details() { return details_; } |
| 220 | 220 |
| 221 private: | 221 private: |
| 222 ThreatDetails* details_; | 222 ThreatDetails* details_; |
| 223 }; | 223 }; |
| 224 | 224 |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 const bool is_subresource = testing::get<0>(GetParam()); | 1323 const bool is_subresource = testing::get<0>(GetParam()); |
| 1324 | 1324 |
| 1325 SafeBrowsingService* sb_service = | 1325 SafeBrowsingService* sb_service = |
| 1326 g_browser_process->safe_browsing_service(); | 1326 g_browser_process->safe_browsing_service(); |
| 1327 SafeBrowsingBlockingPage::UnsafeResource resource; | 1327 SafeBrowsingBlockingPage::UnsafeResource resource; |
| 1328 | 1328 |
| 1329 resource.url = request_url; | 1329 resource.url = request_url; |
| 1330 resource.is_subresource = is_subresource; | 1330 resource.is_subresource = is_subresource; |
| 1331 resource.threat_type = testing::get<1>(GetParam()); | 1331 resource.threat_type = testing::get<1>(GetParam()); |
| 1332 resource.web_contents_getter = | 1332 resource.web_contents_getter = |
| 1333 SafeBrowsingUIManager::UnsafeResource::GetWebContentsGetter( | 1333 security_interstitials::UnsafeResource::GetWebContentsGetter( |
| 1334 contents->GetRenderProcessHost()->GetID(), | 1334 contents->GetRenderProcessHost()->GetID(), |
| 1335 contents->GetMainFrame()->GetRoutingID()); | 1335 contents->GetMainFrame()->GetRoutingID()); |
| 1336 resource.threat_source = safe_browsing::ThreatSource::LOCAL_PVER3; | 1336 resource.threat_source = safe_browsing::ThreatSource::LOCAL_PVER3; |
| 1337 | 1337 |
| 1338 return SafeBrowsingBlockingPage::CreateBlockingPage( | 1338 return SafeBrowsingBlockingPage::CreateBlockingPage( |
| 1339 sb_service->ui_manager().get(), contents, | 1339 sb_service->ui_manager().get(), contents, |
| 1340 is_subresource ? GURL("http://mainframe.example.com/") : request_url, | 1340 is_subresource ? GURL("http://mainframe.example.com/") : request_url, |
| 1341 resource); | 1341 resource); |
| 1342 } | 1342 } |
| 1343 }; | 1343 }; |
| 1344 | 1344 |
| 1345 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest, | 1345 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest, |
| 1346 SafeBrowsingBlockingPageDecodesIDN) { | 1346 SafeBrowsingBlockingPageDecodesIDN) { |
| 1347 EXPECT_TRUE(VerifyIDNDecoded()); | 1347 EXPECT_TRUE(VerifyIDNDecoded()); |
| 1348 } | 1348 } |
| 1349 | 1349 |
| 1350 INSTANTIATE_TEST_CASE_P( | 1350 INSTANTIATE_TEST_CASE_P( |
| 1351 SafeBrowsingBlockingPageIDNTestWithThreatType, | 1351 SafeBrowsingBlockingPageIDNTestWithThreatType, |
| 1352 SafeBrowsingBlockingPageIDNTest, | 1352 SafeBrowsingBlockingPageIDNTest, |
| 1353 testing::Combine(testing::Values(false, true), | 1353 testing::Combine(testing::Values(false, true), |
| 1354 testing::Values(SB_THREAT_TYPE_URL_MALWARE, | 1354 testing::Values(SB_THREAT_TYPE_URL_MALWARE, |
| 1355 SB_THREAT_TYPE_URL_PHISHING, | 1355 SB_THREAT_TYPE_URL_PHISHING, |
| 1356 SB_THREAT_TYPE_URL_UNWANTED))); | 1356 SB_THREAT_TYPE_URL_UNWANTED))); |
| 1357 | 1357 |
| 1358 } // namespace safe_browsing | 1358 } // namespace safe_browsing |
| OLD | NEW |