chromium/components/policy/core/common/policy_map.cc

// Copyright 2013 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/policy/core/common/policy_map.h"

#include <optional>
#include <utility>

#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "base/types/optional_util.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/policy/core/common/cloud/affiliation.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/policy_constants.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"

namespace policy {

namespace {

const std::u16string GetLocalizedString(
    PolicyMap::Entry::L10nLookupFunction lookup,
    const std::map<int, std::optional<std::vector<std::u16string>>>&
        localized_string_ids) {}

// Inserts additional user affiliation IDs to the existing set.
base::flat_set<std::string> CombineIds(
    const base::flat_set<std::string>& ids_first,
    const base::flat_set<std::string>& ids_second) {}

#if !BUILDFLAG(IS_CHROMEOS)
// Returns the calculated priority of the policy entry based on the policy's
// scope and source, in addition to external factors such as precedence
// metapolicy values. Used for browser policies.
PolicyPriorityBrowser GetPriority(
    PolicySource source,
    PolicyScope scope,
    bool cloud_policy_overrides_platform_policy,
    bool cloud_user_policy_overrides_cloud_machine_policy,
    bool is_user_affiliated,
    const PolicyDetails* details) {}
#endif  // BUILDFLAG(IS_CHROMEOS)

// Helper function used in the invocation of `PolicyMap::CloneIf` from
// `PolicyMap::Clone`.
bool AllowAllPolicies(PolicyMap::const_reference unused) {}

}  // namespace

PolicyMap::Entry::Entry() = default;
PolicyMap::Entry::Entry(
    PolicyLevel level,
    PolicyScope scope,
    PolicySource source,
    std::optional<base::Value> value,
    std::unique_ptr<ExternalDataFetcher> external_data_fetcher,
    const PolicyDetails* details)
    :{}

PolicyMap::Entry::~Entry() = default;

PolicyMap::Entry::Entry(Entry&&) noexcept = default;
PolicyMap::Entry& PolicyMap::Entry::operator=(Entry&&) noexcept = default;

PolicyMap::Entry PolicyMap::Entry::DeepCopy() const {}

const base::Value* PolicyMap::Entry::value(base::Value::Type value_type) const {}

base::Value* PolicyMap::Entry::value(base::Value::Type value_type) {}

const base::Value* PolicyMap::Entry::value_unsafe() const {}

base::Value* PolicyMap::Entry::value_unsafe() {}

void PolicyMap::Entry::set_value(std::optional<base::Value> val) {}

bool PolicyMap::Entry::Equals(const PolicyMap::Entry& other) const {}

void PolicyMap::Entry::AddMessage(MessageType type, int message_id) {}

void PolicyMap::Entry::AddMessage(MessageType type,
                                  int message_id,
                                  std::vector<std::u16string>&& message_args) {}

void PolicyMap::Entry::ClearMessage(MessageType type, int message_id) {}

void PolicyMap::Entry::AddConflictingPolicy(Entry&& conflict) {}

void PolicyMap::Entry::ClearConflicts() {}

bool PolicyMap::Entry::HasConflicts() {}

bool PolicyMap::Entry::HasMessage(MessageType type) const {}

std::u16string PolicyMap::Entry::GetLocalizedMessages(
    MessageType type,
    L10nLookupFunction lookup) const {}

bool PolicyMap::Entry::ignored() const {}

void PolicyMap::Entry::SetIgnored() {}

void PolicyMap::Entry::SetBlocked() {}

void PolicyMap::Entry::SetInvalid() {}

void PolicyMap::Entry::SetIgnoredByPolicyAtomicGroup() {}

bool PolicyMap::Entry::IsIgnoredByAtomicGroup() const {}

void PolicyMap::Entry::SetIsDefaultValue() {}

bool PolicyMap::Entry::IsDefaultValue() const {}

PolicyMap::EntryConflict::EntryConflict() = default;
PolicyMap::EntryConflict::EntryConflict(ConflictType type, Entry&& entry)
    :{}

PolicyMap::EntryConflict::~EntryConflict() = default;

PolicyMap::EntryConflict::EntryConflict(EntryConflict&&) noexcept = default;
PolicyMap::EntryConflict& PolicyMap::EntryConflict::operator=(
    EntryConflict&&) noexcept = default;

void PolicyMap::EntryConflict::SetConflictType(ConflictType type) {}

PolicyMap::ConflictType PolicyMap::EntryConflict::conflict_type() const {}

const PolicyMap::Entry& PolicyMap::EntryConflict::entry() const {}

PolicyMap::PolicyMap()
    :{}
PolicyMap::PolicyMap(PolicyMap&&) noexcept = default;
PolicyMap& PolicyMap::operator=(PolicyMap&&) noexcept = default;
PolicyMap::~PolicyMap() = default;

const PolicyMap::Entry* PolicyMap::Get(const std::string& policy) const {}

PolicyMap::Entry* PolicyMap::GetMutable(const std::string& policy) {}

const base::Value* PolicyMap::GetValue(const std::string& policy,
                                       base::Value::Type value_type) const {}

base::Value* PolicyMap::GetMutableValue(const std::string& policy,
                                        base::Value::Type value_type) {}

const base::Value* PolicyMap::GetValueUnsafe(const std::string& policy) const {}

base::Value* PolicyMap::GetMutableValueUnsafe(const std::string& policy) {}

const PolicyMap::Entry* PolicyMap::GetUntrusted(
    const std::string& policy) const {}

PolicyMap::Entry* PolicyMap::GetMutableUntrusted(const std::string& policy) {}

bool PolicyMap::IsPolicySet(const std::string& policy) const {}

void PolicyMap::Set(
    const std::string& policy,
    PolicyLevel level,
    PolicyScope scope,
    PolicySource source,
    std::optional<base::Value> value,
    std::unique_ptr<ExternalDataFetcher> external_data_fetcher) {}

void PolicyMap::Set(const std::string& policy, Entry entry) {}

void PolicyMap::AddMessage(const std::string& policy,
                           MessageType type,
                           int message_id) {}

void PolicyMap::AddMessage(const std::string& policy,
                           MessageType type,
                           int message_id,
                           std::vector<std::u16string>&& message_args) {}

bool PolicyMap::IsPolicyIgnoredByAtomicGroup(const std::string& policy) const {}

void PolicyMap::SetSourceForAll(PolicySource source) {}

void PolicyMap::SetAllInvalid() {}

void PolicyMap::Erase(const std::string& policy) {}

PolicyMap::iterator PolicyMap::EraseIt(const_iterator it) {}

void PolicyMap::Swap(PolicyMap* other) {}

PolicyMap PolicyMap::Clone() const {}

PolicyMap PolicyMap::CloneIf(
    const base::RepeatingCallback<bool(const_reference)>& filter) const {}

void PolicyMap::MergePolicy(const std::string& policy_name,
                            const PolicyMap& other,
                            bool using_default_precedence) {}

void PolicyMap::MergeFrom(const PolicyMap& other) {}

void PolicyMap::MergeValues(const std::vector<PolicyMerger*>& mergers) {}

void PolicyMap::set_chrome_policy_details_callback_for_test(
    const GetChromePolicyDetailsCallback& details_callback) {}

bool PolicyMap::IsPolicyExternal(const std::string& policy) {}

const PolicyDetails* PolicyMap::GetPolicyDetails(
    const std::string& policy) const {}

void PolicyMap::LoadFrom(const base::Value::Dict& policies,
                         PolicyLevel level,
                         PolicyScope scope,
                         PolicySource source) {}

bool PolicyMap::Equals(const PolicyMap& other) const {}

bool PolicyMap::empty() const {}

size_t PolicyMap::size() const {}

PolicyMap::const_iterator PolicyMap::begin() const {}

PolicyMap::const_iterator PolicyMap::end() const {}

PolicyMap::iterator PolicyMap::begin() {}

PolicyMap::iterator PolicyMap::end() {}

void PolicyMap::Clear() {}

// static
bool PolicyMap::MapEntryEquals(const_reference a, const_reference b) {}

bool PolicyMap::EntryHasHigherPriority(const PolicyMap::Entry& lhs,
                                       const PolicyMap::Entry& rhs) const {}

bool PolicyMap::EntryHasHigherPriority(const PolicyMap::Entry& lhs,
                                       const PolicyMap::Entry& rhs,
                                       bool using_default_precedence) const {}

bool PolicyMap::IsUserAffiliated() const {}

void PolicyMap::SetUserAffiliationIds(
    const base::flat_set<std::string>& user_ids) {}

const base::flat_set<std::string>& PolicyMap::GetUserAffiliationIds() const {}

void PolicyMap::SetDeviceAffiliationIds(
    const base::flat_set<std::string>& device_ids) {}

const base::flat_set<std::string>& PolicyMap::GetDeviceAffiliationIds() const {}

#if !BUILDFLAG(IS_CHROMEOS)
void PolicyMap::UpdateStoredComputedMetapolicies() {}
#endif

void PolicyMap::UpdateStoredUserAffiliation() {}

}  // namespace policy