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

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

Issue 7585036: First CL for the about:policy page. This only implements the policy section of the page. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: . Created 9 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_READER_H_
6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_READER_H_
7 #pragma once
8
9 #include "base/scoped_ptr.h"
10 #include "base/values.h"
11 #include "chrome/browser/policy/configuration_policy_provider.h"
12 #include "chrome/browser/policy/policy_status_info.h"
13
14 namespace policy {
15
16 class ConfigurationPolicyStatusKeeper;
17
18 // This class reads policy information from a ConfigurationPolicyProvider in
19 // order to determine the status of a policy (this includes it's value and
20 // whether it could be enforced on the client or not), as required by the
21 // about:policy UI.
22 class ConfigurationPolicyReader : public ConfigurationPolicyProvider::Observer {
23 public:
Mattias Nissler (ping if slow) 2011/08/12 09:42:05 only one space of indentation for the visibility l
simo 2011/08/16 17:36:34 Done.
24 virtual ~ConfigurationPolicyReader();
25
26 bool IsInitializationComplete() const;
27
28 // ConfigurationPolicyProvider::Observer methods:
29 virtual void OnUpdatePolicy();
30 virtual void OnProviderGoingAway();
31
32 // Creates a ConfigurationPolicyReader that reads managed platform
33 // policy.
34 static ConfigurationPolicyReader*
35 CreateManagedPlatformPolicyReader(
36 PolicyStatusInfo::PolicyLevel policy_level);
37
38 // Creates a ConfigurationPolicyReader that reads managed cloud policy.
39 static ConfigurationPolicyReader*
40 CreateManagedCloudPolicyReader(
41 PolicyStatusInfo::PolicyLevel policy_level);
42
43 // Creates a ConfigurationPolicyReader that reads recommended cloud policy.
44 static ConfigurationPolicyReader*
45 CreateRecommendedPlatformPolicyReader(
46 PolicyStatusInfo::PolicyLevel policy_level);
47
48 // Creates a ConfigurationPolicyReader that reads recommended cloud policy.
49 static ConfigurationPolicyReader*
50 CreateRecommendedCloudPolicyReader(
51 PolicyStatusInfo::PolicyLevel policy_level);
52
53 // Returns a pointer to a DictionaryValue object containing policy status
54 // information for the UI. Ownership of the return value is acquired by the
55 // caller. Returns NULL if the reader is not aware of the given policy.
56 DictionaryValue* GetPolicyStatus(ConfigurationPolicyType policy) const;
57
58 private:
59 ConfigurationPolicyReader(ConfigurationPolicyProvider* provider,
60 PolicyStatusInfo::PolicyLevel policy_level);
Mattias Nissler (ping if slow) 2011/08/12 09:42:05 indentation.
simo 2011/08/16 17:36:34 Done.
61
62 // Updates the policy information held in this reader. This is called when
63 // the ConfigurationPolicyProvider is updated.
64 void Refresh();
65
66 // The policy provider from which policy settings are read.
67 ConfigurationPolicyProvider* provider_;
68
69 bool initialization_complete_;
70
71 // Whether this ConfigurationPolicyReader contains managed policies.
72 PolicyStatusInfo::PolicyLevel policy_level_;
73
74 // Current policy status.
75 scoped_ptr<ConfigurationPolicyStatusKeeper> policy_keeper_;
76
77 ConfigurationPolicyObserverRegistrar registrar_;
78
79 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyReader);
80 };
81
82 // This class combines the policy information from different
83 // ConfigurationPolicyReaders into a single list of policy information that the
84 // about:policy UI can display.
85 class PolicyStatus {
86
Mattias Nissler (ping if slow) 2011/08/12 09:42:05 no newline here.
simo 2011/08/16 17:36:34 Done.
87 public:
Mattias Nissler (ping if slow) 2011/08/12 09:42:05 indentation as described above.
simo 2011/08/16 17:36:34 Done.
88 PolicyStatus();
89 ~PolicyStatus();
90
91 // Returns a ListValue pointer containing the status information of all
92 // policies supported by the client. |any_policies_sent| is set to true if
93 // there are policies in the list that were sent by a provider, otherwise
94 // it is set tof alse. This is for the about:policy UI to display.
95 ListValue* GetPolicyStatusList(bool& any_policies_sent) const;
96
97 private:
98 typedef ConfigurationPolicyProvider::PolicyDefinitionList
99 PolicyDefinitionList;
100
101 // Add the policy information for |policy| to the ListValue pointed to be
102 // |list| as it is returned by the different ConfigurationPolicyReader
103 // objects. Returns true if a policy was added and false otherwise.
104 bool AddPolicyFromReaders(ConfigurationPolicyType policy,
105 ListValue* list) const;
106
107 scoped_ptr<ConfigurationPolicyReader> managed_platform_;
108 scoped_ptr<ConfigurationPolicyReader> managed_cloud_;
109 scoped_ptr<ConfigurationPolicyReader> recommended_platform_;
110 scoped_ptr<ConfigurationPolicyReader> recommended_cloud_;
111
112 DISALLOW_COPY_AND_ASSIGN(PolicyStatus);
113 };
114
115 } // namespace policy
116
117 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698