#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include <memory>
#include <string>
#include <utility>
#include "base/check_is_test.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/path_service.h"
#include "base/task/thread_pool.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/enterprise/browser_management/management_service_factory.h"
#include "chrome/browser/policy/configuration_policy_handler_list_factory.h"
#include "chrome/browser/policy/device_management_service_configuration.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_paths.h"
#include "chrome_browser_policy_connector.h"
#include "components/policy/core/common/async_policy_provider.h"
#include "components/policy/core/common/cloud/cloud_external_data_manager.h"
#include "components/policy/core/common/cloud/cloud_policy_client_registration_helper.h"
#include "components/policy/core/common/cloud/device_management_service.h"
#include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
#include "components/policy/core/common/command_line_policy_provider.h"
#include "components/policy/core/common/configuration_policy_provider.h"
#include "components/policy/core/common/local_test_policy_provider.h"
#include "components/policy/core/common/policy_logger.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_namespace.h"
#include "components/policy/core/common/policy_pref_names.h"
#include "components/policy/core/common/policy_proto_decoders.h"
#include "components/policy/core/common/policy_types.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_service.h"
#include "content/public/common/content_switches.h"
#include "extensions/buildflags/buildflags.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#if BUILDFLAG(IS_WIN)
#include "base/win/registry.h"
#include "chrome/browser/browser_switcher/browser_switcher_policy_migrator.h"
#include "components/policy/core/common/policy_loader_win.h"
#elif BUILDFLAG(IS_MAC)
#include <CoreFoundation/CoreFoundation.h>
#include "base/apple/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "components/policy/core/common/policy_loader_mac.h"
#include "components/policy/core/common/preferences_mac.h"
#elif BUILDFLAG(IS_ANDROID)
#include "chrome/browser/policy/chrome_browser_cloud_management_controller_android.h"
#include "components/policy/core/common/android/android_combined_policy_provider.h"
#elif BUILDFLAG(IS_POSIX)
#include "components/policy/core/common/config_dir_policy_loader.h"
#endif
#if !BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.h"
#include "components/enterprise/browser/controller/chrome_browser_cloud_management_controller.h"
#endif
#if !BUILDFLAG(IS_CHROMEOS_ASH)
#include "components/policy/core/common/cloud/machine_level_user_cloud_policy_manager.h"
#include "components/policy/core/common/proxy_policy_provider.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/lacros/device_settings_lacros.h"
#include "chromeos/crosapi/mojom/crosapi.mojom.h"
#include "chromeos/startup/browser_params_proxy.h"
#include "components/policy/core/common/policy_loader_lacros.h"
#endif
namespace policy {
namespace {
bool g_command_line_enabled_for_testing = …;
}
ChromeBrowserPolicyConnector::ChromeBrowserPolicyConnector()
: … { … }
ChromeBrowserPolicyConnector::~ChromeBrowserPolicyConnector() { … }
void ChromeBrowserPolicyConnector::OnResourceBundleCreated() { … }
void ChromeBrowserPolicyConnector::Init(
PrefService* local_state,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) { … }
void ChromeBrowserPolicyConnector::OnBrowserStarted() { … }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
bool ChromeBrowserPolicyConnector::IsMainUserManaged() const {
return PolicyLoaderLacros::IsMainUserManaged();
}
crosapi::mojom::DeviceSettings*
ChromeBrowserPolicyConnector::GetDeviceSettings() const {
return device_settings_->GetDeviceSettings();
}
#endif
bool ChromeBrowserPolicyConnector::IsDeviceEnterpriseManaged() const { … }
bool ChromeBrowserPolicyConnector::HasMachineLevelPolicies() { … }
void ChromeBrowserPolicyConnector::Shutdown() { … }
ConfigurationPolicyProvider*
ChromeBrowserPolicyConnector::GetPlatformProvider() { … }
ConfigurationPolicyProvider*
ChromeBrowserPolicyConnector::local_test_policy_provider() { … }
void ChromeBrowserPolicyConnector::SetLocalTestPolicyProviderForTesting(
ConfigurationPolicyProvider* provider) { … }
void ChromeBrowserPolicyConnector::MaybeApplyLocalTestPolicies(
PrefService* local_state) { … }
#if !BUILDFLAG(IS_CHROMEOS)
void ChromeBrowserPolicyConnector::InitCloudManagementController(
PrefService* local_state,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) { … }
#endif
#if !BUILDFLAG(IS_CHROMEOS_ASH)
void ChromeBrowserPolicyConnector::
SetMachineLevelUserCloudPolicyManagerForTesting(
MachineLevelUserCloudPolicyManager* manager) { … }
void ChromeBrowserPolicyConnector::SetProxyPolicyProviderForTesting(
ProxyPolicyProvider* proxy_policy_provider) { … }
#endif
bool ChromeBrowserPolicyConnector::IsCommandLineSwitchSupported() const { … }
void ChromeBrowserPolicyConnector::EnableCommandLineSupportForTesting() { … }
base::flat_set<std::string>
ChromeBrowserPolicyConnector::device_affiliation_ids() const { … }
void ChromeBrowserPolicyConnector::SetDeviceAffiliatedIdsForTesting(
const base::flat_set<std::string>& device_affiliation_ids) { … }
std::vector<std::unique_ptr<policy::ConfigurationPolicyProvider>>
ChromeBrowserPolicyConnector::CreatePolicyProviders() { … }
std::unique_ptr<ConfigurationPolicyProvider>
ChromeBrowserPolicyConnector::CreatePlatformProvider() { … }
#if !BUILDFLAG(IS_CHROMEOS)
void ChromeBrowserPolicyConnector::MaybeCreateCloudPolicyManager(
std::vector<std::unique_ptr<ConfigurationPolicyProvider>>* providers) { … }
void ChromeBrowserPolicyConnector::OnMachineLevelCloudPolicyManagerCreated(
std::unique_ptr<MachineLevelUserCloudPolicyManager>
machine_level_user_cloud_policy_manager) { … }
#endif
}