OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 cr.define('policy', function() { | 4 cr.define('policy', function() { |
5 | 5 |
6 /** | 6 /** |
7 * A hack to check if we are displaying the mobile version of this page by | 7 * A hack to check if we are displaying the mobile version of this page by |
8 * checking if the first column is hidden. | 8 * checking if the first column is hidden. |
9 * @return {boolean} True if this is the mobile version. | 9 * @return {boolean} True if this is the mobile version. |
10 */ | 10 */ |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 // Populate the remaining columns with policy scope, level and value if a | 128 // Populate the remaining columns with policy scope, level and value if a |
129 // value has been set. Otherwise, leave them blank. | 129 // value has been set. Otherwise, leave them blank. |
130 if (value) { | 130 if (value) { |
131 this.querySelector('.scope').textContent = | 131 this.querySelector('.scope').textContent = |
132 loadTimeData.getString(value.scope == 'user' ? | 132 loadTimeData.getString(value.scope == 'user' ? |
133 'scopeUser' : 'scopeDevice'); | 133 'scopeUser' : 'scopeDevice'); |
134 this.querySelector('.level').textContent = | 134 this.querySelector('.level').textContent = |
135 loadTimeData.getString(value.level == 'recommended' ? | 135 loadTimeData.getString(value.level == 'recommended' ? |
136 'levelRecommended' : 'levelMandatory'); | 136 'levelRecommended' : 'levelMandatory'); |
137 this.querySelector('.source').textContent = | |
138 loadTimeData.getString(value.source); | |
139 this.querySelector('.value').textContent = value.value; | 137 this.querySelector('.value').textContent = value.value; |
140 this.querySelector('.expanded-value').textContent = value.value; | 138 this.querySelector('.expanded-value').textContent = value.value; |
141 } | 139 } |
142 | 140 |
143 // Populate the status column. | 141 // Populate the status column. |
144 var status; | 142 var status; |
145 if (!value) { | 143 if (!value) { |
146 // If the policy value has not been set, show an error message. | 144 // If the policy value has not been set, show an error message. |
147 status = loadTimeData.getString('unset'); | 145 status = loadTimeData.getString('unset'); |
148 } else if (unknown) { | 146 } else if (unknown) { |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 }, | 512 }, |
515 | 513 |
516 /** | 514 /** |
517 * Creates a new table for displaying policies. | 515 * Creates a new table for displaying policies. |
518 * @return {Element} The newly created table. | 516 * @return {Element} The newly created table. |
519 */ | 517 */ |
520 createPolicyTable: function() { | 518 createPolicyTable: function() { |
521 var newTable = window.document.createElement('table'); | 519 var newTable = window.document.createElement('table'); |
522 var tableHead = window.document.createElement('thead'); | 520 var tableHead = window.document.createElement('thead'); |
523 var tableRow = window.document.createElement('tr'); | 521 var tableRow = window.document.createElement('tr'); |
524 var tableHeadings = ['Scope', 'Level', 'Source', 'Name', 'Value', | 522 var tableHeadings = ['Scope', 'Level', 'Name', 'Value', 'Status']; |
525 'Status']; | |
526 for (var i = 0; i < tableHeadings.length; i++) { | 523 for (var i = 0; i < tableHeadings.length; i++) { |
527 var tableHeader = window.document.createElement('th'); | 524 var tableHeader = window.document.createElement('th'); |
528 tableHeader.classList.add(tableHeadings[i].toLowerCase() + '-column'); | 525 tableHeader.classList.add(tableHeadings[i].toLowerCase() + '-column'); |
529 tableHeader.textContent = loadTimeData.getString('header' + | 526 tableHeader.textContent = loadTimeData.getString('header' + |
530 tableHeadings[i]); | 527 tableHeadings[i]); |
531 tableRow.appendChild(tableHeader); | 528 tableRow.appendChild(tableHeader); |
532 } | 529 } |
533 tableHead.appendChild(tableRow); | 530 tableHead.appendChild(tableRow); |
534 newTable.appendChild(tableHead); | 531 newTable.appendChild(tableHead); |
535 cr.ui.decorate(newTable, PolicyTable); | 532 cr.ui.decorate(newTable, PolicyTable); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 return { | 569 return { |
573 Page: Page | 570 Page: Page |
574 }; | 571 }; |
575 }); | 572 }); |
576 | 573 |
577 // Have the main initialization function be called when the page finishes | 574 // Have the main initialization function be called when the page finishes |
578 // loading. | 575 // loading. |
579 document.addEventListener( | 576 document.addEventListener( |
580 'DOMContentLoaded', | 577 'DOMContentLoaded', |
581 policy.Page.getInstance().initialize.bind(policy.Page.getInstance())); | 578 policy.Page.getInstance().initialize.bind(policy.Page.getInstance())); |
OLD | NEW |