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

Side by Side Diff: components/policy/core/common/policy_service.h

Issue 109743002: Move policy code into components/policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moar fixes Created 7 years 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 COMPONENTS_POLICY_CORE_COMMON_POLICY_SERVICE_H_
6 #define CHROME_BROWSER_POLICY_POLICY_SERVICE_H_ 6 #define COMPONENTS_POLICY_CORE_COMMON_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 "components/policy/core/common/policy_map.h" 13 #include "components/policy/core/common/policy_map.h"
14 #include "components/policy/core/common/policy_namespace.h" 14 #include "components/policy/core/common/policy_namespace.h"
15 #include "components/policy/policy_export.h"
15 16
16 namespace policy { 17 namespace policy {
17 18
18 // The PolicyService merges policies from all available sources, taking into 19 // The PolicyService merges policies from all available sources, taking into
19 // account their priorities. Policy clients can retrieve policy for their domain 20 // account their priorities. Policy clients can retrieve policy for their domain
20 // and register for notifications on policy updates. 21 // and register for notifications on policy updates.
21 // 22 //
22 // The PolicyService is available from BrowserProcess as a global singleton. 23 // The PolicyService is available from BrowserProcess as a global singleton.
23 // There is also a PolicyService for browser-wide policies available from 24 // There is also a PolicyService for browser-wide policies available from
24 // BrowserProcess as a global singleton. 25 // BrowserProcess as a global singleton.
25 class PolicyService { 26 class POLICY_EXPORT PolicyService {
26 public: 27 public:
27 class Observer { 28 class POLICY_EXPORT Observer {
28 public: 29 public:
29 // Invoked whenever policies for the given |ns| namespace are modified. 30 // Invoked whenever policies for the given |ns| namespace are modified.
30 // This is only invoked for changes that happen after AddObserver is called. 31 // This is only invoked for changes that happen after AddObserver is called.
31 // |previous| contains the values of the policies before the update, 32 // |previous| contains the values of the policies before the update,
32 // and |current| contains the current values. 33 // and |current| contains the current values.
33 virtual void OnPolicyUpdated(const PolicyNamespace& ns, 34 virtual void OnPolicyUpdated(const PolicyNamespace& ns,
34 const PolicyMap& previous, 35 const PolicyMap& previous,
35 const PolicyMap& current) = 0; 36 const PolicyMap& current) = 0;
36 37
37 // Invoked at most once for each |domain|, when the PolicyService becomes 38 // Invoked at most once for each |domain|, when the PolicyService becomes
(...skipping 30 matching lines...) Expand all
68 virtual bool IsInitializationComplete(PolicyDomain domain) const = 0; 69 virtual bool IsInitializationComplete(PolicyDomain domain) const = 0;
69 70
70 // Asks the PolicyService to reload policy from all available policy sources. 71 // Asks the PolicyService to reload policy from all available policy sources.
71 // |callback| is invoked once every source has reloaded its policies, and 72 // |callback| is invoked once every source has reloaded its policies, and
72 // GetPolicies() is guaranteed to return the updated values at that point. 73 // GetPolicies() is guaranteed to return the updated values at that point.
73 virtual void RefreshPolicies(const base::Closure& callback) = 0; 74 virtual void RefreshPolicies(const base::Closure& callback) = 0;
74 }; 75 };
75 76
76 // A registrar that only observes changes to particular policies within the 77 // A registrar that only observes changes to particular policies within the
77 // PolicyMap for the given policy namespace. 78 // PolicyMap for the given policy namespace.
78 class PolicyChangeRegistrar : public PolicyService::Observer { 79 class POLICY_EXPORT PolicyChangeRegistrar : public PolicyService::Observer {
79 public: 80 public:
80 typedef base::Callback<void(const Value*, const Value*)> UpdateCallback; 81 typedef base::Callback<void(const Value*, const Value*)> UpdateCallback;
81 82
82 // Observes updates to the given (domain, component_id) namespace in the given 83 // Observes updates to the given (domain, component_id) namespace in the given
83 // |policy_service|, and notifies |observer| whenever any of the registered 84 // |policy_service|, and notifies |observer| whenever any of the registered
84 // policy keys changes. Both the |policy_service| and the |observer| must 85 // policy keys changes. Both the |policy_service| and the |observer| must
85 // outlive |this|. 86 // outlive |this|.
86 PolicyChangeRegistrar(PolicyService* policy_service, 87 PolicyChangeRegistrar(PolicyService* policy_service,
87 const PolicyNamespace& ns); 88 const PolicyNamespace& ns);
88 89
(...skipping 15 matching lines...) Expand all
104 105
105 PolicyService* policy_service_; 106 PolicyService* policy_service_;
106 PolicyNamespace ns_; 107 PolicyNamespace ns_;
107 CallbackMap callback_map_; 108 CallbackMap callback_map_;
108 109
109 DISALLOW_COPY_AND_ASSIGN(PolicyChangeRegistrar); 110 DISALLOW_COPY_AND_ASSIGN(PolicyChangeRegistrar);
110 }; 111 };
111 112
112 } // namespace policy 113 } // namespace policy
113 114
114 #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_H_ 115 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_SERVICE_H_
OLDNEW
« no previous file with comments | « components/policy/core/common/policy_loader_win_unittest.cc ('k') | components/policy/core/common/policy_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698