summaryrefslogtreecommitdiffstats
path: root/chrome/browser/policy/device_policy_cache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/policy/device_policy_cache.cc')
-rw-r--r--chrome/browser/policy/device_policy_cache.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/chrome/browser/policy/device_policy_cache.cc b/chrome/browser/policy/device_policy_cache.cc
index a140893..2b65504 100644
--- a/chrome/browser/policy/device_policy_cache.cc
+++ b/chrome/browser/policy/device_policy_cache.cc
@@ -205,10 +205,7 @@ void DevicePolicyCache::OnRetrievePolicyCompleted(
if (!IsReady()) {
std::string device_token;
InstallInitialPolicy(code, policy, &device_token);
- // We need to call SetDeviceToken unconditionally to indicate the cache has
- // finished loading.
- data_store_->SetDeviceToken(device_token, true);
- SetReady();
+ SetTokenAndFlagReady(device_token);
} else { // In other words, IsReady() == true
if (code != chromeos::SignedSettings::SUCCESS) {
if (code == chromeos::SignedSettings::BAD_SIGNATURE) {
@@ -316,6 +313,21 @@ void DevicePolicyCache::InstallInitialPolicy(
set_last_policy_refresh_time(timestamp);
}
+void DevicePolicyCache::SetTokenAndFlagReady(const std::string& device_token) {
+ // Wait for device settings to become available.
+ if (!chromeos::CrosSettings::Get()->PrepareTrustedValues(
+ base::Bind(&DevicePolicyCache::SetTokenAndFlagReady,
+ weak_ptr_factory_.GetWeakPtr(),
+ device_token))) {
+ return;
+ }
+
+ // We need to call SetDeviceToken unconditionally to indicate the cache has
+ // finished loading.
+ data_store_->SetDeviceToken(device_token, true);
+ SetReady();
+}
+
// static
void DevicePolicyCache::DecodeLoginPolicies(
const em::ChromeDeviceSettingsProto& policy,