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

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

Issue 2022783002: Skeleton of the Safe Browsing Subresource Filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implement RenderFrameObserver::OnDestruct introduced by rebase. Created 4 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/subresource_filter/core/browser/subresource_filter_features _test_support.h"
6
7 #include <map>
8 #include <memory>
9
10 #include "base/metrics/field_trial.h"
11 #include "components/subresource_filter/core/browser/subresource_filter_features .h"
12 #include "components/variations/variations_associated_data.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace subresource_filter {
16 namespace testing {
17
18 namespace {
19 const char kTestFieldTrialName[] = "FieldTrialNameShouldNotMatter";
20 const char kTestExperimentGroupName[] = "GroupNameShouldNotMatter";
21 } // namespace
22
23 ScopedSubresourceFilterFeatureToggle::ScopedSubresourceFilterFeatureToggle(
24 base::FeatureList::OverrideState feature_state,
25 const std::string& maximum_activation_state) {
26 base::FeatureList::ClearInstanceForTesting();
27 variations::testing::ClearAllVariationParams();
28
29 std::map<std::string, std::string> variation_params;
30 variation_params[kActivationStateParameterName] = maximum_activation_state;
31 EXPECT_TRUE(variations::AssociateVariationParams(
32 kTestFieldTrialName, kTestExperimentGroupName, variation_params));
33
34 base::FieldTrial* field_trial = base::FieldTrialList::CreateFieldTrial(
35 kTestFieldTrialName, kTestExperimentGroupName);
36
37 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
38 feature_list->RegisterFieldTrialOverride(kSafeBrowsingSubresourceFilter.name,
39 feature_state, field_trial);
40 base::FeatureList::SetInstance(std::move(feature_list));
41 }
42
43 ScopedSubresourceFilterFeatureToggle::~ScopedSubresourceFilterFeatureToggle() {
44 variations::testing::ClearAllVariationParams();
45 base::FeatureList::ClearInstanceForTesting();
46 }
47
48 } // namespace testing
49 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698