Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(901)

Unified Diff: chrome/browser/configuration_policy_provider_win.cc

Issue 2858060: Changing policy while Chrome is running should refresh preferences without relaunching (Closed)
Patch Set: changed name of mock Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/configuration_policy_provider_win.cc
diff --git a/chrome/browser/configuration_policy_provider_win.cc b/chrome/browser/configuration_policy_provider_win.cc
index 61d264ce7abbb29db46e9bacd4fca2c28b52e435..b70f01dd9a855ce64cadaf943dd4474112c5057e 100644
--- a/chrome/browser/configuration_policy_provider_win.cc
+++ b/chrome/browser/configuration_policy_provider_win.cc
@@ -4,18 +4,56 @@
#include "chrome/browser/configuration_policy_provider_win.h"
+#include <userenv.h>
+
#include <algorithm>
#include "base/logging.h"
+#include "base/object_watcher.h"
#include "base/registry.h"
#include "base/scoped_ptr.h"
#include "base/string_piece.h"
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
+#include "base/waitable_event.h"
#include "chrome/common/policy_constants.h"
+ConfigurationPolicyProviderWin::GroupPolicyChangeWatcher::
+ GroupPolicyChangeWatcher(ConfigurationPolicyProvider* provider)
+ : provider_(provider),
+ user_policy_changed_event_(false, false),
+ machine_policy_changed_event_(false, false) {
+ CHECK(RegisterGPNotification(user_policy_changed_event_.handle(), false));
+ CHECK(RegisterGPNotification(machine_policy_changed_event_.handle(), true));
+ user_policy_watcher_.StartWatching(
+ user_policy_changed_event_.handle(),
+ this);
+ machine_policy_watcher_.StartWatching(
+ machine_policy_changed_event_.handle(),
+ this);
+}
+
+void ConfigurationPolicyProviderWin::GroupPolicyChangeWatcher::
+ OnObjectSignaled(HANDLE object) {
+ provider_->NotifyStoreOfPolicyChange();
+ if (object == user_policy_changed_event_.handle()) {
+ user_policy_watcher_.StartWatching(
+ user_policy_changed_event_.handle(),
+ this);
+ } else if (object == machine_policy_changed_event_.handle()) {
+ machine_policy_watcher_.StartWatching(
+ machine_policy_changed_event_.handle(),
+ this);
+ } else {
+ // This method should only be called as a result of signals
+ // to the user- and machine-policy handle watchers.
+ NOTREACHED();
+ }
+}
+
ConfigurationPolicyProviderWin::ConfigurationPolicyProviderWin() {
+ watcher_.reset(new GroupPolicyChangeWatcher(this));
}
bool ConfigurationPolicyProviderWin::GetRegistryPolicyString(
« no previous file with comments | « chrome/browser/configuration_policy_provider_win.h ('k') | chrome/browser/configuration_policy_provider_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698