| Index: chrome/browser/policy/device_policy_cache.cc
|
| diff --git a/chrome/browser/policy/device_policy_cache.cc b/chrome/browser/policy/device_policy_cache.cc
|
| index 818e233aba3092eb882ecfb1c64c09856e592a21..53bc34c4277c57c19a7f7796005b207cc8e09284 100644
|
| --- a/chrome/browser/policy/device_policy_cache.cc
|
| +++ b/chrome/browser/policy/device_policy_cache.cc
|
| @@ -15,10 +15,10 @@
|
| #include "base/logging.h"
|
| #include "base/metrics/histogram.h"
|
| #include "base/values.h"
|
| +#include "chrome/browser/chromeos/cros_settings.h"
|
| #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
|
| #include "chrome/browser/chromeos/dbus/update_engine_client.h"
|
| #include "chrome/browser/chromeos/login/ownership_service.h"
|
| -#include "chrome/browser/chromeos/user_cros_settings_provider.h"
|
| #include "chrome/browser/policy/cloud_policy_data_store.h"
|
| #include "chrome/browser/policy/enterprise_install_attributes.h"
|
| #include "chrome/browser/policy/enterprise_metrics.h"
|
| @@ -32,8 +32,7 @@ namespace {
|
|
|
| // Stores policy, updates the owner key if required and reports the status
|
| // through a callback.
|
| -class StorePolicyOperation : public chromeos::SignedSettingsHelper::Callback,
|
| - public chromeos::OwnerManager::KeyUpdateDelegate {
|
| +class StorePolicyOperation : public chromeos::OwnerManager::KeyUpdateDelegate {
|
| public:
|
| typedef base::Callback<void(chromeos::SignedSettings::ReturnCode)> Callback;
|
|
|
| @@ -42,15 +41,17 @@ class StorePolicyOperation : public chromeos::SignedSettingsHelper::Callback,
|
| const Callback& callback)
|
| : signed_settings_helper_(signed_settings_helper),
|
| policy_(policy),
|
| - callback_(callback) {
|
| - signed_settings_helper_->StartStorePolicyOp(policy, this);
|
| + callback_(callback),
|
| + weak_ptr_factory_(this) {
|
| + signed_settings_helper_->StartStorePolicyOp(
|
| + policy,
|
| + base::Bind(&StorePolicyOperation::OnStorePolicyCompleted,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| }
|
| virtual ~StorePolicyOperation() {
|
| - signed_settings_helper_->CancelCallback(this);
|
| }
|
|
|
| - // SignedSettingsHelper implementation:
|
| - virtual void OnStorePolicyCompleted(
|
| + void OnStorePolicyCompleted(
|
| chromeos::SignedSettings::ReturnCode code) OVERRIDE {
|
| if (code != chromeos::SignedSettings::SUCCESS) {
|
| callback_.Run(code);
|
| @@ -68,7 +69,7 @@ class StorePolicyOperation : public chromeos::SignedSettingsHelper::Callback,
|
| new_key_data, this);
|
| return;
|
| } else {
|
| - UpdateUserCrosSettings();
|
| + chromeos::CrosSettings::Get()->ReloadProviders();
|
| callback_.Run(chromeos::SignedSettings::SUCCESS);
|
| delete this;
|
| return;
|
| @@ -77,23 +78,19 @@ class StorePolicyOperation : public chromeos::SignedSettingsHelper::Callback,
|
|
|
| // OwnerManager::KeyUpdateDelegate implementation:
|
| virtual void OnKeyUpdated() OVERRIDE {
|
| - UpdateUserCrosSettings();
|
| + chromeos::CrosSettings::Get()->ReloadProviders();
|
| callback_.Run(chromeos::SignedSettings::SUCCESS);
|
| delete this;
|
| }
|
|
|
| private:
|
| - void UpdateUserCrosSettings() {
|
| - // TODO(mnissler): Find a better way. This is a hack that updates the
|
| - // UserCrosSettingsProvider's cache, since it is unable to notice we've
|
| - // updated policy information.
|
| - chromeos::UserCrosSettingsProvider().Reload();
|
| - }
|
|
|
| chromeos::SignedSettingsHelper* signed_settings_helper_;
|
| em::PolicyFetchResponse policy_;
|
| Callback callback_;
|
|
|
| + base::WeakPtrFactory<StorePolicyOperation> weak_ptr_factory_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(StorePolicyOperation);
|
| };
|
|
|
| @@ -134,11 +131,12 @@ DevicePolicyCache::DevicePolicyCache(
|
| }
|
|
|
| DevicePolicyCache::~DevicePolicyCache() {
|
| - signed_settings_helper_->CancelCallback(this);
|
| }
|
|
|
| void DevicePolicyCache::Load() {
|
| - signed_settings_helper_->StartRetrievePolicyOp(this);
|
| + signed_settings_helper_->StartRetrievePolicyOp(
|
| + base::Bind(&DevicePolicyCache::OnRetrievePolicyCompleted,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| }
|
|
|
| void DevicePolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) {
|
| @@ -258,7 +256,9 @@ void DevicePolicyCache::PolicyStoreOpCompleted(
|
| }
|
| UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyStoreSucceeded,
|
| kMetricPolicySize);
|
| - signed_settings_helper_->StartRetrievePolicyOp(this);
|
| + signed_settings_helper_->StartRetrievePolicyOp(
|
| + base::Bind(&DevicePolicyCache::OnRetrievePolicyCompleted,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| }
|
|
|
| void DevicePolicyCache::InstallInitialPolicy(
|
|
|