Chromium Code Reviews| 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 #include "components/safe_browsing/features.h" | |
|
Jialiu Lin
2017/07/06 23:58:27
nit: empty line
hkamila
2017/07/07 01:29:49
Acknowledged.
| |
| 5 #include <stddef.h> | |
| 6 #include <algorithm> | |
| 7 #include <utility> | |
|
vakh (use Gerrit instead)
2017/07/07 00:23:40
The overall structure of the file could be like th
hkamila
2017/07/07 01:29:48
Acknowledged.
| |
| 8 #include <vector> | |
| 9 #include "base/feature_list.h" | |
|
Jialiu Lin
2017/07/06 23:58:27
nit:empty line
hkamila
2017/07/07 01:29:49
Acknowledged.
| |
| 10 #include "base/macros.h" | |
| 11 #include "base/values.h" | |
| 12 | |
|
Jialiu Lin
2017/07/06 23:58:27
safe_browsing namespace?
hkamila
2017/07/07 01:29:49
Acknowledged.
| |
| 13 // Add your experimental features list. Please add your features to the vector | |
|
vakh (use Gerrit instead)
2017/07/07 00:23:40
A more descriptive comment would be useful here. S
hkamila
2017/07/07 01:29:49
Acknowledged.
hkamila
2017/07/07 01:29:49
Acknowledged.
| |
| 14 // ExperimentalFeaturesListbelow as well. | |
|
vakh (use Gerrit instead)
2017/07/07 00:23:40
ExperimentalFeaturesList below
hkamila
2017/07/07 01:29:49
Acknowledged.
| |
| 15 const base::Feature kLocalDatabaseManagerEnabled{ | |
| 16 "SafeBrowsingV4LocalDatabaseManagerEnabled", | |
| 17 base::FEATURE_DISABLED_BY_DEFAULT}; | |
| 18 | |
| 19 const base::Feature kV4OnlyEnabled{"SafeBrowsingV4OnlyEnabled", | |
| 20 base::FEATURE_DISABLED_BY_DEFAULT}; | |
| 21 // This Feature specifies which non-resource HTML Elements to collect based on | |
| 22 // their tag and attributes. It's a single param containing a comma-separated | |
| 23 // list of pairs. For example: "tag1,id,tag1,height,tag2,foo" - this will | |
| 24 // collect elements with tag "tag1" that have attribute "id" or "height" set, | |
| 25 // and elements of tag "tag2" if they have attribute "foo" set. All tag names | |
| 26 // and attributes should be lower case. | |
| 27 const base::Feature kThreatDomDetailsTagAndAttributeFeature{ | |
| 28 "ThreatDomDetailsTagAttributes", base::FEATURE_DISABLED_BY_DEFAULT}; | |
| 29 base::ListValue paramList; | |
|
vakh (use Gerrit instead)
2017/07/07 00:23:40
Let's not use global variables :)
hkamila
2017/07/07 01:29:49
Acknowledged.
| |
| 30 | |
| 31 // List of experimental features. Boolean value for each list member should be | |
| 32 // set to True if the experiment is currently running at a probability other | |
| 33 // than 1 or 0, or to False otherwise. | |
| 34 std::vector<std::pair<const base::Feature*, bool>> ExperimentalFeaturesList = { | |
| 35 std::make_pair(&kLocalDatabaseManagerEnabled, true), | |
| 36 std::make_pair(&kV4OnlyEnabled, true), | |
| 37 std::make_pair(&kThreatDomDetailsTagAndAttributeFeature, true)}; | |
| 38 | |
| 39 // Method function for adding the name of the feature and deciding if | |
|
vakh (use Gerrit instead)
2017/07/07 00:23:40
Adds the name and the enabled/disabled status of a
hkamila
2017/07/07 01:29:49
Acknowledged.
| |
| 40 // a feature is enabled or disabled. | |
| 41 void AddFeatureAndAvailability(const base::Feature* expFeature) { | |
| 42 paramList.GetList().push_back(base::Value(expFeature->name)); | |
| 43 if (base::FeatureList::IsEnabled(*expFeature)) { | |
| 44 paramList.GetList().push_back(base::Value("Enabled")); | |
| 45 } else { | |
| 46 paramList.GetList().push_back(base::Value("Disabled")); | |
| 47 } | |
| 48 } | |
| 49 | |
| 50 // Returns the list of the experimental features that are enabled or disabled, | |
| 51 // as part of currently running Safe Browsing experiments. | |
| 52 base::ListValue GetTrueParametersList() { | |
|
vakh (use Gerrit instead)
2017/07/07 00:23:40
rename suggestion: GetFeatureStatusList()
hkamila
2017/07/07 01:29:49
Acknowledged.
| |
| 53 for (unsigned int i = 0; i < ExperimentalFeaturesList.size(); i++) { | |
|
vakh (use Gerrit instead)
2017/07/07 00:23:40
why not use iterator instead?
hkamila
2017/07/07 01:29:49
Acknowledged.
| |
| 54 if (ExperimentalFeaturesList[i].second == true) { | |
|
vakh (use Gerrit instead)
2017/07/07 00:23:40
if (ExperimentalFeaturesList[i].second)
hkamila
2017/07/07 01:29:48
Acknowledged.
| |
| 55 AddFeatureAndAvailability(ExperimentalFeaturesList[i].first); | |
| 56 } | |
| 57 } | |
| 58 return paramList; | |
| 59 } | |
| OLD | NEW |