| 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 Page = cr.ui.pageManager.Page; |
| 7 var PageManager = cr.ui.pageManager.PageManager; |
| 7 var ArrayDataModel = cr.ui.ArrayDataModel; | 8 var ArrayDataModel = cr.ui.ArrayDataModel; |
| 8 | 9 |
| 9 /** | 10 /** |
| 10 * ManagedUserImportOverlay class. | 11 * ManagedUserImportOverlay class. |
| 11 * Encapsulated handling of the 'Import existing managed user' overlay page. | 12 * Encapsulated handling of the 'Import existing managed user' overlay page. |
| 12 * @constructor | 13 * @constructor |
| 13 * @class | 14 * @class |
| 14 */ | 15 */ |
| 15 function ManagedUserImportOverlay() { | 16 function ManagedUserImportOverlay() { |
| 16 var title = loadTimeData.getString('managedUserImportTitle'); | 17 var title = loadTimeData.getString('managedUserImportTitle'); |
| 17 OptionsPage.call(this, 'managedUserImport', | 18 Page.call(this, 'managedUserImport', |
| 18 title, 'managed-user-import'); | 19 title, 'managed-user-import'); |
| 19 }; | 20 }; |
| 20 | 21 |
| 21 cr.addSingletonGetter(ManagedUserImportOverlay); | 22 cr.addSingletonGetter(ManagedUserImportOverlay); |
| 22 | 23 |
| 23 ManagedUserImportOverlay.prototype = { | 24 ManagedUserImportOverlay.prototype = { |
| 24 // Inherit from OptionsPage. | 25 // Inherit from Page. |
| 25 __proto__: OptionsPage.prototype, | 26 __proto__: Page.prototype, |
| 26 | 27 |
| 27 /** @override */ | 28 /** @override */ |
| 28 canShowPage: function() { | 29 canShowPage: function() { |
| 29 return !BrowserOptions.getCurrentProfile().isManaged; | 30 return !BrowserOptions.getCurrentProfile().isManaged; |
| 30 }, | 31 }, |
| 31 | 32 |
| 32 /** | 33 /** |
| 33 * Initialize the page. | 34 * Initialize the page. |
| 34 */ | 35 */ |
| 35 initializePage: function() { | 36 initializePage: function() { |
| 36 // Call base class implementation to start preference initialization. | 37 Page.prototype.initializePage.call(this); |
| 37 OptionsPage.prototype.initializePage.call(this); | |
| 38 | 38 |
| 39 var managedUserList = $('managed-user-list'); | 39 var managedUserList = $('managed-user-list'); |
| 40 options.managedUserOptions.ManagedUserList.decorate(managedUserList); | 40 options.managedUserOptions.ManagedUserList.decorate(managedUserList); |
| 41 | 41 |
| 42 var avatarGrid = $('select-avatar-grid'); | 42 var avatarGrid = $('select-avatar-grid'); |
| 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 }); | 54 }); |
| 55 | 55 |
| 56 var self = this; | 56 var self = this; |
| 57 $('managed-user-import-cancel').onclick = function(event) { | 57 $('managed-user-import-cancel').onclick = function(event) { |
| 58 if (self.inProgress_) { | 58 if (self.inProgress_) { |
| 59 self.updateImportInProgress_(false); | 59 self.updateImportInProgress_(false); |
| 60 | 60 |
| 61 // 'cancelCreateProfile' is handled by CreateProfileHandler. | 61 // 'cancelCreateProfile' is handled by CreateProfileHandler. |
| 62 chrome.send('cancelCreateProfile'); | 62 chrome.send('cancelCreateProfile'); |
| 63 } | 63 } |
| 64 OptionsPage.closeOverlay(); | 64 PageManager.closeOverlay(); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 $('managed-user-import-ok').onclick = | 67 $('managed-user-import-ok').onclick = |
| 68 this.showAvatarGridOrSubmit_.bind(this); | 68 this.showAvatarGridOrSubmit_.bind(this); |
| 69 $('managed-user-select-avatar-ok').onclick = | 69 $('managed-user-select-avatar-ok').onclick = |
| 70 this.showAvatarGridOrSubmit_.bind(this); | 70 this.showAvatarGridOrSubmit_.bind(this); |
| 71 }, | 71 }, |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * @override | 74 * @override |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 225 |
| 226 /** | 226 /** |
| 227 * Closes the overlay if importing the managed user was successful. Also | 227 * Closes the overlay if importing the managed user was successful. Also |
| 228 * reset the cached list of managed users in order to get an updated list | 228 * reset the cached list of managed users in order to get an updated list |
| 229 * when the overlay is reopened. | 229 * when the overlay is reopened. |
| 230 * @private | 230 * @private |
| 231 */ | 231 */ |
| 232 onSuccess_: function() { | 232 onSuccess_: function() { |
| 233 this.updateImportInProgress_(false); | 233 this.updateImportInProgress_(false); |
| 234 options.ManagedUserListData.resetPromise(); | 234 options.ManagedUserListData.resetPromise(); |
| 235 OptionsPage.closeAllOverlays(); | 235 PageManager.closeAllOverlays(); |
| 236 }, | 236 }, |
| 237 }; | 237 }; |
| 238 | 238 |
| 239 // Forward public APIs to private implementations. | 239 // Forward public APIs to private implementations. |
| 240 [ | 240 [ |
| 241 'onSuccess', | 241 'onSuccess', |
| 242 ].forEach(function(name) { | 242 ].forEach(function(name) { |
| 243 ManagedUserImportOverlay[name] = function() { | 243 ManagedUserImportOverlay[name] = function() { |
| 244 var instance = ManagedUserImportOverlay.getInstance(); | 244 var instance = ManagedUserImportOverlay.getInstance(); |
| 245 return instance[name + '_'].apply(instance, arguments); | 245 return instance[name + '_'].apply(instance, arguments); |
| 246 }; | 246 }; |
| 247 }); | 247 }); |
| 248 | 248 |
| 249 // Export | 249 // Export |
| 250 return { | 250 return { |
| 251 ManagedUserImportOverlay: ManagedUserImportOverlay, | 251 ManagedUserImportOverlay: ManagedUserImportOverlay, |
| 252 }; | 252 }; |
| 253 }); | 253 }); |
| OLD | NEW |