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

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

Issue 92153002: Move ConfigurationPolicyProvider, etc. to components/policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_
6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/observer_list.h"
12 #include "components/policy/core/common/policy_bundle.h"
13 #include "components/policy/core/common/policy_namespace.h"
14 #include "components/policy/core/common/schema_registry.h"
15
16 namespace policy {
17
18 // A mostly-abstract super class for platform-specific policy providers.
19 // Platform-specific policy providers (Windows Group Policy, gconf,
20 // etc.) should implement a subclass of this class.
21 class ConfigurationPolicyProvider : public SchemaRegistry::Observer {
22 public:
23 class Observer {
24 public:
25 virtual ~Observer();
26 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) = 0;
27 };
28
29 ConfigurationPolicyProvider();
30
31 // Policy providers can be deleted quite late during shutdown of the browser,
32 // and it's not guaranteed that the message loops will still be running when
33 // this is invoked. Override Shutdown() instead for cleanup code that needs
34 // to post to the FILE thread, for example.
35 virtual ~ConfigurationPolicyProvider();
36
37 // Invoked as soon as the main message loops are spinning. Policy providers
38 // are created early during startup to provide the initial policies; the
39 // Init() call allows them to perform initialization tasks that require
40 // running message loops.
41 // The policy provider will load policy for the components registered in
42 // the |schema_registry| whose domain is supported by this provider.
43 virtual void Init(SchemaRegistry* registry);
44
45 // Must be invoked before deleting the provider. Implementations can override
46 // this method to do appropriate cleanup while threads are still running, and
47 // must also invoke ConfigurationPolicyProvider::Shutdown().
48 // The provider should keep providing the current policies after Shutdown()
49 // is invoked, it only has to stop updating.
50 virtual void Shutdown();
51
52 // Returns the current PolicyBundle.
53 const PolicyBundle& policies() const { return policy_bundle_; }
54
55 // Check whether this provider has completed initialization for the given
56 // policy |domain|. This is used to detect whether initialization is done in
57 // case implementations need to do asynchronous operations for initialization.
58 virtual bool IsInitializationComplete(PolicyDomain domain) const;
59
60 // Asks the provider to refresh its policies. All the updates caused by this
61 // call will be visible on the next call of OnUpdatePolicy on the observers,
62 // which are guaranteed to happen even if the refresh fails.
63 // It is possible that Shutdown() is called first though, and
64 // OnUpdatePolicy won't be called if that happens.
65 virtual void RefreshPolicies() = 0;
66
67 // Observers must detach themselves before the provider is deleted.
68 virtual void AddObserver(Observer* observer);
69 virtual void RemoveObserver(Observer* observer);
70
71 // SchemaRegistry::Observer:
72 virtual void OnSchemaRegistryUpdated(bool has_new_schemas) OVERRIDE;
73 virtual void OnSchemaRegistryReady() OVERRIDE;
74
75 protected:
76 // Subclasses must invoke this to update the policies currently served by
77 // this provider. UpdatePolicy() takes ownership of |policies|.
78 // The observers are notified after the policies are updated.
79 void UpdatePolicy(scoped_ptr<PolicyBundle> bundle);
80
81 SchemaRegistry* schema_registry() const;
82
83 const scoped_refptr<SchemaMap>& schema_map() const;
84
85 private:
86 // The policies currently configured at this provider.
87 PolicyBundle policy_bundle_;
88
89 // Whether Shutdown() has been invoked.
90 bool did_shutdown_;
91
92 SchemaRegistry* schema_registry_;
93
94 ObserverList<Observer, true> observer_list_;
95
96 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProvider);
97 };
98
99 } // namespace policy
100
101 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698