#include "components/policy/core/common/cloud/component_cloud_policy_service.h"
#include <stddef.h>
#include <algorithm>
#include <functional>
#include <memory>
#include <string_view>
#include <unordered_map>
#include <utility>
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/values.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h"
#include "components/policy/core/common/cloud/component_cloud_policy_store.h"
#include "components/policy/core/common/cloud/component_cloud_policy_updater.h"
#include "components/policy/core/common/cloud/external_policy_data_fetcher.h"
#include "components/policy/core/common/cloud/resource_cache.h"
#include "components/policy/core/common/policy_bundle.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/schema.h"
#include "components/policy/core/common/schema_map.h"
#include "components/policy/core/common/values_util.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
em;
ScopedResponseMap;
namespace policy {
namespace {
bool NotInResponseMap(const ScopedResponseMap& map,
PolicyDomain domain,
const std::string& component_id) { … }
bool ToPolicyNamespace(const std::pair<std::string, std::string>& key,
PolicyNamespace* ns) { … }
base::Value::Dict TranslatePolicyMapEntryToJson(const PolicyMap::Entry& entry) { … }
base::Value::Dict TranslatePolicyMapToJson(const PolicyMap& policy_map) { … }
ComponentPolicyMap ToComponentPolicyMap(const PolicyBundle& policy_bundle) { … }
}
ComponentCloudPolicyService::Delegate::~Delegate() = default;
class ComponentCloudPolicyService::Backend
: public ComponentCloudPolicyStore::Delegate { … };
ComponentCloudPolicyService::Backend::Backend(
base::WeakPtr<ComponentCloudPolicyService> service,
scoped_refptr<base::SequencedTaskRunner> task_runner,
scoped_refptr<base::SequencedTaskRunner> service_task_runner,
std::unique_ptr<ResourceCache> cache,
std::unique_ptr<ExternalPolicyDataFetcher> external_policy_data_fetcher,
const std::string& policy_type)
: … { … }
ComponentCloudPolicyService::Backend::~Backend() { … }
void ComponentCloudPolicyService::Backend::ClearCache() { … }
void ComponentCloudPolicyService::Backend::SetCredentials(
const std::string& username,
const std::string& gaia_id,
const std::string& dm_token,
const std::string& device_id,
const std::string& public_key,
int public_key_version) { … }
void ComponentCloudPolicyService::Backend::InitIfNeeded() { … }
void ComponentCloudPolicyService::Backend::SetFetchedPolicy(
std::unique_ptr<ScopedResponseMap> responses) { … }
void ComponentCloudPolicyService::Backend::
OnComponentCloudPolicyStoreUpdated() { … }
void ComponentCloudPolicyService::Backend::UpdateWithLastFetchedPolicy() { … }
ComponentCloudPolicyService::ComponentCloudPolicyService(
const std::string& policy_type,
Delegate* delegate,
SchemaRegistry* schema_registry,
CloudPolicyCore* core,
CloudPolicyClient* client,
std::unique_ptr<ResourceCache> cache,
scoped_refptr<base::SequencedTaskRunner> backend_task_runner)
: … { … }
ComponentCloudPolicyService::~ComponentCloudPolicyService() { … }
bool ComponentCloudPolicyService::SupportsDomain(PolicyDomain domain) { … }
void ComponentCloudPolicyService::ClearCache() { … }
void ComponentCloudPolicyService::AddObserver(
ComponentCloudPolicyServiceObserver* observer) { … }
void ComponentCloudPolicyService::RemoveObserver(
ComponentCloudPolicyServiceObserver* observer) { … }
void ComponentCloudPolicyService::OnSchemaRegistryReady() { … }
void ComponentCloudPolicyService::OnSchemaRegistryUpdated(
bool has_new_schemas) { … }
void ComponentCloudPolicyService::OnCoreConnected(CloudPolicyCore* core) { … }
void ComponentCloudPolicyService::OnCoreDisconnecting(CloudPolicyCore* core) { … }
void ComponentCloudPolicyService::OnRefreshSchedulerStarted(
CloudPolicyCore* core) { … }
void ComponentCloudPolicyService::OnStoreLoaded(CloudPolicyStore* store) { … }
void ComponentCloudPolicyService::OnStoreError(CloudPolicyStore* store) { … }
void ComponentCloudPolicyService::OnPolicyFetched(CloudPolicyClient* client) { … }
void ComponentCloudPolicyService::OnRegistrationStateChanged(
CloudPolicyClient* client) { … }
void ComponentCloudPolicyService::OnClientError(CloudPolicyClient* client) { … }
void ComponentCloudPolicyService::UpdateFromSuperiorStore() { … }
void ComponentCloudPolicyService::UpdateFromClient() { … }
void ComponentCloudPolicyService::UpdateFromSchemaRegistry() { … }
void ComponentCloudPolicyService::Disconnect() { … }
void ComponentCloudPolicyService::SetPolicy(
std::unique_ptr<PolicyBundle> policy) { … }
void ComponentCloudPolicyService::FilterAndInstallPolicy() { … }
void ComponentCloudPolicyService::NotifyComponentPolicyUpdated() { … }
}