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

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: Added a test case for PolicyStatus 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 its 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:
24 ConfigurationPolicyReader(ConfigurationPolicyProvider* provider,
25 PolicyStatusInfo::PolicyLevel policy_level);
26 virtual ~ConfigurationPolicyReader();
27
28 // ConfigurationPolicyProvider::Observer methods:
29 virtual void OnUpdatePolicy();
30 virtual void OnProviderGoingAway();
31
32 // Creates a ConfigurationPolicyReader that reads managed platform policy.
33 static ConfigurationPolicyReader*
34 CreateManagedPlatformPolicyReader(
35 PolicyStatusInfo::PolicyLevel policy_level);
Mattias Nissler (ping if slow) 2011/08/25 11:01:02 Another 4 spaces indentation here
simo 2011/08/25 13:29:47 Done.
36
37 // Creates a ConfigurationPolicyReader that reads managed cloud policy.
38 static ConfigurationPolicyReader*
39 CreateManagedCloudPolicyReader(
40 PolicyStatusInfo::PolicyLevel policy_level);
Mattias Nissler (ping if slow) 2011/08/25 11:01:02 same here
simo 2011/08/25 13:29:47 Done.
41
42 // Creates a ConfigurationPolicyReader that reads recommended platform policy.
43 static ConfigurationPolicyReader*
44 CreateRecommendedPlatformPolicyReader(
Mattias Nissler (ping if slow) 2011/08/25 11:01:02 4 spaces indentation
simo 2011/08/25 13:29:47 Done.
45 PolicyStatusInfo::PolicyLevel policy_level);
46
47 // Creates a ConfigurationPolicyReader that reads recommended cloud policy.
48 static ConfigurationPolicyReader*
49 CreateRecommendedCloudPolicyReader(
50 PolicyStatusInfo::PolicyLevel policy_level);
Mattias Nissler (ping if slow) 2011/08/25 11:01:02 same here
simo 2011/08/25 13:29:47 Done.
51
52 // Returns a pointer to a DictionaryValue object containing policy status
53 // information for the UI. Ownership of the return value is acquired by the
54 // caller. Returns NULL if the reader is not aware of the given policy.
55 DictionaryValue* GetPolicyStatus(ConfigurationPolicyType policy) const;
56
57 private:
58 // Updates the policy information held in this reader. This is called when
59 // the ConfigurationPolicyProvider is updated.
60 void Refresh();
61
62 // The policy provider from which policy settings are read.
63 ConfigurationPolicyProvider* provider_;
64
65 // Whether this ConfigurationPolicyReader contains managed policies.
66 PolicyStatusInfo::PolicyLevel policy_level_;
67
68 // Current policy status.
69 scoped_ptr<ConfigurationPolicyStatusKeeper> policy_keeper_;
70
71 ConfigurationPolicyObserverRegistrar registrar_;
72
73 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyReader);
74 };
75
76 // This class combines the policy information from different
77 // ConfigurationPolicyReaders into a single list of policy information that the
78 // about:policy UI can display.
79 class PolicyStatus {
80 public:
81 PolicyStatus(ConfigurationPolicyReader* managed_platform,
82 ConfigurationPolicyReader* managed_cloud,
83 ConfigurationPolicyReader* recommended_platform,
84 ConfigurationPolicyReader* recommended_cloud);
85 ~PolicyStatus();
86
87 // Returns a ListValue pointer containing the status information of all
88 // policies supported by the client. |any_policies_sent| is set to true if
89 // there are policies in the list that were sent by a provider, otherwise
90 // it is set to false. This is for the about:policy UI to display.
91 ListValue* GetPolicyStatusList(bool* any_policies_sent) const;
92
93 // Returns a string16 containing the actual name of the policy corresponding
94 // to |policy_type|. Returns an empty string if there is no such policy_type
95 // among the policies supported by the client.
96 static string16 GetPolicyName(ConfigurationPolicyType policy_type);
97
98 private:
99 typedef ConfigurationPolicyProvider::PolicyDefinitionList
100 PolicyDefinitionList;
101
102 // Add the policy information for |policy| to the ListValue pointed to be
103 // |list| as it is returned by the different ConfigurationPolicyReader
104 // objects. Returns true if a policy was added and false otherwise.
105 bool AddPolicyFromReaders(ConfigurationPolicyType policy,
106 ListValue* list) const;
107
108 scoped_ptr<ConfigurationPolicyReader> managed_platform_;
109 scoped_ptr<ConfigurationPolicyReader> managed_cloud_;
110 scoped_ptr<ConfigurationPolicyReader> recommended_platform_;
111 scoped_ptr<ConfigurationPolicyReader> recommended_cloud_;
112
113 DISALLOW_COPY_AND_ASSIGN(PolicyStatus);
114 };
115
116 } // namespace policy
117
118 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698