OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/subresource_filter/content/browser/content_subresource_filt
er_driver_factory.h" | 5 #include "components/subresource_filter/content/browser/content_subresource_filt
er_driver_factory.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 base::HistogramTester tester; | 304 base::HistogramTester tester; |
305 EXPECT_CALL(*client(), ToggleNotificationVisibility(false)).Times(1); | 305 EXPECT_CALL(*client(), ToggleNotificationVisibility(false)).Times(1); |
306 | 306 |
307 std::unique_ptr<content::NavigationSimulator> navigation_simulator = | 307 std::unique_ptr<content::NavigationSimulator> navigation_simulator = |
308 content::NavigationSimulator::CreateRendererInitiated( | 308 content::NavigationSimulator::CreateRendererInitiated( |
309 navigation_chain.front(), main_rfh()); | 309 navigation_chain.front(), main_rfh()); |
310 navigation_simulator->SetReferrer(referrer); | 310 navigation_simulator->SetReferrer(referrer); |
311 navigation_simulator->SetTransition(transition); | 311 navigation_simulator->SetTransition(transition); |
312 navigation_simulator->Start(); | 312 navigation_simulator->Start(); |
313 | 313 |
| 314 if (blacklisted_urls.front()) { |
| 315 factory()->OnMainResourceMatchedSafeBrowsingBlacklist( |
| 316 navigation_chain.front(), threat_type, threat_type_metadata); |
| 317 } |
314 ::testing::Mock::VerifyAndClearExpectations(client()); | 318 ::testing::Mock::VerifyAndClearExpectations(client()); |
315 for (size_t i = 1; i < navigation_chain.size(); ++i) | |
316 navigation_simulator->Redirect(navigation_chain[i]); | |
317 | 319 |
318 if (blacklisted_urls.size() != navigation_chain.size() || | 320 for (size_t i = 1; i < navigation_chain.size(); ++i) { |
319 !blacklisted_urls.back()) { | 321 const GURL url = navigation_chain[i]; |
320 threat_type = safe_browsing::SBThreatType::SB_THREAT_TYPE_SAFE; | 322 if (i < blacklisted_urls.size() && blacklisted_urls[i]) { |
321 threat_type_metadata = safe_browsing::ThreatPatternType::NONE; | 323 factory()->OnMainResourceMatchedSafeBrowsingBlacklist( |
| 324 url, threat_type, threat_type_metadata); |
| 325 } |
| 326 navigation_simulator->Redirect(url); |
322 } | 327 } |
323 factory()->OnSafeBrowsingMatchComputed( | |
324 navigation_simulator->GetNavigationHandle(), threat_type, | |
325 threat_type_metadata); | |
326 std::string suffix; | 328 std::string suffix; |
327 ActivationList activation_list = | 329 ActivationList activation_list = |
328 GetListForThreatTypeAndMetadata(threat_type, threat_type_metadata); | 330 GetListForThreatTypeAndMetadata(threat_type, threat_type_metadata); |
329 suffix = blacklisted_urls.back() ? GetSuffixForList(activation_list) | 331 suffix = blacklisted_urls.back() ? GetSuffixForList(activation_list) |
330 : std::string(); | 332 : std::string(); |
331 | 333 |
332 navigation_simulator->Commit(); | 334 navigation_simulator->Commit(); |
333 ExpectActivationSignalForFrame(main_rfh(), expected_activation); | 335 ExpectActivationSignalForFrame(main_rfh(), expected_activation); |
334 EXPECT_EQ(expected_activation_decision, | 336 EXPECT_EQ(expected_activation_decision, |
335 factory()->GetActivationDecisionForLastCommittedPageLoad()); | 337 factory()->GetActivationDecisionForLastCommittedPageLoad()); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 ActivationScopeTest, | 756 ActivationScopeTest, |
755 ContentSubresourceFilterDriverFactoryActivationScopeTest, | 757 ContentSubresourceFilterDriverFactoryActivationScopeTest, |
756 ::testing::ValuesIn(kActivationScopeTestData)); | 758 ::testing::ValuesIn(kActivationScopeTestData)); |
757 | 759 |
758 INSTANTIATE_TEST_CASE_P( | 760 INSTANTIATE_TEST_CASE_P( |
759 ActivationLevelTest, | 761 ActivationLevelTest, |
760 ContentSubresourceFilterDriverFactoryActivationLevelTest, | 762 ContentSubresourceFilterDriverFactoryActivationLevelTest, |
761 ::testing::ValuesIn(kActivationLevelTestData)); | 763 ::testing::ValuesIn(kActivationLevelTestData)); |
762 | 764 |
763 } // namespace subresource_filter | 765 } // namespace subresource_filter |
OLD | NEW |