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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_POLICY_POLICY_CHANGE_WATCHER_H_
6 #define CHROME_BROWSER_POLICY_POLICY_CHANGE_WATCHER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/observer_list.h"
14 #include "chrome/browser/policy/policy_bundle.h"
15 #include "chrome/browser/policy/policy_service.h"
16
17 class PrefRegistrySimple;
18 class PrefRegistrySyncable;
19 class Profile;
20
21 namespace policy {
22
23 class PolicyServiceChangeWatcher : public PolicyService::Observer {
24 public:
25 PolicyServiceChangeWatcher(PolicyService* policy_service,
26 const std::string& current_hash);
27 virtual ~PolicyServiceChangeWatcher();
28
29 // PolicyService::Observer:
30 virtual void OnPolicyUpdated(const PolicyNamespace& ns,
31 const PolicyMap& previous,
32 const PolicyMap& current) OVERRIDE;
33 virtual void OnPolicyServiceInitialized(PolicyDomain domain) OVERRIDE;
34
35 protected:
36 bool is_initialization_complete() const {
37 return !domains_pending_initialization_;
38 }
39
40 const std::string& current_hash() const { return current_hash_; };
41
42 virtual void Init();
43
44 virtual void OnPolicyChanged() = 0;
45
46 private:
47 void CheckIfPolicyChanged(const PolicyBundle& bundle);
48
49 int domains_pending_initialization_;
50 std::string current_hash_;
51
52 PolicyService* policy_service_;
53
54 DISALLOW_COPY_AND_ASSIGN(PolicyServiceChangeWatcher);
55 };
56
57 class DevicePolicyChangeWatcher : public PolicyServiceChangeWatcher {
58 public:
59 class Observer {
60 public:
61 virtual void OnDevicePolicyStatusChanged(
62 const std::vector<std::string>& users_with_changed_device_policy) = 0;
63
64 protected:
65 virtual ~Observer();
66 };
67
68 DevicePolicyChangeWatcher();
69 virtual ~DevicePolicyChangeWatcher();
70
71 void AddObserver(Observer* observer);
72 void RemoveObserver(Observer* observer);
73
74 static void RegisterPrefs(PrefRegistrySimple* registry);
75
76 void AcknowledgePolicyChange(const std::string& username);
77
78 private:
79 std::vector<std::string> ListUsersWithChangedDevicePolicy() const;
80 void NotifyDevicePolicyStatusChanged();
81
82 // PolicyServiceChangeWatcher:
83 virtual void OnPolicyChanged() OVERRIDE;
84
85 ObserverList<Observer, true> observers_;
86
87 DISALLOW_COPY_AND_ASSIGN(DevicePolicyChangeWatcher);
88 };
89
90 class UserPolicyChangeWatcher : public PolicyServiceChangeWatcher {
91 public:
92 UserPolicyChangeWatcher(Profile* profile);
93 virtual ~UserPolicyChangeWatcher();
94
95 static void RegisterUserPrefs(PrefRegistrySyncable* registry);
96
97 private:
98 // PolicyServiceChangeWatcher:
99 virtual void OnPolicyChanged() OVERRIDE;
100
101 DISALLOW_COPY_AND_ASSIGN(UserPolicyChangeWatcher);
102 };
103
104 } // namespace policy
105
106 #endif // CHROME_BROWSER_POLICY_POLICY_CHANGE_WATCHER_H_
OLDNEW
« 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