| 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 | 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. | 14 // and true if it is being sent due to a change of policy values. |
| 15 'isPolicyUpdate': false, | 15 'isPolicyUpdate': false, |
| 16 |
| 17 // True if a policy fetch that was requested has completed. |
| 18 'isRefreshDone': false, |
| 19 |
| 16 'policies': [ | 20 'policies': [ |
| 17 { | 21 { |
| 18 'level': 'managed', | 22 'level': 'managed', |
| 19 'name': 'AllowXYZ', | 23 'name': 'AllowXYZ', |
| 20 'set': true, | 24 'set': true, |
| 21 'scope': 'Machine', | 25 'scope': 'Machine', |
| 22 'status': 'ok', | 26 'status': 'ok', |
| 23 'value': true | 27 'value': true |
| 24 } | 28 } |
| 25 ], | 29 ], |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 Policy.requestData = function() { | 213 Policy.requestData = function() { |
| 210 chrome.send('requestData'); | 214 chrome.send('requestData'); |
| 211 }; | 215 }; |
| 212 | 216 |
| 213 /** | 217 /** |
| 214 * Called by the C++ PolicyUIHandler when it has the requested data. | 218 * Called by the C++ PolicyUIHandler when it has the requested data. |
| 215 * @param {Object} policyData The policy information in the format described | 219 * @param {Object} policyData The policy information in the format described |
| 216 * by the policyDataFormat. | 220 * by the policyDataFormat. |
| 217 */ | 221 */ |
| 218 Policy.returnData = function(policyData) { | 222 Policy.returnData = function(policyData) { |
| 223 if (policyData.isRefreshDone) |
| 224 $('fetch-policies-button').disabled = false; |
| 219 if (policyData.isPolicyUpdate) { | 225 if (policyData.isPolicyUpdate) { |
| 220 Policy.getInstance().collapseExpandedCells(); | 226 Policy.getInstance().collapseExpandedCells(); |
| 221 Policy.getInstance().renderTemplate(policyData); | 227 Policy.getInstance().renderTemplate(policyData); |
| 222 Policy.getInstance().updatePolicyVisibility(); | 228 Policy.getInstance().updatePolicyVisibility(); |
| 223 | |
| 224 $('fetch-policies-button').disabled = false; | |
| 225 } else { | 229 } else { |
| 226 Policy.getInstance().renderTemplate(policyData); | 230 Policy.getInstance().renderTemplate(policyData); |
| 227 } | 231 } |
| 228 }; | 232 }; |
| 229 | 233 |
| 230 /** | 234 /** |
| 231 * Asks the C++ PolicyUIHandler to re-fetch policy information. | 235 * Asks the C++ PolicyUIHandler to re-fetch policy information. |
| 232 */ | 236 */ |
| 233 Policy.triggerPolicyFetch = function() { | 237 Policy.triggerPolicyFetch = function() { |
| 234 chrome.send('fetchPolicy'); | 238 chrome.send('fetchPolicy'); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // Export | 273 // Export |
| 270 return { | 274 return { |
| 271 Policy: Policy | 275 Policy: Policy |
| 272 }; | 276 }; |
| 273 }); | 277 }); |
| 274 | 278 |
| 275 var Policy = policies.Policy; | 279 var Policy = policies.Policy; |
| 276 | 280 |
| 277 // Get data and have it displayed upon loading. | 281 // Get data and have it displayed upon loading. |
| 278 document.addEventListener('DOMContentLoaded', policies.Policy.initialize); | 282 document.addEventListener('DOMContentLoaded', policies.Policy.initialize); |
| OLD | NEW |