summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-15 19:06:12 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-15 19:06:12 +0000
commit15636d35b58dcc3ec8d891f2ffd687d3d07cd885 (patch)
treedba79c9e4514d734d0ffb2fe667988d3b239a9f8 /chrome
parenta621dc99d02ae35be283fd73ffa6f04f864c4ce9 (diff)
downloadchromium_src-15636d35b58dcc3ec8d891f2ffd687d3d07cd885.zip
chromium_src-15636d35b58dcc3ec8d891f2ffd687d3d07cd885.tar.gz
chromium_src-15636d35b58dcc3ec8d891f2ffd687d3d07cd885.tar.bz2
Refresh cache in UserCrosSettingsProvider after storing policy
This is necessary because UserCrosSettingsProvider has no way of noticing that device settings have changed and thus cannot update its local cache. In order to work around this, we trigger a explicit reload so the caches get updated. This is only temporary and should go away when we do the big SignedSettings interface refactoring on the Chrome side. BUG=chromium-os:14188 TEST=manual Review URL: http://codereview.chromium.org/6864010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81777 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/user_cros_settings_provider.cc16
-rw-r--r--chrome/browser/chromeos/user_cros_settings_provider.h3
-rw-r--r--chrome/browser/policy/device_policy_cache.cc15
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_;