chromium/chrome/updater/policy/service.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.

#include "chrome/updater/policy/service.h"

#include <concepts>
#include <functional>
#include <optional>
#include <set>
#include <string>
#include <utility>
#include <vector>

#include "base/check.h"
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "base/ranges/algorithm.h"
#include "base/sequence_checker.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/updater/constants.h"
#include "chrome/updater/external_constants.h"
#include "chrome/updater/policy/dm_policy_manager.h"
#include "chrome/updater/policy/policy_fetcher.h"
#include "chrome/updater/policy/policy_manager.h"
#if BUILDFLAG(IS_WIN)
#include "chrome/updater/policy/win/group_policy_manager.h"
#elif BUILDFLAG(IS_MAC)
#include "chrome/updater/policy/mac/managed_preference_policy_manager.h"
#endif

namespace updater {

namespace {

// Sorts the managed policy managers ahead of the non-managed ones in the
// vector, and creates a named map indexed by `source()`.
PolicyService::PolicyManagers SortManagers(
    std::vector<scoped_refptr<PolicyManagerInterface>> managers) {}

#if BUILDFLAG(IS_WIN)
bool CloudPolicyOverridesPlatformPolicy(
    std::vector<scoped_refptr<PolicyManagerInterface>> providers) {
  auto it = base::ranges::find_if(
      providers, [](scoped_refptr<PolicyManagerInterface> p) {
        return p && p->CloudPolicyOverridesPlatformPolicy();
      });

  return it == providers.end() ? false
                               : *(*it)->CloudPolicyOverridesPlatformPolicy();
}
#endif

}  // namespace

std::vector<scoped_refptr<PolicyManagerInterface>> CreateManagers(
    bool should_take_policy_critical_section,
    scoped_refptr<ExternalConstants> external_constants,
    scoped_refptr<PolicyManagerInterface> dm_policy_manager) {}

PolicyService::PolicyManagers::PolicyManagers(
    std::vector<scoped_refptr<PolicyManagerInterface>> managers,
    base::flat_map<std::string, scoped_refptr<PolicyManagerInterface>>
        manager_names)
    :{}
PolicyService::PolicyManagers::~PolicyManagers() = default;

PolicyService::PolicyService(
    std::vector<scoped_refptr<PolicyManagerInterface>> managers,
    bool usage_stats_enabled)
    :{}

// The policy managers are initialized without taking the Group Policy critical
// section here, by passing `false` for `should_take_policy_critical_section`,
// to avoid blocking the main sequence. Later in `FetchPoliciesDone`, the
// policies are reloaded with the critical section lock.
PolicyService::PolicyService(
    scoped_refptr<ExternalConstants> external_constants,
    bool usage_stats_enabled)
    :{}

PolicyService::~PolicyService() = default;

void PolicyService::FetchPolicies(base::OnceCallback<void(int)> callback) {}

void PolicyService::DoFetchPolicies(base::OnceCallback<void(int)> callback,
                                    bool is_cbcm_managed) {}

void PolicyService::FetchPoliciesDone(
    scoped_refptr<PolicyFetcher> fetcher,
    int result,
    scoped_refptr<PolicyManagerInterface> dm_policy_manager) {}

void PolicyService::PolicyManagerLoaded(
    int result,
    std::vector<scoped_refptr<PolicyManagerInterface>> managers) {}

std::string PolicyService::source() const {}

PolicyStatus<bool> PolicyService::CloudPolicyOverridesPlatformPolicy() const {}

PolicyStatus<base::TimeDelta> PolicyService::GetLastCheckPeriod() const {}

PolicyStatus<UpdatesSuppressedTimes> PolicyService::GetUpdatesSuppressedTimes()
    const {}

PolicyStatus<std::string> PolicyService::GetDownloadPreference() const {}

PolicyStatus<int> PolicyService::GetPackageCacheSizeLimitMBytes() const {}

PolicyStatus<int> PolicyService::GetPackageCacheExpirationTimeDays() const {}

PolicyStatus<int> PolicyService::GetPolicyForAppInstalls(
    const std::string& app_id) const {}

PolicyStatus<int> PolicyService::GetPolicyForAppUpdates(
    const std::string& app_id) const {}

PolicyStatus<std::string> PolicyService::GetTargetChannel(
    const std::string& app_id) const {}

PolicyStatus<std::string> PolicyService::GetTargetVersionPrefix(
    const std::string& app_id) const {}

PolicyStatus<bool> PolicyService::IsRollbackToTargetVersionAllowed(
    const std::string& app_id) const {}

PolicyStatus<std::string> PolicyService::GetProxyMode() const {}

PolicyStatus<std::string> PolicyService::GetProxyPacUrl() const {}

PolicyStatus<std::string> PolicyService::GetProxyServer() const {}

PolicyStatus<std::vector<std::string>> PolicyService::GetForceInstallApps()
    const {}

PolicyStatus<int> PolicyService::DeprecatedGetLastCheckPeriodMinutes() const {}

std::set<std::string> PolicyService::GetAppsWithPolicy() const {}

base::Value PolicyService::GetAllPolicies() const {}

std::string PolicyService::GetAllPoliciesAsString() const {}

bool PolicyService::AreUpdatesSuppressedNow(const base::Time& now) const {}

template <typename T, typename U>
PolicyStatus<U> PolicyService::QueryPolicy(
    PolicyQueryFunction<T> policy_query_function,
    const base::RepeatingCallback<std::optional<U>(std::optional<T>)>&
        transform) const {}

template <typename T>
PolicyStatus<T> PolicyService::QueryAppPolicy(
    AppPolicyQueryFunction<T> policy_query_function,
    const std::string& app_id) const {}

PolicyServiceProxyConfiguration::PolicyServiceProxyConfiguration() = default;
PolicyServiceProxyConfiguration::~PolicyServiceProxyConfiguration() = default;
PolicyServiceProxyConfiguration::PolicyServiceProxyConfiguration(
    const PolicyServiceProxyConfiguration&) = default;
PolicyServiceProxyConfiguration::PolicyServiceProxyConfiguration(
    PolicyServiceProxyConfiguration&&) = default;
PolicyServiceProxyConfiguration& PolicyServiceProxyConfiguration::operator=(
    const PolicyServiceProxyConfiguration&) = default;
PolicyServiceProxyConfiguration& PolicyServiceProxyConfiguration::operator=(
    PolicyServiceProxyConfiguration&&) = default;

std::optional<PolicyServiceProxyConfiguration>
PolicyServiceProxyConfiguration::Get(
    scoped_refptr<PolicyService> policy_service) {}

}  // namespace updater