Chromium Code Reviews| Index: components/safe_browsing/features.cc |
| diff --git a/components/safe_browsing/features.cc b/components/safe_browsing/features.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c8f28e2bf0336dda18b05bbd0812c962e096b21b |
| --- /dev/null |
| +++ b/components/safe_browsing/features.cc |
| @@ -0,0 +1,59 @@ |
| +// Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| +#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.
|
| +#include <stddef.h> |
| +#include <algorithm> |
| +#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.
|
| +#include <vector> |
| +#include "base/feature_list.h" |
|
Jialiu Lin
2017/07/06 23:58:27
nit:empty line
hkamila
2017/07/07 01:29:49
Acknowledged.
|
| +#include "base/macros.h" |
| +#include "base/values.h" |
| + |
|
Jialiu Lin
2017/07/06 23:58:27
safe_browsing namespace?
hkamila
2017/07/07 01:29:49
Acknowledged.
|
| +// 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.
|
| +// ExperimentalFeaturesListbelow as well. |
|
vakh (use Gerrit instead)
2017/07/07 00:23:40
ExperimentalFeaturesList below
hkamila
2017/07/07 01:29:49
Acknowledged.
|
| +const base::Feature kLocalDatabaseManagerEnabled{ |
| + "SafeBrowsingV4LocalDatabaseManagerEnabled", |
| + base::FEATURE_DISABLED_BY_DEFAULT}; |
| + |
| +const base::Feature kV4OnlyEnabled{"SafeBrowsingV4OnlyEnabled", |
| + base::FEATURE_DISABLED_BY_DEFAULT}; |
| +// This Feature specifies which non-resource HTML Elements to collect based on |
| +// their tag and attributes. It's a single param containing a comma-separated |
| +// list of pairs. For example: "tag1,id,tag1,height,tag2,foo" - this will |
| +// collect elements with tag "tag1" that have attribute "id" or "height" set, |
| +// and elements of tag "tag2" if they have attribute "foo" set. All tag names |
| +// and attributes should be lower case. |
| +const base::Feature kThreatDomDetailsTagAndAttributeFeature{ |
| + "ThreatDomDetailsTagAttributes", base::FEATURE_DISABLED_BY_DEFAULT}; |
| +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.
|
| + |
| +// List of experimental features. Boolean value for each list member should be |
| +// set to True if the experiment is currently running at a probability other |
| +// than 1 or 0, or to False otherwise. |
| +std::vector<std::pair<const base::Feature*, bool>> ExperimentalFeaturesList = { |
| + std::make_pair(&kLocalDatabaseManagerEnabled, true), |
| + std::make_pair(&kV4OnlyEnabled, true), |
| + std::make_pair(&kThreatDomDetailsTagAndAttributeFeature, true)}; |
| + |
| +// 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.
|
| +// a feature is enabled or disabled. |
| +void AddFeatureAndAvailability(const base::Feature* expFeature) { |
| + paramList.GetList().push_back(base::Value(expFeature->name)); |
| + if (base::FeatureList::IsEnabled(*expFeature)) { |
| + paramList.GetList().push_back(base::Value("Enabled")); |
| + } else { |
| + paramList.GetList().push_back(base::Value("Disabled")); |
| + } |
| +} |
| + |
| +// Returns the list of the experimental features that are enabled or disabled, |
| +// as part of currently running Safe Browsing experiments. |
| +base::ListValue GetTrueParametersList() { |
|
vakh (use Gerrit instead)
2017/07/07 00:23:40
rename suggestion: GetFeatureStatusList()
hkamila
2017/07/07 01:29:49
Acknowledged.
|
| + 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.
|
| + 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.
|
| + AddFeatureAndAvailability(ExperimentalFeaturesList[i].first); |
| + } |
| + } |
| + return paramList; |
| +} |