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

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

Issue 8586030: Added ConfigurationPolicyProvider::RefreshPolicies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 10 matching lines...) Expand all
21 class PolicyMap; 21 class PolicyMap;
22 22
23 // A mostly-abstract super class for platform-specific policy providers. 23 // A mostly-abstract super class for platform-specific policy providers.
24 // Platform-specific policy providers (Windows Group Policy, gconf, 24 // Platform-specific policy providers (Windows Group Policy, gconf,
25 // etc.) should implement a subclass of this class. 25 // etc.) should implement a subclass of this class.
26 class ConfigurationPolicyProvider { 26 class ConfigurationPolicyProvider {
27 public: 27 public:
28 class Observer { 28 class Observer {
29 public: 29 public:
30 virtual ~Observer(); 30 virtual ~Observer();
31 virtual void OnUpdatePolicy() = 0; 31 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) = 0;
32 virtual void OnProviderGoingAway(); 32 virtual void OnProviderGoingAway();
Mattias Nissler (ping if slow) 2011/11/18 11:00:25 Pass provider also to OnProviderGoingAway() for sy
Joao da Silva 2011/11/18 14:03:30 Done.
33 }; 33 };
34 34
35 explicit ConfigurationPolicyProvider(const PolicyDefinitionList* policy_list); 35 explicit ConfigurationPolicyProvider(const PolicyDefinitionList* policy_list);
36 36
37 virtual ~ConfigurationPolicyProvider(); 37 virtual ~ConfigurationPolicyProvider();
38 38
39 // Fills the given |result| with the current policy values. Returns true if 39 // Fills the given |result| with the current policy values. Returns true if
40 // the policies were provided. This is used mainly by the 40 // the policies were provided. This is used mainly by the
41 // ConfigurationPolicyPrefStore, which retrieves policy values from here. 41 // ConfigurationPolicyPrefStore, which retrieves policy values from here.
42 bool Provide(PolicyMap* result); 42 bool Provide(PolicyMap* result);
43 43
44 // Check whether this provider has completed initialization. This is used to 44 // Check whether this provider has completed initialization. This is used to
45 // detect whether initialization is done in case providers implementations 45 // detect whether initialization is done in case providers implementations
46 // need to do asynchronous operations for initialization. 46 // need to do asynchronous operations for initialization.
47 virtual bool IsInitializationComplete() const; 47 virtual bool IsInitializationComplete() const;
48 48
49 #if !defined(OFFICIAL_BUILD) 49 #if !defined(OFFICIAL_BUILD)
50 // Overrides the policy values that are obtained in calls to |Provide|. 50 // Overrides the policy values that are obtained in calls to |Provide|.
51 // The default behavior is restored if |policies| is NULL. 51 // The default behavior is restored if |policies| is NULL.
52 // Takes ownership of |policies|. 52 // Takes ownership of |policies|.
53 // This is meant for tests only, and is disabled on official builds. 53 // This is meant for tests only, and is disabled on official builds.
54 void OverridePolicies(PolicyMap* policies); 54 void OverridePolicies(PolicyMap* policies);
55 #endif 55 #endif
56 56
57 // Asks the provider to refresh its policies. All the updates caused by this
58 // call will be visible on the next calls of OnUpdatePolicy on the observers,
59 // which are guaranteed to happen even if the refresh fails.
60 // It is possible that OnProviderGoingAway is called first though, and
61 // OnUpdatePolicy won't be called if that happens.
62 virtual void RefreshPolicies() = 0;
63
57 protected: 64 protected:
58 // Sends a policy update notification to observers. 65 // Sends a policy update notification to observers.
59 void NotifyPolicyUpdated(); 66 void NotifyPolicyUpdated();
60 67
61 // Must be implemented by subclasses to provide their policy values. The 68 // Must be implemented by subclasses to provide their policy values. The
62 // values actually provided by |Provide| can be overridden using 69 // values actually provided by |Provide| can be overridden using
63 // |OverridePolicies|. 70 // |OverridePolicies|.
64 virtual bool ProvideInternal(PolicyMap* result) = 0; 71 virtual bool ProvideInternal(PolicyMap* result) = 0;
65 72
66 const PolicyDefinitionList* policy_definition_list() const { 73 const PolicyDefinitionList* policy_definition_list() const {
(...skipping 26 matching lines...) Expand all
93 // needs to register itself anyway to get OnProviderGoingAway notifications). 100 // needs to register itself anyway to get OnProviderGoingAway notifications).
94 class ConfigurationPolicyObserverRegistrar 101 class ConfigurationPolicyObserverRegistrar
95 : ConfigurationPolicyProvider::Observer { 102 : ConfigurationPolicyProvider::Observer {
96 public: 103 public:
97 ConfigurationPolicyObserverRegistrar(); 104 ConfigurationPolicyObserverRegistrar();
98 virtual ~ConfigurationPolicyObserverRegistrar(); 105 virtual ~ConfigurationPolicyObserverRegistrar();
99 void Init(ConfigurationPolicyProvider* provider, 106 void Init(ConfigurationPolicyProvider* provider,
100 ConfigurationPolicyProvider::Observer* observer); 107 ConfigurationPolicyProvider::Observer* observer);
101 108
102 // ConfigurationPolicyProvider::Observer implementation: 109 // ConfigurationPolicyProvider::Observer implementation:
103 virtual void OnUpdatePolicy(); 110 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider);
104 virtual void OnProviderGoingAway(); 111 virtual void OnProviderGoingAway();
105 112
106 ConfigurationPolicyProvider* provider() { return provider_; } 113 ConfigurationPolicyProvider* provider() { return provider_; }
107 114
108 private: 115 private:
109 ConfigurationPolicyProvider* provider_; 116 ConfigurationPolicyProvider* provider_;
110 ConfigurationPolicyProvider::Observer* observer_; 117 ConfigurationPolicyProvider::Observer* observer_;
111 118
112 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyObserverRegistrar); 119 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyObserverRegistrar);
113 }; 120 };
114 121
115 } // namespace policy 122 } // namespace policy
116 123
117 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ 124 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698