#include "components/enterprise/browser/controller/chrome_browser_cloud_management_controller.h"
#include <utility>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/observer_list.h"
#include "base/path_service.h"
#include "base/strings/strcat.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "build/build_config.h"
#include "components/enterprise/browser/controller/browser_dm_token_storage.h"
#include "components/enterprise/browser/controller/chrome_browser_cloud_management_helper.h"
#include "components/enterprise/browser/enterprise_switches.h"
#include "components/enterprise/browser/reporting/real_time_report_controller.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/common/cloud/client_data_delegate.h"
#include "components/policy/core/common/cloud/cloud_external_data_manager.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/dm_token.h"
#include "components/policy/core/common/cloud/machine_level_user_cloud_policy_manager.h"
#include "components/policy/core/common/cloud/machine_level_user_cloud_policy_store.h"
#include "components/policy/core/common/configuration_policy_provider.h"
#include "components/policy/core/common/policy_logger.h"
#include "components/prefs/pref_service.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#if !BUILDFLAG(IS_ANDROID)
#include "components/enterprise/browser/reporting/report_generator.h"
#include "components/enterprise/browser/reporting/report_scheduler.h"
#endif
namespace policy {
const base::FilePath::CharType
ChromeBrowserCloudManagementController::kPolicyDir[] = …);
std::unique_ptr<enterprise_connectors::DeviceTrustKeyManager>
ChromeBrowserCloudManagementController::Delegate::
CreateDeviceTrustKeyManager() { … }
void ChromeBrowserCloudManagementController::Delegate::DeferInitialization(
base::OnceClosure callback) { … }
ChromeBrowserCloudManagementController::ChromeBrowserCloudManagementController(
std::unique_ptr<ChromeBrowserCloudManagementController::Delegate> delegate)
: … { … }
ChromeBrowserCloudManagementController::
~ChromeBrowserCloudManagementController() { … }
bool ChromeBrowserCloudManagementController::IsEnabled() { … }
std::unique_ptr<MachineLevelUserCloudPolicyManager>
ChromeBrowserCloudManagementController::CreatePolicyManager(
ConfigurationPolicyProvider* platform_provider) { … }
void ChromeBrowserCloudManagementController::DeferrableCreatePolicyManager(
ConfigurationPolicyProvider* platform_provider,
base::OnceCallback<
void(std::unique_ptr<MachineLevelUserCloudPolicyManager>)> callback) { … }
void ChromeBrowserCloudManagementController::Init(
PrefService* local_state,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) { … }
void ChromeBrowserCloudManagementController::MaybeInit(
PrefService* local_state,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) { … }
bool ChromeBrowserCloudManagementController::
WaitUntilPolicyEnrollmentFinished() { … }
void ChromeBrowserCloudManagementController::AddObserver(Observer* observer) { … }
void ChromeBrowserCloudManagementController::RemoveObserver(
Observer* observer) { … }
bool ChromeBrowserCloudManagementController::
IsEnterpriseStartupDialogShowing() { … }
void ChromeBrowserCloudManagementController::UnenrollBrowser(
bool delete_dm_token) { … }
void ChromeBrowserCloudManagementController::InvalidatePolicies() { … }
void ChromeBrowserCloudManagementController::UnenrollCallback(
const std::string& metric_name,
bool success) { … }
void ChromeBrowserCloudManagementController::OnPolicyFetched(
CloudPolicyClient* client) { … }
void ChromeBrowserCloudManagementController::OnRegistrationStateChanged(
CloudPolicyClient* client) { … }
void ChromeBrowserCloudManagementController::OnClientError(
CloudPolicyClient* client) { … }
void ChromeBrowserCloudManagementController::OnServiceAccountSet(
CloudPolicyClient* client,
const std::string& account_email) { … }
void ChromeBrowserCloudManagementController::ShutDown() { … }
enterprise_connectors::DeviceTrustKeyManager*
ChromeBrowserCloudManagementController::GetDeviceTrustKeyManager() { … }
void ChromeBrowserCloudManagementController::SetGaiaURLLoaderFactory(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) { … }
void ChromeBrowserCloudManagementController::NotifyPolicyRegisterFinished(
bool succeeded) { … }
void ChromeBrowserCloudManagementController::NotifyBrowserUnenrolled(
bool succeeded) { … }
void ChromeBrowserCloudManagementController::NotifyCloudReportingLaunched() { … }
void ChromeBrowserCloudManagementController::NotifyShutdown() { … }
bool ChromeBrowserCloudManagementController::GetEnrollmentTokenAndClientId(
std::string* enrollment_token,
std::string* client_id) { … }
void ChromeBrowserCloudManagementController::
RegisterForCloudManagementWithEnrollmentTokenCallback(
const std::string& dm_token,
const std::string& client_id) { … }
void ChromeBrowserCloudManagementController::CreateReportScheduler() { … }
void ChromeBrowserCloudManagementController::DeferrableCreatePolicyManagerImpl(
ConfigurationPolicyProvider* platform_provider,
base::OnceCallback<
void(std::unique_ptr<MachineLevelUserCloudPolicyManager>)> callback) { … }
void ChromeBrowserCloudManagementController::RecordEnrollmentResult(
ChromeBrowserCloudManagementEnrollmentResult result) { … }
}