diff options
-rw-r--r-- | chrome/browser/chromeos/user_cros_settings_provider.cc | 16 | ||||
-rw-r--r-- | chrome/browser/chromeos/user_cros_settings_provider.h | 3 | ||||
-rw-r--r-- | chrome/browser/policy/device_policy_cache.cc | 15 |
3 files changed, 27 insertions, 7 deletions
diff --git a/chrome/browser/chromeos/user_cros_settings_provider.cc b/chrome/browser/chromeos/user_cros_settings_provider.cc index f231a57..4e76d86 100644 --- a/chrome/browser/chromeos/user_cros_settings_provider.cc +++ b/chrome/browser/chromeos/user_cros_settings_provider.cc @@ -200,6 +200,13 @@ class UserCrosSettingsTrust : public SignedSettingsHelper::Callback { } } + void Reload() { + for (size_t i = 0; i < arraysize(kBooleanSettings); ++i) + StartFetchingSetting(kBooleanSettings[i]); + for (size_t i = 0; i < arraysize(kStringSettings); ++i) + StartFetchingSetting(kStringSettings[i]); + } + void Set(const std::string& path, Value* in_value) { PrefService* prefs = g_browser_process->local_state(); DCHECK(!prefs->IsManagedPreference(path.c_str())); @@ -240,10 +247,7 @@ class UserCrosSettingsTrust : public SignedSettingsHelper::Callback { : ownership_service_(OwnershipService::GetSharedInstance()), retries_left_(kNumRetriesLimit) { // Start prefetching Boolean and String preferences. - for (size_t i = 0; i < arraysize(kBooleanSettings); ++i) - StartFetchingSetting(kBooleanSettings[i]); - for (size_t i = 0; i < arraysize(kStringSettings); ++i) - StartFetchingSetting(kStringSettings[i]); + Reload(); } ~UserCrosSettingsTrust() { @@ -431,6 +435,10 @@ bool UserCrosSettingsProvider::RequestTrustedOwner(Task* callback) { kDeviceOwner, callback); } +void UserCrosSettingsProvider::Reload() { + UserCrosSettingsTrust::GetInstance()->Reload(); +} + // static bool UserCrosSettingsProvider::cached_allow_guest() { // Trigger prefetching if singleton object still does not exist. diff --git a/chrome/browser/chromeos/user_cros_settings_provider.h b/chrome/browser/chromeos/user_cros_settings_provider.h index 9735091..a382335 100644 --- a/chrome/browser/chromeos/user_cros_settings_provider.h +++ b/chrome/browser/chromeos/user_cros_settings_provider.h @@ -40,6 +40,9 @@ class UserCrosSettingsProvider : public CrosSettingsProvider { bool RequestTrustedShowUsersOnSignin(Task* callback); bool RequestTrustedOwner(Task* callback); + // Reloads values from device settings. + void Reload(); + // Helper functions to access cached settings. static bool cached_allow_guest(); static bool cached_allow_new_user(); diff --git a/chrome/browser/policy/device_policy_cache.cc b/chrome/browser/policy/device_policy_cache.cc index ce02bdf..6ab2e33 100644 --- a/chrome/browser/policy/device_policy_cache.cc +++ b/chrome/browser/policy/device_policy_cache.cc @@ -9,19 +9,19 @@ #include "base/logging.h" #include "base/task.h" #include "base/values.h" +#include "chrome/browser/chromeos/cros_settings_names.h" #include "chrome/browser/chromeos/login/ownership_service.h" #include "chrome/browser/chromeos/login/signed_settings_helper.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/policy_map.h" -#include "chrome/browser/policy/proto/cloud_policy.pb.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" -using google::protobuf::RepeatedPtrField; - namespace { // Stores policy, updates the owner key if required and reports the status @@ -62,6 +62,7 @@ class StorePolicyOperation : public chromeos::SignedSettingsHelper::Callback, new_key_data, this); return; } else { + UpdateUserCrosSettings(); callback_->Run(chromeos::SignedSettings::SUCCESS); delete this; return; @@ -70,11 +71,19 @@ class StorePolicyOperation : public chromeos::SignedSettingsHelper::Callback, // OwnerManager::KeyUpdateDelegate implementation: virtual void OnKeyUpdated() OVERRIDE { + UpdateUserCrosSettings(); 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_; scoped_ptr<Callback> callback_; |