OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_POLICY_POLICY_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_POLICY_SERVICE_H_ |
6 #define CHROME_BROWSER_POLICY_POLICY_SERVICE_H_ | 6 #define CHROME_BROWSER_POLICY_POLICY_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 // The PolicyService merges policies from all available sources, taking into | 30 // The PolicyService merges policies from all available sources, taking into |
31 // account their priorities. Policy clients can retrieve policy for their domain | 31 // account their priorities. Policy clients can retrieve policy for their domain |
32 // and register for notifications on policy updates. | 32 // and register for notifications on policy updates. |
33 // | 33 // |
34 // The PolicyService is available from BrowserProcess as a global singleton. | 34 // The PolicyService is available from BrowserProcess as a global singleton. |
35 class PolicyService { | 35 class PolicyService { |
36 public: | 36 public: |
37 class Observer { | 37 class Observer { |
38 public: | 38 public: |
39 virtual ~Observer() {} | |
40 | |
41 // Invoked whenever policies for the |domain|, |component_id| namespace are | 39 // Invoked whenever policies for the |domain|, |component_id| namespace are |
42 // modified. This is only invoked for changes that happen after AddObserver | 40 // modified. This is only invoked for changes that happen after AddObserver |
43 // is called. |previous| contains the values of the policies before the | 41 // is called. |previous| contains the values of the policies before the |
44 // update, and |current| contains the current values. | 42 // update, and |current| contains the current values. |
45 virtual void OnPolicyUpdated(PolicyDomain domain, | 43 virtual void OnPolicyUpdated(PolicyDomain domain, |
46 const std::string& component_id, | 44 const std::string& component_id, |
47 const PolicyMap& previous, | 45 const PolicyMap& previous, |
48 const PolicyMap& current) = 0; | 46 const PolicyMap& current) = 0; |
49 | 47 |
50 // Invoked at most once, when the PolicyService becomes ready. If | 48 // Invoked at most once, when the PolicyService becomes ready. If |
51 // IsInitializationComplete() is false, then this will be invoked once all | 49 // IsInitializationComplete() is false, then this will be invoked once all |
52 // the policy providers are ready. | 50 // the policy providers are ready. |
53 virtual void OnPolicyServiceInitialized() {} | 51 virtual void OnPolicyServiceInitialized() {} |
| 52 |
| 53 protected: |
| 54 virtual ~Observer() {} |
54 }; | 55 }; |
55 | 56 |
56 virtual ~PolicyService() {} | 57 virtual ~PolicyService() {} |
57 | 58 |
58 virtual void AddObserver(PolicyDomain domain, | 59 virtual void AddObserver(PolicyDomain domain, |
59 const std::string& component_id, | 60 const std::string& component_id, |
60 Observer* observer) = 0; | 61 Observer* observer) = 0; |
61 | 62 |
62 virtual void RemoveObserver(PolicyDomain domain, | 63 virtual void RemoveObserver(PolicyDomain domain, |
63 const std::string& component_id, | 64 const std::string& component_id, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 PolicyDomain domain_; | 121 PolicyDomain domain_; |
121 std::string component_id_; | 122 std::string component_id_; |
122 CallbackMap callback_map_; | 123 CallbackMap callback_map_; |
123 | 124 |
124 DISALLOW_COPY_AND_ASSIGN(PolicyChangeRegistrar); | 125 DISALLOW_COPY_AND_ASSIGN(PolicyChangeRegistrar); |
125 }; | 126 }; |
126 | 127 |
127 } // namespace policy | 128 } // namespace policy |
128 | 129 |
129 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_H_ | 130 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_H_ |
OLD | NEW |