#include "chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.h"
#include <utility>
#include "base/check_is_test.h"
#include "base/command_line.h"
#include "base/path_service.h"
#include "base/task/single_thread_task_runner.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/device_identity/device_identity_provider.h"
#include "chrome/browser/device_identity/device_oauth2_token_service.h"
#include "chrome/browser/device_identity/device_oauth2_token_service_factory.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_loader.h"
#include "chrome/browser/enterprise/remote_commands/cbcm_remote_commands_factory.h"
#include "chrome/browser/enterprise/reporting/reporting_delegate_factory_desktop.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/policy/chrome_browser_cloud_management_register_watcher.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/policy/client_data_delegate_desktop.h"
#include "chrome/browser/policy/cloud/cloud_policy_invalidator.h"
#include "chrome/browser/policy/cloud/fm_registration_token_uploader.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_paths.h"
#include "components/gcm_driver/gcm_driver.h"
#include "components/gcm_driver/instance_id/instance_id_driver.h"
#include "components/invalidation/invalidation_factory.h"
#include "components/invalidation/invalidation_listener.h"
#include "components/invalidation/public/invalidation_service.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/machine_level_user_cloud_policy_manager.h"
#include "components/policy/core/common/remote_commands/remote_commands_invalidator_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/network_service_instance.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
#include "base/base_paths_win.h"
#include "chrome/install_static/install_modes.h"
#else
#include "chrome/common/chrome_switches.h"
#endif
#if BUILDFLAG(IS_MAC)
#include "chrome/browser/app_controller_mac.h"
#include "chrome/browser/policy/browser_dm_token_storage_mac.h"
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/policy/browser_dm_token_storage_linux.h"
#endif
#if BUILDFLAG(IS_WIN)
#include "chrome/browser/policy/browser_dm_token_storage_win.h"
#include "chrome/install_static/install_util.h"
#endif
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC)
#include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl.h"
#include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher.h"
#endif
namespace policy {
namespace {
#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
constexpr base::FilePath::StringPieceType kCachedPolicyDirname =
FILE_PATH_LITERAL("Policies");
#endif
constexpr char kInvalidationListenerLogPrefix[] = …;
}
ChromeBrowserCloudManagementControllerDesktop::
ChromeBrowserCloudManagementControllerDesktop()
: … { … }
ChromeBrowserCloudManagementControllerDesktop::
~ChromeBrowserCloudManagementControllerDesktop() = default;
void ChromeBrowserCloudManagementControllerDesktop::
SetDMTokenStorageDelegate() { … }
int ChromeBrowserCloudManagementControllerDesktop::GetUserDataDirKey() { … }
base::FilePath
ChromeBrowserCloudManagementControllerDesktop::GetExternalPolicyDir() { … }
ChromeBrowserCloudManagementController::Delegate::NetworkConnectionTrackerGetter
ChromeBrowserCloudManagementControllerDesktop::
CreateNetworkConnectionTrackerGetter() { … }
void ChromeBrowserCloudManagementControllerDesktop::InitializeOAuthTokenFactory(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
PrefService* local_state) { … }
void ChromeBrowserCloudManagementControllerDesktop::StartWatchingRegistration(
ChromeBrowserCloudManagementController* controller) { … }
bool ChromeBrowserCloudManagementControllerDesktop::
WaitUntilPolicyEnrollmentFinished() { … }
bool ChromeBrowserCloudManagementControllerDesktop::
IsEnterpriseStartupDialogShowing() { … }
void ChromeBrowserCloudManagementControllerDesktop::OnServiceAccountSet(
CloudPolicyClient* client,
const std::string& account_email) { … }
void ChromeBrowserCloudManagementControllerDesktop::ShutDown() { … }
MachineLevelUserCloudPolicyManager*
ChromeBrowserCloudManagementControllerDesktop::
GetMachineLevelUserCloudPolicyManager() { … }
DeviceManagementService*
ChromeBrowserCloudManagementControllerDesktop::GetDeviceManagementService() { … }
scoped_refptr<network::SharedURLLoaderFactory>
ChromeBrowserCloudManagementControllerDesktop::GetSharedURLLoaderFactory() { … }
scoped_refptr<base::SingleThreadTaskRunner>
ChromeBrowserCloudManagementControllerDesktop::GetBestEffortTaskRunner() { … }
std::unique_ptr<enterprise_reporting::ReportingDelegateFactory>
ChromeBrowserCloudManagementControllerDesktop::GetReportingDelegateFactory() { … }
void ChromeBrowserCloudManagementControllerDesktop::SetGaiaURLLoaderFactory(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) { … }
bool ChromeBrowserCloudManagementControllerDesktop::
ReadyToCreatePolicyManager() { … }
bool ChromeBrowserCloudManagementControllerDesktop::ReadyToInit() { … }
std::unique_ptr<ClientDataDelegate>
ChromeBrowserCloudManagementControllerDesktop::CreateClientDataDelegate() { … }
std::unique_ptr<enterprise_connectors::DeviceTrustKeyManager>
ChromeBrowserCloudManagementControllerDesktop::CreateDeviceTrustKeyManager() { … }
void ChromeBrowserCloudManagementControllerDesktop::StartInvalidations() { … }
scoped_refptr<network::SharedURLLoaderFactory>
ChromeBrowserCloudManagementControllerDesktop::GetURLLoaderFactory() { … }
bool ChromeBrowserCloudManagementControllerDesktop::
IsInvalidationsServiceStarted() const { … }
}