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

Side by Side Diff: chrome/browser/resources/policy.js

Issue 10236003: Added RefreshPolicies to PolicyService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed ui/js messages, addressed comments Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/prefs/proxy_policy_unittest.cc ('k') | chrome/browser/ui/webui/policy_ui.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 22 matching lines...) Expand all
48 cr.addSingletonGetter(Policy); 45 cr.addSingletonGetter(Policy);
49 46
50 Policy.prototype = { 47 Policy.prototype = {
51 /** 48 /**
52 * True if none of the received policies are actually set, false otherwise. 49 * True if none of the received policies are actually set, false otherwise.
53 * @type {boolean} 50 * @type {boolean}
54 */ 51 */
55 noActivePolicies_: false, 52 noActivePolicies_: false,
56 53
57 /** 54 /**
55 * True if the UI is waiting for the initial policy data to be provided by
56 * the PolicyUIHandler.
57 * @type {boolean}
58 */
59 waitingForInitialData_: true,
60
61 /**
58 * The current search term for filtering of the policy table. 62 * The current search term for filtering of the policy table.
59 * @type {string} 63 * @type {string}
60 * @private 64 * @private
61 */ 65 */
62 searchTerm_: '', 66 searchTerm_: '',
63 67
64 /** 68 /**
65 * Takes the |policyData| argument and populates the page with this data. It 69 * Takes the |policyData| argument and populates the page with this data. It
66 * expects an object structure like the policyDataFormat above. 70 * expects an object structure like the policyDataFormat above.
67 * @param {Object} policyData Detailed info about policies. 71 * @param {Object} policyData Detailed info about policies.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
219 if (policyData.isPolicyUpdate) { 223 var policy = Policy.getInstance();
220 Policy.getInstance().collapseExpandedCells(); 224 var isFirstLoad = policy.waitingForInitialData_;
221 Policy.getInstance().renderTemplate(policyData); 225 policy.waitingForInitialData_ = false;
222 Policy.getInstance().updatePolicyVisibility();
223 226
224 $('fetch-policies-button').disabled = false; 227 if (isFirstLoad) {
228 policy.renderTemplate(policyData);
225 } else { 229 } else {
226 Policy.getInstance().renderTemplate(policyData); 230 policy.collapseExpandedCells();
231 policy.renderTemplate(policyData);
232 policy.updatePolicyVisibility();
Mattias Nissler (ping if slow) 2012/04/27 12:52:58 Any reason why we need the isFirstLoad distinction
Joao da Silva 2012/04/27 13:26:43 I didn't look at first. This was the original code
227 } 233 }
228 }; 234 };
229 235
230 /** 236 /**
237 * Called by the C++ PolicyUIHandler when a requested policy refresh has
238 * completed.
239 */
240 Policy.refreshDone = function() {
241 $('fetch-policies-button').disabled = false;
242 };
243
244 /**
231 * Asks the C++ PolicyUIHandler to re-fetch policy information. 245 * Asks the C++ PolicyUIHandler to re-fetch policy information.
232 */ 246 */
233 Policy.triggerPolicyFetch = function() { 247 Policy.triggerPolicyFetch = function() {
234 chrome.send('fetchPolicy'); 248 chrome.send('fetchPolicy');
235 }; 249 };
236 250
237 /** 251 /**
238 * Determines whether a policy should be visible or not. 252 * Determines whether a policy should be visible or not.
239 * @param {Object} policy An entry in the 'policies' array given by the above 253 * @param {Object} policy An entry in the 'policies' array given by the above
240 * PolicyDataFormat. 254 * PolicyDataFormat.
(...skipping 28 matching lines...) Expand all
269 // Export 283 // Export
270 return { 284 return {
271 Policy: Policy 285 Policy: Policy
272 }; 286 };
273 }); 287 });
274 288
275 var Policy = policies.Policy; 289 var Policy = policies.Policy;
276 290
277 // Get data and have it displayed upon loading. 291 // Get data and have it displayed upon loading.
278 document.addEventListener('DOMContentLoaded', policies.Policy.initialize); 292 document.addEventListener('DOMContentLoaded', policies.Policy.initialize);
OLDNEW
« no previous file with comments | « chrome/browser/prefs/proxy_policy_unittest.cc ('k') | chrome/browser/ui/webui/policy_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698