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

Unified Diff: chrome/browser/policy/policy_change_watcher.h

Issue 16254003: WIP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
« no previous file with comments | « chrome/browser/policy/policy_bundle.h ('k') | chrome/browser/policy/policy_change_watcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/policy_change_watcher.h
diff --git a/chrome/browser/policy/policy_change_watcher.h b/chrome/browser/policy/policy_change_watcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..024023848d920a5dba37363221543f61b758052e
--- /dev/null
+++ b/chrome/browser/policy/policy_change_watcher.h
@@ -0,0 +1,106 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_POLICY_POLICY_CHANGE_WATCHER_H_
+#define CHROME_BROWSER_POLICY_POLICY_CHANGE_WATCHER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/observer_list.h"
+#include "chrome/browser/policy/policy_bundle.h"
+#include "chrome/browser/policy/policy_service.h"
+
+class PrefRegistrySimple;
+class PrefRegistrySyncable;
+class Profile;
+
+namespace policy {
+
+class PolicyServiceChangeWatcher : public PolicyService::Observer {
+ public:
+ PolicyServiceChangeWatcher(PolicyService* policy_service,
+ const std::string& current_hash);
+ virtual ~PolicyServiceChangeWatcher();
+
+ // PolicyService::Observer:
+ virtual void OnPolicyUpdated(const PolicyNamespace& ns,
+ const PolicyMap& previous,
+ const PolicyMap& current) OVERRIDE;
+ virtual void OnPolicyServiceInitialized(PolicyDomain domain) OVERRIDE;
+
+ protected:
+ bool is_initialization_complete() const {
+ return !domains_pending_initialization_;
+ }
+
+ const std::string& current_hash() const { return current_hash_; };
+
+ virtual void Init();
+
+ virtual void OnPolicyChanged() = 0;
+
+ private:
+ void CheckIfPolicyChanged(const PolicyBundle& bundle);
+
+ int domains_pending_initialization_;
+ std::string current_hash_;
+
+ PolicyService* policy_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(PolicyServiceChangeWatcher);
+};
+
+class DevicePolicyChangeWatcher : public PolicyServiceChangeWatcher {
+ public:
+ class Observer {
+ public:
+ virtual void OnDevicePolicyStatusChanged(
+ const std::vector<std::string>& users_with_changed_device_policy) = 0;
+
+ protected:
+ virtual ~Observer();
+ };
+
+ DevicePolicyChangeWatcher();
+ virtual ~DevicePolicyChangeWatcher();
+
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
+ void AcknowledgePolicyChange(const std::string& username);
+
+ private:
+ std::vector<std::string> ListUsersWithChangedDevicePolicy() const;
+ void NotifyDevicePolicyStatusChanged();
+
+ // PolicyServiceChangeWatcher:
+ virtual void OnPolicyChanged() OVERRIDE;
+
+ ObserverList<Observer, true> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(DevicePolicyChangeWatcher);
+};
+
+class UserPolicyChangeWatcher : public PolicyServiceChangeWatcher {
+ public:
+ UserPolicyChangeWatcher(Profile* profile);
+ virtual ~UserPolicyChangeWatcher();
+
+ static void RegisterUserPrefs(PrefRegistrySyncable* registry);
+
+ private:
+ // PolicyServiceChangeWatcher:
+ virtual void OnPolicyChanged() OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(UserPolicyChangeWatcher);
+};
+
+} // namespace policy
+
+#endif // CHROME_BROWSER_POLICY_POLICY_CHANGE_WATCHER_H_
« no previous file with comments | « chrome/browser/policy/policy_bundle.h ('k') | chrome/browser/policy/policy_change_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698