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

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

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: Removed the map wrapper and wrapped the javascript functions into an object. 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 #include "chrome/browser/policy/configuration_policy_reader.h"
6
7 #include <string>
8
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/webui/policy_ui.h"
11 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
12 #include "chrome/common/url_constants.h"
13 #include "content/browser/tab_contents/tab_contents.h"
14 #include "grit/browser_resources.h"
15 #include "grit/generated_resources.h"
16
17 ChromeWebUIDataSource* CreatePolicyUIHTMLSource() {
18 ChromeWebUIDataSource* source =
19 new ChromeWebUIDataSource(chrome::kChromeUIPolicyHost);
20
21 // Localized strings.
22 source->AddLocalizedString("policyTitle", IDS_POLICY_TITLE);
23 source->AddLocalizedString("aboutPolicyDescription", IDS_POLICY_DESCRIPTION);
24 source->AddLocalizedString("statusPaneTitle", IDS_POLICY_STATUS_TITLE);
25 source->AddLocalizedString("fetchPoliciesText", IDS_POLICY_FETCH);
26 source->AddLocalizedString("devicePoliciesBoxTitle",
27 IDS_POLICY_DEVICE_POLICIES);
28 source->AddLocalizedString("userPoliciesBoxTitle",
29 IDS_POLICY_USER_POLICIES);
30 source->AddLocalizedString("enrollmentDomainText",
31 IDS_POLICY_ENROLLMENT_DOMAIN);
32 source->AddLocalizedString("lastFetchedText", IDS_POLICY_LAST_FETCHED);
33 source->AddLocalizedString("fetchIntervalText", IDS_POLICY_FETCH_INTERVAL);
34 source->AddLocalizedString("serverStatusText", IDS_POLICY_SERVER_STATUS);
35 source->AddLocalizedString("showUnsentPoliciesText",
36 IDS_POLICY_SHOW_UNSENT);
37 source->AddLocalizedString("filterPoliciesText", IDS_POLICY_FILTER);
38 source->AddLocalizedString("appliesToTableHeader", IDS_POLICY_APPLIES_TO);
39 source->AddLocalizedString("policyLevelTableHeader", IDS_POLICY_LEVEL);
40 source->AddLocalizedString("policyNameTableHeader", IDS_POLICY_ENTRY_NAME);
41 source->AddLocalizedString("policyValueTableHeader", IDS_POLICY_ENTRY_VALUE);
42 source->AddLocalizedString("policyStatusTableHeader",
43 IDS_POLICY_ENTRY_STATUS);
44 source->set_json_path("strings.js");
45
46 // Add required resources.
47 source->add_resource_path("policy.css", IDR_POLICY_CSS);
48 source->add_resource_path("policy.js", IDR_POLICY_JS);
49 source->set_default_resource(IDR_POLICY_HTML);
50
51 return source;
52 }
53
54 ////////////////////////////////////////////////////////////////////////////////
55 //
56 // PolicyUIHandler
57 //
58 ////////////////////////////////////////////////////////////////////////////////
59
60 PolicyUIHandler::PolicyUIHandler() {
61 policy_status_.reset(new policy::PolicyStatus());
62 }
63
64 PolicyUIHandler::~PolicyUIHandler() {
65 }
66
67 WebUIMessageHandler* PolicyUIHandler::Attach(WebUI* web_ui) {
68 return WebUIMessageHandler::Attach(web_ui);
69 }
70
71 void PolicyUIHandler::RegisterMessages() {
72 web_ui_->RegisterMessageCallback("requestPolicyData",
73 NewCallback(this, &PolicyUIHandler::HandleRequestPolicyData));
74 }
75
76 void PolicyUIHandler::HandleRequestPolicyData(const ListValue* args) {
77 ListValue* list = policy_status_->GetPolicyStatusList();
78 DictionaryValue results;
79 results.Set("policies", list);
80 web_ui_->CallJavascriptFunction("returnPolicyData", results);
81 }
82
83 ////////////////////////////////////////////////////////////////////////////////
84 //
85 // PolicyUI
86 //
87 ////////////////////////////////////////////////////////////////////////////////
88
89 PolicyUI::PolicyUI(TabContents* contents) : ChromeWebUI(contents) {
90 AddMessageHandler((new PolicyUIHandler)->Attach(this));
91
92 // Set up the chrome://policy/ source.
93 Profile* profile = Profile::FromBrowserContext(contents->browser_context());
94 profile->GetChromeURLDataManager()->AddDataSource(CreatePolicyUIHTMLSource());
95 }
96
97 PolicyUI::~PolicyUI() {
98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698