chromium/components/variations/field_trial_config/field_trial_util.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO: crbug.com/352691908 - Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "components/variations/field_trial_config/field_trial_util.h"

#include <stddef.h>

#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>

#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_params.h"
#include "base/strings/escape.h"
#include "base/strings/utf_string_conversions.h"
#include "base/system/sys_info.h"
#include "components/variations/client_filterable_state.h"
#include "components/variations/field_trial_config/fieldtrial_testing_config.h"
#include "components/variations/study_filtering.h"
#include "components/variations/variations_seed_processor.h"

namespace variations {
namespace {

bool HasPlatform(const FieldTrialTestingExperiment& experiment,
                 Study::Platform platform) {}

// Returns true if the experiment config has a different value for
// is_low_end_device than the current system value does.
// If experiment has is_low_end_device missing, then it is False.
bool HasDeviceLevelMismatch(const FieldTrialTestingExperiment& experiment) {}

// Returns true if the experiment config has a missing form_factors or it
// contains the current system's form_factor. Otherwise, it is False.
bool HasFormFactor(const FieldTrialTestingExperiment& experiment,
                   Study::FormFactor current_form_factor) {}

// Returns true if the experiment config has a missing |min_os_version| or
// GetOSVersion() >= |min_os_version|.
bool HasMinOSVersion(const FieldTrialTestingExperiment& experiment) {}

// Records the override ui string config. Mainly used for testing.
void ApplyUIStringOverrides(
    const FieldTrialTestingExperiment& experiment,
    const VariationsSeedProcessor::UIStringOverrideCallback& callback) {}

// Determines whether an experiment should be skipped or not. An experiment
// should be skipped if it enables or disables a feature that is already
// overridden through the command line.
bool ShouldSkipExperiment(const FieldTrialTestingExperiment& experiment,
                          base::FeatureList* feature_list) {}

void AssociateParamsFromExperiment(
    const std::string& study_name,
    const FieldTrialTestingExperiment& experiment,
    const VariationsSeedProcessor::UIStringOverrideCallback& callback,
    base::FeatureList* feature_list) {}

Study::Filter CreateFilter(const FieldTrialTestingExperiment& experiment) {}

// Choose an experiment to associate. The rules are:
// - Out of the experiments which match this platform:
//   - If there is a forcing flag for any experiment, choose the first such
//     experiment.
//   - Otherwise, If running on low_end_device and the config specify
//     a different experiment group for low end devices then pick that.
//   - Otherwise, If running on non low_end_device and the config specify
//     a different experiment group for non low_end_device then pick that.
//   - Otherwise, select the first experiment.
// - The chosen experiment must not enable or disable a feature that is
//   explicitly enabled or disabled through a switch, such as the
//   |--enable-features| or |--disable-features| switches. If it does, then no
//   experiment is associated.
// - If no experiments match this platform, do not associate any of them.
void ChooseExperiment(
    const FieldTrialTestingStudy& study,
    const VariationsSeedProcessor::UIStringOverrideCallback& callback,
    Study::Platform platform,
    Study::FormFactor current_form_factor,
    base::FeatureList* feature_list) {}

}  // namespace

std::string EscapeValue(const std::string& value) {}

bool AssociateParamsFromString(const std::string& varations_string) {}

void AssociateParamsFromFieldTrialConfig(
    const FieldTrialTestingConfig& config,
    const VariationsSeedProcessor::UIStringOverrideCallback& callback,
    Study::Platform platform,
    Study::FormFactor current_form_factor,
    base::FeatureList* feature_list) {}

void AssociateDefaultFieldTrialConfig(
    const VariationsSeedProcessor::UIStringOverrideCallback& callback,
    Study::Platform platform,
    Study::FormFactor current_form_factor,
    base::FeatureList* feature_list) {}

}  // namespace variations