| 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 f972779342d4f73d8e8c90b75954915fd4137945..95c5ccbcfc0126769577d8ee95964b360b1bd7c3 100644
|
| --- a/chrome/browser/policy/device_policy_cache.cc
|
| +++ b/chrome/browser/policy/device_policy_cache.cc
|
| @@ -4,24 +4,23 @@
|
|
|
| #include "chrome/browser/policy/device_policy_cache.h"
|
|
|
| +#include <string>
|
| +
|
| #include "base/basictypes.h"
|
| #include "base/compiler_specific.h"
|
| #include "base/logging.h"
|
| -#include "base/task.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/chromeos/cros/cros_library.h"
|
| #include "chrome/browser/chromeos/cros/update_library.h"
|
| #include "chrome/browser/chromeos/cros_settings_names.h"
|
| #include "chrome/browser/chromeos/login/ownership_service.h"
|
| #include "chrome/browser/chromeos/user_cros_settings_provider.h"
|
| -#include "chrome/browser/policy/configuration_policy_pref_store.h"
|
| -#include "chrome/browser/policy/device_policy_identity_strategy.h"
|
| +#include "chrome/browser/policy/cloud_policy_data.h"
|
| #include "chrome/browser/policy/enterprise_install_attributes.h"
|
| #include "chrome/browser/policy/policy_map.h"
|
| #include "chrome/browser/policy/proto/device_management_backend.pb.h"
|
| #include "chrome/browser/policy/proto/device_management_constants.h"
|
| #include "chrome/browser/policy/proto/device_management_local.pb.h"
|
| -#include "content/browser/browser_thread.h"
|
| #include "policy/configuration_policy_type.h"
|
|
|
| namespace {
|
| @@ -111,9 +110,9 @@ Value* DecodeIntegerValue(google::protobuf::int64 value) {
|
| namespace policy {
|
|
|
| DevicePolicyCache::DevicePolicyCache(
|
| - DevicePolicyIdentityStrategy* identity_strategy,
|
| + CloudPolicyData* data,
|
| EnterpriseInstallAttributes* install_attributes)
|
| - : identity_strategy_(identity_strategy),
|
| + : data_(data),
|
| install_attributes_(install_attributes),
|
| signed_settings_helper_(chromeos::SignedSettingsHelper::Get()),
|
| starting_up_(true),
|
| @@ -121,10 +120,10 @@ DevicePolicyCache::DevicePolicyCache(
|
| }
|
|
|
| DevicePolicyCache::DevicePolicyCache(
|
| - DevicePolicyIdentityStrategy* identity_strategy,
|
| + CloudPolicyData* data,
|
| EnterpriseInstallAttributes* install_attributes,
|
| chromeos::SignedSettingsHelper* signed_settings_helper)
|
| - : identity_strategy_(identity_strategy),
|
| + : data_(data),
|
| install_attributes_(install_attributes),
|
| signed_settings_helper_(signed_settings_helper),
|
| starting_up_(true),
|
| @@ -192,11 +191,15 @@ void DevicePolicyCache::OnRetrievePolicyCompleted(
|
| DCHECK(CalledOnValidThread());
|
| if (starting_up_) {
|
| starting_up_ = false;
|
| + // All the code paths should issue a data_->SetDeviceToken(..., true)
|
| + // to signal that the cache has finished loading, so other components
|
| + // are free to modify token data.
|
| if (code == chromeos::SignedSettings::NOT_FOUND ||
|
| code == chromeos::SignedSettings::KEY_UNAVAILABLE ||
|
| !policy.has_policy_data()) {
|
| InformNotifier(CloudPolicySubsystem::UNENROLLED,
|
| CloudPolicySubsystem::NO_DETAILS);
|
| + data_->SetDeviceToken("", true);
|
| return;
|
| }
|
| em::PolicyData policy_data;
|
| @@ -204,6 +207,7 @@ void DevicePolicyCache::OnRetrievePolicyCompleted(
|
| LOG(WARNING) << "Failed to parse PolicyData protobuf.";
|
| InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
|
| CloudPolicySubsystem::POLICY_LOCAL_ERROR);
|
| + data_->SetDeviceToken("", true);
|
| return;
|
| }
|
| if (!policy_data.has_request_token() ||
|
| @@ -214,17 +218,18 @@ void DevicePolicyCache::OnRetrievePolicyCompleted(
|
| // TODO(jkummerow): Reminder: When we want to feed device-wide settings
|
| // made by a local owner into this cache, we need to call
|
| // SetPolicyInternal() here.
|
| + data_->SetDeviceToken("", true);
|
| return;
|
| }
|
| if (!policy_data.has_username() || !policy_data.has_device_id()) {
|
| InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
|
| CloudPolicySubsystem::POLICY_LOCAL_ERROR);
|
| + data_->SetDeviceToken("", true);
|
| return;
|
| }
|
| - identity_strategy_->SetDeviceManagementCredentials(
|
| - policy_data.username(),
|
| - policy_data.device_id(),
|
| - policy_data.request_token());
|
| + data_->set_user_name(policy_data.username());
|
| + data_->set_device_id(policy_data.device_id());
|
| + data_->SetDeviceToken(policy_data.request_token(), true);
|
| SetPolicyInternal(policy, NULL, false);
|
| } else { // In other words, starting_up_ == false.
|
| if (code != chromeos::SignedSettings::SUCCESS) {
|
|
|