chromium/components/policy/core/browser/policy_conversions_client.cc

// 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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/policy/core/browser/policy_conversions_client.h"

#include <optional>

#include "base/containers/flat_map.h"
#include "base/functional/bind.h"
#include "base/json/json_writer.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/policy/core/browser/configuration_policy_handler_list.h"
#include "components/policy/core/browser/policy_error_map.h"
#include "components/policy/core/common/policy_details.h"
#include "components/policy/core/common/policy_logger.h"
#include "components/policy/core/common/policy_merger.h"
#include "components/policy/core/common/policy_service.h"
#include "components/policy/core/common/schema.h"
#include "components/policy/core/common/schema_map.h"
#include "components/policy/core/common/schema_registry.h"
#include "components/policy/policy_constants.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"

Value;

namespace policy {

namespace {
const char* USER_SCOPE =;
const char* DEVICE_SCOPE =;
#if BUILDFLAG(IS_CHROMEOS_LACROS)
const char* ALL_USERS_SCOPE = "allUsers";
#endif

// Return true if machine policy information needs to be hidden.
bool IsMachineInfoHidden(PolicyScope scope, bool show_machine_values) {}

}  // namespace

PolicyConversionsClient::PolicyConversionsClient() = default;
PolicyConversionsClient::~PolicyConversionsClient() = default;

void PolicyConversionsClient::EnableConvertTypes(bool enabled) {}

void PolicyConversionsClient::EnableConvertValues(bool enabled) {}

void PolicyConversionsClient::EnableDeviceLocalAccountPolicies(bool enabled) {}

void PolicyConversionsClient::EnableDeviceInfo(bool enabled) {}

void PolicyConversionsClient::EnablePrettyPrint(bool enabled) {}

void PolicyConversionsClient::EnableUserPolicies(bool enabled) {}

void PolicyConversionsClient::SetDropDefaultValues(bool enabled) {}

void PolicyConversionsClient::EnableShowMachineValues(bool enabled) {}

std::string PolicyConversionsClient::ConvertValueToJSON(
    const Value& value) const {}

base::Value::Dict PolicyConversionsClient::GetChromePolicies() {}

base::Value::Dict PolicyConversionsClient::GetPrecedencePolicies() {}

base::Value::List PolicyConversionsClient::GetPrecedenceOrder() {}

Value PolicyConversionsClient::CopyAndMaybeConvert(
    const Value& value,
    const std::optional<Schema>& schema,
    PolicyScope scope) const {}

Value::Dict PolicyConversionsClient::GetPolicyValue(
    const std::string& policy_name,
    const PolicyMap::Entry& policy,
    const PoliciesSet& deprecated_policies,
    const PoliciesSet& future_policies,
    PolicyErrorMap* errors,
    const std::optional<PolicyConversions::PolicyToSchemaMap>&
        known_policy_schemas) const {}

Value::Dict PolicyConversionsClient::GetPolicyValues(
    const PolicyMap& map,
    PolicyErrorMap* errors,
    const PoliciesSet& deprecated_policies,
    const PoliciesSet& future_policies,
    const std::optional<PolicyConversions::PolicyToSchemaMap>&
        known_policy_schemas) const {}

std::optional<Schema> PolicyConversionsClient::GetKnownPolicySchema(
    const std::optional<PolicyConversions::PolicyToSchemaMap>&
        known_policy_schemas,
    const std::string& policy_name) const {}

std::optional<PolicyConversions::PolicyToSchemaMap>
PolicyConversionsClient::GetKnownPolicies(
    const scoped_refptr<SchemaMap> schema_map,
    const PolicyNamespace& policy_namespace) const {}

bool PolicyConversionsClient::GetDeviceLocalAccountPoliciesEnabled() const {}

bool PolicyConversionsClient::GetDeviceInfoEnabled() const {}

bool PolicyConversionsClient::GetUserPoliciesEnabled() const {}

#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
Value::Dict PolicyConversionsClient::ConvertUpdaterPolicies(
    PolicyMap updater_policies,
    std::optional<PolicyConversions::PolicyToSchemaMap>
        updater_policy_schemas) {
  return GetPolicyValues(updater_policies, nullptr, PoliciesSet(),
                         PoliciesSet(), updater_policy_schemas);
}
#endif  // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)

std::string PolicyConversionsClient::GetPolicyScope(
    const std::string& policy_name,
    const PolicyScope& policy_scope) const {}

#if BUILDFLAG(IS_CHROMEOS_LACROS)
void PolicyConversionsClient::PopulatePerProfileMap() {
  if (per_profile_map_) {
    return;
  }

  per_profile_map_ = std::make_unique<std::map<std::string, bool>>();
  for (const BooleanPolicyAccess& access : kBooleanPolicyAccess) {
    per_profile_map_->emplace(std::string(access.policy_key),
                              access.per_profile);
  }
  for (const IntegerPolicyAccess& access : kIntegerPolicyAccess) {
    per_profile_map_->emplace(std::string(access.policy_key),
                              access.per_profile);
  }
  for (const StringPolicyAccess& access : kStringPolicyAccess) {
    per_profile_map_->emplace(std::string(access.policy_key),
                              access.per_profile);
  }
  for (const StringListPolicyAccess& access : kStringListPolicyAccess) {
    per_profile_map_->emplace(std::string(access.policy_key),
                              access.per_profile);
  }
}
#endif  // BUILDFLAG(IS_CHROMEOS_LACROS)

std::u16string PolicyConversionsClient::GetPolicyError(
    const std::string& policy_name,
    const PolicyMap::Entry& policy,
    PolicyErrorMap* errors,
    std::optional<Schema> known_policy_schema) const {}

}  // namespace policy