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

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

Issue 2272323002: Allow Safe Browsing Saresource Filter to distinguish between different lists. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix safe_browsing_service_browsertest Created 4 years, 3 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 <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
11 #include "components/subresource_filter/core/browser/subresource_filter_features .h" 11 #include "components/subresource_filter/core/browser/subresource_filter_features .h"
12 #include "components/variations/variations_associated_data.h" 12 #include "components/variations/variations_associated_data.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace subresource_filter { 15 namespace subresource_filter {
16 namespace testing { 16 namespace testing {
17 17
18 namespace { 18 namespace {
19 const char kTestFieldTrialName[] = "FieldTrialNameShouldNotMatter"; 19 const char kTestFieldTrialName[] = "FieldTrialNameShouldNotMatter";
20 const char kTestExperimentGroupName[] = "GroupNameShouldNotMatter"; 20 const char kTestExperimentGroupName[] = "GroupNameShouldNotMatter";
21 } // namespace 21 } // namespace
22 22
23 ScopedSubresourceFilterFeatureToggle::ScopedSubresourceFilterFeatureToggle( 23 ScopedSubresourceFilterFeatureToggle::ScopedSubresourceFilterFeatureToggle(
24 base::FeatureList::OverrideState feature_state, 24 base::FeatureList::OverrideState feature_state,
25 const std::string& maximum_activation_state, 25 const std::string& maximum_activation_state,
26 const std::string& activation_scope) { 26 const std::string& activation_scope)
27 : ScopedSubresourceFilterFeatureToggle(feature_state,
28 maximum_activation_state,
29 activation_scope,
30 std::string()) {}
31
32 ScopedSubresourceFilterFeatureToggle::ScopedSubresourceFilterFeatureToggle(
33 base::FeatureList::OverrideState feature_state,
34 const std::string& maximum_activation_state,
35 const std::string& activation_scope,
36 const std::string& activation_lists) {
27 variations::testing::ClearAllVariationParams(); 37 variations::testing::ClearAllVariationParams();
28 38
29 std::map<std::string, std::string> variation_params; 39 std::map<std::string, std::string> variation_params;
30 variation_params[kActivationStateParameterName] = maximum_activation_state; 40 variation_params[kActivationStateParameterName] = maximum_activation_state;
31 variation_params[kActivationScopeParameterName] = activation_scope; 41 variation_params[kActivationScopeParameterName] = activation_scope;
42 variation_params[kActivationListsParameterName] = activation_lists;
32 EXPECT_TRUE(variations::AssociateVariationParams( 43 EXPECT_TRUE(variations::AssociateVariationParams(
33 kTestFieldTrialName, kTestExperimentGroupName, variation_params)); 44 kTestFieldTrialName, kTestExperimentGroupName, variation_params));
34 45
35 base::FieldTrial* field_trial = base::FieldTrialList::CreateFieldTrial( 46 base::FieldTrial* field_trial = base::FieldTrialList::CreateFieldTrial(
36 kTestFieldTrialName, kTestExperimentGroupName); 47 kTestFieldTrialName, kTestExperimentGroupName);
37 48
38 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 49 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
39 feature_list->RegisterFieldTrialOverride(kSafeBrowsingSubresourceFilter.name, 50 feature_list->RegisterFieldTrialOverride(kSafeBrowsingSubresourceFilter.name,
40 feature_state, field_trial); 51 feature_state, field_trial);
41 scoped_feature_list_.InitWithFeatureList(std::move(feature_list)); 52 scoped_feature_list_.InitWithFeatureList(std::move(feature_list));
42 } 53 }
43 54
44 ScopedSubresourceFilterFeatureToggle::~ScopedSubresourceFilterFeatureToggle() { 55 ScopedSubresourceFilterFeatureToggle::~ScopedSubresourceFilterFeatureToggle() {
45 variations::testing::ClearAllVariationParams(); 56 variations::testing::ClearAllVariationParams();
46 } 57 }
47 58
48 } // namespace testing 59 } // namespace testing
49 } // namespace subresource_filter 60 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698