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

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

Issue 1321713004: Flag for Material Design policy construction page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved policy page to independent page. Created 5 years, 2 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
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 #include "chrome/browser/ui/webui/policy_ui.h" 5 #include "chrome/browser/ui/webui/policy_ui.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/policy/profile_policy_connector.h" 21 #include "chrome/browser/policy/profile_policy_connector.h"
22 #include "chrome/browser/policy/profile_policy_connector_factory.h" 22 #include "chrome/browser/policy/profile_policy_connector_factory.h"
23 #include "chrome/browser/policy/schema_registry_service.h" 23 #include "chrome/browser/policy/schema_registry_service.h"
24 #include "chrome/browser/policy/schema_registry_service_factory.h" 24 #include "chrome/browser/policy/schema_registry_service_factory.h"
25 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
27 #include "components/policy/core/browser/browser_policy_connector.h" 28 #include "components/policy/core/browser/browser_policy_connector.h"
28 #include "components/policy/core/browser/cloud/message_util.h" 29 #include "components/policy/core/browser/cloud/message_util.h"
29 #include "components/policy/core/browser/configuration_policy_handler_list.h" 30 #include "components/policy/core/browser/configuration_policy_handler_list.h"
30 #include "components/policy/core/browser/policy_error_map.h" 31 #include "components/policy/core/browser/policy_error_map.h"
31 #include "components/policy/core/common/cloud/cloud_policy_client.h" 32 #include "components/policy/core/common/cloud/cloud_policy_client.h"
32 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 33 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
33 #include "components/policy/core/common/cloud/cloud_policy_core.h" 34 #include "components/policy/core/common/cloud/cloud_policy_core.h"
34 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" 35 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h"
35 #include "components/policy/core/common/cloud/cloud_policy_store.h" 36 #include "components/policy/core/common/cloud/cloud_policy_store.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 95
95 void AddLocalizedPoilcySourceStrings(content::WebUIDataSource* source) { 96 void AddLocalizedPoilcySourceStrings(content::WebUIDataSource* source) {
96 DCHECK_EQ(static_cast<size_t>(policy::POLICY_SOURCE_COUNT), 97 DCHECK_EQ(static_cast<size_t>(policy::POLICY_SOURCE_COUNT),
97 arraysize(kPolicySources)); 98 arraysize(kPolicySources));
98 for (size_t i = 0; i < arraysize(kPolicySources); ++i) { 99 for (size_t i = 0; i < arraysize(kPolicySources); ++i) {
99 source->AddLocalizedString(kPolicySources[i].key, 100 source->AddLocalizedString(kPolicySources[i].key,
100 kPolicySources[i].string_id); 101 kPolicySources[i].string_id);
101 } 102 }
102 } 103 }
103 104
104 content::WebUIDataSource* CreatePolicyUIHTMLSource() { 105 void AddCommonLocalizedStringsToSource(content::WebUIDataSource* source) {
105 content::WebUIDataSource* source =
106 content::WebUIDataSource::Create(chrome::kChromeUIPolicyHost);
107
108 // Localized strings.
109 source->AddLocalizedString("title", IDS_POLICY_TITLE); 106 source->AddLocalizedString("title", IDS_POLICY_TITLE);
110 source->AddLocalizedString("filterPlaceholder", 107 source->AddLocalizedString("filterPlaceholder",
111 IDS_POLICY_FILTER_PLACEHOLDER); 108 IDS_POLICY_FILTER_PLACEHOLDER);
112 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES); 109 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES);
113 source->AddLocalizedString("status", IDS_POLICY_STATUS); 110 source->AddLocalizedString("status", IDS_POLICY_STATUS);
114 source->AddLocalizedString("statusDevice", IDS_POLICY_STATUS_DEVICE); 111 source->AddLocalizedString("statusDevice", IDS_POLICY_STATUS_DEVICE);
115 source->AddLocalizedString("statusUser", IDS_POLICY_STATUS_USER); 112 source->AddLocalizedString("statusUser", IDS_POLICY_STATUS_USER);
116 source->AddLocalizedString("labelDomain", IDS_POLICY_LABEL_DOMAIN); 113 source->AddLocalizedString("labelDomain", IDS_POLICY_LABEL_DOMAIN);
117 source->AddLocalizedString("labelUsername", IDS_POLICY_LABEL_USERNAME); 114 source->AddLocalizedString("labelUsername", IDS_POLICY_LABEL_USERNAME);
118 source->AddLocalizedString("labelClientId", IDS_POLICY_LABEL_CLIENT_ID); 115 source->AddLocalizedString("labelClientId", IDS_POLICY_LABEL_CLIENT_ID);
(...skipping 22 matching lines...) Expand all
141 source->AddLocalizedString("scopeDevice", IDS_POLICY_SCOPE_DEVICE); 138 source->AddLocalizedString("scopeDevice", IDS_POLICY_SCOPE_DEVICE);
142 source->AddLocalizedString("levelRecommended", IDS_POLICY_LEVEL_RECOMMENDED); 139 source->AddLocalizedString("levelRecommended", IDS_POLICY_LEVEL_RECOMMENDED);
143 source->AddLocalizedString("levelMandatory", IDS_POLICY_LEVEL_MANDATORY); 140 source->AddLocalizedString("levelMandatory", IDS_POLICY_LEVEL_MANDATORY);
144 source->AddLocalizedString("ok", IDS_POLICY_OK); 141 source->AddLocalizedString("ok", IDS_POLICY_OK);
145 source->AddLocalizedString("unset", IDS_POLICY_UNSET); 142 source->AddLocalizedString("unset", IDS_POLICY_UNSET);
146 source->AddLocalizedString("unknown", IDS_POLICY_UNKNOWN); 143 source->AddLocalizedString("unknown", IDS_POLICY_UNKNOWN);
147 source->AddLocalizedString("notSpecified", IDS_POLICY_NOT_SPECIFIED); 144 source->AddLocalizedString("notSpecified", IDS_POLICY_NOT_SPECIFIED);
148 AddLocalizedPoilcySourceStrings(source); 145 AddLocalizedPoilcySourceStrings(source);
149 146
150 source->SetJsonPath("strings.js"); 147 source->SetJsonPath("strings.js");
148 }
151 149
150 content::WebUIDataSource* CreatePolicyMaterialDesignUIHTMLSource() {
151 content::WebUIDataSource* source =
152 content::WebUIDataSource::Create(chrome::kChromeUIMdPolicyHost);
153 AddCommonLocalizedStringsToSource(source);
154 source->SetDefaultResource(IDR_MD_POLICY_HTML);
155 return source;
156 }
157
158
159 content::WebUIDataSource* CreatePolicyUIHTMLSource() {
160 content::WebUIDataSource* source =
161 content::WebUIDataSource::Create(chrome::kChromeUIPolicyHost);
162 AddCommonLocalizedStringsToSource(source);
152 // Add required resources. 163 // Add required resources.
153 source->AddResourcePath("policy.css", IDR_POLICY_CSS); 164 source->AddResourcePath("policy.css", IDR_POLICY_CSS);
154 source->AddResourcePath("policy.js", IDR_POLICY_JS); 165 source->AddResourcePath("policy.js", IDR_POLICY_JS);
155 source->AddResourcePath("uber_utils.js", IDR_UBER_UTILS_JS); 166 source->AddResourcePath("uber_utils.js", IDR_UBER_UTILS_JS);
156 source->SetDefaultResource(IDR_POLICY_HTML); 167 source->SetDefaultResource(IDR_POLICY_HTML);
157
158 return source; 168 return source;
159 } 169 }
160 170
161 // Formats the association state indicated by |data|. If |data| is NULL, the 171 // Formats the association state indicated by |data|. If |data| is NULL, the
162 // state is considered to be UNMANAGED. 172 // state is considered to be UNMANAGED.
163 base::string16 FormatAssociationState(const em::PolicyData* data) { 173 base::string16 FormatAssociationState(const em::PolicyData* data) {
164 if (data) { 174 if (data) {
165 switch (data->state()) { 175 switch (data->state()) {
166 case em::PolicyData::ACTIVE: 176 case em::PolicyData::ACTIVE:
167 return l10n_util::GetStringUTF16(IDS_POLICY_ASSOCIATION_STATE_ACTIVE); 177 return l10n_util::GetStringUTF16(IDS_POLICY_ASSOCIATION_STATE_ACTIVE);
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 } 874 }
865 875
866 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { 876 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) {
867 web_ui->AddMessageHandler(new PolicyUIHandler); 877 web_ui->AddMessageHandler(new PolicyUIHandler);
868 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), 878 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui),
869 CreatePolicyUIHTMLSource()); 879 CreatePolicyUIHTMLSource());
870 } 880 }
871 881
872 PolicyUI::~PolicyUI() { 882 PolicyUI::~PolicyUI() {
873 } 883 }
884
885 PolicyMaterialDesignUI::PolicyMaterialDesignUI(content::WebUI* web_ui) :
886 WebUIController(web_ui) {
887 web_ui->AddMessageHandler(new PolicyUIHandler);
888 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui),
889 CreatePolicyMaterialDesignUIHTMLSource());
890 }
891
892 PolicyMaterialDesignUI::~PolicyMaterialDesignUI() {
Thiemo Nagel 2015/09/25 15:49:30 What's the purpose of this?
fhorschig 2015/09/28 09:38:58 In case you are pointing to the new WebUIControlle
Thiemo Nagel 2015/09/28 12:02:20 My bad. "Empty" destructors are used to prevent de
893 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698