| OLD | NEW |
| 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 /** | 5 /** |
| 6 * This variable structure is here to document the structure that the template | 6 * This variable structure is here to document the structure that the template |
| 7 * expects to correctly populate the page. | 7 * expects to correctly populate the page. |
| 8 */ | 8 */ |
| 9 var policyDataFormat = { | 9 var policyDataFormat = { |
| 10 // Whether any of the policies in 'policies' have a value. | 10 // Whether any of the policies in 'policies' have a value. |
| 11 'anyPoliciesSet': true, | 11 'anyPoliciesSet': true, |
| 12 | 12 |
| 13 // False if the policy information is being sent due to an initial page load | |
| 14 // and true if it is being sent due to a change of policy values. | |
| 15 'isPolicyUpdate': false, | |
| 16 'policies': [ | 13 'policies': [ |
| 17 { | 14 { |
| 18 'level': 'managed', | 15 'level': 'managed', |
| 19 'name': 'AllowXYZ', | 16 'name': 'AllowXYZ', |
| 20 'set': true, | 17 'set': true, |
| 21 'scope': 'Machine', | 18 'scope': 'Machine', |
| 22 'status': 'ok', | 19 'status': 'ok', |
| 23 'value': true | 20 'value': true |
| 24 } | 21 } |
| 25 ], | 22 ], |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 Policy.requestData = function() { | 206 Policy.requestData = function() { |
| 210 chrome.send('requestData'); | 207 chrome.send('requestData'); |
| 211 }; | 208 }; |
| 212 | 209 |
| 213 /** | 210 /** |
| 214 * Called by the C++ PolicyUIHandler when it has the requested data. | 211 * Called by the C++ PolicyUIHandler when it has the requested data. |
| 215 * @param {Object} policyData The policy information in the format described | 212 * @param {Object} policyData The policy information in the format described |
| 216 * by the policyDataFormat. | 213 * by the policyDataFormat. |
| 217 */ | 214 */ |
| 218 Policy.returnData = function(policyData) { | 215 Policy.returnData = function(policyData) { |
| 219 if (policyData.isPolicyUpdate) { | 216 var policy = Policy.getInstance(); |
| 220 Policy.getInstance().collapseExpandedCells(); | 217 policy.collapseExpandedCells(); |
| 221 Policy.getInstance().renderTemplate(policyData); | 218 policy.renderTemplate(policyData); |
| 222 Policy.getInstance().updatePolicyVisibility(); | 219 policy.updatePolicyVisibility(); |
| 223 | |
| 224 $('fetch-policies-button').disabled = false; | |
| 225 } else { | |
| 226 Policy.getInstance().renderTemplate(policyData); | |
| 227 } | |
| 228 }; | 220 }; |
| 229 | 221 |
| 230 /** | 222 /** |
| 223 * Called by the C++ PolicyUIHandler when a requested policy refresh has |
| 224 * completed. |
| 225 */ |
| 226 Policy.refreshDone = function() { |
| 227 $('fetch-policies-button').disabled = false; |
| 228 }; |
| 229 |
| 230 /** |
| 231 * Asks the C++ PolicyUIHandler to re-fetch policy information. | 231 * Asks the C++ PolicyUIHandler to re-fetch policy information. |
| 232 */ | 232 */ |
| 233 Policy.triggerPolicyFetch = function() { | 233 Policy.triggerPolicyFetch = function() { |
| 234 chrome.send('fetchPolicy'); | 234 chrome.send('fetchPolicy'); |
| 235 }; | 235 }; |
| 236 | 236 |
| 237 /** | 237 /** |
| 238 * Determines whether a policy should be visible or not. | 238 * Determines whether a policy should be visible or not. |
| 239 * @param {Object} policy An entry in the 'policies' array given by the above | 239 * @param {Object} policy An entry in the 'policies' array given by the above |
| 240 * PolicyDataFormat. | 240 * PolicyDataFormat. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 269 // Export | 269 // Export |
| 270 return { | 270 return { |
| 271 Policy: Policy | 271 Policy: Policy |
| 272 }; | 272 }; |
| 273 }); | 273 }); |
| 274 | 274 |
| 275 var Policy = policies.Policy; | 275 var Policy = policies.Policy; |
| 276 | 276 |
| 277 // Get data and have it displayed upon loading. | 277 // Get data and have it displayed upon loading. |
| 278 document.addEventListener('DOMContentLoaded', policies.Policy.initialize); | 278 document.addEventListener('DOMContentLoaded', policies.Policy.initialize); |
| OLD | NEW |