| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 | 4 |
| 5 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 var OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
| 7 var ArrayDataModel = cr.ui.ArrayDataModel; | 7 var ArrayDataModel = cr.ui.ArrayDataModel; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * ManagedUserImportOverlay class. | 10 * ManagedUserImportOverlay class. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 options.ProfilesIconGrid.decorate(avatarGrid); | 43 options.ProfilesIconGrid.decorate(avatarGrid); |
| 44 var avatarIcons = loadTimeData.getValue('avatarIcons'); | 44 var avatarIcons = loadTimeData.getValue('avatarIcons'); |
| 45 avatarGrid.dataModel = new ArrayDataModel(avatarIcons); | 45 avatarGrid.dataModel = new ArrayDataModel(avatarIcons); |
| 46 | 46 |
| 47 managedUserList.addEventListener('change', function(event) { | 47 managedUserList.addEventListener('change', function(event) { |
| 48 var managedUser = managedUserList.selectedItem; | 48 var managedUser = managedUserList.selectedItem; |
| 49 if (!managedUser) | 49 if (!managedUser) |
| 50 return; | 50 return; |
| 51 | 51 |
| 52 $('managed-user-import-ok').disabled = | 52 $('managed-user-import-ok').disabled = |
| 53 managedUserList.selectedItem.onCurrentDevice; | 53 managedUserList.selectedItem.onCurrentDevice || |
| 54 managedUserList.selectedItem.nameConflict; |
| 54 }); | 55 }); |
| 55 | 56 |
| 56 var self = this; | 57 var self = this; |
| 57 $('managed-user-import-cancel').onclick = function(event) { | 58 $('managed-user-import-cancel').onclick = function(event) { |
| 58 OptionsPage.closeOverlay(); | 59 OptionsPage.closeOverlay(); |
| 59 self.updateImportInProgress_(false); | 60 self.updateImportInProgress_(false); |
| 60 | 61 |
| 61 // 'cancelCreateProfile' is handled by CreateProfileHandler. | 62 // 'cancelCreateProfile' is handled by CreateProfileHandler. |
| 62 chrome.send('cancelCreateProfile'); | 63 chrome.send('cancelCreateProfile'); |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 $('managed-user-import-ok').onclick = | 66 $('managed-user-import-ok').onclick = |
| 66 this.showAvatarGridOrSubmit_.bind(this); | 67 this.showAvatarGridOrSubmit_.bind(this); |
| 67 | 68 |
| 68 $('create-new-user-link').onclick = function(event) { | 69 $('create-new-user-link').onclick = function(event) { |
| 69 OptionsPage.closeOverlay(); | 70 OptionsPage.closeOverlay(); |
| 70 OptionsPage.navigateToPage('createProfile'); | 71 OptionsPage.navigateToPage('createProfile'); |
| 71 }; | 72 }; |
| 72 }, | 73 }, |
| 73 | 74 |
| 74 /** | 75 /** |
| 75 * @override | 76 * @override |
| 76 */ | 77 */ |
| 77 didShowPage: function() { | 78 didShowPage: function() { |
| 78 options.ManagedUserListData.requestExistingManagedUsers( | 79 options.ManagedUserListData.requestExistingManagedUsers().then( |
| 79 this.receiveExistingManagedUsers_, this.onSigninError_.bind(this)); | 80 this.receiveExistingManagedUsers_, this.onSigninError_.bind(this)); |
| 80 | 81 |
| 81 this.updateImportInProgress_(false); | 82 this.updateImportInProgress_(false); |
| 82 $('managed-user-import-error-bubble').hidden = true; | 83 $('managed-user-import-error-bubble').hidden = true; |
| 83 $('managed-user-import-ok').disabled = true; | 84 $('managed-user-import-ok').disabled = true; |
| 84 $('select-avatar-grid').hidden = true; | 85 $('select-avatar-grid').hidden = true; |
| 85 $('managed-user-list').hidden = false; | 86 $('managed-user-list').hidden = false; |
| 86 | 87 |
| 87 $('managed-user-import-ok').textContent = | 88 $('managed-user-import-ok').textContent = |
| 88 loadTimeData.getString('managedUserImportOk'); | 89 loadTimeData.getString('managedUserImportOk'); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 161 |
| 161 /** | 162 /** |
| 162 * Sets the data model of the managed user list to |managedUsers|. | 163 * Sets the data model of the managed user list to |managedUsers|. |
| 163 * @param {Array.<Object>} managedUsers An array of managed user objects. | 164 * @param {Array.<Object>} managedUsers An array of managed user objects. |
| 164 * Each object is of the form: | 165 * Each object is of the form: |
| 165 * managedUser = { | 166 * managedUser = { |
| 166 * id: "Managed User ID", | 167 * id: "Managed User ID", |
| 167 * name: "Managed User Name", | 168 * name: "Managed User Name", |
| 168 * iconURL: "chrome://path/to/icon/image", | 169 * iconURL: "chrome://path/to/icon/image", |
| 169 * onCurrentDevice: true or false, | 170 * onCurrentDevice: true or false, |
| 171 * nameConflict: true or false, |
| 170 * needAvatar: true or false | 172 * needAvatar: true or false |
| 171 * } | 173 * } |
| 172 * @private | 174 * @private |
| 173 */ | 175 */ |
| 174 receiveExistingManagedUsers_: function(managedUsers) { | 176 receiveExistingManagedUsers_: function(managedUsers) { |
| 175 managedUsers.sort(function(a, b) { | 177 managedUsers.sort(function(a, b) { |
| 178 if (a.onCurrentDevice != b.onCurrentDevice) |
| 179 return a.onCurrentDevice ? 1 : -1; |
| 180 if (a.nameConflict != b.nameConflict) |
| 181 return a.nameConflict ? 1 : -1; |
| 176 return a.name.localeCompare(b.name); | 182 return a.name.localeCompare(b.name); |
| 177 }); | 183 }); |
| 178 | 184 |
| 179 $('managed-user-list').dataModel = new ArrayDataModel(managedUsers); | 185 $('managed-user-list').dataModel = new ArrayDataModel(managedUsers); |
| 180 if (managedUsers.length == 0) { | 186 if (managedUsers.length == 0) { |
| 181 this.onError_(loadTimeData.getString('noExistingManagedUsers')); | 187 this.onError_(loadTimeData.getString('noExistingManagedUsers')); |
| 182 $('managed-user-import-ok').disabled = true; | 188 $('managed-user-import-ok').disabled = true; |
| 183 } else { | 189 } else { |
| 184 // Hide the error bubble. | 190 // Hide the error bubble. |
| 185 $('managed-user-import-error-bubble').hidden = true; | 191 $('managed-user-import-error-bubble').hidden = true; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 var instance = ManagedUserImportOverlay.getInstance(); | 229 var instance = ManagedUserImportOverlay.getInstance(); |
| 224 return instance[name + '_'].apply(instance, arguments); | 230 return instance[name + '_'].apply(instance, arguments); |
| 225 }; | 231 }; |
| 226 }); | 232 }); |
| 227 | 233 |
| 228 // Export | 234 // Export |
| 229 return { | 235 return { |
| 230 ManagedUserImportOverlay: ManagedUserImportOverlay, | 236 ManagedUserImportOverlay: ManagedUserImportOverlay, |
| 231 }; | 237 }; |
| 232 }); | 238 }); |
| OLD | NEW |