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

Side by Side Diff: chrome/browser/policy/policy_service.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_namespace.cc ('k') | chrome/browser/policy/policy_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "chrome/browser/policy/policy_bundle.h"
15 #include "chrome/browser/policy/policy_map.h" 16 #include "chrome/browser/policy/policy_map.h"
17 #include "chrome/browser/policy/policy_namespace.h"
16 18
17 namespace policy { 19 namespace policy {
18 20
19 // 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 // "extensions" then the ID identifies the extension that the policies control.
22 enum PolicyDomain {
23 // The component ID for chrome policies is always the empty string.
24 POLICY_DOMAIN_CHROME,
25
26 // The extensions policy domain is a work in progress. Included here for
27 // tests.
28 POLICY_DOMAIN_EXTENSIONS,
29
30 // Must be the last entry.
31 POLICY_DOMAIN_SIZE,
32 };
33
34 // Groups a policy domain and a component ID in a single object representing
35 // a policy namespace. Objects of this class can be used as keys in std::maps.
36 struct PolicyNamespace {
37 public:
38 PolicyNamespace();
39 PolicyNamespace(PolicyDomain domain, const std::string& component_id);
40 PolicyNamespace(const PolicyNamespace& other);
41 ~PolicyNamespace();
42
43 PolicyNamespace& operator=(const PolicyNamespace& other);
44 bool operator<(const PolicyNamespace& other) const;
45 bool operator==(const PolicyNamespace& other) const;
46 bool operator!=(const PolicyNamespace& other) const;
47
48 PolicyDomain domain;
49 std::string component_id;
50 };
51
52 // The PolicyService merges policies from all available sources, taking into 21 // The PolicyService merges policies from all available sources, taking into
53 // account their priorities. Policy clients can retrieve policy for their domain 22 // account their priorities. Policy clients can retrieve policy for their domain
54 // and register for notifications on policy updates. 23 // and register for notifications on policy updates.
55 // 24 //
56 // The PolicyService is available from BrowserProcess as a global singleton. 25 // The PolicyService is available from BrowserProcess as a global singleton.
57 // There is also a PolicyService for browser-wide policies available from 26 // There is also a PolicyService for browser-wide policies available from
58 // BrowserProcess as a global singleton. 27 // BrowserProcess as a global singleton.
59 class PolicyService { 28 class PolicyService {
60 public: 29 public:
61 class Observer { 30 class Observer {
(...skipping 28 matching lines...) Expand all
90 // |component_ids| is the current set of components for that |domain|, and 59 // |component_ids| is the current set of components for that |domain|, and
91 // replaces any previously registered set. 60 // replaces any previously registered set.
92 // The policy providers will try to load policy for these components, and may 61 // The policy providers will try to load policy for these components, and may
93 // flush cached data for components that aren't registered anymore. 62 // flush cached data for components that aren't registered anymore.
94 virtual void RegisterPolicyDomain( 63 virtual void RegisterPolicyDomain(
95 PolicyDomain domain, 64 PolicyDomain domain,
96 const std::set<std::string>& component_ids) = 0; 65 const std::set<std::string>& component_ids) = 0;
97 66
98 virtual const PolicyMap& GetPolicies(const PolicyNamespace& ns) const = 0; 67 virtual const PolicyMap& GetPolicies(const PolicyNamespace& ns) const = 0;
99 68
69 virtual const PolicyBundle& GetAllPolicies() const = 0;
70
100 // The PolicyService loads policy from several sources, and some require 71 // The PolicyService loads policy from several sources, and some require
101 // asynchronous loads. IsInitializationComplete() returns true once all 72 // asynchronous loads. IsInitializationComplete() returns true once all
102 // sources have loaded their policies for the given |domain|. 73 // sources have loaded their policies for the given |domain|.
103 // It is safe to read policy from the PolicyService even if 74 // It is safe to read policy from the PolicyService even if
104 // IsInitializationComplete() is false; there will be an OnPolicyUpdated() 75 // IsInitializationComplete() is false; there will be an OnPolicyUpdated()
105 // notification once new policies become available. 76 // notification once new policies become available.
106 // 77 //
107 // OnPolicyServiceInitialized() is called when IsInitializationComplete() 78 // OnPolicyServiceInitialized() is called when IsInitializationComplete()
108 // becomes true, which happens at most once for each domain. 79 // becomes true, which happens at most once for each domain.
109 // If IsInitializationComplete() is already true for |domain| when an Observer 80 // If IsInitializationComplete() is already true for |domain| when an Observer
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 PolicyService* policy_service_; 120 PolicyService* policy_service_;
150 PolicyNamespace ns_; 121 PolicyNamespace ns_;
151 CallbackMap callback_map_; 122 CallbackMap callback_map_;
152 123
153 DISALLOW_COPY_AND_ASSIGN(PolicyChangeRegistrar); 124 DISALLOW_COPY_AND_ASSIGN(PolicyChangeRegistrar);
154 }; 125 };
155 126
156 } // namespace policy 127 } // namespace policy
157 128
158 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_H_ 129 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_namespace.cc ('k') | chrome/browser/policy/policy_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698