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

Side by Side Diff: chrome/browser/ui/webui/policy_ui.h

Issue 12084065: Convert chrome://policy to new WebUI style (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed tag names from CSS selectors that unambiguously match on id anyway. Created 7 years, 10 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_UI_WEBUI_POLICY_UI_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_
6 #define CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_ 6 #define CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/string16.h"
14 #include "base/values.h"
15 #include "chrome/browser/policy/policy_map.h"
16 #include "chrome/browser/policy/policy_service.h"
17 #include "content/public/browser/web_ui_controller.h" 11 #include "content/public/browser/web_ui_controller.h"
18 #include "content/public/browser/web_ui_message_handler.h"
19 #include "policy/policy_constants.h"
20 12
21 class CloudPolicyStatusProvider; 13 namespace content {
14 class WebUI;
15 }
22 16
23 // The base class handler of Javascript messages of the about:policy page. 17 // The Web UI controller for the chrome://policy page.
24 class PolicyUIHandler : public content::WebUIMessageHandler,
25 public policy::PolicyService::Observer {
26 public:
27 // Keys expected in a DictionaryValue representing the status of a policy.
28 // Public for testing.
29 static const char kLevel[];
30 static const char kName[];
31 static const char kScope[];
32 static const char kSet[];
33 static const char kStatus[];
34 static const char kValue[];
35
36 PolicyUIHandler();
37 virtual ~PolicyUIHandler();
38
39 // WebUIMessageHandler implementation.
40 virtual void RegisterMessages() OVERRIDE;
41
42 // policy::PolicyService::Observer implementation.
43 virtual void OnPolicyUpdated(policy::PolicyDomain domain,
44 const std::string& component_id,
45 const policy::PolicyMap& previous,
46 const policy::PolicyMap& current) OVERRIDE;
47
48 // Returns a ListValue pointer containing the status information of all
49 // policies defined in |policies|. |any_policies_set| is set to true if
50 // there are policies in the list that were valid, otherwise it's false.
51 static scoped_ptr<base::ListValue> GetPolicyStatusList(
52 const policy::PolicyMap& policies,
53 bool* any_policies_set);
54
55 private:
56 // Callback for the "requestData" message. The parameter |args| is unused.
57 void HandleRequestData(const base::ListValue* args);
58
59 // Callback for the "fetchPolicy" message. The parameter |args| is unused.
60 void HandleFetchPolicy(const base::ListValue* args);
61
62 // Callback for completion of a RefreshPolicies call.
63 void OnRefreshDone();
64
65 // Sends policy data to UI.
66 void SendDataToUI();
67
68 // Returns the policy service to use.
69 policy::PolicyService* GetPolicyService();
70
71 // Returns a DictionaryValue pointer containing information about the status
72 // of the policy system. The caller acquires ownership of the returned
73 // DictionaryValue pointer.
74 base::DictionaryValue* GetStatusData();
75
76 // Used to post a callback to RefreshPolicies with a WeakPtr to |this|.
77 base::WeakPtrFactory<PolicyUIHandler> weak_factory_;
78
79 // Providers that supply status dictionaries for user and device policy,
80 // respectively. These are created on initialization time as appropriate for
81 // the platform (Chrome OS / desktop) and type of policy that is in effect.
82 scoped_ptr<CloudPolicyStatusProvider> user_status_provider_;
83 scoped_ptr<CloudPolicyStatusProvider> device_status_provider_;
84
85 // The domain the device is enrolled to, if applicable.
86 string16 enterprise_domain_;
87
88 DISALLOW_COPY_AND_ASSIGN(PolicyUIHandler);
89 };
90
91 // The Web UI handler for about:policy.
92 class PolicyUI : public content::WebUIController { 18 class PolicyUI : public content::WebUIController {
93 public: 19 public:
94 explicit PolicyUI(content::WebUI* web_ui); 20 explicit PolicyUI(content::WebUI* web_ui);
95 virtual ~PolicyUI(); 21 virtual ~PolicyUI();
96 22
97 private: 23 private:
98 DISALLOW_COPY_AND_ASSIGN(PolicyUI); 24 DISALLOW_COPY_AND_ASSIGN(PolicyUI);
99 }; 25 };
100 26
101 #endif // CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_ 27 #endif // CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698