#include "components/feature_engagement/internal/chrome_variations_configuration.h"
#include <map>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/not_fatal_until.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/feature_engagement/public/configuration.h"
#include "components/feature_engagement/public/configuration_provider.h"
#include "components/feature_engagement/public/feature_list.h"
#include "components/feature_engagement/public/group_constants.h"
#include "components/feature_engagement/public/stats.h"
namespace feature_engagement {
namespace {
template <typename T>
void RecordParseResult(std::string name,
T config,
const ConfigurationProvider& provider) { … }
std::vector<std::string> FlattenGroupsAndFeatures(
std::vector<std::string> original_names,
std::map<std::string, std::vector<std::string>> group_mapping,
const GroupVector& all_groups) { … }
}
ChromeVariationsConfiguration::ChromeVariationsConfiguration() = default;
ChromeVariationsConfiguration::~ChromeVariationsConfiguration() = default;
void ChromeVariationsConfiguration::LoadConfigs(
const ConfigurationProviderList& configuration_providers,
const FeatureVector& features,
const GroupVector& groups) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
void ChromeVariationsConfiguration::UpdateConfig(
const base::Feature& feature,
const ConfigurationProvider* provider) {
FeatureConfig& config = configs_[feature.name];
config = FeatureConfig();
provider->MaybeProvideFeatureConfiguration(feature, config, {}, {});
}
const Configuration::EventPrefixSet&
ChromeVariationsConfiguration::GetRegisteredAllowedEventPrefixes() const {
return event_prefixes_;
}
#endif
void ChromeVariationsConfiguration::LoadFeatureConfig(
const base::Feature& feature,
const ConfigurationProviderList& configuration_providers,
const FeatureVector& all_features,
const GroupVector& all_groups) { … }
void ChromeVariationsConfiguration::LoadGroupConfig(
const base::Feature& group,
const ConfigurationProviderList& configuration_providers) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
void ChromeVariationsConfiguration::LoadAllowedEventPrefixes(
const base::Feature& feature,
const ConfigurationProviderList& configuration_providers) {
for (const auto& provider : configuration_providers) {
const auto prefixes = provider->MaybeProvideAllowedEventPrefixes(feature);
for (auto it = prefixes.begin(); it != prefixes.end(); ++it) {
if (it->empty()) {
continue;
}
const auto inserted = event_prefixes_.insert(*it);
CHECK(inserted.second)
<< "Configuration has duplicate event prefixes: " << *it;
}
}
}
#endif
void ChromeVariationsConfiguration::ExpandGroupNamesInFeatures(
const GroupVector& all_groups) { … }
const FeatureConfig& ChromeVariationsConfiguration::GetFeatureConfig(
const base::Feature& feature) const { … }
const FeatureConfig& ChromeVariationsConfiguration::GetFeatureConfigByName(
const std::string& feature_name) const { … }
const Configuration::ConfigMap&
ChromeVariationsConfiguration::GetRegisteredFeatureConfigs() const { … }
const std::vector<std::string>
ChromeVariationsConfiguration::GetRegisteredFeatures() const { … }
const GroupConfig& ChromeVariationsConfiguration::GetGroupConfig(
const base::Feature& group) const { … }
const GroupConfig& ChromeVariationsConfiguration::GetGroupConfigByName(
const std::string& group_name) const { … }
const Configuration::GroupConfigMap&
ChromeVariationsConfiguration::GetRegisteredGroupConfigs() const { … }
const std::vector<std::string>
ChromeVariationsConfiguration::GetRegisteredGroups() const { … }
}