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

Side by Side Diff: chrome/browser/policy/policy_service.h

Issue 15061007: Added a PolicyDomainDescriptor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <set>
10 #include <string> 9 #include <string>
11 #include <utility>
12 10
13 #include "base/basictypes.h" 11 #include "base/basictypes.h"
14 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
15 #include "chrome/browser/policy/policy_map.h" 14 #include "chrome/browser/policy/policy_map.h"
16 15
17 namespace policy { 16 namespace policy {
18 17
18 class PolicyDomainDescriptor;
19
19 // Policies are namespaced by a (PolicyDomain, ID) pair. The meaning of the ID 20 // Policies are namespaced by a (PolicyDomain, ID) pair. The meaning of the ID
20 // string depends on the domain; for example, if the PolicyDomain is 21 // string depends on the domain; for example, if the PolicyDomain is
21 // "extensions" then the ID identifies the extension that the policies control. 22 // "extensions" then the ID identifies the extension that the policies control.
22 enum PolicyDomain { 23 enum PolicyDomain {
23 // The component ID for chrome policies is always the empty string. 24 // The component ID for chrome policies is always the empty string.
24 POLICY_DOMAIN_CHROME, 25 POLICY_DOMAIN_CHROME,
25 26
26 // The extensions policy domain is a work in progress. Included here for 27 // The extensions policy domain is a work in progress. Included here for
27 // tests. 28 // tests.
28 POLICY_DOMAIN_EXTENSIONS, 29 POLICY_DOMAIN_EXTENSIONS,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 virtual ~Observer() {} 79 virtual ~Observer() {}
79 }; 80 };
80 81
81 virtual ~PolicyService() {} 82 virtual ~PolicyService() {}
82 83
83 // Observes changes to all components of the given |domain|. 84 // Observes changes to all components of the given |domain|.
84 virtual void AddObserver(PolicyDomain domain, Observer* observer) = 0; 85 virtual void AddObserver(PolicyDomain domain, Observer* observer) = 0;
85 86
86 virtual void RemoveObserver(PolicyDomain domain, Observer* observer) = 0; 87 virtual void RemoveObserver(PolicyDomain domain, Observer* observer) = 0;
87 88
88 // Registers the current components of the given policy |domain|, signaling 89 // Registers the |descriptor| of a policy domain, indicated by
89 // that there is interest in receiving policy for them. 90 // |descriptor->domain()|. This overrides the descriptor previously set, if
90 // |component_ids| is the current set of components for that |domain|, and 91 // there was one.
91 // replaces any previously registered set. 92 // This registration signals that there is interest in receiving policy for
92 // The policy providers will try to load policy for these components, and may 93 // the components listed in the descriptor. The policy providers will try to
93 // flush cached data for components that aren't registered anymore. 94 // load policy for these components, and validate it against the descriptor.
95 // Cached data for components that aren't registered anymore may be dropped.
94 virtual void RegisterPolicyDomain( 96 virtual void RegisterPolicyDomain(
95 PolicyDomain domain, 97 scoped_refptr<const PolicyDomainDescriptor> descriptor) = 0;
96 const std::set<std::string>& component_ids) = 0;
97 98
98 virtual const PolicyMap& GetPolicies(const PolicyNamespace& ns) const = 0; 99 virtual const PolicyMap& GetPolicies(const PolicyNamespace& ns) const = 0;
99 100
100 // The PolicyService loads policy from several sources, and some require 101 // The PolicyService loads policy from several sources, and some require
101 // asynchronous loads. IsInitializationComplete() returns true once all 102 // asynchronous loads. IsInitializationComplete() returns true once all
102 // sources have loaded their policies for the given |domain|. 103 // sources have loaded their policies for the given |domain|.
103 // It is safe to read policy from the PolicyService even if 104 // It is safe to read policy from the PolicyService even if
104 // IsInitializationComplete() is false; there will be an OnPolicyUpdated() 105 // IsInitializationComplete() is false; there will be an OnPolicyUpdated()
105 // notification once new policies become available. 106 // notification once new policies become available.
106 // 107 //
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 PolicyService* policy_service_; 150 PolicyService* policy_service_;
150 PolicyNamespace ns_; 151 PolicyNamespace ns_;
151 CallbackMap callback_map_; 152 CallbackMap callback_map_;
152 153
153 DISALLOW_COPY_AND_ASSIGN(PolicyChangeRegistrar); 154 DISALLOW_COPY_AND_ASSIGN(PolicyChangeRegistrar);
154 }; 155 };
155 156
156 } // namespace policy 157 } // namespace policy
157 158
158 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_H_ 159 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_prefs_browsertest.cc ('k') | chrome/browser/policy/policy_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698