| 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" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "chrome/browser/policy/policy_map.h" | 14 #include "chrome/browser/policy/policy_map.h" |
| 15 #include "components/policy/core/common/policy_namespace.h" |
| 15 | 16 |
| 16 namespace policy { | 17 namespace policy { |
| 17 | 18 |
| 18 class PolicyDomainDescriptor; | 19 class PolicyDomainDescriptor; |
| 19 | 20 |
| 20 // Policies are namespaced by a (PolicyDomain, ID) pair. The meaning of the ID | |
| 21 // string depends on the domain; for example, if the PolicyDomain is | |
| 22 // "extensions" then the ID identifies the extension that the policies control. | |
| 23 enum PolicyDomain { | |
| 24 // The component ID for chrome policies is always the empty string. | |
| 25 POLICY_DOMAIN_CHROME, | |
| 26 | |
| 27 // The extensions policy domain is a work in progress. Included here for | |
| 28 // tests. | |
| 29 POLICY_DOMAIN_EXTENSIONS, | |
| 30 | |
| 31 // Must be the last entry. | |
| 32 POLICY_DOMAIN_SIZE, | |
| 33 }; | |
| 34 | |
| 35 // Groups a policy domain and a component ID in a single object representing | |
| 36 // a policy namespace. Objects of this class can be used as keys in std::maps. | |
| 37 struct PolicyNamespace { | |
| 38 public: | |
| 39 PolicyNamespace(); | |
| 40 PolicyNamespace(PolicyDomain domain, const std::string& component_id); | |
| 41 PolicyNamespace(const PolicyNamespace& other); | |
| 42 ~PolicyNamespace(); | |
| 43 | |
| 44 PolicyNamespace& operator=(const PolicyNamespace& other); | |
| 45 bool operator<(const PolicyNamespace& other) const; | |
| 46 bool operator==(const PolicyNamespace& other) const; | |
| 47 bool operator!=(const PolicyNamespace& other) const; | |
| 48 | |
| 49 PolicyDomain domain; | |
| 50 std::string component_id; | |
| 51 }; | |
| 52 | |
| 53 // The PolicyService merges policies from all available sources, taking into | 21 // The PolicyService merges policies from all available sources, taking into |
| 54 // account their priorities. Policy clients can retrieve policy for their domain | 22 // account their priorities. Policy clients can retrieve policy for their domain |
| 55 // and register for notifications on policy updates. | 23 // and register for notifications on policy updates. |
| 56 // | 24 // |
| 57 // The PolicyService is available from BrowserProcess as a global singleton. | 25 // The PolicyService is available from BrowserProcess as a global singleton. |
| 58 // There is also a PolicyService for browser-wide policies available from | 26 // There is also a PolicyService for browser-wide policies available from |
| 59 // BrowserProcess as a global singleton. | 27 // BrowserProcess as a global singleton. |
| 60 class PolicyService { | 28 class PolicyService { |
| 61 public: | 29 public: |
| 62 class Observer { | 30 class Observer { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 PolicyService* policy_service_; | 121 PolicyService* policy_service_; |
| 154 PolicyNamespace ns_; | 122 PolicyNamespace ns_; |
| 155 CallbackMap callback_map_; | 123 CallbackMap callback_map_; |
| 156 | 124 |
| 157 DISALLOW_COPY_AND_ASSIGN(PolicyChangeRegistrar); | 125 DISALLOW_COPY_AND_ASSIGN(PolicyChangeRegistrar); |
| 158 }; | 126 }; |
| 159 | 127 |
| 160 } // namespace policy | 128 } // namespace policy |
| 161 | 129 |
| 162 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_H_ | 130 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_H_ |
| OLD | NEW |