Chromium Code Reviews| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 {ActivationDecision::ACTIVATION_DISABLED, ActivationLevel::DISABLED}, | 182 {ActivationDecision::ACTIVATION_DISABLED, ActivationLevel::DISABLED}, |
| 183 }; | 183 }; |
| 184 | 184 |
| 185 class MockSubresourceFilterClient : public SubresourceFilterClient { | 185 class MockSubresourceFilterClient : public SubresourceFilterClient { |
| 186 public: | 186 public: |
| 187 MockSubresourceFilterClient(VerifiedRulesetDealer::Handle* ruleset_dealer) | 187 MockSubresourceFilterClient(VerifiedRulesetDealer::Handle* ruleset_dealer) |
| 188 : ruleset_dealer_(ruleset_dealer) {} | 188 : ruleset_dealer_(ruleset_dealer) {} |
| 189 | 189 |
| 190 ~MockSubresourceFilterClient() override = default; | 190 ~MockSubresourceFilterClient() override = default; |
| 191 | 191 |
| 192 bool ShouldSuppressActivation(content::NavigationHandle* handle) override { | 192 bool OnPageActivationComputed(content::NavigationHandle* handle, |
| 193 return handle->IsInMainFrame() && | 193 bool activated) override { |
| 194 whitelisted_hosts_.find(handle->GetURL().host()) != | 194 DCHECK(handle->IsInMainFrame()); |
| 195 whitelisted_hosts_.end(); | 195 return activated && whitelisted_hosts_.find(handle->GetURL().host()) != |
| 196 whitelisted_hosts_.end(); | |
|
shivanisha
2017/05/10 17:34:25
nit (for sake of conciseness):
return activated
engedy
2017/05/10 17:40:20
Actually, I just discovered there is base::Contain
Charlie Harrison
2017/05/10 18:17:21
Changed to use base::ContainsValue, but it's a set
| |
| 196 } | 197 } |
| 197 | 198 |
| 198 void WhitelistByContentSettings(const GURL& url) override {} | 199 void WhitelistByContentSettings(const GURL& url) override {} |
| 199 void WhitelistInCurrentWebContents(const GURL& url) override { | 200 void WhitelistInCurrentWebContents(const GURL& url) override { |
| 200 if (url.SchemeIsHTTPOrHTTPS()) | 201 if (url.SchemeIsHTTPOrHTTPS()) |
| 201 whitelisted_hosts_.insert(url.host()); | 202 whitelisted_hosts_.insert(url.host()); |
| 202 } | 203 } |
| 203 | 204 |
| 204 VerifiedRulesetDealer::Handle* GetRulesetDealer() override { | 205 VerifiedRulesetDealer::Handle* GetRulesetDealer() override { |
| 205 return ruleset_dealer_; | 206 return ruleset_dealer_; |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 ActivationScopeTest, | 862 ActivationScopeTest, |
| 862 ContentSubresourceFilterDriverFactoryActivationScopeTest, | 863 ContentSubresourceFilterDriverFactoryActivationScopeTest, |
| 863 ::testing::ValuesIn(kActivationScopeTestData)); | 864 ::testing::ValuesIn(kActivationScopeTestData)); |
| 864 | 865 |
| 865 INSTANTIATE_TEST_CASE_P( | 866 INSTANTIATE_TEST_CASE_P( |
| 866 ActivationLevelTest, | 867 ActivationLevelTest, |
| 867 ContentSubresourceFilterDriverFactoryActivationLevelTest, | 868 ContentSubresourceFilterDriverFactoryActivationLevelTest, |
| 868 ::testing::ValuesIn(kActivationLevelTestData)); | 869 ::testing::ValuesIn(kActivationLevelTestData)); |
| 869 | 870 |
| 870 } // namespace subresource_filter | 871 } // namespace subresource_filter |
| OLD | NEW |