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

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: Fixing accidentally-removed line in prev patch 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') | no next file with comments »
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 6aa4eee02b77e63d455a54c29ccb84638e1f5893..0e1f87d2d41bf59a699bd86bdd087830fe17001e 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;
},
/**
@@ -308,8 +301,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);
},
};
@@ -330,8 +322,25 @@ 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();
+
+ // Clear all policy tables.
+ page.mainSection.innerHTML = '';
+ page.policyTables = {};
+
+ // Create tables and set known policy names for Chrome and extensions.
+ if (names.hasOwnProperty('chromePolicyNames')) {
+ var table = page.appendNewTable('chrome', 'Chrome policies', '');
+ table.setPolicyNames(names.chromePolicyNames);
+ }
+
+ if (names.hasOwnProperty('extensionPolicyNames')) {
+ for (var ext in names.extensionPolicyNames) {
+ var table = page.appendNewTable('extension-' + ext,
+ names.extensionPolicyNames[ext].name, 'ID: ' + ext);
+ table.setPolicyNames(names.extensionPolicyNames[ext].policyNames);
+ }
+ }
};
/**
@@ -342,7 +351,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);
@@ -350,10 +358,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]);
}
}
};
@@ -385,9 +392,6 @@ cr.define('policy', function() {
this.mainSection = $('main-section');
this.policyTables = {};
- var chromeTable = this.getOrCreateTable('chrome', 'Chrome policies', '',
- true);
-
// Place the initial focus on the filter input field.
$('filter').focus();
@@ -414,35 +418,30 @@ cr.define('policy', function() {
chrome.send('initialized');
},
- /**
- * Gets the existing policy table for the given id, or if none exists,
- * creates a new policy table section, adds the section to the page,
+ /**
+ * Creates a new policy table section, adds the section to the page,
* and returns the new table from that section.
- * @param {string} id The key for the table in policyTables.
+ * @param {string} id The key for storing the new table in policyTables.
* @param {string} label_title Title for this policy table.
* @param {string} label_content Description for the policy table.
- * @return {Element} Policy table associated with the given id.
+ * @return {Element} The newly created table.
*/
- getOrCreateTable: function(id, label_title, label_content, includeStatus) {
- if (!this.policyTables.hasOwnProperty(id)) {
- var newSection = this.createPolicyTableSection(id, label_title,
- label_content, includeStatus);
- this.mainSection.appendChild(newSection);
- }
+ appendNewTable: function(id, label_title, label_content) {
+ var newSection = this.createPolicyTableSection(id, label_title,
+ label_content);
+ this.mainSection.appendChild(newSection);
return this.policyTables[id];
},
/**
* Creates a new section containing a title, description and table of
* policies.
- * @param {string} id Used as key when storing new table in policyTables.
+ * @param {id} id The key for storing the new table in policyTables.
* @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(id, label_title, label_content,
- includeStatus) {
+ createPolicyTableSection: function(id, label_title, label_content) {
var section = document.createElement('section');
section.setAttribute('class', 'policy-table-section');
@@ -465,7 +464,7 @@ cr.define('policy', function() {
section.appendChild(noPolicies);
// Add table of policies.
- var newTable = this.createPolicyTable(includeStatus);
+ var newTable = this.createPolicyTable();
this.policyTables[id] = newTable;
section.appendChild(newTable);
@@ -474,29 +473,19 @@ cr.define('policy', function() {
/**
* Creates a new table for displaying policies.
- * @param {boolean} includeStatus Whether to include a status column.
* @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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698