#include "chrome/updater/policy/policy_fetcher.h"
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/time/default_clock.h"
#include "chrome/enterprise_companion/device_management_storage/dm_storage.h"
#include "chrome/enterprise_companion/enterprise_companion_client.h"
#include "chrome/enterprise_companion/mojom/enterprise_companion.mojom.h"
#include "chrome/updater/configurator.h"
#include "chrome/updater/constants.h"
#include "chrome/updater/device_management/dm_client.h"
#include "chrome/updater/device_management/dm_response_validator.h"
#include "chrome/updater/policy/dm_policy_manager.h"
#include "chrome/updater/policy/service.h"
#include "chrome/updater/util/util.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/isolated_connection.h"
#include "url/gurl.h"
namespace updater {
PolicyFetchCompleteCallback;
FallbackPolicyFetcher::FallbackPolicyFetcher(scoped_refptr<PolicyFetcher> impl,
scoped_refptr<PolicyFetcher> next)
: … { … }
FallbackPolicyFetcher::~FallbackPolicyFetcher() = default;
void FallbackPolicyFetcher::FetchPolicies(
PolicyFetchCompleteCallback callback) { … }
void FallbackPolicyFetcher::PolicyFetched(
int result,
scoped_refptr<PolicyManagerInterface> policy_manager) { … }
class InProcessPolicyFetcher : public PolicyFetcher { … };
InProcessPolicyFetcher::InProcessPolicyFetcher(
const GURL& server_url,
std::optional<PolicyServiceProxyConfiguration> proxy_configuration,
std::optional<bool> override_is_managed_device)
: … { … }
InProcessPolicyFetcher::~InProcessPolicyFetcher() = default;
void InProcessPolicyFetcher::FetchPolicies(
PolicyFetchCompleteCallback callback) { … }
void InProcessPolicyFetcher::RegisterDevice(
scoped_refptr<base::SequencedTaskRunner> main_task_runner,
base::OnceCallback<void(bool, DMClient::RequestResult)> callback) { … }
void InProcessPolicyFetcher::OnRegisterDeviceRequestComplete(
PolicyFetchCompleteCallback callback,
bool is_enrollment_mandatory,
DMClient::RequestResult result) { … }
void InProcessPolicyFetcher::FetchPolicy(
base::OnceCallback<void(scoped_refptr<PolicyManagerInterface>)> callback) { … }
scoped_refptr<PolicyManagerInterface>
InProcessPolicyFetcher::OnFetchPolicyRequestComplete(
DMClient::RequestResult result,
const std::vector<PolicyValidationResult>& validation_results) { … }
class OutOfProcessPolicyFetcher : public PolicyFetcher { … };
OutOfProcessPolicyFetcher::OutOfProcessPolicyFetcher(
bool usage_stats_enabled,
std::optional<bool> override_is_managed_device)
: … { … }
OutOfProcessPolicyFetcher::~OutOfProcessPolicyFetcher() = default;
void OutOfProcessPolicyFetcher::FetchPolicies(
PolicyFetchCompleteCallback callback) { … }
void OutOfProcessPolicyFetcher::OnConnected(
std::unique_ptr<mojo::IsolatedConnection> connection,
mojo::Remote<enterprise_companion::mojom::EnterpriseCompanion> remote) { … }
void OutOfProcessPolicyFetcher::OnPoliciesFetched(
enterprise_companion::mojom::StatusPtr status) { … }
void OutOfProcessPolicyFetcher::OnRPCDropped() { … }
scoped_refptr<PolicyFetcher> CreateInProcessPolicyFetcher(
const GURL& server_url,
std::optional<PolicyServiceProxyConfiguration> proxy_configuration,
std::optional<bool> override_is_managed_device) { … }
scoped_refptr<PolicyFetcher> CreateOutOfProcessPolicyFetcher(
bool usage_stats_enabled,
std::optional<bool> override_is_managed_device) { … }
}