chromium/third_party/blink/renderer/build/scripts/tests/permissions_policy_default_value_control/output/permissions_policy_features_generated.cc.ref

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


#include "third_party/blink/common/permissions_policy/permissions_policy_features_generated.h"

#include "base/no_destructor.h"
#include "base/feature_list.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom.h"

namespace blink {

// Applies new defaults based on flags.
void UpdatePermissionsPolicyFeatureListFlagDefaults(PermissionsPolicyFeatureList& mutable_feature_list) {
  if (base::FeatureList::IsEnabled(features::kTestFlag)) {
    mutable_feature_list.find(mojom::PermissionsPolicyFeature::kAccelerometer)->second =
      PermissionsPolicyFeatureDefault::EnableForSelf;
  } else {
    mutable_feature_list.find(mojom::PermissionsPolicyFeature::kAccelerometer)->second =
      PermissionsPolicyFeatureDefault::EnableForAll;
  }

}

// The base list with no flags or special cases.
PermissionsPolicyFeatureList GetBasePermissionsPolicyFeatureList() {
  static const base::NoDestructor<PermissionsPolicyFeatureList> feature_list({        {
          mojom::PermissionsPolicyFeature::kAccelerometer,
          PermissionsPolicyFeatureDefault::EnableForAll
        },    });
  return *feature_list;
}

// Defaults with "unload" using EnabledForNone.
PermissionsPolicyFeatureList& GetPermissionsPolicyFeatureListUnloadNone() {
  static base::NoDestructor<PermissionsPolicyFeatureList> feature_list([] {
    PermissionsPolicyFeatureList map = GetBasePermissionsPolicyFeatureList();
    UpdatePermissionsPolicyFeatureListFlagDefaults(map);


    return map;
  }());
  return *feature_list;
}

// Defaults with "unload" using EnabledForAll.
PermissionsPolicyFeatureList& GetPermissionsPolicyFeatureListUnloadAll() {
  static base::NoDestructor<PermissionsPolicyFeatureList> feature_list([] {
    PermissionsPolicyFeatureList map = GetBasePermissionsPolicyFeatureList();
    UpdatePermissionsPolicyFeatureListFlagDefaults(map);


    return map;
  }());
  return *feature_list;
}

} // namespace blink