blob: 50108df498c18c8f66639ac3b48b919bb14412c6 [file] [log] [blame]
// 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"
#include <stddef.h>
#include <algorithm>
#include <utility>
#include <vector>
#include "base/feature_list.h"
#include "base/macros.h"
#include "base/values.h"
namespace safe_browsing {
// Please define any new SafeBrowsing related features in this file, and add
// them to the ExperimentalFeaturesList below to start displaying their status
// on the chrome://safe-browsing page.
// Allows an ad sample report to be created but not sent. Used to measure
// performance impact of report generation.
const base::Feature kAdSamplerCollectButDontSendFeature{
// Controls various parameters related to occasionally collecting ad samples,
// for example to control how often collection should occur.
const base::Feature kAdSamplerTriggerFeature{"SafeBrowsingAdSamplerTrigger",
const base::Feature kGaiaPasswordReuseReporting{
"SyncPasswordReuseEvent", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kGoogleBrandedPhishingWarning{
// If enabled, SafeBrowsing URL checks don't defer starting requests or
// following redirects, no matter on desktop or mobile. Instead they only defer
// response processing.
// Please note that when --enable-features=NetworkService is in effect,
// SafeBrowsing URL checks never block starting requests or following redirects.
// S13nSafeBrowsingParallelUrlCheck is ignored in that case.
const base::Feature kParallelUrlCheck{"S13nSafeBrowsingParallelUrlCheck",
const base::Feature kThreatDomDetailsTagAndAttributeFeature{
"ThreatDomDetailsTagAttributes", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kTriggerThrottlerDailyQuotaFeature{
const base::Feature kDispatchSafetyNetCheckOffThread{
"DispatchSafetyNetCheckOffThread", base::FEATURE_DISABLED_BY_DEFAULT};
namespace {
// 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.
constexpr struct {
const base::Feature* feature;
// True if the feature is running at a probability other than 1 or 0.
bool probabilistically_enabled;
} kExperimentalFeatures[]{
{&kAdSamplerCollectButDontSendFeature, false},
{&kAdSamplerTriggerFeature, false},
{&kGaiaPasswordReuseReporting, true},
{&kGoogleBrandedPhishingWarning, true},
{&kParallelUrlCheck, true},
{&kThreatDomDetailsTagAndAttributeFeature, false},
{&kTriggerThrottlerDailyQuotaFeature, false},
{&kDispatchSafetyNetCheckOffThread, false},
// Adds the name and the enabled/disabled status of a given feature.
void AddFeatureAndAvailability(const base::Feature* exp_feature,
base::ListValue* param_list) {
if (base::FeatureList::IsEnabled(*exp_feature)) {
} else {
} // namespace
// Returns the list of the experimental features that are enabled or disabled,
// as part of currently running Safe Browsing experiments.
base::ListValue GetFeatureStatusList() {
base::ListValue param_list;
for (const auto& feature_status : kExperimentalFeatures) {
if (feature_status.probabilistically_enabled)
AddFeatureAndAvailability(feature_status.feature, &param_list);
return param_list;
} // namespace safe_browsing