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>> |
| 39 GetExperimentalFeaturesList() { |
| 40 std::vector<std::pair<const base::Feature*, bool>> experimental_features_list{ |
| 41 std::make_pair(&kLocalDatabaseManagerEnabled, true), |
| 42 std::make_pair(&kV4OnlyEnabled, true), |
| 43 std::make_pair(&kThreatDomDetailsTagAndAttributeFeature, true)}; |
| 44 |
| 45 return experimental_features_list; |
| 46 } |
| 47 |
| 48 // Adds the name and the enabled/disabled status of a given feature. |
| 49 void AddFeatureAndAvailability(const base::Feature* exp_feature, |
| 50 base::ListValue* param_list) { |
| 51 param_list->GetList().push_back(base::Value(exp_feature->name)); |
| 52 if (base::FeatureList::IsEnabled(*exp_feature)) { |
| 53 param_list->GetList().push_back(base::Value("Enabled")); |
| 54 } else { |
| 55 param_list->GetList().push_back(base::Value("Disabled")); |
| 56 } |
| 57 } |
| 58 } // namespace |
| 59 |
| 60 // Returns the list of the experimental features that are enabled or disabled, |
| 61 // as part of currently running Safe Browsing experiments. |
| 62 base::ListValue GetFeatureStatusList() { |
| 63 std::vector<std::pair<const base::Feature*, bool>> features_list = |
| 64 GetExperimentalFeaturesList(); |
| 65 |
| 66 base::ListValue param_list; |
| 67 for (std::vector<std::pair<const base::Feature*, bool>>::iterator it = |
| 68 features_list.begin(); |
| 69 it != features_list.end(); ++it) { |
| 70 if ((*it).second) { |
| 71 AddFeatureAndAvailability((*it).first, ¶m_list); |
| 72 } |
| 73 } |
| 74 return param_list; |
| 75 } |
| 76 |
| 77 } // namespace safe_browsing |
OLD | NEW |