| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 RenderViewHostTestHarness::SetUp(); | 229 RenderViewHostTestHarness::SetUp(); |
| 230 | 230 |
| 231 std::vector<proto::UrlRule> rules; | 231 std::vector<proto::UrlRule> rules; |
| 232 rules.push_back(testing::CreateSuffixRule("disallowed.html")); | 232 rules.push_back(testing::CreateSuffixRule("disallowed.html")); |
| 233 ASSERT_NO_FATAL_FAILURE(test_ruleset_creator_.CreateRulesetWithRules( | 233 ASSERT_NO_FATAL_FAILURE(test_ruleset_creator_.CreateRulesetWithRules( |
| 234 rules, &test_ruleset_pair_)); | 234 rules, &test_ruleset_pair_)); |
| 235 ruleset_dealer_ = base::MakeUnique<VerifiedRulesetDealer::Handle>( | 235 ruleset_dealer_ = base::MakeUnique<VerifiedRulesetDealer::Handle>( |
| 236 base::MessageLoop::current()->task_runner()); | 236 base::MessageLoop::current()->task_runner()); |
| 237 ruleset_dealer_->SetRulesetFile( | 237 ruleset_dealer_->SetRulesetFile( |
| 238 testing::TestRuleset::Open(test_ruleset_pair_.indexed)); | 238 testing::TestRuleset::Open(test_ruleset_pair_.indexed)); |
| 239 client_ = new MockSubresourceFilterClient(ruleset_dealer_.get()); | 239 client_ = |
| 240 base::MakeUnique<MockSubresourceFilterClient>(ruleset_dealer_.get()); |
| 240 ContentSubresourceFilterDriverFactory::CreateForWebContents( | 241 ContentSubresourceFilterDriverFactory::CreateForWebContents( |
| 241 RenderViewHostTestHarness::web_contents(), base::WrapUnique(client())); | 242 RenderViewHostTestHarness::web_contents(), client()); |
| 242 ResetConfigurationToEnableFilteringOnSocialEngineeringSites(); | 243 ResetConfigurationToEnableFilteringOnSocialEngineeringSites(); |
| 243 | 244 |
| 244 // Add a subframe. | 245 // Add a subframe. |
| 245 content::RenderFrameHostTester* rfh_tester = | 246 content::RenderFrameHostTester* rfh_tester = |
| 246 content::RenderFrameHostTester::For(main_rfh()); | 247 content::RenderFrameHostTester::For(main_rfh()); |
| 247 rfh_tester->InitializeRenderFrameIfNeeded(); | 248 rfh_tester->InitializeRenderFrameIfNeeded(); |
| 248 rfh_tester->AppendChild(kSubframeName); | 249 rfh_tester->AppendChild(kSubframeName); |
| 249 | 250 |
| 250 Observe(content::RenderViewHostTestHarness::web_contents()); | 251 Observe(content::RenderViewHostTestHarness::web_contents()); |
| 251 } | 252 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 269 ResetConfiguration(Configuration( | 270 ResetConfiguration(Configuration( |
| 270 ActivationLevel::ENABLED, ActivationScope::ACTIVATION_LIST, | 271 ActivationLevel::ENABLED, ActivationScope::ACTIVATION_LIST, |
| 271 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL)); | 272 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL)); |
| 272 } | 273 } |
| 273 | 274 |
| 274 ContentSubresourceFilterDriverFactory* factory() { | 275 ContentSubresourceFilterDriverFactory* factory() { |
| 275 return ContentSubresourceFilterDriverFactory::FromWebContents( | 276 return ContentSubresourceFilterDriverFactory::FromWebContents( |
| 276 RenderViewHostTestHarness::web_contents()); | 277 RenderViewHostTestHarness::web_contents()); |
| 277 } | 278 } |
| 278 | 279 |
| 279 MockSubresourceFilterClient* client() { return client_; } | 280 MockSubresourceFilterClient* client() { return client_.get(); } |
| 280 | 281 |
| 281 content::RenderFrameHost* GetSubframeRFH() { | 282 content::RenderFrameHost* GetSubframeRFH() { |
| 282 for (content::RenderFrameHost* rfh : | 283 for (content::RenderFrameHost* rfh : |
| 283 RenderViewHostTestHarness::web_contents()->GetAllFrames()) { | 284 RenderViewHostTestHarness::web_contents()->GetAllFrames()) { |
| 284 if (rfh->GetFrameName() == kSubframeName) | 285 if (rfh->GetFrameName() == kSubframeName) |
| 285 return rfh; | 286 return rfh; |
| 286 } | 287 } |
| 287 return nullptr; | 288 return nullptr; |
| 288 } | 289 } |
| 289 | 290 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 .performance_measurement_rate; | 487 .performance_measurement_rate; |
| 487 // Note: The case when 0 < rate < 1 is not deterministic, don't test it. | 488 // Note: The case when 0 < rate < 1 is not deterministic, don't test it. |
| 488 EXPECT_TRUE(rate == 0 || rate == 1); | 489 EXPECT_TRUE(rate == 0 || rate == 1); |
| 489 return rate == 1; | 490 return rate == 1; |
| 490 } | 491 } |
| 491 | 492 |
| 492 testing::ScopedSubresourceFilterConfigurator scoped_configuration_; | 493 testing::ScopedSubresourceFilterConfigurator scoped_configuration_; |
| 493 testing::TestRulesetCreator test_ruleset_creator_; | 494 testing::TestRulesetCreator test_ruleset_creator_; |
| 494 testing::TestRulesetPair test_ruleset_pair_; | 495 testing::TestRulesetPair test_ruleset_pair_; |
| 495 | 496 |
| 496 // Owned by the factory. | 497 std::unique_ptr<MockSubresourceFilterClient> client_; |
| 497 MockSubresourceFilterClient* client_; | |
| 498 | |
| 499 std::unique_ptr<VerifiedRulesetDealer::Handle> ruleset_dealer_; | 498 std::unique_ptr<VerifiedRulesetDealer::Handle> ruleset_dealer_; |
| 500 | 499 |
| 501 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterDriverFactoryTest); | 500 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterDriverFactoryTest); |
| 502 }; | 501 }; |
| 503 | 502 |
| 504 class ContentSubresourceFilterDriverFactoryThreatTypeTest | 503 class ContentSubresourceFilterDriverFactoryThreatTypeTest |
| 505 : public ContentSubresourceFilterDriverFactoryTest, | 504 : public ContentSubresourceFilterDriverFactoryTest, |
| 506 public ::testing::WithParamInterface<ActivationListTestData> { | 505 public ::testing::WithParamInterface<ActivationListTestData> { |
| 507 public: | 506 public: |
| 508 ContentSubresourceFilterDriverFactoryThreatTypeTest() {} | 507 ContentSubresourceFilterDriverFactoryThreatTypeTest() {} |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 ActivationScopeTest, | 861 ActivationScopeTest, |
| 863 ContentSubresourceFilterDriverFactoryActivationScopeTest, | 862 ContentSubresourceFilterDriverFactoryActivationScopeTest, |
| 864 ::testing::ValuesIn(kActivationScopeTestData)); | 863 ::testing::ValuesIn(kActivationScopeTestData)); |
| 865 | 864 |
| 866 INSTANTIATE_TEST_CASE_P( | 865 INSTANTIATE_TEST_CASE_P( |
| 867 ActivationLevelTest, | 866 ActivationLevelTest, |
| 868 ContentSubresourceFilterDriverFactoryActivationLevelTest, | 867 ContentSubresourceFilterDriverFactoryActivationLevelTest, |
| 869 ::testing::ValuesIn(kActivationLevelTestData)); | 868 ::testing::ValuesIn(kActivationLevelTestData)); |
| 870 | 869 |
| 871 } // namespace subresource_filter | 870 } // namespace subresource_filter |
| OLD | NEW |