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

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

Issue 10386097: Refactored ConfigurationPolicyProvider to provide PolicyBundles instead of PolicyMaps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased patch Created 8 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_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 <map>
10 #include <string>
11
12 #include "base/basictypes.h" 9 #include "base/basictypes.h"
13 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
14 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "chrome/browser/policy/policy_bundle.h"
15 13
16 namespace policy { 14 namespace policy {
17 15
18 struct PolicyDefinitionList; 16 struct PolicyDefinitionList;
19 class PolicyMap; 17 class PolicyMap;
20 18
21 // A mostly-abstract super class for platform-specific policy providers. 19 // A mostly-abstract super class for platform-specific policy providers.
22 // Platform-specific policy providers (Windows Group Policy, gconf, 20 // Platform-specific policy providers (Windows Group Policy, gconf,
23 // etc.) should implement a subclass of this class. 21 // etc.) should implement a subclass of this class.
24 class ConfigurationPolicyProvider { 22 class ConfigurationPolicyProvider {
25 public: 23 public:
26 class Observer { 24 class Observer {
27 public: 25 public:
28 virtual ~Observer(); 26 virtual ~Observer();
29 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) = 0; 27 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) = 0;
30 virtual void OnProviderGoingAway(ConfigurationPolicyProvider* provider); 28 virtual void OnProviderGoingAway(ConfigurationPolicyProvider* provider);
31 }; 29 };
32 30
33 explicit ConfigurationPolicyProvider(const PolicyDefinitionList* policy_list); 31 explicit ConfigurationPolicyProvider(const PolicyDefinitionList* policy_list);
34 32
35 virtual ~ConfigurationPolicyProvider(); 33 virtual ~ConfigurationPolicyProvider();
36 34
37 // Fills the given |result| with the current policy values. Returns true if 35 // Fills the given |result| with the current policy values. Returns true if
38 // the policies were provided. This is used mainly by the 36 // the policies were provided. This is used mainly by the
39 // ConfigurationPolicyPrefStore, which retrieves policy values from here. 37 // ConfigurationPolicyPrefStore, which retrieves policy values from here.
38 // DEPRECATED: this call is going away, use policies() instead.
39 // http://crbug.com/108993
40 bool Provide(PolicyMap* result); 40 bool Provide(PolicyMap* result);
41 41
42 // Returns the current PolicyBundle.
43 const PolicyBundle& policies() const { return policy_bundle_; }
44
42 // Check whether this provider has completed initialization. This is used to 45 // Check whether this provider has completed initialization. This is used to
43 // detect whether initialization is done in case providers implementations 46 // detect whether initialization is done in case providers implementations
44 // need to do asynchronous operations for initialization. 47 // need to do asynchronous operations for initialization.
45 virtual bool IsInitializationComplete() const; 48 virtual bool IsInitializationComplete() const;
46 49
47 // Asks the provider to refresh its policies. All the updates caused by this 50 // Asks the provider to refresh its policies. All the updates caused by this
48 // call will be visible on the next call of OnUpdatePolicy on the observers, 51 // call will be visible on the next call of OnUpdatePolicy on the observers,
49 // which are guaranteed to happen even if the refresh fails. 52 // which are guaranteed to happen even if the refresh fails.
50 // It is possible that OnProviderGoingAway is called first though, and 53 // It is possible that OnProviderGoingAway is called first though, and
51 // OnUpdatePolicy won't be called if that happens. 54 // OnUpdatePolicy won't be called if that happens.
52 virtual void RefreshPolicies() = 0; 55 virtual void RefreshPolicies() = 0;
53 56
54 // Utility method that converts deprecated policies into their corresponding 57 // Utility method that converts deprecated policies into their corresponding
55 // actual policies. Subclasses can use this to fix deprecated policies in 58 // actual policies. Subclasses can use this to fix deprecated policies in
56 // PolicyMaps that they obtained from elsewhere. 59 // PolicyMaps that they obtained from elsewhere.
57 static void FixDeprecatedPolicies(PolicyMap* policies); 60 static void FixDeprecatedPolicies(PolicyMap* policies);
58 61
59 protected: 62 protected:
60 // Sends a policy update notification to observers. 63 // Subclasses must invoke this to update the policies currently served by
61 void NotifyPolicyUpdated(); 64 // this provider. UpdateProviderPolicy() takes ownership of |policies|.
62 65 // The observers are notified after the policies are updated.
63 // Must be implemented by subclasses to provide their policy values. 66 void UpdateProviderPolicy(scoped_ptr<PolicyBundle> bundle);
Mattias Nissler (ping if slow) 2012/05/14 09:07:21 Why not just UpdatePolicy()?
Joao da Silva 2012/05/14 09:39:17 Done.
64 virtual bool ProvideInternal(PolicyMap* result) = 0;
65 67
66 const PolicyDefinitionList* policy_definition_list() const { 68 const PolicyDefinitionList* policy_definition_list() const {
67 return policy_definition_list_; 69 return policy_definition_list_;
68 } 70 }
69 71
70 private: 72 private:
71 friend class ConfigurationPolicyObserverRegistrar; 73 friend class ConfigurationPolicyObserverRegistrar;
72 74
73 virtual void AddObserver(Observer* observer); 75 virtual void AddObserver(Observer* observer);
74 virtual void RemoveObserver(Observer* observer); 76 virtual void RemoveObserver(Observer* observer);
75 77
78 // The policies currently configured at this provider.
79 PolicyBundle policy_bundle_;
80
76 // Contains the default mapping from policy values to the actual names. 81 // Contains the default mapping from policy values to the actual names.
77 const PolicyDefinitionList* policy_definition_list_; 82 const PolicyDefinitionList* policy_definition_list_;
78 83
79 ObserverList<Observer, true> observer_list_; 84 ObserverList<Observer, true> observer_list_;
80 85
81 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProvider); 86 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProvider);
82 }; 87 };
83 88
84 // Manages observers for a ConfigurationPolicyProvider. Is used to register 89 // Manages observers for a ConfigurationPolicyProvider. Is used to register
85 // observers, and automatically removes them upon destruction. 90 // observers, and automatically removes them upon destruction.
(...skipping 18 matching lines...) Expand all
104 private: 109 private:
105 ConfigurationPolicyProvider* provider_; 110 ConfigurationPolicyProvider* provider_;
106 ConfigurationPolicyProvider::Observer* observer_; 111 ConfigurationPolicyProvider::Observer* observer_;
107 112
108 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyObserverRegistrar); 113 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyObserverRegistrar);
109 }; 114 };
110 115
111 } // namespace policy 116 } // namespace policy
112 117
113 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ 118 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698