chromium/components/feature_engagement/internal/chrome_variations_configuration.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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) {}

// Takes a list of |original_names| and expands any groups in the list into the
// features that make up that group, using |group_mapping| and |all_groups|.
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) {}

}  // namespace

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];

  // Clear existing configs.
  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) {
  // Allowed prefixes from different providers are inserted in a set, therefore,
  // it could potential affect other features.
  for (const auto& provider : configuration_providers) {
    const auto prefixes = provider->MaybeProvideAllowedEventPrefixes(feature);
    for (auto it = prefixes.begin(); it != prefixes.end(); ++it) {
      // Do not insert empty prefix.
      if (it->empty()) {
        continue;
      }

      // Check if there are duplicate prefixes.
      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 {}

}  // namespace feature_engagement