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

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

Issue 10545033: Removed the PolicyDefinitionList from the ConfigurationPolicyProvider interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 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
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_CONFIGURATION_POLICY_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_
6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "chrome/browser/policy/policy_bundle.h" 12 #include "chrome/browser/policy/policy_bundle.h"
13 13
14 namespace policy { 14 namespace policy {
15 15
16 struct PolicyDefinitionList;
17
18 // A mostly-abstract super class for platform-specific policy providers. 16 // A mostly-abstract super class for platform-specific policy providers.
19 // Platform-specific policy providers (Windows Group Policy, gconf, 17 // Platform-specific policy providers (Windows Group Policy, gconf,
20 // etc.) should implement a subclass of this class. 18 // etc.) should implement a subclass of this class.
21 class ConfigurationPolicyProvider { 19 class ConfigurationPolicyProvider {
22 public: 20 public:
23 class Observer { 21 class Observer {
24 public: 22 public:
25 virtual ~Observer(); 23 virtual ~Observer();
26 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) = 0; 24 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) = 0;
27 virtual void OnProviderGoingAway(ConfigurationPolicyProvider* provider); 25 virtual void OnProviderGoingAway(ConfigurationPolicyProvider* provider);
28 }; 26 };
29 27
30 explicit ConfigurationPolicyProvider(const PolicyDefinitionList* policy_list); 28 ConfigurationPolicyProvider();
31 29
32 virtual ~ConfigurationPolicyProvider(); 30 virtual ~ConfigurationPolicyProvider();
33 31
34 // Returns the current PolicyBundle. 32 // Returns the current PolicyBundle.
35 const PolicyBundle& policies() const { return policy_bundle_; } 33 const PolicyBundle& policies() const { return policy_bundle_; }
36 34
37 // Check whether this provider has completed initialization. This is used to 35 // Check whether this provider has completed initialization. This is used to
38 // detect whether initialization is done in case providers implementations 36 // detect whether initialization is done in case providers implementations
39 // need to do asynchronous operations for initialization. 37 // need to do asynchronous operations for initialization.
40 virtual bool IsInitializationComplete() const; 38 virtual bool IsInitializationComplete() const;
41 39
42 // Asks the provider to refresh its policies. All the updates caused by this 40 // Asks the provider to refresh its policies. All the updates caused by this
43 // call will be visible on the next call of OnUpdatePolicy on the observers, 41 // call will be visible on the next call of OnUpdatePolicy on the observers,
44 // which are guaranteed to happen even if the refresh fails. 42 // which are guaranteed to happen even if the refresh fails.
45 // It is possible that OnProviderGoingAway is called first though, and 43 // It is possible that OnProviderGoingAway is called first though, and
46 // OnUpdatePolicy won't be called if that happens. 44 // OnUpdatePolicy won't be called if that happens.
47 virtual void RefreshPolicies() = 0; 45 virtual void RefreshPolicies() = 0;
48 46
49 protected: 47 protected:
50 // Subclasses must invoke this to update the policies currently served by 48 // Subclasses must invoke this to update the policies currently served by
51 // this provider. UpdatePolicy() takes ownership of |policies|. 49 // this provider. UpdatePolicy() takes ownership of |policies|.
52 // The observers are notified after the policies are updated. 50 // The observers are notified after the policies are updated.
53 void UpdatePolicy(scoped_ptr<PolicyBundle> bundle); 51 void UpdatePolicy(scoped_ptr<PolicyBundle> bundle);
54 52
55 const PolicyDefinitionList* policy_definition_list() const {
56 return policy_definition_list_;
57 }
58
59 private: 53 private:
60 friend class ConfigurationPolicyObserverRegistrar; 54 friend class ConfigurationPolicyObserverRegistrar;
61 55
62 virtual void AddObserver(Observer* observer); 56 virtual void AddObserver(Observer* observer);
63 virtual void RemoveObserver(Observer* observer); 57 virtual void RemoveObserver(Observer* observer);
64 58
65 // The policies currently configured at this provider. 59 // The policies currently configured at this provider.
66 PolicyBundle policy_bundle_; 60 PolicyBundle policy_bundle_;
67 61
68 // Contains the default mapping from policy values to the actual names.
69 const PolicyDefinitionList* policy_definition_list_;
70
71 ObserverList<Observer, true> observer_list_; 62 ObserverList<Observer, true> observer_list_;
72 63
73 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProvider); 64 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProvider);
74 }; 65 };
75 66
76 // Manages observers for a ConfigurationPolicyProvider. Is used to register 67 // Manages observers for a ConfigurationPolicyProvider. Is used to register
77 // observers, and automatically removes them upon destruction. 68 // observers, and automatically removes them upon destruction.
78 // Implementation detail: to avoid duplicate bookkeeping of registered 69 // Implementation detail: to avoid duplicate bookkeeping of registered
79 // observers, this registrar class acts as a proxy for notifications (since it 70 // observers, this registrar class acts as a proxy for notifications (since it
80 // needs to register itself anyway to get OnProviderGoingAway notifications). 71 // needs to register itself anyway to get OnProviderGoingAway notifications).
(...skipping 15 matching lines...) Expand all
96 private: 87 private:
97 ConfigurationPolicyProvider* provider_; 88 ConfigurationPolicyProvider* provider_;
98 ConfigurationPolicyProvider::Observer* observer_; 89 ConfigurationPolicyProvider::Observer* observer_;
99 90
100 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyObserverRegistrar); 91 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyObserverRegistrar);
101 }; 92 };
102 93
103 } // namespace policy 94 } // namespace policy
104 95
105 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ 96 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/config_dir_policy_provider_unittest.cc ('k') | chrome/browser/policy/configuration_policy_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698