Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: components/subresource_filter/core/browser/subresource_filter_features_test_support.cc

Issue 2844063002: Add support for multiple simultaneous subresource_filter::Configurations. (Closed)
Patch Set: Polish + rebase. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/core/browser/subresource_filter_features _test_support.h" 5 #include "components/subresource_filter/core/browser/subresource_filter_features _test_support.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 12
13 namespace subresource_filter { 13 namespace subresource_filter {
14 namespace testing { 14 namespace testing {
15 15
16 // ScopedSubresourceFilterConfigurator ---------------------------------------- 16 // ScopedSubresourceFilterConfigurator ----------------------------------------
17 17
18 ScopedSubresourceFilterConfigurator::ScopedSubresourceFilterConfigurator( 18 ScopedSubresourceFilterConfigurator::ScopedSubresourceFilterConfigurator(
19 scoped_refptr<ConfigurationList> configs) 19 scoped_refptr<ConfigurationList> configs)
20 : original_config_(GetAndSetActivateConfigurations(configs)) {} 20 : original_config_(GetAndSetActivateConfigurations(configs)) {}
21 21
22 ScopedSubresourceFilterConfigurator::ScopedSubresourceFilterConfigurator( 22 ScopedSubresourceFilterConfigurator::ScopedSubresourceFilterConfigurator(
23 Configuration config) 23 Configuration config)
24 : ScopedSubresourceFilterConfigurator( 24 : ScopedSubresourceFilterConfigurator(
25 base::MakeShared<ConfigurationList>(std::move(config))) {} 25 base::MakeShared<ConfigurationList>(std::move(config))) {}
26 26
27 ScopedSubresourceFilterConfigurator::ScopedSubresourceFilterConfigurator(
28 std::vector<Configuration> configs)
29 : ScopedSubresourceFilterConfigurator(
30 base::MakeShared<ConfigurationList>(std::move(configs))) {}
31
27 ScopedSubresourceFilterConfigurator::~ScopedSubresourceFilterConfigurator() { 32 ScopedSubresourceFilterConfigurator::~ScopedSubresourceFilterConfigurator() {
28 GetAndSetActivateConfigurations(std::move(original_config_)); 33 GetAndSetActivateConfigurations(std::move(original_config_));
29 } 34 }
30 35
31 void ScopedSubresourceFilterConfigurator::ResetConfiguration( 36 void ScopedSubresourceFilterConfigurator::ResetConfiguration(
32 Configuration config) { 37 Configuration config) {
33 GetAndSetActivateConfigurations( 38 GetAndSetActivateConfigurations(
34 base::MakeShared<ConfigurationList>(std::move(config))); 39 base::MakeShared<ConfigurationList>(std::move(config)));
35 } 40 }
36 41
37 // ScopedSubresourceFilterFeatureToggle --------------------------------------- 42 // ScopedSubresourceFilterFeatureToggle ---------------------------------------
38 43
39 ScopedSubresourceFilterFeatureToggle::ScopedSubresourceFilterFeatureToggle( 44 ScopedSubresourceFilterFeatureToggle::ScopedSubresourceFilterFeatureToggle(
40 base::FeatureList::OverrideState feature_state) { 45 base::FeatureList::OverrideState feature_state) {
41 if (feature_state == base::FeatureList::OVERRIDE_ENABLE_FEATURE) 46 if (feature_state == base::FeatureList::OVERRIDE_ENABLE_FEATURE)
42 scoped_feature_list_.InitAndEnableFeature(kSafeBrowsingSubresourceFilter); 47 scoped_feature_list_.InitAndEnableFeature(kSafeBrowsingSubresourceFilter);
43 else if (feature_state == base::FeatureList::OVERRIDE_DISABLE_FEATURE) 48 else if (feature_state == base::FeatureList::OVERRIDE_DISABLE_FEATURE)
44 scoped_feature_list_.InitAndDisableFeature(kSafeBrowsingSubresourceFilter); 49 scoped_feature_list_.InitAndDisableFeature(kSafeBrowsingSubresourceFilter);
45 } 50 }
46 51
47 ScopedSubresourceFilterFeatureToggle::~ScopedSubresourceFilterFeatureToggle() {} 52 ScopedSubresourceFilterFeatureToggle::~ScopedSubresourceFilterFeatureToggle() {}
48 53
49 } // namespace testing 54 } // namespace testing
50 } // namespace subresource_filter 55 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698