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

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

Issue 9111022: Removed ConfigurationPolicyType and extended PolicyMap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 11 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) 2011 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_READER_H_ 5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_READER_H_
6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_READER_H_ 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_READER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/policy/configuration_policy_provider.h" 12 #include "chrome/browser/policy/configuration_policy_provider.h"
13 #include "chrome/browser/policy/policy_status_info.h" 13 #include "chrome/browser/policy/policy_status_info.h"
14 #include "policy/configuration_policy_type.h"
15 14
16 namespace policy { 15 namespace policy {
17 16
18 class ConfigurationPolicyStatusKeeper; 17 class ConfigurationPolicyStatusKeeper;
19 18
20 // This class reads policy information from a ConfigurationPolicyProvider in 19 // This class reads policy information from a ConfigurationPolicyProvider in
21 // order to determine the status of a policy (this includes its value and 20 // order to determine the status of a policy (this includes its value and
22 // whether it could be enforced on the client or not), as required by the 21 // whether it could be enforced on the client or not), as required by the
23 // about:policy UI. 22 // about:policy UI.
24 class ConfigurationPolicyReader : public ConfigurationPolicyProvider::Observer { 23 class ConfigurationPolicyReader : public ConfigurationPolicyProvider::Observer {
25 public: 24 public:
26 25
27 // Observer class for the ConfigurationPolicyReader. Observer objects are 26 // Observer class for the ConfigurationPolicyReader. Observer objects are
28 // notified when policy values have changed. 27 // notified when policy values have changed.
29 class Observer { 28 class Observer {
30 public: 29 public:
31 // Called on an observer when the policy values have changed. 30 // Called on an observer when the policy values have changed.
32 virtual void OnPolicyValuesChanged() = 0; 31 virtual void OnPolicyValuesChanged() = 0;
33 32
34 protected: 33 protected:
35 virtual ~Observer() {} 34 virtual ~Observer() {}
36 }; 35 };
37 36
38 ConfigurationPolicyReader(ConfigurationPolicyProvider* provider, 37 explicit ConfigurationPolicyReader(ConfigurationPolicyProvider* provider);
39 PolicyStatusInfo::PolicyLevel policy_level);
40 virtual ~ConfigurationPolicyReader(); 38 virtual ~ConfigurationPolicyReader();
41 39
42 // ConfigurationPolicyProvider::Observer methods: 40 // ConfigurationPolicyProvider::Observer methods:
43 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) OVERRIDE; 41 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) OVERRIDE;
44 virtual void OnProviderGoingAway( 42 virtual void OnProviderGoingAway(
45 ConfigurationPolicyProvider* provider) OVERRIDE; 43 ConfigurationPolicyProvider* provider) OVERRIDE;
46 44
47 // Methods to handle Observers. |observer| must be non-NULL. 45 // Methods to handle Observers. |observer| must be non-NULL.
48 void AddObserver(Observer* observer); 46 void AddObserver(Observer* observer);
49 void RemoveObserver(Observer* observer); 47 void RemoveObserver(Observer* observer);
50 48
51 // Creates a ConfigurationPolicyReader that reads managed platform policy. 49 // Creates a ConfigurationPolicyReader that reads managed platform policy.
52 static ConfigurationPolicyReader* CreateManagedPlatformPolicyReader(); 50 static ConfigurationPolicyReader* CreateManagedPlatformPolicyReader();
53 51
54 // Creates a ConfigurationPolicyReader that reads managed cloud policy. 52 // Creates a ConfigurationPolicyReader that reads managed cloud policy.
55 static ConfigurationPolicyReader* CreateManagedCloudPolicyReader(); 53 static ConfigurationPolicyReader* CreateManagedCloudPolicyReader();
56 54
57 // Creates a ConfigurationPolicyReader that reads recommended platform policy. 55 // Creates a ConfigurationPolicyReader that reads recommended platform policy.
58 static ConfigurationPolicyReader* CreateRecommendedPlatformPolicyReader(); 56 static ConfigurationPolicyReader* CreateRecommendedPlatformPolicyReader();
59 57
60 // Creates a ConfigurationPolicyReader that reads recommended cloud policy. 58 // Creates a ConfigurationPolicyReader that reads recommended cloud policy.
61 static ConfigurationPolicyReader* CreateRecommendedCloudPolicyReader(); 59 static ConfigurationPolicyReader* CreateRecommendedCloudPolicyReader();
62 60
63 // Returns a pointer to a DictionaryValue object containing policy status 61 // Returns a pointer to a DictionaryValue object containing policy status
64 // information for the UI. Ownership of the return value is acquired by the 62 // information for the UI. Ownership of the return value is acquired by the
65 // caller. Returns NULL if the reader is not aware of the given policy. 63 // caller. Returns NULL if the reader is not aware of the given policy.
66 virtual DictionaryValue* 64 virtual DictionaryValue* GetPolicyStatus(const char* policy) const;
67 GetPolicyStatus(ConfigurationPolicyType policy) const;
68 65
69 private: 66 private:
70 friend class MockConfigurationPolicyReader; 67 friend class MockConfigurationPolicyReader;
71 68
72 // Only used in tests. 69 // Only used in tests.
73 ConfigurationPolicyReader(); 70 ConfigurationPolicyReader();
74 71
75 // Updates the policy information held in this reader. This is called when 72 // Updates the policy information held in this reader. This is called when
76 // the ConfigurationPolicyProvider is updated. 73 // the ConfigurationPolicyProvider is updated.
77 void Refresh(); 74 void Refresh();
78 75
79 // The policy provider from which policy settings are read. 76 // The policy provider from which policy settings are read.
80 ConfigurationPolicyProvider* provider_; 77 ConfigurationPolicyProvider* provider_;
81 78
82 // Whether this ConfigurationPolicyReader contains managed policies.
83 PolicyStatusInfo::PolicyLevel policy_level_;
84
85 // Current policy status. 79 // Current policy status.
86 scoped_ptr<ConfigurationPolicyStatusKeeper> policy_keeper_; 80 scoped_ptr<ConfigurationPolicyStatusKeeper> policy_keeper_;
87 81
88 // The list of observers for this ConfigurationPolicyReader. 82 // The list of observers for this ConfigurationPolicyReader.
89 ObserverList<Observer, true> observers_; 83 ObserverList<Observer, true> observers_;
90 84
91 ConfigurationPolicyObserverRegistrar registrar_; 85 ConfigurationPolicyObserverRegistrar registrar_;
92 86
93 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyReader); 87 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyReader);
94 }; 88 };
(...skipping 19 matching lines...) Expand all
114 // Returns a ListValue pointer containing the status information of all 108 // Returns a ListValue pointer containing the status information of all
115 // policies supported by the client. |any_policies_set| is set to true if 109 // policies supported by the client. |any_policies_set| is set to true if
116 // there are policies in the list that were sent by a provider, otherwise 110 // there are policies in the list that were sent by a provider, otherwise
117 // it is set to false. This is for the about:policy UI to display. 111 // it is set to false. This is for the about:policy UI to display.
118 ListValue* GetPolicyStatusList(bool* any_policies_set) const; 112 ListValue* GetPolicyStatusList(bool* any_policies_set) const;
119 113
120 private: 114 private:
121 // Add the policy information for |policy| to the ListValue pointed to be 115 // Add the policy information for |policy| to the ListValue pointed to be
122 // |list| as it is returned by the different ConfigurationPolicyReader 116 // |list| as it is returned by the different ConfigurationPolicyReader
123 // objects. Returns true if a policy was added and false otherwise. 117 // objects. Returns true if a policy was added and false otherwise.
124 bool AddPolicyFromReaders(ConfigurationPolicyType policy, 118 bool AddPolicyFromReaders(const char* policy, ListValue* list) const;
125 ListValue* list) const;
126 119
127 scoped_ptr<ConfigurationPolicyReader> managed_platform_; 120 scoped_ptr<ConfigurationPolicyReader> managed_platform_;
128 scoped_ptr<ConfigurationPolicyReader> managed_cloud_; 121 scoped_ptr<ConfigurationPolicyReader> managed_cloud_;
129 scoped_ptr<ConfigurationPolicyReader> recommended_platform_; 122 scoped_ptr<ConfigurationPolicyReader> recommended_platform_;
130 scoped_ptr<ConfigurationPolicyReader> recommended_cloud_; 123 scoped_ptr<ConfigurationPolicyReader> recommended_cloud_;
131 124
132 DISALLOW_COPY_AND_ASSIGN(PolicyStatus); 125 DISALLOW_COPY_AND_ASSIGN(PolicyStatus);
133 }; 126 };
134 127
135 } // namespace policy 128 } // namespace policy
136 129
137 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_READER_H_ 130 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698