OLD | NEW |
| (Empty) |
1 // Copyright (c) 2017 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/safe_browsing/features.h" | |
6 | |
7 #include <stddef.h> | |
8 #include <algorithm> | |
9 #include <utility> | |
10 #include <vector> | |
11 #include "base/feature_list.h" | |
12 | |
13 #include "base/macros.h" | |
14 #include "base/values.h" | |
15 namespace safe_browsing { | |
16 // Please define any new SafeBrowsing related features in this file, and add | |
17 // them to the ExperimentalFeaturesList below to start displaying their status | |
18 // on the chrome://safe-browsing page. | |
19 const base::Feature kLocalDatabaseManagerEnabled{ | |
20 "SafeBrowsingV4LocalDatabaseManagerEnabled", | |
21 base::FEATURE_DISABLED_BY_DEFAULT}; | |
22 | |
23 const base::Feature kV4OnlyEnabled{"SafeBrowsingV4OnlyEnabled", | |
24 base::FEATURE_DISABLED_BY_DEFAULT}; | |
25 // This Feature specifies which non-resource HTML Elements to collect based on | |
26 // their tag and attributes. It's a single param containing a comma-separated | |
27 // list of pairs. For example: "tag1,id,tag1,height,tag2,foo" - this will | |
28 // collect elements with tag "tag1" that have attribute "id" or "height" set, | |
29 // and elements of tag "tag2" if they have attribute "foo" set. All tag names | |
30 // and attributes should be lower case. | |
31 const base::Feature kThreatDomDetailsTagAndAttributeFeature{ | |
32 "ThreatDomDetailsTagAttributes", base::FEATURE_DISABLED_BY_DEFAULT}; | |
33 | |
34 namespace { | |
35 // List of experimental features. Boolean value for each list member should be | |
36 // set to True if the experiment is currently running at a probability other | |
37 // than 1 or 0, or to False otherwise. | |
38 std::vector<std::pair<const base::Feature*, bool>> ExperimentalFeaturesList = { | |
39 std::make_pair(&kLocalDatabaseManagerEnabled, true), | |
40 std::make_pair(&kV4OnlyEnabled, true), | |
41 std::make_pair(&kThreatDomDetailsTagAndAttributeFeature, true)}; | |
42 | |
43 // Adds the name and the enabled/disabled status of a given feature. | |
44 void AddFeatureAndAvailability(const base::Feature* expFeature, | |
45 base::ListValue* paramList) { | |
46 paramList->GetList().push_back(base::Value(expFeature->name)); | |
47 if (base::FeatureList::IsEnabled(*expFeature)) { | |
48 paramList->GetList().push_back(base::Value("Enabled")); | |
49 } else { | |
50 paramList->GetList().push_back(base::Value("Disabled")); | |
51 } | |
52 } | |
53 } // namespace | |
54 // Returns the list of the experimental features that are enabled or disabled, | |
55 // as part of currently running Safe Browsing experiments. | |
56 base::ListValue GetFeatureStatusList() { | |
57 base::ListValue paramList; | |
58 for (std::vector<std::pair<const base::Feature*, bool>>::iterator it = | |
59 ExperimentalFeaturesList.begin(); | |
60 it != ExperimentalFeaturesList.end(); ++it) { | |
61 if ((*it).second) { | |
62 AddFeatureAndAvailability((*it).first, ¶mList); | |
63 } | |
64 } | |
65 return paramList; | |
66 } | |
67 | |
68 } // namespace safe_browsing | |
OLD | NEW |