Index: chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.cc |
diff --git a/chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.cc b/chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.cc |
index 243ca3553cf5b78f41545cafdb93907f7003916b..4f2ca9520b7a326469bd30cd10c5e143a5fdd5a1 100644 |
--- a/chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.cc |
+++ b/chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.cc |
@@ -12,10 +12,13 @@ |
#include "base/bind_helpers.h" |
#include "base/callback.h" |
#include "base/command_line.h" |
+#include "base/files/file_path.h" |
#include "base/logging.h" |
#include "base/macros.h" |
#include "base/memory/ptr_util.h" |
+#include "base/path_service.h" |
#include "base/strings/string_number_conversions.h" |
+#include "base/sys_info.h" |
#include "base/time/time.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" |
@@ -31,17 +34,20 @@ |
#include "chrome/browser/chromeos/settings/install_attributes.h" |
#include "chrome/common/pref_names.h" |
#include "chromeos/chromeos_constants.h" |
+#include "chromeos/chromeos_paths.h" |
#include "chromeos/chromeos_switches.h" |
#include "chromeos/system/statistics_provider.h" |
#include "components/policy/core/common/cloud/cloud_policy_core.h" |
#include "components/policy/core/common/cloud/cloud_policy_service.h" |
#include "components/policy/core/common/cloud/cloud_policy_store.h" |
#include "components/policy/core/common/remote_commands/remote_commands_factory.h" |
+#include "components/policy/core/common/schema_registry.h" |
#include "components/policy/proto/device_management_backend.pb.h" |
#include "components/prefs/pref_registry_simple.h" |
#include "components/prefs/pref_service.h" |
#include "content/public/browser/browser_thread.h" |
#include "crypto/sha2.h" |
+#include "net/url_request/url_request_context_getter.h" |
#include "url/gurl.h" |
using content::BrowserThread; |
@@ -187,6 +193,7 @@ void DeviceCloudPolicyManagerChromeOS::Shutdown() { |
heartbeat_scheduler_.reset(); |
state_keys_update_subscription_.reset(); |
CloudPolicyManager::Shutdown(); |
+ signin_profile_forwarding_schema_registry_.reset(); |
} |
// static |
@@ -231,6 +238,18 @@ void DeviceCloudPolicyManagerChromeOS::StartConnection( |
if (ForcedReEnrollmentEnabled()) |
client_to_connect->SetStateKeysToUpload(state_keys_broker_->state_keys()); |
+ if (is_component_policy_enabled_) { |
+ base::FilePath component_policy_cache_dir; |
+ CHECK(PathService::Get(chromeos::DIR_SIGNIN_PROFILE_COMPONENT_POLICY, |
+ &component_policy_cache_dir)); |
+ CHECK(signin_profile_forwarding_schema_registry_); |
+ CreateComponentCloudPolicyService( |
+ dm_protocol::kChromeSigninExtensionPolicyType, |
+ component_policy_cache_dir, g_browser_process->system_request_context(), |
+ client_to_connect.get(), |
+ signin_profile_forwarding_schema_registry_.get()); |
+ } |
+ |
core()->Connect(std::move(client_to_connect)); |
core()->StartRefreshScheduler(); |
core()->StartRemoteCommandsService(std::unique_ptr<RemoteCommandsFactory>( |
@@ -278,6 +297,18 @@ void DeviceCloudPolicyManagerChromeOS::Disconnect() { |
NotifyDisconnected(); |
} |
+void DeviceCloudPolicyManagerChromeOS::SetSigninProfileSchemaRegistry( |
+ SchemaRegistry* schema_registry) { |
+ DCHECK(!signin_profile_forwarding_schema_registry_); |
+ // Note that the forwarding schema registry is created with the parameter to |
+ // forward the readiness state too. This lets the component cloud policy |
+ // service, which in case of device policy is using the forwarding schema |
+ // registry, to start using it only after the required initialization |
+ // finishes. |
+ signin_profile_forwarding_schema_registry_.reset(new ForwardingSchemaRegistry( |
+ schema_registry, true /* forward_readiness */)); |
+} |
+ |
void DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated() { |
if (client() && ForcedReEnrollmentEnabled()) |
client()->SetStateKeysToUpload(state_keys_broker_->state_keys()); |