Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 /** | 5 /** |
| 6 * @fileoverview Locally managed user creation flow screen. | 6 * @fileoverview Supervised user creation flow screen. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 login.createScreen('LocallyManagedUserCreationScreen', | 9 login.createScreen('SupervisedUserCreationScreen', |
| 10 'managed-user-creation', function() { | 10 'supervised-user-creation', function() { |
| 11 var MAX_NAME_LENGTH = 50; | 11 var MAX_NAME_LENGTH = 50; |
| 12 var UserImagesGrid = options.UserImagesGrid; | 12 var UserImagesGrid = options.UserImagesGrid; |
| 13 var ButtonImages = UserImagesGrid.ButtonImages; | 13 var ButtonImages = UserImagesGrid.ButtonImages; |
| 14 | 14 |
| 15 var ManagerPod = cr.ui.define(function() { | 15 var ManagerPod = cr.ui.define(function() { |
| 16 var node = $('managed-user-creation-manager-template').cloneNode(true); | 16 var node = $('supervised-user-creation-manager-template').cloneNode(true); |
| 17 node.removeAttribute('id'); | 17 node.removeAttribute('id'); |
| 18 node.removeAttribute('hidden'); | 18 node.removeAttribute('hidden'); |
| 19 return node; | 19 return node; |
| 20 }); | 20 }); |
| 21 | 21 |
| 22 ManagerPod.userImageSalt_ = {}; | 22 ManagerPod.userImageSalt_ = {}; |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * UI element for displaying single account in list of possible managers for | 25 * UI element for displaying single account in list of possible managers for |
| 26 * new locally managed user. | 26 * new supervised user. |
| 27 * @type {Object} | 27 * @type {Object} |
| 28 */ | 28 */ |
| 29 ManagerPod.prototype = { | 29 ManagerPod.prototype = { |
| 30 __proto__: HTMLDivElement.prototype, | 30 __proto__: HTMLDivElement.prototype, |
| 31 | 31 |
| 32 /** @override */ | 32 /** @override */ |
| 33 decorate: function() { | 33 decorate: function() { |
| 34 // Mousedown has to be used instead of click to be able to prevent 'focus' | 34 // Mousedown has to be used instead of click to be able to prevent 'focus' |
| 35 // event later. | 35 // event later. |
| 36 this.addEventListener('mousedown', | 36 this.addEventListener('mousedown', |
| 37 this.handleMouseDown_.bind(this)); | 37 this.handleMouseDown_.bind(this)); |
| 38 var screen = $('managed-user-creation'); | 38 var screen = $('supervised-user-creation'); |
| 39 var managerPod = this; | 39 var managerPod = this; |
| 40 var managerPodList = screen.managerList_; | 40 var managerPodList = screen.managerList_; |
| 41 var hideManagerPasswordError = function(element) { | 41 var hideManagerPasswordError = function(element) { |
| 42 managerPod.passwordElement.classList.remove('password-error'); | 42 managerPod.passwordElement.classList.remove('password-error'); |
| 43 $('bubble').hide(); | 43 $('bubble').hide(); |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 screen.configureTextInput( | 46 screen.configureTextInput( |
| 47 this.passwordElement, | 47 this.passwordElement, |
| 48 screen.updateNextButtonForManager_.bind(screen), | 48 screen.updateNextButtonForManager_.bind(screen), |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 74 '?id=' + ManagerPod.userImageSalt_[this.user.username]; | 74 '?id=' + ManagerPod.userImageSalt_[this.user.username]; |
| 75 | 75 |
| 76 this.nameElement.textContent = this.user.displayName; | 76 this.nameElement.textContent = this.user.displayName; |
| 77 this.emailElement.textContent = this.user.emailAddress; | 77 this.emailElement.textContent = this.user.emailAddress; |
| 78 }, | 78 }, |
| 79 | 79 |
| 80 showPasswordError: function() { | 80 showPasswordError: function() { |
| 81 this.passwordElement.classList.add('password-error'); | 81 this.passwordElement.classList.add('password-error'); |
| 82 $('bubble').showTextForElement( | 82 $('bubble').showTextForElement( |
| 83 this.passwordElement, | 83 this.passwordElement, |
| 84 loadTimeData.getString('createManagedUserWrongManagerPasswordText'), | 84 loadTimeData.getString( |
| 85 'createSupervisedUserWrongManagerPasswordText'), | |
| 85 cr.ui.Bubble.Attachment.BOTTOM, | 86 cr.ui.Bubble.Attachment.BOTTOM, |
| 86 24, 4); | 87 24, 4); |
| 87 }, | 88 }, |
| 88 | 89 |
| 89 /** | 90 /** |
| 90 * Brings focus to password field. | 91 * Brings focus to password field. |
| 91 */ | 92 */ |
| 92 focusInput: function() { | 93 focusInput: function() { |
| 93 this.passwordElement.focus(); | 94 this.passwordElement.focus(); |
| 94 }, | 95 }, |
| 95 | 96 |
| 96 /** | 97 /** |
| 97 * Gets image element. | 98 * Gets image element. |
| 98 * @type {!HTMLImageElement} | 99 * @type {!HTMLImageElement} |
| 99 */ | 100 */ |
| 100 get imageElement() { | 101 get imageElement() { |
| 101 return this.querySelector('.managed-user-creation-manager-image'); | 102 return this.querySelector('.supervised-user-creation-manager-image'); |
| 102 }, | 103 }, |
| 103 | 104 |
| 104 /** | 105 /** |
| 105 * Gets name element. | 106 * Gets name element. |
| 106 * @type {!HTMLDivElement} | 107 * @type {!HTMLDivElement} |
| 107 */ | 108 */ |
| 108 get nameElement() { | 109 get nameElement() { |
| 109 return this.querySelector('.managed-user-creation-manager-name'); | 110 return this.querySelector('.supervised-user-creation-manager-name'); |
| 110 }, | 111 }, |
| 111 | 112 |
| 112 /** | 113 /** |
| 113 * Gets e-mail element. | 114 * Gets e-mail element. |
| 114 * @type {!HTMLDivElement} | 115 * @type {!HTMLDivElement} |
| 115 */ | 116 */ |
| 116 get emailElement() { | 117 get emailElement() { |
| 117 return this.querySelector('.managed-user-creation-manager-email'); | 118 return this.querySelector('.supervised-user-creation-manager-email'); |
| 118 }, | 119 }, |
| 119 | 120 |
| 120 /** | 121 /** |
| 121 * Gets password element. | 122 * Gets password element. |
| 122 * @type {!HTMLDivElement} | 123 * @type {!HTMLDivElement} |
| 123 */ | 124 */ |
| 124 get passwordElement() { | 125 get passwordElement() { |
| 125 return this.querySelector('.managed-user-creation-manager-password'); | 126 return this.querySelector('.supervised-user-creation-manager-password'); |
| 126 }, | 127 }, |
| 127 | 128 |
| 128 /** | 129 /** |
| 129 * Gets password enclosing block. | 130 * Gets password enclosing block. |
| 130 * @type {!HTMLDivElement} | 131 * @type {!HTMLDivElement} |
| 131 */ | 132 */ |
| 132 get passwordBlock() { | 133 get passwordBlock() { |
| 133 return this.querySelector('.password-block'); | 134 return this.querySelector('.password-block'); |
| 134 }, | 135 }, |
| 135 | 136 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 150 }, | 151 }, |
| 151 set user(userDict) { | 152 set user(userDict) { |
| 152 this.user_ = userDict; | 153 this.user_ = userDict; |
| 153 this.update(); | 154 this.update(); |
| 154 }, | 155 }, |
| 155 }; | 156 }; |
| 156 | 157 |
| 157 var ManagerPodList = cr.ui.define('div'); | 158 var ManagerPodList = cr.ui.define('div'); |
| 158 | 159 |
| 159 /** | 160 /** |
| 160 * UI element for selecting manager account for new managed user. | 161 * UI element for selecting manager account for new supervised user. |
| 161 * @type {Object} | 162 * @type {Object} |
| 162 */ | 163 */ |
| 163 ManagerPodList.prototype = { | 164 ManagerPodList.prototype = { |
| 164 __proto__: HTMLDivElement.prototype, | 165 __proto__: HTMLDivElement.prototype, |
| 165 | 166 |
| 166 selectedPod_: null, | 167 selectedPod_: null, |
| 167 | 168 |
| 168 /** @override */ | 169 /** @override */ |
| 169 decorate: function() { | 170 decorate: function() { |
| 170 }, | 171 }, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 200 pod.passwordElement.value = ''; | 201 pod.passwordElement.value = ''; |
| 201 pod.passwordBlock.hidden = true; | 202 pod.passwordBlock.hidden = true; |
| 202 } | 203 } |
| 203 } | 204 } |
| 204 if (!podToSelect) | 205 if (!podToSelect) |
| 205 return; | 206 return; |
| 206 podToSelect.classList.add('focused'); | 207 podToSelect.classList.add('focused'); |
| 207 podToSelect.passwordBlock.hidden = false; | 208 podToSelect.passwordBlock.hidden = false; |
| 208 podToSelect.passwordElement.value = ''; | 209 podToSelect.passwordElement.value = ''; |
| 209 podToSelect.focusInput(); | 210 podToSelect.focusInput(); |
| 210 chrome.send('managerSelectedOnLocallyManagedUserCreationFlow', | 211 chrome.send('managerSelectedOnSupervisedUserCreationFlow', |
| 211 [podToSelect.user.username]); | 212 [podToSelect.user.username]); |
| 212 }, | 213 }, |
| 213 | 214 |
| 214 /** | 215 /** |
| 215 * Select pod next to currently selected one in given |direction|. | 216 * Select pod next to currently selected one in given |direction|. |
| 216 * @param {integer} direction - +1 for selecting pod below current, -1 for | 217 * @param {integer} direction - +1 for selecting pod below current, -1 for |
| 217 * selecting pod above current. | 218 * selecting pod above current. |
| 218 * @type {boolean} returns if selected pod has changed. | 219 * @type {boolean} returns if selected pod has changed. |
| 219 */ | 220 */ |
| 220 selectNextPod: function(direction) { | 221 selectNextPod: function(direction) { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 231 return false; | 232 return false; |
| 232 index = index + direction; | 233 index = index + direction; |
| 233 if (index < 0 || index >= this.pods.length) | 234 if (index < 0 || index >= this.pods.length) |
| 234 return false; | 235 return false; |
| 235 this.selectPod(this.pods[index]); | 236 this.selectPod(this.pods[index]); |
| 236 return true; | 237 return true; |
| 237 } | 238 } |
| 238 }; | 239 }; |
| 239 | 240 |
| 240 var ImportPod = cr.ui.define(function() { | 241 var ImportPod = cr.ui.define(function() { |
| 241 var node = $('managed-user-creation-import-template').cloneNode(true); | 242 var node = $('supervised-user-creation-import-template').cloneNode(true); |
| 242 node.removeAttribute('id'); | 243 node.removeAttribute('id'); |
| 243 node.removeAttribute('hidden'); | 244 node.removeAttribute('hidden'); |
| 244 return node; | 245 return node; |
| 245 }); | 246 }); |
| 246 | 247 |
| 247 /** | 248 /** |
| 248 * UI element for displaying single supervised user in list of possible users | 249 * UI element for displaying single supervised user in list of possible users |
| 249 * for importing existing users. | 250 * for importing existing users. |
| 250 * @type {Object} | 251 * @type {Object} |
| 251 */ | 252 */ |
| 252 ImportPod.prototype = { | 253 ImportPod.prototype = { |
| 253 __proto__: HTMLDivElement.prototype, | 254 __proto__: HTMLDivElement.prototype, |
| 254 | 255 |
| 255 /** @override */ | 256 /** @override */ |
| 256 decorate: function() { | 257 decorate: function() { |
| 257 // Mousedown has to be used instead of click to be able to prevent 'focus' | 258 // Mousedown has to be used instead of click to be able to prevent 'focus' |
| 258 // event later. | 259 // event later. |
| 259 this.addEventListener('mousedown', this.handleMouseDown_.bind(this)); | 260 this.addEventListener('mousedown', this.handleMouseDown_.bind(this)); |
| 260 var screen = $('managed-user-creation'); | 261 var screen = $('supervised-user-creation'); |
| 261 var importList = screen.importList_; | 262 var importList = screen.importList_; |
| 262 }, | 263 }, |
| 263 | 264 |
| 264 /** | 265 /** |
| 265 * Updates UI elements from user data. | 266 * Updates UI elements from user data. |
| 266 */ | 267 */ |
| 267 update: function() { | 268 update: function() { |
| 268 this.imageElement.src = this.user.avatarurl; | 269 this.imageElement.src = this.user.avatarurl; |
| 269 this.nameElement.textContent = this.user.name; | 270 this.nameElement.textContent = this.user.name; |
| 270 if (this.user.exists) { | 271 if (this.user.exists) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 ImportPodList.prototype = { | 328 ImportPodList.prototype = { |
| 328 __proto__: HTMLDivElement.prototype, | 329 __proto__: HTMLDivElement.prototype, |
| 329 | 330 |
| 330 selectedPod_: null, | 331 selectedPod_: null, |
| 331 | 332 |
| 332 /** @override */ | 333 /** @override */ |
| 333 decorate: function() { | 334 decorate: function() { |
| 334 this.setAttribute('tabIndex', 0); | 335 this.setAttribute('tabIndex', 0); |
| 335 this.classList.add('nofocus'); | 336 this.classList.add('nofocus'); |
| 336 var importList = this; | 337 var importList = this; |
| 337 var screen = $('managed-user-creation'); | 338 var screen = $('supervised-user-creation'); |
| 338 | 339 |
| 339 this.addEventListener('focus', function(e) { | 340 this.addEventListener('focus', function(e) { |
| 340 if (importList.selectedPod_ == null) { | 341 if (importList.selectedPod_ == null) { |
| 341 if (importList.pods.length > 0) | 342 if (importList.pods.length > 0) |
| 342 importList.selectPod(importList.pods[0]); | 343 importList.selectPod(importList.pods[0]); |
| 343 } | 344 } |
| 344 }); | 345 }); |
| 345 | 346 |
| 346 this.addEventListener('keydown', function(e) { | 347 this.addEventListener('keydown', function(e) { |
| 347 switch (e.keyIdentifier) { | 348 switch (e.keyIdentifier) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 this.selectedPod_ = podToSelect; | 442 this.selectedPod_ = podToSelect; |
| 442 for (var i = 0; i < this.pods.length; i++) { | 443 for (var i = 0; i < this.pods.length; i++) { |
| 443 var pod = this.pods[i]; | 444 var pod = this.pods[i]; |
| 444 if (pod != podToSelect) | 445 if (pod != podToSelect) |
| 445 pod.classList.remove('focused'); | 446 pod.classList.remove('focused'); |
| 446 } | 447 } |
| 447 if (!podToSelect) | 448 if (!podToSelect) |
| 448 return; | 449 return; |
| 449 podToSelect.classList.add('focused'); | 450 podToSelect.classList.add('focused'); |
| 450 podToSelect.focus(); | 451 podToSelect.focus(); |
| 451 var screen = $('managed-user-creation'); | 452 var screen = $('supervised-user-creation'); |
| 452 if (!this.selectedPod_) { | 453 if (!this.selectedPod_) { |
| 453 screen.getScreenButton('import').disabled = true; | 454 screen.getScreenButton('import').disabled = true; |
| 454 } else { | 455 } else { |
| 455 screen.getScreenButton('import').disabled = | 456 screen.getScreenButton('import').disabled = |
| 456 this.selectedPod_.user.exists; | 457 this.selectedPod_.user.exists; |
| 457 if (!this.selectedPod_.user.exists) { | 458 if (!this.selectedPod_.user.exists) { |
| 458 chrome.send('userSelectedForImportInManagedUserCreationFlow', | 459 chrome.send('userSelectedForImportInSupervisedUserCreationFlow', |
| 459 [podToSelect.user.id]); | 460 [podToSelect.user.id]); |
| 460 } | 461 } |
| 461 } | 462 } |
| 462 }, | 463 }, |
| 463 | 464 |
| 464 selectNextPod: function(direction) { | 465 selectNextPod: function(direction) { |
| 465 if (!this.selectedPod_) | 466 if (!this.selectedPod_) |
| 466 return false; | 467 return false; |
| 467 var index = -1; | 468 var index = -1; |
| 468 for (var i = 0, pod; pod = this.pods[i]; ++i) { | 469 for (var i = 0, pod; pod = this.pods[i]; ++i) { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 487 this.scrollIntoView(pod); | 488 this.scrollIntoView(pod); |
| 488 break; | 489 break; |
| 489 } | 490 } |
| 490 } | 491 } |
| 491 }, | 492 }, |
| 492 }; | 493 }; |
| 493 | 494 |
| 494 return { | 495 return { |
| 495 EXTERNAL_API: [ | 496 EXTERNAL_API: [ |
| 496 'loadManagers', | 497 'loadManagers', |
| 497 'managedUserSuggestImport', | |
| 498 'managedUserNameError', | |
| 499 'managedUserNameOk', | |
| 500 'showErrorPage', | 498 'showErrorPage', |
| 501 'showIntroPage', | 499 'showIntroPage', |
| 502 'showManagerPage', | 500 'showManagerPage', |
| 503 'showManagerPasswordError', | 501 'showManagerPasswordError', |
| 504 'showPasswordError', | 502 'showPasswordError', |
| 505 'showProgress', | 503 'showProgress', |
| 506 'showStatusError', | 504 'showStatusError', |
| 507 'showTutorialPage', | 505 'showTutorialPage', |
| 508 'showUsernamePage', | 506 'showUsernamePage', |
| 509 'showPage', | 507 'showPage', |
| 510 'setDefaultImages', | 508 'setDefaultImages', |
|
Pam (message me for reviews)
2014/07/23 21:13:39
As long as you're moving things around, e < h
Marc Treib
2014/07/24 12:11:54
Done.
Pam (message me for reviews)
2014/07/24 17:03:27
Hm, I meant that set* should come before show*.
Marc Treib
2014/07/25 09:41:28
Dammit, I seem to be really bad with the alphabet.
| |
| 511 'setCameraPresent', | 509 'setCameraPresent', |
| 512 'setExistingManagedUsers', | 510 'setExistingSupervisedUsers', |
| 511 'supervisedUserSuggestImport', | |
| 512 'supervisedUserNameError', | |
| 513 'supervisedUserNameOk', | |
| 513 ], | 514 ], |
| 514 | 515 |
| 515 lastVerifiedName_: null, | 516 lastVerifiedName_: null, |
| 516 lastIncorrectUserName_: null, | 517 lastIncorrectUserName_: null, |
| 517 managerList_: null, | 518 managerList_: null, |
| 518 importList_: null, | 519 importList_: null, |
| 519 | 520 |
| 520 currentPage_: null, | 521 currentPage_: null, |
| 521 imagesRequested_: false, | 522 imagesRequested_: false, |
| 522 | 523 |
| 523 // Contains data that can be auto-shared with handler. | 524 // Contains data that can be auto-shared with handler. |
| 524 context_: {}, | 525 context_: {}, |
| 525 | 526 |
| 526 /** @override */ | 527 /** @override */ |
| 527 decorate: function() { | 528 decorate: function() { |
| 528 this.managerList_ = new ManagerPodList(); | 529 this.managerList_ = new ManagerPodList(); |
| 529 $('managed-user-creation-managers-pane').appendChild(this.managerList_); | 530 $('supervised-user-creation-managers-pane').appendChild( |
| 531 this.managerList_); | |
| 530 | 532 |
| 531 this.importList_ = new ImportPodList(); | 533 this.importList_ = new ImportPodList(); |
| 532 $('managed-user-creation-import-pane').appendChild(this.importList_); | 534 $('supervised-user-creation-import-pane').appendChild(this.importList_); |
| 533 | 535 |
| 534 var userNameField = $('managed-user-creation-name'); | 536 var userNameField = $('supervised-user-creation-name'); |
| 535 var passwordField = $('managed-user-creation-password'); | 537 var passwordField = $('supervised-user-creation-password'); |
| 536 var password2Field = $('managed-user-creation-password-confirm'); | 538 var password2Field = $('supervised-user-creation-password-confirm'); |
| 537 | 539 |
| 538 var creationScreen = this; | 540 var creationScreen = this; |
| 539 | 541 |
| 540 var hideUserPasswordError = function(element) { | 542 var hideUserPasswordError = function(element) { |
| 541 $('bubble').hide(); | 543 $('bubble').hide(); |
| 542 $('managed-user-creation-password').classList.remove('password-error'); | 544 $('supervised-user-creation-password').classList.remove( |
| 545 'password-error'); | |
| 543 }; | 546 }; |
| 544 | 547 |
| 545 this.configureTextInput(userNameField, | 548 this.configureTextInput(userNameField, |
| 546 this.checkUserName_.bind(this), | 549 this.checkUserName_.bind(this), |
| 547 this.validIfNotEmpty_.bind(this), | 550 this.validIfNotEmpty_.bind(this), |
| 548 function(element) { | 551 function(element) { |
| 549 passwordField.focus(); | 552 passwordField.focus(); |
| 550 }, | 553 }, |
| 551 this.clearUserNameError_.bind(this)); | 554 this.clearUserNameError_.bind(this)); |
| 552 this.configureTextInput(passwordField, | 555 this.configureTextInput(passwordField, |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 | 765 |
| 763 var status = this.makeFromTemplate('status-container', 'status'); | 766 var status = this.makeFromTemplate('status-container', 'status'); |
| 764 buttons.appendChild(status); | 767 buttons.appendChild(status); |
| 765 | 768 |
| 766 linkElement = createLink.querySelector('.signin-link'); | 769 linkElement = createLink.querySelector('.signin-link'); |
| 767 linkElement.addEventListener('click', | 770 linkElement.addEventListener('click', |
| 768 this.createLinkPressed_.bind(this)); | 771 this.createLinkPressed_.bind(this)); |
| 769 | 772 |
| 770 buttons.appendChild(this.makeButton( | 773 buttons.appendChild(this.makeButton( |
| 771 'start', | 774 'start', |
| 772 'managedUserCreationFlow', | 775 'supervisedUserCreationFlow', |
| 773 this.startButtonPressed_.bind(this), | 776 this.startButtonPressed_.bind(this), |
| 774 ['intro'], | 777 ['intro'], |
| 775 ['custom-appearance', 'button-fancy', 'button-blue'])); | 778 ['custom-appearance', 'button-fancy', 'button-blue'])); |
| 776 | 779 |
| 777 buttons.appendChild(this.makeButton( | 780 buttons.appendChild(this.makeButton( |
| 778 'prev', | 781 'prev', |
| 779 'managedUserCreationFlow', | 782 'supervisedUserCreationFlow', |
| 780 this.prevButtonPressed_.bind(this), | 783 this.prevButtonPressed_.bind(this), |
| 781 ['manager'], | 784 ['manager'], |
| 782 [])); | 785 [])); |
| 783 | 786 |
| 784 buttons.appendChild(this.makeButton( | 787 buttons.appendChild(this.makeButton( |
| 785 'next', | 788 'next', |
| 786 'managedUserCreationFlow', | 789 'supervisedUserCreationFlow', |
| 787 this.nextButtonPressed_.bind(this), | 790 this.nextButtonPressed_.bind(this), |
| 788 ['manager', 'username'], | 791 ['manager', 'username'], |
| 789 [])); | 792 [])); |
| 790 | 793 |
| 791 buttons.appendChild(this.makeButton( | 794 buttons.appendChild(this.makeButton( |
| 792 'import', | 795 'import', |
| 793 'managedUserCreationFlow', | 796 'supervisedUserCreationFlow', |
| 794 this.importButtonPressed_.bind(this), | 797 this.importButtonPressed_.bind(this), |
| 795 ['import', 'import-password'], | 798 ['import', 'import-password'], |
| 796 [])); | 799 [])); |
| 797 | 800 |
| 798 buttons.appendChild(this.makeButton( | 801 buttons.appendChild(this.makeButton( |
| 799 'gotit', | 802 'gotit', |
| 800 'managedUserCreationFlow', | 803 'supervisedUserCreationFlow', |
| 801 this.gotItButtonPressed_.bind(this), | 804 this.gotItButtonPressed_.bind(this), |
| 802 ['created'], | 805 ['created'], |
| 803 ['custom-appearance', 'button-fancy', 'button-blue'])); | 806 ['custom-appearance', 'button-fancy', 'button-blue'])); |
| 804 return [links, buttons]; | 807 return [links, buttons]; |
| 805 }, | 808 }, |
| 806 | 809 |
| 807 /** | 810 /** |
| 808 * Does sanity check and calls backend with current user name/password pair | 811 * Does sanity check and calls backend with current user name/password pair |
| 809 * to authenticate manager. May result in showManagerPasswordError. | 812 * to authenticate manager. May result in showManagerPasswordError. |
| 810 * @private | 813 * @private |
| 811 */ | 814 */ |
| 812 validateAndLogInAsManager_: function() { | 815 validateAndLogInAsManager_: function() { |
| 813 var selectedPod = this.managerList_.selectedPod_; | 816 var selectedPod = this.managerList_.selectedPod_; |
| 814 if (null == selectedPod) | 817 if (null == selectedPod) |
| 815 return; | 818 return; |
| 816 | 819 |
| 817 var managerId = selectedPod.user.username; | 820 var managerId = selectedPod.user.username; |
| 818 var managerDisplayId = selectedPod.user.emailAddress; | 821 var managerDisplayId = selectedPod.user.emailAddress; |
| 819 var managerPassword = selectedPod.passwordElement.value; | 822 var managerPassword = selectedPod.passwordElement.value; |
| 820 if (managerPassword.length == 0) | 823 if (managerPassword.length == 0) |
| 821 return; | 824 return; |
| 822 if (this.disabled) | 825 if (this.disabled) |
| 823 return; | 826 return; |
| 824 this.disabled = true; | 827 this.disabled = true; |
| 825 this.context_.managerId = managerId; | 828 this.context_.managerId = managerId; |
| 826 this.context_.managerDisplayId = managerDisplayId; | 829 this.context_.managerDisplayId = managerDisplayId; |
| 827 this.context_.managerName = selectedPod.user.displayName; | 830 this.context_.managerName = selectedPod.user.displayName; |
| 828 chrome.send('authenticateManagerInLocallyManagedUserCreationFlow', | 831 chrome.send('authenticateManagerInSupervisedUserCreationFlow', |
| 829 [managerId, managerPassword]); | 832 [managerId, managerPassword]); |
| 830 }, | 833 }, |
| 831 | 834 |
| 832 /** | 835 /** |
| 833 * Does sanity check and calls backend with user display name/password pair | 836 * Does sanity check and calls backend with user display name/password pair |
| 834 * to create a user. | 837 * to create a user. |
| 835 * @private | 838 * @private |
| 836 */ | 839 */ |
| 837 validateAndCreateLocallyManagedUser_: function() { | 840 validateAndCreateSupervisedUser_: function() { |
| 838 var firstPassword = $('managed-user-creation-password').value; | 841 var firstPassword = $('supervised-user-creation-password').value; |
| 839 var secondPassword = | 842 var secondPassword = |
| 840 $('managed-user-creation-password-confirm').value; | 843 $('supervised-user-creation-password-confirm').value; |
| 841 var userName = $('managed-user-creation-name').value; | 844 var userName = $('supervised-user-creation-name').value; |
| 842 if (firstPassword != secondPassword) { | 845 if (firstPassword != secondPassword) { |
| 843 this.showPasswordError( | 846 this.showPasswordError(loadTimeData.getString( |
| 844 loadTimeData.getString('createManagedUserPasswordMismatchError')); | 847 'createSupervisedUserPasswordMismatchError')); |
| 845 return; | 848 return; |
| 846 } | 849 } |
| 847 if (this.disabled) | 850 if (this.disabled) |
| 848 return; | 851 return; |
| 849 this.disabled = true; | 852 this.disabled = true; |
| 850 | 853 |
| 851 this.context_.managedName = userName; | 854 this.context_.supervisedName = userName; |
| 852 chrome.send('specifyLocallyManagedUserCreationFlowUserData', | 855 chrome.send('specifySupervisedUserCreationFlowUserData', |
| 853 [userName, firstPassword]); | 856 [userName, firstPassword]); |
| 854 }, | 857 }, |
| 855 | 858 |
| 856 /** | 859 /** |
| 857 * Does sanity check and calls backend with selected existing supervised | 860 * Does sanity check and calls backend with selected existing supervised |
| 858 * user id to import user. | 861 * user id to import user. |
| 859 * @private | 862 * @private |
| 860 */ | 863 */ |
| 861 importSupervisedUser_: function() { | 864 importSupervisedUser_: function() { |
| 862 if (this.disabled) | 865 if (this.disabled) |
| 863 return; | 866 return; |
| 864 if (this.currentPage_ == 'import-password') { | 867 if (this.currentPage_ == 'import-password') { |
| 865 var firstPassword = this.getScreenElement('password').value; | 868 var firstPassword = this.getScreenElement('password').value; |
| 866 var secondPassword = this.getScreenElement('password-confirm').value; | 869 var secondPassword = this.getScreenElement('password-confirm').value; |
| 867 if (firstPassword != secondPassword) { | 870 if (firstPassword != secondPassword) { |
| 868 this.showPasswordError( | 871 this.showPasswordError(loadTimeData.getString( |
| 869 loadTimeData.getString('createManagedUserPasswordMismatchError')); | 872 'createSupervisedUserPasswordMismatchError')); |
| 870 return; | 873 return; |
| 871 } | 874 } |
| 872 var userId = this.context_.importUserId; | 875 var userId = this.context_.importUserId; |
| 873 this.disabled = true; | 876 this.disabled = true; |
| 874 chrome.send('importSupervisedUserWithPassword', | 877 chrome.send('importSupervisedUserWithPassword', |
| 875 [userId, firstPassword]); | 878 [userId, firstPassword]); |
| 876 return; | 879 return; |
| 877 } else { | 880 } else { |
| 878 var selectedPod = this.importList_.selectedPod_; | 881 var selectedPod = this.importList_.selectedPod_; |
| 879 if (!selectedPod) | 882 if (!selectedPod) |
| 880 return; | 883 return; |
| 881 var user = selectedPod.user; | 884 var user = selectedPod.user; |
| 882 var userId = user.id; | 885 var userId = user.id; |
| 883 | 886 |
| 884 this.context_.importUserId = userId; | 887 this.context_.importUserId = userId; |
| 885 this.context_.managedName = user.name; | 888 this.context_.supervisedName = user.name; |
| 886 this.context_.selectedImageUrl = user.avatarurl; | 889 this.context_.selectedImageUrl = user.avatarurl; |
| 887 if (!user.needPassword) { | 890 if (!user.needPassword) { |
| 888 this.disabled = true; | 891 this.disabled = true; |
| 889 chrome.send('importSupervisedUser', [userId]); | 892 chrome.send('importSupervisedUser', [userId]); |
| 890 } else { | 893 } else { |
| 891 this.setVisiblePage_('import-password'); | 894 this.setVisiblePage_('import-password'); |
| 892 } | 895 } |
| 893 } | 896 } |
| 894 }, | 897 }, |
| 895 | 898 |
| 896 /** | 899 /** |
| 897 * Calls backend part to check if current user name is valid/not taken. | 900 * Calls backend part to check if current user name is valid/not taken. |
| 898 * Results in call to either managedUserNameOk or managedUserNameError. | 901 * Results in a call to either supervisedUserNameOk or |
| 902 * supervisedUserNameError. | |
| 899 * @private | 903 * @private |
| 900 */ | 904 */ |
| 901 checkUserName_: function() { | 905 checkUserName_: function() { |
| 902 var userName = this.getScreenElement('name').value; | 906 var userName = this.getScreenElement('name').value; |
| 903 | 907 |
| 904 // Avoid flickering | 908 // Avoid flickering |
| 905 if (userName == this.lastIncorrectUserName_ || | 909 if (userName == this.lastIncorrectUserName_ || |
| 906 userName == this.lastVerifiedName_) { | 910 userName == this.lastVerifiedName_) { |
| 907 return; | 911 return; |
| 908 } | 912 } |
| 909 if (userName.length > 0) { | 913 if (userName.length > 0) { |
| 910 chrome.send('checkLocallyManagedUserName', [userName]); | 914 chrome.send('checkSupervisedUserName', [userName]); |
| 911 } else { | 915 } else { |
| 912 this.nameErrorVisible = false; | 916 this.nameErrorVisible = false; |
| 913 this.lastVerifiedName_ = null; | 917 this.lastVerifiedName_ = null; |
| 914 this.lastIncorrectUserName_ = null; | 918 this.lastIncorrectUserName_ = null; |
| 915 this.updateNextButtonForUser_(); | 919 this.updateNextButtonForUser_(); |
| 916 } | 920 } |
| 917 }, | 921 }, |
| 918 | 922 |
| 919 /** | 923 /** |
| 920 * Called by backend part in case of successful name validation. | 924 * Called by backend part in case of successful name validation. |
| 921 * @param {string} name - name that was validated. | 925 * @param {string} name - name that was validated. |
| 922 */ | 926 */ |
| 923 managedUserNameOk: function(name) { | 927 supervisedUserNameOk: function(name) { |
| 924 this.lastVerifiedName_ = name; | 928 this.lastVerifiedName_ = name; |
| 925 this.lastIncorrectUserName_ = null; | 929 this.lastIncorrectUserName_ = null; |
| 926 if ($('managed-user-creation-name').value == name) | 930 if ($('supervised-user-creation-name').value == name) |
| 927 this.clearUserNameError_(); | 931 this.clearUserNameError_(); |
| 928 this.updateNextButtonForUser_(); | 932 this.updateNextButtonForUser_(); |
| 929 }, | 933 }, |
| 930 | 934 |
| 931 /** | 935 /** |
| 932 * Called by backend part in case of name validation failure. | 936 * Called by backend part in case of name validation failure. |
| 933 * @param {string} name - name that was validated. | 937 * @param {string} name - name that was validated. |
| 934 * @param {string} errorText - reason why this name is invalid. | 938 * @param {string} errorText - reason why this name is invalid. |
| 935 */ | 939 */ |
| 936 managedUserNameError: function(name, errorText) { | 940 supervisedUserNameError: function(name, errorText) { |
| 937 this.disabled = false; | 941 this.disabled = false; |
| 938 this.lastIncorrectUserName_ = name; | 942 this.lastIncorrectUserName_ = name; |
| 939 this.lastVerifiedName_ = null; | 943 this.lastVerifiedName_ = null; |
| 940 | 944 |
| 941 var userNameField = $('managed-user-creation-name'); | 945 var userNameField = $('supervised-user-creation-name'); |
| 942 if (userNameField.value == this.lastIncorrectUserName_) { | 946 if (userNameField.value == this.lastIncorrectUserName_) { |
| 943 this.nameErrorVisible = true; | 947 this.nameErrorVisible = true; |
| 944 $('bubble').showTextForElement( | 948 $('bubble').showTextForElement( |
| 945 $('managed-user-creation-name'), | 949 $('supervised-user-creation-name'), |
| 946 errorText, | 950 errorText, |
| 947 cr.ui.Bubble.Attachment.RIGHT, | 951 cr.ui.Bubble.Attachment.RIGHT, |
| 948 12, 4); | 952 12, 4); |
| 949 this.setButtonDisabledStatus('next', true); | 953 this.setButtonDisabledStatus('next', true); |
| 950 } | 954 } |
| 951 }, | 955 }, |
| 952 | 956 |
| 953 managedUserSuggestImport: function(name, user_id) { | 957 supervisedUserSuggestImport: function(name, user_id) { |
| 954 this.disabled = false; | 958 this.disabled = false; |
| 955 this.lastIncorrectUserName_ = name; | 959 this.lastIncorrectUserName_ = name; |
| 956 this.lastVerifiedName_ = null; | 960 this.lastVerifiedName_ = null; |
| 957 | 961 |
| 958 var userNameField = $('managed-user-creation-name'); | 962 var userNameField = $('supervised-user-creation-name'); |
| 959 var creationScreen = this; | 963 var creationScreen = this; |
| 960 | 964 |
| 961 if (userNameField.value == this.lastIncorrectUserName_) { | 965 if (userNameField.value == this.lastIncorrectUserName_) { |
| 962 this.nameErrorVisible = true; | 966 this.nameErrorVisible = true; |
| 963 var link = this.ownerDocument.createElement('div'); | 967 var link = this.ownerDocument.createElement('div'); |
| 964 link.innerHTML = loadTimeData.getStringF( | 968 link.innerHTML = loadTimeData.getStringF( |
| 965 'importBubbleText', | 969 'importBubbleText', |
| 966 '<a class="signin-link" href="#">', | 970 '<a class="signin-link" href="#">', |
| 967 name, | 971 name, |
| 968 '</a>'); | 972 '</a>'); |
| 969 link.querySelector('.signin-link').addEventListener('click', | 973 link.querySelector('.signin-link').addEventListener('click', |
| 970 function(e) { | 974 function(e) { |
| 971 creationScreen.handleSuggestImport_(user_id); | 975 creationScreen.handleSuggestImport_(user_id); |
| 972 e.stopPropagation(); | 976 e.stopPropagation(); |
| 973 }); | 977 }); |
| 974 $('bubble').showContentForElement( | 978 $('bubble').showContentForElement( |
| 975 $('managed-user-creation-name'), | 979 $('supervised-user-creation-name'), |
| 976 cr.ui.Bubble.Attachment.RIGHT, | 980 cr.ui.Bubble.Attachment.RIGHT, |
| 977 link, | 981 link, |
| 978 12, 4); | 982 12, 4); |
| 979 this.setButtonDisabledStatus('next', true); | 983 this.setButtonDisabledStatus('next', true); |
| 980 } | 984 } |
| 981 }, | 985 }, |
| 982 | 986 |
| 983 /** | 987 /** |
| 984 * Clears user name error, if name is no more guaranteed to be invalid. | 988 * Clears user name error, if name is no more guaranteed to be invalid. |
| 985 * @private | 989 * @private |
| 986 */ | 990 */ |
| 987 clearUserNameError_: function() { | 991 clearUserNameError_: function() { |
| 988 // Avoid flickering | 992 // Avoid flickering |
| 989 if ($('managed-user-creation-name').value == | 993 if ($('supervised-user-creation-name').value == |
| 990 this.lastIncorrectUserName_) { | 994 this.lastIncorrectUserName_) { |
| 991 return; | 995 return; |
| 992 } | 996 } |
| 993 this.nameErrorVisible = false; | 997 this.nameErrorVisible = false; |
| 994 }, | 998 }, |
| 995 | 999 |
| 996 /** | 1000 /** |
| 997 * Called by backend part in case of password validation failure. | 1001 * Called by backend part in case of password validation failure. |
| 998 * @param {string} errorText - reason why this password is invalid. | 1002 * @param {string} errorText - reason why this password is invalid. |
| 999 */ | 1003 */ |
| 1000 showPasswordError: function(errorText) { | 1004 showPasswordError: function(errorText) { |
| 1001 $('bubble').showTextForElement( | 1005 $('bubble').showTextForElement( |
| 1002 $('managed-user-creation-password'), | 1006 $('supervised-user-creation-password'), |
| 1003 errorText, | 1007 errorText, |
| 1004 cr.ui.Bubble.Attachment.RIGHT, | 1008 cr.ui.Bubble.Attachment.RIGHT, |
| 1005 12, 4); | 1009 12, 4); |
| 1006 $('managed-user-creation-password').classList.add('password-error'); | 1010 $('supervised-user-creation-password').classList.add('password-error'); |
| 1007 $('managed-user-creation-password').focus(); | 1011 $('supervised-user-creation-password').focus(); |
| 1008 this.disabled = false; | 1012 this.disabled = false; |
| 1009 this.setButtonDisabledStatus('next', true); | 1013 this.setButtonDisabledStatus('next', true); |
| 1010 }, | 1014 }, |
| 1011 | 1015 |
| 1012 /** | 1016 /** |
| 1013 * True if user name error should be displayed. | 1017 * True if user name error should be displayed. |
| 1014 * @type {boolean} | 1018 * @type {boolean} |
| 1015 */ | 1019 */ |
| 1016 set nameErrorVisible(value) { | 1020 set nameErrorVisible(value) { |
| 1017 $('managed-user-creation-name'). | 1021 $('supervised-user-creation-name'). |
| 1018 classList.toggle('duplicate-name', value); | 1022 classList.toggle('duplicate-name', value); |
| 1019 if (!value) | 1023 if (!value) |
| 1020 $('bubble').hide(); | 1024 $('bubble').hide(); |
| 1021 }, | 1025 }, |
| 1022 | 1026 |
| 1023 /** | 1027 /** |
| 1024 * Updates state of Continue button after minimal checks. | 1028 * Updates state of Continue button after minimal checks. |
| 1025 * @return {boolean} true, if form seems to be valid. | 1029 * @return {boolean} true, if form seems to be valid. |
| 1026 * @private | 1030 * @private |
| 1027 */ | 1031 */ |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1097 'import' : 'import', | 1101 'import' : 'import', |
| 1098 'import-password' : 'import', | 1102 'import-password' : 'import', |
| 1099 'created' : 'gotit'}; | 1103 'created' : 'gotit'}; |
| 1100 this.hideStatus_(); | 1104 this.hideStatus_(); |
| 1101 var pageToDisplay = visiblePage; | 1105 var pageToDisplay = visiblePage; |
| 1102 if (visiblePage == 'import-password') | 1106 if (visiblePage == 'import-password') |
| 1103 pageToDisplay = 'username'; | 1107 pageToDisplay = 'username'; |
| 1104 | 1108 |
| 1105 for (i in pageNames) { | 1109 for (i in pageNames) { |
| 1106 var pageName = pageNames[i]; | 1110 var pageName = pageNames[i]; |
| 1107 var page = $('managed-user-creation-' + pageName); | 1111 var page = $('supervised-user-creation-' + pageName); |
| 1108 page.hidden = (pageName != pageToDisplay); | 1112 page.hidden = (pageName != pageToDisplay); |
| 1109 if (pageName == pageToDisplay) | 1113 if (pageName == pageToDisplay) |
| 1110 $('step-logo').hidden = page.classList.contains('step-no-logo'); | 1114 $('step-logo').hidden = page.classList.contains('step-no-logo'); |
| 1111 } | 1115 } |
| 1112 | 1116 |
| 1113 for (i in this.buttonIds) { | 1117 for (i in this.buttonIds) { |
| 1114 var button = this.getScreenButton(this.buttonIds[i]); | 1118 var button = this.getScreenButton(this.buttonIds[i]); |
| 1115 button.hidden = button.pages.indexOf(visiblePage) < 0; | 1119 button.hidden = button.pages.indexOf(visiblePage) < 0; |
| 1116 button.disabled = false; | 1120 button.disabled = false; |
| 1117 } | 1121 } |
| 1118 | 1122 |
| 1119 var pagesWithCancel = ['intro', 'manager', 'username', 'import-password', | 1123 var pagesWithCancel = ['intro', 'manager', 'username', 'import-password', |
| 1120 'error', 'import']; | 1124 'error', 'import']; |
| 1121 $('login-header-bar').allowCancel = | 1125 $('login-header-bar').allowCancel = |
| 1122 pagesWithCancel.indexOf(visiblePage) > 0; | 1126 pagesWithCancel.indexOf(visiblePage) > 0; |
| 1123 $('cancel-add-user-button').disabled = false; | 1127 $('cancel-add-user-button').disabled = false; |
| 1124 | 1128 |
| 1125 this.getScreenElement('import-link').hidden = true; | 1129 this.getScreenElement('import-link').hidden = true; |
| 1126 this.getScreenElement('create-link').hidden = true; | 1130 this.getScreenElement('create-link').hidden = true; |
| 1127 | 1131 |
| 1128 if (pageButtons[visiblePage]) | 1132 if (pageButtons[visiblePage]) |
| 1129 this.getScreenButton(pageButtons[visiblePage]).focus(); | 1133 this.getScreenButton(pageButtons[visiblePage]).focus(); |
| 1130 | 1134 |
| 1131 this.currentPage_ = visiblePage; | 1135 this.currentPage_ = visiblePage; |
| 1132 | 1136 |
| 1133 if (visiblePage == 'manager' || visiblePage == 'intro') { | 1137 if (visiblePage == 'manager' || visiblePage == 'intro') { |
| 1134 $('managed-user-creation-password').classList.remove('password-error'); | 1138 $('supervised-user-creation-password').classList.remove( |
| 1139 'password-error'); | |
| 1135 if (this.managerList_.pods.length > 0) | 1140 if (this.managerList_.pods.length > 0) |
| 1136 this.managerList_.selectPod(this.managerList_.pods[0]); | 1141 this.managerList_.selectPod(this.managerList_.pods[0]); |
| 1137 } | 1142 } |
| 1138 | 1143 |
| 1139 if (visiblePage == 'username' || visiblePage == 'import-password') { | 1144 if (visiblePage == 'username' || visiblePage == 'import-password') { |
| 1140 var elements = this.getScreenElement(pageToDisplay). | 1145 var elements = this.getScreenElement(pageToDisplay). |
| 1141 querySelectorAll('.hide-on-import'); | 1146 querySelectorAll('.hide-on-import'); |
| 1142 for (var i = 0; i < elements.length; i++) { | 1147 for (var i = 0; i < elements.length; i++) { |
| 1143 elements[i].classList.toggle('hidden-on-import', | 1148 elements[i].classList.toggle('hidden-on-import', |
| 1144 visiblePage == 'import-password'); | 1149 visiblePage == 'import-password'); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1184 if (visiblePage == 'import') { | 1189 if (visiblePage == 'import') { |
| 1185 this.getScreenElement('create-link').hidden = false; | 1190 this.getScreenElement('create-link').hidden = false; |
| 1186 this.getScreenButton('import').disabled = | 1191 this.getScreenButton('import').disabled = |
| 1187 !this.importList_.selectedPod_ || | 1192 !this.importList_.selectedPod_ || |
| 1188 this.importList_.selectedPod_.user.exists; | 1193 this.importList_.selectedPod_.user.exists; |
| 1189 } | 1194 } |
| 1190 chrome.send('currentSupervisedUserPage', [this.currentPage_]); | 1195 chrome.send('currentSupervisedUserPage', [this.currentPage_]); |
| 1191 }, | 1196 }, |
| 1192 | 1197 |
| 1193 setButtonDisabledStatus: function(buttonName, status) { | 1198 setButtonDisabledStatus: function(buttonName, status) { |
| 1194 var button = $('managed-user-creation-' + buttonName + '-button'); | 1199 var button = $('supervised-user-creation-' + buttonName + '-button'); |
| 1195 button.disabled = status; | 1200 button.disabled = status; |
| 1196 }, | 1201 }, |
| 1197 | 1202 |
| 1198 gotItButtonPressed_: function() { | 1203 gotItButtonPressed_: function() { |
| 1199 chrome.send('finishLocalManagedUserCreation'); | 1204 chrome.send('finishLocalSupervisedUserCreation'); |
| 1200 }, | 1205 }, |
| 1201 | 1206 |
| 1202 handleErrorButtonPressed_: function() { | 1207 handleErrorButtonPressed_: function() { |
| 1203 chrome.send('abortLocalManagedUserCreation'); | 1208 chrome.send('abortLocalSupervisedUserCreation'); |
| 1204 }, | 1209 }, |
| 1205 | 1210 |
| 1206 startButtonPressed_: function() { | 1211 startButtonPressed_: function() { |
| 1207 this.setVisiblePage_('manager'); | 1212 this.setVisiblePage_('manager'); |
| 1208 this.setButtonDisabledStatus('next', true); | 1213 this.setButtonDisabledStatus('next', true); |
| 1209 }, | 1214 }, |
| 1210 | 1215 |
| 1211 nextButtonPressed_: function() { | 1216 nextButtonPressed_: function() { |
| 1212 if (this.currentPage_ == 'manager') { | 1217 if (this.currentPage_ == 'manager') { |
| 1213 this.validateAndLogInAsManager_(); | 1218 this.validateAndLogInAsManager_(); |
| 1214 return; | 1219 return; |
| 1215 } | 1220 } |
| 1216 if (this.currentPage_ == 'username') { | 1221 if (this.currentPage_ == 'username') { |
| 1217 this.validateAndCreateLocallyManagedUser_(); | 1222 this.validateAndCreateSupervisedUser_(); |
| 1218 } | 1223 } |
| 1219 }, | 1224 }, |
| 1220 | 1225 |
| 1221 importButtonPressed_: function() { | 1226 importButtonPressed_: function() { |
| 1222 this.importSupervisedUser_(); | 1227 this.importSupervisedUser_(); |
| 1223 }, | 1228 }, |
| 1224 | 1229 |
| 1225 importLinkPressed_: function() { | 1230 importLinkPressed_: function() { |
| 1226 this.setVisiblePage_('import'); | 1231 this.setVisiblePage_('import'); |
| 1227 }, | 1232 }, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1267 hideStatus_: function() { | 1272 hideStatus_: function() { |
| 1268 var status = this.getScreenElement('status'); | 1273 var status = this.getScreenElement('status'); |
| 1269 status.hidden = true; | 1274 status.hidden = true; |
| 1270 }, | 1275 }, |
| 1271 | 1276 |
| 1272 /** | 1277 /** |
| 1273 * Updates state of login header so that necessary buttons are displayed. | 1278 * Updates state of login header so that necessary buttons are displayed. |
| 1274 **/ | 1279 **/ |
| 1275 onBeforeShow: function(data) { | 1280 onBeforeShow: function(data) { |
| 1276 $('login-header-bar').signinUIState = | 1281 $('login-header-bar').signinUIState = |
| 1277 SIGNIN_UI_STATE.MANAGED_USER_CREATION_FLOW; | 1282 SIGNIN_UI_STATE.SUPERVISED_USER_CREATION_FLOW; |
| 1278 if (data['managers']) { | 1283 if (data['managers']) { |
| 1279 this.loadManagers(data['managers']); | 1284 this.loadManagers(data['managers']); |
| 1280 } | 1285 } |
| 1281 var imageGrid = this.getScreenElement('image-grid'); | 1286 var imageGrid = this.getScreenElement('image-grid'); |
| 1282 imageGrid.updateAndFocus(); | 1287 imageGrid.updateAndFocus(); |
| 1283 }, | 1288 }, |
| 1284 | 1289 |
| 1285 /** | 1290 /** |
| 1286 * Update state of login header so that necessary buttons are displayed. | 1291 * Update state of login header so that necessary buttons are displayed. |
| 1287 */ | 1292 */ |
| 1288 onBeforeHide: function() { | 1293 onBeforeHide: function() { |
| 1289 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.HIDDEN; | 1294 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.HIDDEN; |
| 1290 this.getScreenElement('image-grid').stopCamera(); | 1295 this.getScreenElement('image-grid').stopCamera(); |
| 1291 }, | 1296 }, |
| 1292 | 1297 |
| 1293 /** | 1298 /** |
| 1294 * Returns a control which should receive an initial focus. | 1299 * Returns a control which should receive an initial focus. |
| 1295 */ | 1300 */ |
| 1296 get defaultControl() { | 1301 get defaultControl() { |
| 1297 return $('managed-user-creation-name'); | 1302 return $('supervised-user-creation-name'); |
| 1298 }, | 1303 }, |
| 1299 | 1304 |
| 1300 /** | 1305 /** |
| 1301 * True if the the screen is disabled (handles no user interaction). | 1306 * True if the the screen is disabled (handles no user interaction). |
| 1302 * @type {boolean} | 1307 * @type {boolean} |
| 1303 */ | 1308 */ |
| 1304 disabled_: false, | 1309 disabled_: false, |
| 1305 | 1310 |
| 1306 get disabled() { | 1311 get disabled() { |
| 1307 return this.disabled_; | 1312 return this.disabled_; |
| 1308 }, | 1313 }, |
| 1309 | 1314 |
| 1310 set disabled(value) { | 1315 set disabled(value) { |
| 1311 this.disabled_ = value; | 1316 this.disabled_ = value; |
| 1312 var controls = this.querySelectorAll('button,input'); | 1317 var controls = this.querySelectorAll('button,input'); |
| 1313 for (var i = 0, control; control = controls[i]; ++i) { | 1318 for (var i = 0, control; control = controls[i]; ++i) { |
| 1314 control.disabled = value; | 1319 control.disabled = value; |
| 1315 } | 1320 } |
| 1316 $('login-header-bar').disabled = value; | 1321 $('login-header-bar').disabled = value; |
| 1317 $('cancel-add-user-button').disabled = false; | 1322 $('cancel-add-user-button').disabled = false; |
| 1318 }, | 1323 }, |
| 1319 | 1324 |
| 1320 /** | 1325 /** |
| 1321 * Called by backend part to propagate list of possible managers. | 1326 * Called by backend part to propagate list of possible managers. |
| 1322 * @param {Array} userList - list of users that can be managers. | 1327 * @param {Array} userList - list of users that can be managers. |
| 1323 */ | 1328 */ |
| 1324 loadManagers: function(userList) { | 1329 loadManagers: function(userList) { |
| 1325 $('managed-user-creation-managers-block').hidden = false; | 1330 $('supervised-user-creation-managers-block').hidden = false; |
| 1326 this.managerList_.clearPods(); | 1331 this.managerList_.clearPods(); |
| 1327 for (var i = 0; i < userList.length; ++i) | 1332 for (var i = 0; i < userList.length; ++i) |
| 1328 this.managerList_.addPod(userList[i]); | 1333 this.managerList_.addPod(userList[i]); |
| 1329 if (userList.length > 0) | 1334 if (userList.length > 0) |
| 1330 this.managerList_.selectPod(this.managerList_.pods[0]); | 1335 this.managerList_.selectPod(this.managerList_.pods[0]); |
| 1331 }, | 1336 }, |
| 1332 | 1337 |
| 1333 /** | 1338 /** |
| 1334 * Cancels user creation and drops to user screen (either sign). | 1339 * Cancels user creation and drops to user screen (either sign). |
| 1335 */ | 1340 */ |
| 1336 cancel: function() { | 1341 cancel: function() { |
| 1337 var notSignedInPages = ['intro', 'manager']; | 1342 var notSignedInPages = ['intro', 'manager']; |
| 1338 var postCreationPages = ['created']; | 1343 var postCreationPages = ['created']; |
| 1339 if (notSignedInPages.indexOf(this.currentPage_) >= 0) { | 1344 if (notSignedInPages.indexOf(this.currentPage_) >= 0) { |
| 1340 // Make sure no manager password is kept: | 1345 // Make sure no manager password is kept: |
| 1341 this.managerList_.clearPods(); | 1346 this.managerList_.clearPods(); |
| 1342 | 1347 |
| 1343 $('pod-row').loadLastWallpaper(); | 1348 $('pod-row').loadLastWallpaper(); |
| 1344 | 1349 |
| 1345 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER}); | 1350 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER}); |
| 1346 Oobe.resetSigninUI(true); | 1351 Oobe.resetSigninUI(true); |
| 1347 return; | 1352 return; |
| 1348 } | 1353 } |
| 1349 if (postCreationPages.indexOf(this.currentPage_) >= 0) { | 1354 if (postCreationPages.indexOf(this.currentPage_) >= 0) { |
| 1350 chrome.send('finishLocalManagedUserCreation'); | 1355 chrome.send('finishLocalSupervisedUserCreation'); |
| 1351 return; | 1356 return; |
| 1352 } | 1357 } |
| 1353 chrome.send('abortLocalManagedUserCreation'); | 1358 chrome.send('abortLocalSupervisedUserCreation'); |
| 1354 }, | 1359 }, |
| 1355 | 1360 |
| 1356 updateText_: function() { | 1361 updateText_: function() { |
| 1357 var managerDisplayId = this.context_.managerDisplayId; | 1362 var managerDisplayId = this.context_.managerDisplayId; |
| 1358 this.updateElementText_('intro-alternate-text', | 1363 this.updateElementText_('intro-alternate-text', |
| 1359 'createManagedUserIntroAlternateText'); | 1364 'createSupervisedUserIntroAlternateText'); |
| 1360 this.updateElementText_('created-text-1', | 1365 this.updateElementText_('created-text-1', |
| 1361 'createManagedUserCreatedText1', | 1366 'createSupervisedUserCreatedText1', |
| 1362 this.context_.managedName); | 1367 this.context_.supervisedName); |
| 1363 // TODO(antrim): Move wrapping with strong in grd file, and eliminate this | 1368 // TODO(antrim): Move wrapping with strong in grd file, and eliminate this |
| 1364 //call. | 1369 //call. |
| 1365 this.updateElementText_('created-text-2', | 1370 this.updateElementText_('created-text-2', |
| 1366 'createManagedUserCreatedText2', | 1371 'createSupervisedUserCreatedText2', |
| 1367 this.wrapStrong( | 1372 this.wrapStrong( |
| 1368 loadTimeData.getString('managementURL')), | 1373 loadTimeData.getString('managementURL')), |
| 1369 this.context_.managedName); | 1374 this.context_.supervisedName); |
| 1370 this.updateElementText_('created-text-3', | 1375 this.updateElementText_('created-text-3', |
| 1371 'createManagedUserCreatedText3', | 1376 'createSupervisedUserCreatedText3', |
| 1372 managerDisplayId); | 1377 managerDisplayId); |
| 1373 this.updateElementText_('name-explanation', | 1378 this.updateElementText_('name-explanation', |
| 1374 'createManagedUserNameExplanation', | 1379 'createSupervisedUserNameExplanation', |
| 1375 managerDisplayId); | 1380 managerDisplayId); |
| 1376 }, | 1381 }, |
| 1377 | 1382 |
| 1378 wrapStrong: function(original) { | 1383 wrapStrong: function(original) { |
| 1379 if (original == undefined) | 1384 if (original == undefined) |
| 1380 return original; | 1385 return original; |
| 1381 return '<strong>' + original + '</strong>'; | 1386 return '<strong>' + original + '</strong>'; |
| 1382 }, | 1387 }, |
| 1383 | 1388 |
| 1384 updateElementText_: function(localId, templateName) { | 1389 updateElementText_: function(localId, templateName) { |
| 1385 var args = Array.prototype.slice.call(arguments); | 1390 var args = Array.prototype.slice.call(arguments); |
| 1386 args.shift(); | 1391 args.shift(); |
| 1387 this.getScreenElement(localId).innerHTML = | 1392 this.getScreenElement(localId).innerHTML = |
| 1388 loadTimeData.getStringF.apply(loadTimeData, args); | 1393 loadTimeData.getStringF.apply(loadTimeData, args); |
| 1389 }, | 1394 }, |
| 1390 | 1395 |
| 1391 showIntroPage: function() { | 1396 showIntroPage: function() { |
| 1392 $('managed-user-creation-password').value = ''; | 1397 $('supervised-user-creation-password').value = ''; |
| 1393 $('managed-user-creation-password-confirm').value = ''; | 1398 $('supervised-user-creation-password-confirm').value = ''; |
| 1394 $('managed-user-creation-name').value = ''; | 1399 $('supervised-user-creation-name').value = ''; |
| 1395 | 1400 |
| 1396 this.lastVerifiedName_ = null; | 1401 this.lastVerifiedName_ = null; |
| 1397 this.lastIncorrectUserName_ = null; | 1402 this.lastIncorrectUserName_ = null; |
| 1398 this.passwordErrorVisible = false; | 1403 this.passwordErrorVisible = false; |
| 1399 $('managed-user-creation-password').classList.remove('password-error'); | 1404 $('supervised-user-creation-password').classList.remove('password-error'); |
| 1400 this.nameErrorVisible = false; | 1405 this.nameErrorVisible = false; |
| 1401 | 1406 |
| 1402 this.setVisiblePage_('intro'); | 1407 this.setVisiblePage_('intro'); |
| 1403 }, | 1408 }, |
| 1404 | 1409 |
| 1405 showManagerPage: function() { | 1410 showManagerPage: function() { |
| 1406 this.setVisiblePage_('manager'); | 1411 this.setVisiblePage_('manager'); |
| 1407 }, | 1412 }, |
| 1408 | 1413 |
| 1409 showUsernamePage: function() { | 1414 showUsernamePage: function() { |
| 1410 this.setVisiblePage_('username'); | 1415 this.setVisiblePage_('username'); |
| 1411 }, | 1416 }, |
| 1412 | 1417 |
| 1413 showTutorialPage: function() { | 1418 showTutorialPage: function() { |
| 1414 this.setVisiblePage_('created'); | 1419 this.setVisiblePage_('created'); |
| 1415 }, | 1420 }, |
| 1416 | 1421 |
| 1417 showPage: function(page) { | 1422 showPage: function(page) { |
| 1418 this.setVisiblePage_(page); | 1423 this.setVisiblePage_(page); |
| 1419 }, | 1424 }, |
| 1420 | 1425 |
| 1421 showErrorPage: function(errorTitle, errorText, errorButtonText) { | 1426 showErrorPage: function(errorTitle, errorText, errorButtonText) { |
| 1422 this.disabled = false; | 1427 this.disabled = false; |
| 1423 $('managed-user-creation-error-title').innerHTML = errorTitle; | 1428 $('supervised-user-creation-error-title').innerHTML = errorTitle; |
| 1424 $('managed-user-creation-error-text').innerHTML = errorText; | 1429 $('supervised-user-creation-error-text').innerHTML = errorText; |
| 1425 $('managed-user-creation-error-button').textContent = errorButtonText; | 1430 $('supervised-user-creation-error-button').textContent = errorButtonText; |
| 1426 this.setVisiblePage_('error'); | 1431 this.setVisiblePage_('error'); |
| 1427 }, | 1432 }, |
| 1428 | 1433 |
| 1429 showManagerPasswordError: function() { | 1434 showManagerPasswordError: function() { |
| 1430 this.disabled = false; | 1435 this.disabled = false; |
| 1431 this.showSelectedManagerPasswordError_(); | 1436 this.showSelectedManagerPasswordError_(); |
| 1432 }, | 1437 }, |
| 1433 | 1438 |
| 1434 /* | 1439 /* |
| 1435 TODO(antrim) : this is an explicit code duplications with UserImageScreen. | 1440 TODO(antrim) : this is an explicit code duplications with UserImageScreen. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1466 | 1471 |
| 1467 /** | 1472 /** |
| 1468 * Handles selection change. | 1473 * Handles selection change. |
| 1469 * @param {Event} e Selection change event. | 1474 * @param {Event} e Selection change event. |
| 1470 * @private | 1475 * @private |
| 1471 */ | 1476 */ |
| 1472 handleSelect_: function(e) { | 1477 handleSelect_: function(e) { |
| 1473 var imageGrid = this.getScreenElement('image-grid'); | 1478 var imageGrid = this.getScreenElement('image-grid'); |
| 1474 this.updateNextButtonForUser_(); | 1479 this.updateNextButtonForUser_(); |
| 1475 | 1480 |
| 1476 $('managed-user-creation-flip-photo').tabIndex = | 1481 $('supervised-user-creation-flip-photo').tabIndex = |
| 1477 (imageGrid.selectionType == 'camera') ? 0 : -1; | 1482 (imageGrid.selectionType == 'camera') ? 0 : -1; |
| 1478 if (imageGrid.cameraLive || imageGrid.selectionType != 'camera') | 1483 if (imageGrid.cameraLive || imageGrid.selectionType != 'camera') |
| 1479 imageGrid.previewElement.classList.remove('phototaken'); | 1484 imageGrid.previewElement.classList.remove('phototaken'); |
| 1480 else | 1485 else |
| 1481 imageGrid.previewElement.classList.add('phototaken'); | 1486 imageGrid.previewElement.classList.add('phototaken'); |
| 1482 | 1487 |
| 1483 if (!imageGrid.cameraLive || imageGrid.selectionType != 'camera') { | 1488 if (!imageGrid.cameraLive || imageGrid.selectionType != 'camera') { |
| 1484 this.context_.selectedImageUrl = imageGrid.selectedItemUrl; | 1489 this.context_.selectedImageUrl = imageGrid.selectedItemUrl; |
| 1485 chrome.send('supervisedUserSelectImage', | 1490 chrome.send('supervisedUserSelectImage', |
| 1486 [imageGrid.selectedItemUrl, imageGrid.selectionType]); | 1491 [imageGrid.selectedItemUrl, imageGrid.selectionType]); |
| 1487 } | 1492 } |
| 1488 // Start/stop camera on (de)selection. | 1493 // Start/stop camera on (de)selection. |
| 1489 if (!imageGrid.inProgramSelection && | 1494 if (!imageGrid.inProgramSelection && |
| 1490 imageGrid.selectionType != e.oldSelectionType) { | 1495 imageGrid.selectionType != e.oldSelectionType) { |
| 1491 if (imageGrid.selectionType == 'camera') { | 1496 if (imageGrid.selectionType == 'camera') { |
| 1492 // Programmatic selection of camera item is done in | 1497 // Programmatic selection of camera item is done in |
| 1493 // startCamera callback where streaming is started by itself. | 1498 // startCamera callback where streaming is started by itself. |
| 1494 imageGrid.startCamera( | 1499 imageGrid.startCamera( |
| 1495 function() { | 1500 function() { |
| 1496 // Start capture if camera is still the selected item. | 1501 // Start capture if camera is still the selected item. |
| 1497 $('managed-user-creation-image-preview-img').classList.toggle( | 1502 $('supervised-user-creation-image-preview-img').classList. |
| 1498 'animated-transform', true); | 1503 toggle('animated-transform', true); |
| 1499 return imageGrid.selectedItem == imageGrid.cameraImage; | 1504 return imageGrid.selectedItem == imageGrid.cameraImage; |
| 1500 }); | 1505 }); |
| 1501 } else { | 1506 } else { |
| 1502 $('managed-user-creation-image-preview-img').classList.toggle( | 1507 $('supervised-user-creation-image-preview-img').classList.toggle( |
| 1503 'animated-transform', false); | 1508 'animated-transform', false); |
| 1504 imageGrid.stopCamera(); | 1509 imageGrid.stopCamera(); |
| 1505 } | 1510 } |
| 1506 } | 1511 } |
| 1507 }, | 1512 }, |
| 1508 | 1513 |
| 1509 /** | 1514 /** |
| 1510 * Handle camera-photo flip. | 1515 * Handle camera-photo flip. |
| 1511 */ | 1516 */ |
| 1512 handleFlipPhoto_: function() { | 1517 handleFlipPhoto_: function() { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1548 imageGrid.discardPhoto(); | 1553 imageGrid.discardPhoto(); |
| 1549 chrome.send('supervisedUserDiscardPhoto'); | 1554 chrome.send('supervisedUserDiscardPhoto'); |
| 1550 announceAccessibleMessage( | 1555 announceAccessibleMessage( |
| 1551 loadTimeData.getString('photoDiscardAccessibleText')); | 1556 loadTimeData.getString('photoDiscardAccessibleText')); |
| 1552 }, | 1557 }, |
| 1553 | 1558 |
| 1554 setCameraPresent: function(present) { | 1559 setCameraPresent: function(present) { |
| 1555 this.getScreenElement('image-grid').cameraPresent = present; | 1560 this.getScreenElement('image-grid').cameraPresent = present; |
| 1556 }, | 1561 }, |
| 1557 | 1562 |
| 1558 setExistingManagedUsers: function(users) { | 1563 setExistingSupervisedUsers: function(users) { |
| 1559 var selectedUser = null; | 1564 var selectedUser = null; |
| 1560 // Store selected user | 1565 // Store selected user |
| 1561 if (this.importList_.selectedPod) | 1566 if (this.importList_.selectedPod) |
| 1562 selectedUser = this.importList_.selectedPod.user.id; | 1567 selectedUser = this.importList_.selectedPod.user.id; |
| 1563 | 1568 |
| 1564 var userList = users; | 1569 var userList = users; |
| 1565 userList.sort(function(a, b) { | 1570 userList.sort(function(a, b) { |
| 1566 // Put existing users last. | 1571 // Put existing users last. |
| 1567 if (a.exists != b.exists) | 1572 if (a.exists != b.exists) |
| 1568 return a.exists ? 1 : -1; | 1573 return a.exists ? 1 : -1; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1583 | 1588 |
| 1584 if (selectedIndex >= 0) | 1589 if (selectedIndex >= 0) |
| 1585 this.importList_.selectPod(this.importList_.pods[selectedIndex]); | 1590 this.importList_.selectPod(this.importList_.pods[selectedIndex]); |
| 1586 | 1591 |
| 1587 if (this.currentPage_ == 'username') | 1592 if (this.currentPage_ == 'username') |
| 1588 this.getScreenElement('import-link').hidden = (userList.length == 0); | 1593 this.getScreenElement('import-link').hidden = (userList.length == 0); |
| 1589 }, | 1594 }, |
| 1590 }; | 1595 }; |
| 1591 }); | 1596 }); |
| 1592 | 1597 |
| OLD | NEW |