| 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 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 const bool is_subresource = testing::get<0>(GetParam()); | 1283 const bool is_subresource = testing::get<0>(GetParam()); |
| 1284 | 1284 |
| 1285 SafeBrowsingService* sb_service = | 1285 SafeBrowsingService* sb_service = |
| 1286 g_browser_process->safe_browsing_service(); | 1286 g_browser_process->safe_browsing_service(); |
| 1287 SafeBrowsingBlockingPage::UnsafeResource resource; | 1287 SafeBrowsingBlockingPage::UnsafeResource resource; |
| 1288 | 1288 |
| 1289 resource.url = request_url; | 1289 resource.url = request_url; |
| 1290 resource.is_subresource = is_subresource; | 1290 resource.is_subresource = is_subresource; |
| 1291 resource.threat_type = testing::get<1>(GetParam()); | 1291 resource.threat_type = testing::get<1>(GetParam()); |
| 1292 resource.web_contents_getter = | 1292 resource.web_contents_getter = |
| 1293 SafeBrowsingUIManager::UnsafeResource::GetWebContentsGetter( | 1293 security_interstitials::UnsafeResource::GetWebContentsGetter( |
| 1294 contents->GetRenderProcessHost()->GetID(), | 1294 contents->GetRenderProcessHost()->GetID(), |
| 1295 contents->GetMainFrame()->GetRoutingID()); | 1295 contents->GetMainFrame()->GetRoutingID()); |
| 1296 resource.threat_source = safe_browsing::ThreatSource::LOCAL_PVER3; | 1296 resource.threat_source = safe_browsing::ThreatSource::LOCAL_PVER3; |
| 1297 | 1297 |
| 1298 return SafeBrowsingBlockingPage::CreateBlockingPage( | 1298 return SafeBrowsingBlockingPage::CreateBlockingPage( |
| 1299 sb_service->ui_manager().get(), contents, | 1299 sb_service->ui_manager().get(), contents, |
| 1300 is_subresource ? GURL("http://mainframe.example.com/") : request_url, | 1300 is_subresource ? GURL("http://mainframe.example.com/") : request_url, |
| 1301 resource); | 1301 resource); |
| 1302 } | 1302 } |
| 1303 }; | 1303 }; |
| 1304 | 1304 |
| 1305 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest, | 1305 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest, |
| 1306 SafeBrowsingBlockingPageDecodesIDN) { | 1306 SafeBrowsingBlockingPageDecodesIDN) { |
| 1307 EXPECT_TRUE(VerifyIDNDecoded()); | 1307 EXPECT_TRUE(VerifyIDNDecoded()); |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 INSTANTIATE_TEST_CASE_P( | 1310 INSTANTIATE_TEST_CASE_P( |
| 1311 SafeBrowsingBlockingPageIDNTestWithThreatType, | 1311 SafeBrowsingBlockingPageIDNTestWithThreatType, |
| 1312 SafeBrowsingBlockingPageIDNTest, | 1312 SafeBrowsingBlockingPageIDNTest, |
| 1313 testing::Combine(testing::Values(false, true), | 1313 testing::Combine(testing::Values(false, true), |
| 1314 testing::Values(SB_THREAT_TYPE_URL_MALWARE, | 1314 testing::Values(SB_THREAT_TYPE_URL_MALWARE, |
| 1315 SB_THREAT_TYPE_URL_PHISHING, | 1315 SB_THREAT_TYPE_URL_PHISHING, |
| 1316 SB_THREAT_TYPE_URL_UNWANTED))); | 1316 SB_THREAT_TYPE_URL_UNWANTED))); |
| 1317 | 1317 |
| 1318 } // namespace safe_browsing | 1318 } // namespace safe_browsing |
| OLD | NEW |