| Index: chrome/browser/chromeos/policy/device_local_account_policy_provider.cc
|
| diff --git a/chrome/browser/chromeos/policy/device_local_account_policy_provider.cc b/chrome/browser/chromeos/policy/device_local_account_policy_provider.cc
|
| index 837eb99e57bfea1b50bb9ab3486e29e2427d7b80..9a93e53244d249def64923a5dcadb66e96c1b821 100644
|
| --- a/chrome/browser/chromeos/policy/device_local_account_policy_provider.cc
|
| +++ b/chrome/browser/chromeos/policy/device_local_account_policy_provider.cc
|
| @@ -5,19 +5,16 @@
|
| #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h"
|
|
|
| #include "base/bind.h"
|
| -#include "base/command_line.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/chromeos/policy/device_local_account.h"
|
| #include "chrome/browser/chromeos/policy/device_local_account_external_data_manager.h"
|
| #include "chromeos/dbus/power_policy_controller.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/component_cloud_policy_service.h"
|
| #include "components/policy/core/common/policy_bundle.h"
|
| #include "components/policy/core/common/policy_map.h"
|
| #include "components/policy/core/common/policy_namespace.h"
|
| -#include "components/policy/core/common/policy_switches.h"
|
| -#include "content/public/browser/browser_thread.h"
|
| -#include "net/url_request/url_request_context_getter.h"
|
| #include "policy/policy_constants.h"
|
|
|
| namespace policy {
|
| @@ -98,18 +95,13 @@ DeviceLocalAccountPolicyProvider::Create(
|
| return provider.Pass();
|
| }
|
|
|
| -void DeviceLocalAccountPolicyProvider::Init(SchemaRegistry* schema_registry) {
|
| - ConfigurationPolicyProvider::Init(schema_registry);
|
| - MaybeCreateComponentPolicyService();
|
| -}
|
| -
|
| bool DeviceLocalAccountPolicyProvider::IsInitializationComplete(
|
| PolicyDomain domain) const {
|
| if (domain == POLICY_DOMAIN_CHROME)
|
| return store_initialized_;
|
| if (ComponentCloudPolicyService::SupportsDomain(domain) &&
|
| - component_policy_service_) {
|
| - return component_policy_service_->is_initialized();
|
| + GetBroker()->component_policy_service()) {
|
| + return GetBroker()->component_policy_service()->is_initialized();
|
| }
|
| return true;
|
| }
|
| @@ -126,38 +118,18 @@ void DeviceLocalAccountPolicyProvider::RefreshPolicies() {
|
| }
|
| }
|
|
|
| -void DeviceLocalAccountPolicyProvider::Shutdown() {
|
| - component_policy_service_.reset();
|
| - ConfigurationPolicyProvider::Shutdown();
|
| -}
|
| -
|
| void DeviceLocalAccountPolicyProvider::OnPolicyUpdated(
|
| const std::string& user_id) {
|
| - if (user_id == user_id_) {
|
| - MaybeCreateComponentPolicyService();
|
| + if (user_id == user_id_)
|
| UpdateFromBroker();
|
| - }
|
| }
|
|
|
| void DeviceLocalAccountPolicyProvider::OnDeviceLocalAccountsChanged() {
|
| - MaybeCreateComponentPolicyService();
|
| UpdateFromBroker();
|
| }
|
|
|
| -void DeviceLocalAccountPolicyProvider::OnBrokerShutdown(
|
| - DeviceLocalAccountPolicyBroker* broker) {
|
| - if (broker->user_id() == user_id_) {
|
| - // The |component_policy_service_| relies on the broker's CloudPolicyCore,
|
| - // so destroy it if the broker is going away.
|
| - component_policy_service_.reset();
|
| - }
|
| -}
|
| -
|
| -void DeviceLocalAccountPolicyProvider::OnComponentCloudPolicyUpdated() {
|
| - UpdateFromBroker();
|
| -}
|
| -
|
| -DeviceLocalAccountPolicyBroker* DeviceLocalAccountPolicyProvider::GetBroker() {
|
| +DeviceLocalAccountPolicyBroker* DeviceLocalAccountPolicyProvider::GetBroker()
|
| + const {
|
| return service_->GetBrokerForUser(user_id_);
|
| }
|
|
|
| @@ -176,6 +148,9 @@ void DeviceLocalAccountPolicyProvider::UpdateFromBroker() {
|
| bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
|
| .CopyFrom(broker->core()->store()->policy_map());
|
| external_data_manager_ = broker->external_data_manager();
|
| +
|
| + if (broker->component_policy_service())
|
| + bundle->MergeFrom(broker->component_policy_service()->policy());
|
| } else {
|
| // Wait for the refresh to finish.
|
| return;
|
| @@ -187,9 +162,6 @@ void DeviceLocalAccountPolicyProvider::UpdateFromBroker() {
|
| bundle->CopyFrom(policies());
|
| }
|
|
|
| - if (component_policy_service_)
|
| - bundle->MergeFrom(component_policy_service_->policy());
|
| -
|
| // Apply overrides.
|
| if (chrome_policy_overrides_) {
|
| PolicyMap& chrome_policy =
|
| @@ -206,35 +178,4 @@ void DeviceLocalAccountPolicyProvider::UpdateFromBroker() {
|
| UpdatePolicy(bundle.Pass());
|
| }
|
|
|
| -void DeviceLocalAccountPolicyProvider::MaybeCreateComponentPolicyService() {
|
| - if (component_policy_service_)
|
| - return; // Already started.
|
| -
|
| - if (CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kDisableComponentCloudPolicy)) {
|
| - // Disabled via the command line.
|
| - return;
|
| - }
|
| -
|
| - DeviceLocalAccountPolicyBroker* broker = GetBroker();
|
| - if (!broker || !schema_registry())
|
| - return; // Missing broker or not initialized yet.
|
| -
|
| - scoped_ptr<ResourceCache> resource_cache(
|
| - new ResourceCache(broker->GetComponentPolicyCachePath(),
|
| - content::BrowserThread::GetMessageLoopProxyForThread(
|
| - content::BrowserThread::FILE)));
|
| -
|
| - component_policy_service_.reset(new ComponentCloudPolicyService(
|
| - this,
|
| - schema_registry(),
|
| - broker->core(),
|
| - resource_cache.Pass(),
|
| - service_->request_context(),
|
| - content::BrowserThread::GetMessageLoopProxyForThread(
|
| - content::BrowserThread::FILE),
|
| - content::BrowserThread::GetMessageLoopProxyForThread(
|
| - content::BrowserThread::IO)));
|
| -}
|
| -
|
| } // namespace policy
|
|
|