Index: components/subresource_filter/core/browser/subresource_filter_features_test_support.cc |
diff --git a/components/subresource_filter/core/browser/subresource_filter_features_test_support.cc b/components/subresource_filter/core/browser/subresource_filter_features_test_support.cc |
index d1cf6a51efacb67bc36f8cbfce3d62d9d1b0afe6..df18a7386246c667b6fb29c82310aa4f34c1bfbf 100644 |
--- a/components/subresource_filter/core/browser/subresource_filter_features_test_support.cc |
+++ b/components/subresource_filter/core/browser/subresource_filter_features_test_support.cc |
@@ -16,32 +16,69 @@ namespace testing { |
// ScopedSubresourceFilterConfigurator ---------------------------------------- |
ScopedSubresourceFilterConfigurator::ScopedSubresourceFilterConfigurator( |
- scoped_refptr<ConfigurationList> configs) |
- : original_config_(GetAndSetActivateConfigurations(configs)) {} |
+ scoped_refptr<ConfigurationList> configs_list) |
+ : original_config_(GetAndSetActivateConfigurations(configs_list)) {} |
ScopedSubresourceFilterConfigurator::ScopedSubresourceFilterConfigurator( |
Configuration config) |
: ScopedSubresourceFilterConfigurator( |
- base::MakeShared<ConfigurationList>(std::move(config))) {} |
+ std::vector<Configuration>(1, std::move(config))) {} |
+ |
+ScopedSubresourceFilterConfigurator::ScopedSubresourceFilterConfigurator( |
+ std::vector<Configuration> configs) |
+ : ScopedSubresourceFilterConfigurator( |
+ base::MakeShared<ConfigurationList>(std::move(configs))) {} |
ScopedSubresourceFilterConfigurator::~ScopedSubresourceFilterConfigurator() { |
GetAndSetActivateConfigurations(std::move(original_config_)); |
} |
+void ScopedSubresourceFilterConfigurator::ResetConfiguration( |
+ scoped_refptr<ConfigurationList> configs_list) { |
+ GetAndSetActivateConfigurations(configs_list); |
+} |
+ |
void ScopedSubresourceFilterConfigurator::ResetConfiguration( |
Configuration config) { |
- GetAndSetActivateConfigurations( |
- base::MakeShared<ConfigurationList>(std::move(config))); |
+ ResetConfiguration(std::vector<Configuration>(1, std::move(config))); |
+} |
+ |
+void ScopedSubresourceFilterConfigurator::ResetConfiguration( |
+ std::vector<Configuration> config) { |
+ ResetConfiguration(base::MakeShared<ConfigurationList>(std::move(config))); |
} |
// ScopedSubresourceFilterFeatureToggle --------------------------------------- |
+ScopedSubresourceFilterFeatureToggle::ScopedSubresourceFilterFeatureToggle() {} |
ScopedSubresourceFilterFeatureToggle::ScopedSubresourceFilterFeatureToggle( |
- base::FeatureList::OverrideState feature_state) { |
- if (feature_state == base::FeatureList::OVERRIDE_ENABLE_FEATURE) |
- scoped_feature_list_.InitAndEnableFeature(kSafeBrowsingSubresourceFilter); |
- else if (feature_state == base::FeatureList::OVERRIDE_DISABLE_FEATURE) |
- scoped_feature_list_.InitAndDisableFeature(kSafeBrowsingSubresourceFilter); |
+ base::FeatureList::OverrideState feature_state, |
+ const std::string& additional_features_to_enable) { |
+ ResetSubresourceFilterState(feature_state, additional_features_to_enable); |
+} |
+ |
+void ScopedSubresourceFilterFeatureToggle::ResetSubresourceFilterState( |
+ base::FeatureList::OverrideState feature_state, |
+ const std::string& additional_features_to_enable) { |
+ std::string enabled_features; |
+ std::string disabled_features; |
+ |
+ if (feature_state == base::FeatureList::OVERRIDE_ENABLE_FEATURE) { |
+ enabled_features = kSafeBrowsingSubresourceFilter.name; |
+ } else if (feature_state == base::FeatureList::OVERRIDE_DISABLE_FEATURE) { |
+ disabled_features = kSafeBrowsingSubresourceFilter.name; |
+ } |
+ |
+ if (!additional_features_to_enable.empty()) { |
+ if (!enabled_features.empty()) |
+ enabled_features += ','; |
+ enabled_features += additional_features_to_enable; |
+ } |
+ |
+ scoped_configuration_.ResetConfiguration(); |
+ scoped_feature_list_ = base::MakeUnique<base::test::ScopedFeatureList>(); |
+ scoped_feature_list_->InitFromCommandLine(enabled_features, |
+ disabled_features); |
} |
ScopedSubresourceFilterFeatureToggle::~ScopedSubresourceFilterFeatureToggle() {} |