| 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "chrome/browser/policy/policy_map.h" | 13 #include "chrome/browser/policy/policy_map.h" |
| 15 #include "components/policy/core/common/policy_namespace.h" | 14 #include "components/policy/core/common/policy_namespace.h" |
| 16 | 15 |
| 17 namespace policy { | 16 namespace policy { |
| 18 | 17 |
| 19 class PolicyDomainDescriptor; | |
| 20 | |
| 21 // The PolicyService merges policies from all available sources, taking into | 18 // The PolicyService merges policies from all available sources, taking into |
| 22 // account their priorities. Policy clients can retrieve policy for their domain | 19 // account their priorities. Policy clients can retrieve policy for their domain |
| 23 // and register for notifications on policy updates. | 20 // and register for notifications on policy updates. |
| 24 // | 21 // |
| 25 // The PolicyService is available from BrowserProcess as a global singleton. | 22 // The PolicyService is available from BrowserProcess as a global singleton. |
| 26 // There is also a PolicyService for browser-wide policies available from | 23 // There is also a PolicyService for browser-wide policies available from |
| 27 // BrowserProcess as a global singleton. | 24 // BrowserProcess as a global singleton. |
| 28 class PolicyService { | 25 class PolicyService { |
| 29 public: | 26 public: |
| 30 class Observer { | 27 class Observer { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 47 virtual ~Observer() {} | 44 virtual ~Observer() {} |
| 48 }; | 45 }; |
| 49 | 46 |
| 50 virtual ~PolicyService() {} | 47 virtual ~PolicyService() {} |
| 51 | 48 |
| 52 // Observes changes to all components of the given |domain|. | 49 // Observes changes to all components of the given |domain|. |
| 53 virtual void AddObserver(PolicyDomain domain, Observer* observer) = 0; | 50 virtual void AddObserver(PolicyDomain domain, Observer* observer) = 0; |
| 54 | 51 |
| 55 virtual void RemoveObserver(PolicyDomain domain, Observer* observer) = 0; | 52 virtual void RemoveObserver(PolicyDomain domain, Observer* observer) = 0; |
| 56 | 53 |
| 57 // Registers the |descriptor| of a policy domain, indicated by | |
| 58 // |descriptor->domain()|. This overrides the descriptor previously set, if | |
| 59 // there was one. | |
| 60 // This registration signals that there is interest in receiving policy for | |
| 61 // the components listed in the descriptor. The policy providers will try to | |
| 62 // load policy for these components, and validate it against the descriptor. | |
| 63 // Cached data for components that aren't registered anymore may be dropped. | |
| 64 virtual void RegisterPolicyDomain( | |
| 65 scoped_refptr<const PolicyDomainDescriptor> descriptor) = 0; | |
| 66 | |
| 67 virtual const PolicyMap& GetPolicies(const PolicyNamespace& ns) const = 0; | 54 virtual const PolicyMap& GetPolicies(const PolicyNamespace& ns) const = 0; |
| 68 | 55 |
| 69 virtual scoped_refptr<const PolicyDomainDescriptor> GetPolicyDomainDescriptor( | |
| 70 PolicyDomain domain) const = 0; | |
| 71 | |
| 72 // The PolicyService loads policy from several sources, and some require | 56 // The PolicyService loads policy from several sources, and some require |
| 73 // asynchronous loads. IsInitializationComplete() returns true once all | 57 // asynchronous loads. IsInitializationComplete() returns true once all |
| 74 // sources have loaded their policies for the given |domain|. | 58 // sources have loaded their policies for the given |domain|. |
| 75 // It is safe to read policy from the PolicyService even if | 59 // It is safe to read policy from the PolicyService even if |
| 76 // IsInitializationComplete() is false; there will be an OnPolicyUpdated() | 60 // IsInitializationComplete() is false; there will be an OnPolicyUpdated() |
| 77 // notification once new policies become available. | 61 // notification once new policies become available. |
| 78 // | 62 // |
| 79 // OnPolicyServiceInitialized() is called when IsInitializationComplete() | 63 // OnPolicyServiceInitialized() is called when IsInitializationComplete() |
| 80 // becomes true, which happens at most once for each domain. | 64 // becomes true, which happens at most once for each domain. |
| 81 // If IsInitializationComplete() is already true for |domain| when an Observer | 65 // If IsInitializationComplete() is already true for |domain| when an Observer |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 PolicyService* policy_service_; | 105 PolicyService* policy_service_; |
| 122 PolicyNamespace ns_; | 106 PolicyNamespace ns_; |
| 123 CallbackMap callback_map_; | 107 CallbackMap callback_map_; |
| 124 | 108 |
| 125 DISALLOW_COPY_AND_ASSIGN(PolicyChangeRegistrar); | 109 DISALLOW_COPY_AND_ASSIGN(PolicyChangeRegistrar); |
| 126 }; | 110 }; |
| 127 | 111 |
| 128 } // namespace policy | 112 } // namespace policy |
| 129 | 113 |
| 130 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_H_ | 114 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_H_ |
| OLD | NEW |