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

// Copyright 2012 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/common/policy_service_impl.h"

#include <stddef.h>

#include <algorithm>
#include <cstddef>
#include <string>
#include <utility>
#include <vector>

#include "base/containers/contains.h"
#include "base/containers/flat_set.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/observer_list.h"
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/policy/core/common/policy_bundle.h"
#include "components/policy/core/common/policy_logger.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_merger.h"
#include "components/policy/core/common/policy_types.h"
#include "components/policy/core/common/proxy_settings_constants.h"
#include "components/policy/core/common/values_util.h"
#include "components/policy/policy_constants.h"
#include "components/strings/grit/components_strings.h"
#include "extensions/buildflags/buildflags.h"

#if BUILDFLAG(IS_ANDROID)
#include "components/policy/core/common/android/policy_service_android.h"
#endif

#if BUILDFLAG(IS_CHROMEOS)
#include "components/policy/core/common/default_chrome_apps_migrator.h"
#endif

namespace policy {

namespace {

// Metrics should not be enforced so if this policy is set as mandatory
// downgrade it to a recommended level policy.
void DowngradeMetricsReportingToRecommendedPolicy(PolicyMap* policies) {}

// Returns the string values of |policy|. Returns an empty set if the values are
// not strings.
base::flat_set<std::string> GetStringListPolicyItems(
    const PolicyBundle& bundle,
    const PolicyNamespace& space,
    const std::string& policy) {}

bool IsUserCloudMergingAllowed(const PolicyMap& policies) {}

void AddPolicyMessages(PolicyMap& policies) {}

// Returns the list of histogram names to record depending on scope and number
// of policies.
std::vector<std::string> InitTimeHistogramsToRecord(
    PolicyServiceImpl::ScopeForMetrics scope_for_metrics,
    size_t policy_count) {}

}  // namespace

PolicyServiceImpl::PolicyServiceImpl(Providers providers,
                                     ScopeForMetrics scope_for_metrics,
                                     Migrators migrators)
    :{}

PolicyServiceImpl::PolicyServiceImpl(Providers providers,
                                     ScopeForMetrics scope_for_metrics,
                                     Migrators migrators,
                                     bool initialization_throttled)
    :{}

// static
std::unique_ptr<PolicyServiceImpl>
PolicyServiceImpl::CreateWithThrottledInitialization(
    Providers providers,
    ScopeForMetrics scope_for_metrics,
    Migrators migrators) {}

PolicyServiceImpl::~PolicyServiceImpl() {}

void PolicyServiceImpl::AddObserver(PolicyDomain domain,
                                    PolicyService::Observer* observer) {}

void PolicyServiceImpl::RemoveObserver(PolicyDomain domain,
                                       PolicyService::Observer* observer) {}

void PolicyServiceImpl::AddProviderUpdateObserver(
    ProviderUpdateObserver* observer) {}

void PolicyServiceImpl::RemoveProviderUpdateObserver(
    ProviderUpdateObserver* observer) {}

bool PolicyServiceImpl::HasProvider(
    ConfigurationPolicyProvider* provider) const {}

const PolicyMap& PolicyServiceImpl::GetPolicies(
    const PolicyNamespace& ns) const {}

bool PolicyServiceImpl::IsInitializationComplete(PolicyDomain domain) const {}

bool PolicyServiceImpl::IsFirstPolicyLoadComplete(PolicyDomain domain) const {}

void PolicyServiceImpl::RefreshPolicies(base::OnceClosure callback,
                                        PolicyFetchReason reason) {}

#if BUILDFLAG(IS_ANDROID)
android::PolicyServiceAndroid* PolicyServiceImpl::GetPolicyServiceAndroid() {
  if (!policy_service_android_)
    policy_service_android_ =
        std::make_unique<android::PolicyServiceAndroid>(this);
  return policy_service_android_.get();
}
#endif

void PolicyServiceImpl::UnthrottleInitialization() {}

void PolicyServiceImpl::UseLocalTestPolicyProvider(
    ConfigurationPolicyProvider* provider) {}

void PolicyServiceImpl::OnUpdatePolicy(ConfigurationPolicyProvider* provider) {}

void PolicyServiceImpl::NotifyNamespaceUpdated(const PolicyNamespace& ns,
                                               const PolicyMap& previous,
                                               const PolicyMap& current) {}

void PolicyServiceImpl::NotifyProviderUpdatesPropagated() {}

void PolicyServiceImpl::NotifyPoliciesUpdated(const PolicyBundle& old_bundle) {}

void PolicyServiceImpl::MergeAndTriggerUpdates() {}

// static
PolicyBundle PolicyServiceImpl::MergePolicyBundles(
    std::vector<const policy::PolicyBundle*>& bundles,
    Migrators& migrators) {}

std::vector<PolicyDomain> PolicyServiceImpl::UpdatePolicyDomainStatus() {}

void PolicyServiceImpl::MaybeNotifyPolicyDomainStatusChange(
    const std::vector<PolicyDomain>& updated_domains) {}

void PolicyServiceImpl::CheckRefreshComplete() {}

void PolicyServiceImpl::RecordUserAffiliationStatus() {}

// static
void PolicyServiceImpl::IgnoreUserCloudPrecedencePolicies(PolicyMap* policies) {}

// static
void PolicyServiceImpl::RecordInitializationTime(
    PolicyServiceImpl::ScopeForMetrics scope_for_metrics,
    size_t policy_count,
    base::TimeDelta initialization_time) {}

}  // namespace policy