#include "components/subresource_filter/core/browser/subresource_filter_features.h"
#include <map>
#include <ostream>
#include <sstream>
#include <string_view>
#include <tuple>
#include <utility>
#include "base/containers/contains.h"
#include "base/lazy_instance.h"
#include "base/metrics/field_trial_params.h"
#include "base/rand_util.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/synchronization/lock.h"
#include "base/time/time.h"
#include "base/trace_event/traced_value.h"
#include "components/subresource_filter/core/common/common_features.h"
#include "components/subresource_filter/core/mojom/subresource_filter.mojom.h"
namespace subresource_filter {
namespace {
class CommaSeparatedStrings { … };
std::string TakeVariationParamOrReturnEmpty(
std::map<std::string, std::string>* params,
const std::string& key) { … }
mojom::ActivationLevel ParseActivationLevel(
const std::string_view activation_level) { … }
ActivationScope ParseActivationScope(const std::string_view activation_scope) { … }
ActivationList ParseActivationList(std::string activation_lists_string) { … }
double ParsePerformanceMeasurementRate(const std::string& rate) { … }
int ParseInt(const std::string_view value) { … }
std::vector<Configuration> FillEnabledPresetConfigurations(
std::map<std::string, std::string>* params) { … }
Configuration ParseExperimentalConfiguration(
std::map<std::string, std::string>* params) { … }
std::vector<Configuration> ParseEnabledConfigurations() { … }
template <class T>
std::string StreamToString(const T& value) { … }
std::vector<Configuration> SortConfigsByDecreasingPriority(
std::vector<Configuration> configs) { … }
std::string_view GetLexicographicallyGreatestRulesetFlavor(
const std::vector<Configuration>& configs) { … }
base::LazyInstance<base::Lock>::Leaky g_active_configurations_lock = …;
base::LazyInstance<scoped_refptr<ConfigurationList>>::Leaky
g_active_configurations = …;
}
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
const base::FeatureParam<base::TimeDelta> kAdsInterventionDuration = …;
const char kActivationLevelParameterName[] = …;
const char kActivationLevelDryRun[] = …;
const char kActivationLevelEnabled[] = …;
const char kActivationLevelDisabled[] = …;
const char kActivationScopeParameterName[] = …;
const char kActivationScopeAllSites[] = …;
const char kActivationScopeActivationList[] = …;
const char kActivationScopeNoSites[] = …;
const char kActivationListsParameterName[] = …;
const char kActivationListSocialEngineeringAdsInterstitial[] = …;
const char kActivationListPhishingInterstitial[] = …;
const char kActivationListSubresourceFilter[] = …;
const char kActivationListBetterAds[] = …;
const char kActivationPriorityParameterName[] = …;
const char kPerformanceMeasurementRateParameterName[] = …;
const char kRulesetFlavorParameterName[] = …;
const char kEnablePresetsParameterName[] = …;
const char kDisablePresetsParameterName[] = …;
const char kPresetLiveRunOnPhishingSites[] = …;
const char kPresetPerformanceTestingDryRunOnAllSites[] = …;
const char kPresetLiveRunForBetterAds[] = …;
Configuration Configuration::MakePresetForLiveRunOnPhishingSites() { … }
Configuration Configuration::MakePresetForPerformanceTestingDryRunOnAllSites() { … }
Configuration Configuration::MakePresetForLiveRunForBetterAds() { … }
Configuration::Configuration() = default;
Configuration::Configuration(mojom::ActivationLevel activation_level,
ActivationScope activation_scope,
ActivationList activation_list) { … }
Configuration::Configuration(const Configuration&) = default;
Configuration::Configuration(Configuration&&) = default;
Configuration::~Configuration() = default;
Configuration& Configuration::operator=(const Configuration&) = default;
Configuration& Configuration::operator=(Configuration&&) = default;
bool Configuration::operator==(const Configuration& rhs) const { … }
bool Configuration::operator!=(const Configuration& rhs) const { … }
std::unique_ptr<base::trace_event::TracedValue>
Configuration::ActivationConditions::ToTracedValue() const { … }
void Configuration::ActivationConditions::AddToValue(
base::trace_event::TracedValue* value) const { … }
std::unique_ptr<base::trace_event::TracedValue> Configuration::ToTracedValue()
const { … }
void Configuration::AddToValue(base::trace_event::TracedValue* value) const { … }
mojom::ActivationState Configuration::GetActivationState(
mojom::ActivationLevel effective_activation_level) const { … }
std::ostream& operator<<(std::ostream& os, const Configuration& config) { … }
ConfigurationList::ConfigurationList(std::vector<Configuration> configs)
: … { … }
ConfigurationList::~ConfigurationList() = default;
scoped_refptr<ConfigurationList> GetEnabledConfigurations() { … }
bool HasEnabledConfiguration(const Configuration& config) { … }
namespace testing {
scoped_refptr<ConfigurationList> GetAndSetActivateConfigurations(
scoped_refptr<ConfigurationList> new_configs) { … }
}
}