| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 /** | 6 /** |
| 7 * SupervisedUserListData class. | 7 * SupervisedUserListData class. |
| 8 * Handles requests for retrieving a list of existing supervised users which | 8 * Handles requests for retrieving a list of existing supervised users which |
| 9 * are supervised by the current profile. For each request a promise is | 9 * are supervised by the current profile. For each request a promise is |
| 10 * returned, which is cached in order to reuse the retrieved supervised users | 10 * returned, which is cached in order to reuse the retrieved supervised users |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * Each object is of the form: | 24 * Each object is of the form: |
| 25 * supervisedUser = { | 25 * supervisedUser = { |
| 26 * id: "Supervised User ID", | 26 * id: "Supervised User ID", |
| 27 * name: "Supervised User Name", | 27 * name: "Supervised User Name", |
| 28 * iconURL: "chrome://path/to/icon/image", | 28 * iconURL: "chrome://path/to/icon/image", |
| 29 * onCurrentDevice: true or false, | 29 * onCurrentDevice: true or false, |
| 30 * needAvatar: true or false | 30 * needAvatar: true or false |
| 31 * } | 31 * } |
| 32 * @private | 32 * @private |
| 33 */ | 33 */ |
| 34 SupervisedUserListData.prototype.receiveExistingSupervisedUsers_ = function( | 34 SupervisedUserListData.prototype.receiveExistingSupervisedUsers_ = |
| 35 supervisedUsers) { | 35 function(supervisedUsers) { |
| 36 if (!this.promise_) { | 36 if (!this.promise_) { |
| 37 this.onDataChanged_(supervisedUsers); | 37 this.onDataChanged_(supervisedUsers); |
| 38 return; | 38 return; |
| 39 } | 39 } |
| 40 this.resolve_(supervisedUsers); | 40 this.resolve_(supervisedUsers); |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * Called when there is a signin error when retrieving the list of supervised | 44 * Called when there is a signin error when retrieving the list of supervised |
| 45 * users. Rejects the promise and resets the cached promise to null. | 45 * users. Rejects the promise and resets the cached promise to null. |
| 46 * @private | 46 * @private |
| 47 */ | 47 */ |
| 48 SupervisedUserListData.prototype.onSigninError_ = function() { | 48 SupervisedUserListData.prototype.onSigninError_ = function() { |
| 49 assert(this.promise_); | 49 if (!this.promise_) { |
| 50 return; |
| 51 } |
| 50 this.reject_(); | 52 this.reject_(); |
| 51 this.resetPromise_(); | 53 this.resetPromise_(); |
| 52 }; | 54 }; |
| 53 | 55 |
| 54 /** | 56 /** |
| 55 * Handles the request for the list of existing supervised users by returning | 57 * Handles the request for the list of existing supervised users by returning |
| 56 * a promise for the requested data. If there is no cached promise yet, a new | 58 * a promise for the requested data. If there is no cached promise yet, a new |
| 57 * one will be created. | 59 * one will be created. |
| 58 * @return {Promise} The promise containing the list of supervised users. | 60 * @return {Promise} The promise containing the list of supervised users. |
| 59 * @private | 61 * @private |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 var instance = SupervisedUserListData.getInstance(); | 146 var instance = SupervisedUserListData.getInstance(); |
| 145 return instance[name + '_'].apply(instance, arguments); | 147 return instance[name + '_'].apply(instance, arguments); |
| 146 }; | 148 }; |
| 147 }); | 149 }); |
| 148 | 150 |
| 149 // Export | 151 // Export |
| 150 return { | 152 return { |
| 151 SupervisedUserListData: SupervisedUserListData, | 153 SupervisedUserListData: SupervisedUserListData, |
| 152 }; | 154 }; |
| 153 }); | 155 }); |
| OLD | NEW |