| Index: chrome/browser/resources/policy.js
|
| diff --git a/chrome/browser/resources/policy.js b/chrome/browser/resources/policy.js
|
| index f7dd60c1c14be12a08530ec8b93f08c6de41d5be..466819b9a0bdf9782db38c0ee84d36695fda9a1e 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);
|
| + 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,14 +350,9 @@ cr.define('policy', function() {
|
|
|
| if (values.hasOwnProperty('extensionPolicies')) {
|
| for (var extensionId in values.extensionPolicies) {
|
| - var tableId = 'extension-' + extensionId;
|
| - var table = page.policyTables[tableId];
|
| - if (!table) {
|
| - var tableName = values.extensionPolicies[extensionId].name;
|
| - table = page.createTable(tableId, tableName, 'ID: ' + extensionId,
|
| - false);
|
| - }
|
| - table.setPolicyValues(values.extensionPolicies[extensionId].policies);
|
| + var table = page.policyTables['extension-' + extensionId];
|
| + if (table)
|
| + table.setPolicyValues(values.extensionPolicies[extensionId]);
|
| }
|
| }
|
| };
|
| @@ -387,7 +383,8 @@ cr.define('policy', function() {
|
|
|
| this.mainSection = $('main-section');
|
| this.policyTables = {};
|
| - this.createTable('chrome', 'Chrome policies', '', true);
|
| + var chromeTable = this.createTable('chrome', 'Chrome policies', '');
|
| + this.mainSection.appendChild(chromeTable);
|
|
|
| // Place the initial focus on the filter input field.
|
| $('filter').focus();
|
| @@ -416,13 +413,32 @@ cr.define('policy', function() {
|
| },
|
|
|
| /**
|
| - * Creates a new table and adds it to the main section.
|
| + * Gets the existing policy table for the given id, or if none exists,
|
| + * creates a new table and adds it to the page.
|
| + * @param {string} id Used as key when storing new table in policyTables.
|
| + * @param {string} label_title Title for this policy table.
|
| + * @param {string} label_content Description for the policy table.
|
| + */
|
| + getOrCreateTable: function(id, label_title, label_content) {
|
| + if (this.policyTables.hasOwnProperty(id))
|
| + return this.policyTables[id];
|
| + else {
|
| + var section = this.createTable(id, label_title, label_content);
|
| + this.mainSection.appendChild(section);
|
| + return section.getElementsByTagName('table')[0];
|
| + }
|
| + },
|
| +
|
| + /**
|
| + * Creates a new table for displaying policies.
|
| * @param {string} id Used as key when storing 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.
|
| */
|
| - createTable: function(id, label_title, label_content, includeStatus) {
|
| + createTable: function(id, label_title, label_content) {
|
| + if (this.policyTables.hasOwnProperty(id)) {
|
| + return this.policyTables[id];
|
| + }
|
| var section = document.createElement('section');
|
|
|
| // Add title and description.
|
| @@ -448,20 +464,12 @@ cr.define('policy', function() {
|
| 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);
|
| @@ -469,9 +477,8 @@ cr.define('policy', function() {
|
| section.appendChild(newTable);
|
| section.setAttribute('class', 'policy-table-section');
|
|
|
| - this.mainSection.appendChild(section);
|
| this.policyTables[id] = newTable;
|
| - return newTable;
|
| + return section;
|
| },
|
|
|
| /**
|
|
|