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

Unified Diff: chrome/browser/resources/policy.js

Issue 17387002: Sending known policy names for extensions to chrome://policy page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@anita-policies
Patch Set: After rebasing against patch set 9 of issue 16689004 Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/webui/policy_ui.cc » ('j') | chrome/browser/ui/webui/policy_ui.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/policy.js
diff --git a/chrome/browser/resources/policy.js b/chrome/browser/resources/policy.js
index 942a103a90485ea8b5d7e6623a44ee37b29b35bc..65812c3e5b7c2bf985726711c06b06b739e66336 100644
--- a/chrome/browser/resources/policy.js
+++ b/chrome/browser/resources/policy.js
@@ -88,9 +88,8 @@ cr.define('policy', function() {
* @param {string} name The policy name.
* @param {Object} value Dictionary with information about the policy value.
* @param {boolean} unknown Whether the policy name is not recognized.
- * @param {boolean} includeStatus Whether the table has a status column.
*/
- initialize: function(name, value, unknown, includeStatus) {
+ initialize: function(name, value, unknown) {
this.name = name;
this.unset = !value;
@@ -110,29 +109,23 @@ cr.define('policy', function() {
this.querySelector('.expanded-value').textContent = value.value;
}
- if (includeStatus) {
- // Populate the status column.
- var status;
- if (!value) {
- // If the policy value has not been set, show an error message.
- status = loadTimeData.getString('unset');
- } else if (unknown) {
- // If the policy name is not recognized, show an error message.
- status = loadTimeData.getString('unknown');
- } else if (value.error) {
- // If an error occurred while parsing the policy value, show the error
- // message.
- status = value.error;
- } else {
- // Otherwise, indicate that the policy value was parsed correctly.
- status = loadTimeData.getString('ok');
- }
- this.querySelector('.status').textContent = status;
+ // Populate the status column.
+ var status;
+ if (!value) {
+ // If the policy value has not been set, show an error message.
+ status = loadTimeData.getString('unset');
+ } else if (unknown) {
+ // If the policy name is not recognized, show an error message.
+ status = loadTimeData.getString('unknown');
+ } else if (value.error) {
+ // If an error occurred while parsing the policy value, show the error
+ // message.
+ status = value.error;
} else {
- // Remove status column.
- this.querySelector('.status-container').remove();
- this.querySelector('.expanded-value').setAttribute('colspan', 4);
+ // Otherwise, indicate that the policy value was parsed correctly.
+ status = loadTimeData.getString('ok');
}
+ this.querySelector('.status').textContent = status;
},
/**
@@ -307,8 +300,7 @@ cr.define('policy', function() {
*/
setPolicyValue_: function(name, value, unknown) {
var policy = new Policy;
- var includeStatus = this.querySelector('.status-column') != null;
- policy.initialize(name, value, unknown, includeStatus);
+ policy.initialize(name, value, unknown);
this.appendChild(policy);
},
};
@@ -329,8 +321,18 @@ cr.define('policy', function() {
* @param {Object} names Dictionary containing all known policy names.
*/
Page.setPolicyNames = function(names) {
- var table = this.getInstance().policyTables['chrome'];
- table.setPolicyNames(names);
+ var page = this.getInstance();
+ if (names.hasOwnProperty('chromePolicyNames')) {
+ var table = page.policyTables['chrome'];
+ table.setPolicyNames(names.chromePolicyNames);
+ }
+ if (names.hasOwnProperty('extensionPolicyNames')) {
+ for (var ext in names.extensionPolicyNames) {
+ var table = page.getOrCreateTable('extension-' + ext,
+ names.extensionPolicyNames[ext].name, 'ID: ' + ext);
Joao da Silva 2013/06/18 13:26:04 nit: indent
anitawoodruff 2013/06/18 13:50:41 Done.
+ table.setPolicyNames(names.extensionPolicyNames[ext].policyNames);
+ }
+ }
};
/**
@@ -341,7 +343,6 @@ cr.define('policy', function() {
*/
Page.setPolicyValues = function(values) {
var page = this.getInstance();
-
if (values.hasOwnProperty('chromePolicies')) {
var table = page.policyTables['chrome'];
table.setPolicyValues(values.chromePolicies);
@@ -349,10 +350,9 @@ cr.define('policy', function() {
if (values.hasOwnProperty('extensionPolicies')) {
for (var extensionId in values.extensionPolicies) {
- var tableName = values.extensionPolicies[extensionId].name;
- var table = page.getOrCreateTable('extension-' + extensionId, tableName,
- 'ID: ' + extensionId, false);
- table.setPolicyValues(values.extensionPolicies[extensionId].policies);
+ var table = page.policyTables['extension-' + extensionId];
+ if (table)
+ table.setPolicyValues(values.extensionPolicies[extensionId]);
}
}
};
@@ -383,9 +383,7 @@ cr.define('policy', function() {
this.mainSection = $('main-section');
this.policyTables = {};
-
- var chromeTable = this.getOrCreateTable('chrome', 'Chrome policies', '',
- true);
+ var chromeTable = this.getOrCreateTable('chrome', 'Chrome policies', '');
// Place the initial focus on the filter input field.
$('filter').focus();
@@ -422,12 +420,12 @@ cr.define('policy', function() {
* @param {string} label_content Description for the policy table.
* @return {Element} Policy table associated with the given id.
*/
- getOrCreateTable: function(id, label_title, label_content, includeStatus) {
+ getOrCreateTable: function(id, label_title, label_content) {
if (this.policyTables.hasOwnProperty(id))
return this.policyTables[id];
else {
var newSection = this.createPolicyTableSection(label_title,
- label_content, includeStatus);
+ label_content);
Joao da Silva 2013/06/18 13:26:04 nit: indent
anitawoodruff 2013/06/18 13:50:41 Done.
this.mainSection.appendChild(newSection);
var newTable = newSection.getElementsByTagName('table')[0];
this.policyTables[id] = newTable;
@@ -441,11 +439,9 @@ cr.define('policy', function() {
* @param {string} id Used as key when storing new table in policyTables.
anitawoodruff 2013/06/18 13:50:41 oops, this parameter description should have been
* @param {string} label_title Title for this policy table.
* @param {string} label_content Description for the policy table.
- * @param {boolean} includeStatus Whether to display a status column.
* @return {Element} The newly created section.
*/
- createPolicyTableSection: function(label_title, label_content,
- includeStatus) {
+ createPolicyTableSection: function(label_title, label_content) {
var section = document.createElement('section');
section.setAttribute('class', 'policy-table-section');
@@ -468,7 +464,7 @@ cr.define('policy', function() {
section.appendChild(noPolicies);
// Add table of policies.
- var newTable = this.createPolicyTable(includeStatus);
+ var newTable = this.createPolicyTable();
section.appendChild(newTable);
return section;
@@ -479,26 +475,17 @@ cr.define('policy', function() {
* @param {boolean} includeStatus Whether to include a status column.
anitawoodruff 2013/06/18 13:50:41 this one too.
* @return {Element} The newly created table.
*/
- createPolicyTable: function(includeStatus) {
+ createPolicyTable: function() {
var newTable = window.document.createElement('table');
var tableHead = window.document.createElement('thead');
var tableRow = window.document.createElement('tr');
var tableHeadings = ['headerScope', 'headerLevel',
- 'headerName', 'headerValue'];
-
+ 'headerName', 'headerValue', 'headerStatus'];
for (var i = 0; i < tableHeadings.length; i++) {
var tableHeader = window.document.createElement('th');
tableHeader.textContent = loadTimeData.getString(tableHeadings[i]);
tableRow.appendChild(tableHeader);
}
-
- if (includeStatus) {
- var statusHeader = window.document.createElement('th');
- statusHeader.classList.add('status-column');
- statusHeader.textContent = loadTimeData.getString('headerStatus');
- tableRow.appendChild(statusHeader);
- }
-
tableHead.appendChild(tableRow);
newTable.appendChild(tableHead);
cr.ui.decorate(newTable, PolicyTable);
« no previous file with comments | « no previous file | chrome/browser/ui/webui/policy_ui.cc » ('j') | chrome/browser/ui/webui/policy_ui.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698