| OLD | NEW |
| 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 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 * ManageProfileOverlay class | 10 * ManageProfileOverlay class |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 CreateProfileOverlay.cancelCreateProfile(); | 64 CreateProfileOverlay.cancelCreateProfile(); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 $('manage-profile-cancel').onclick = | 67 $('manage-profile-cancel').onclick = |
| 68 $('disconnect-managed-profile-cancel').onclick = | 68 $('disconnect-managed-profile-cancel').onclick = |
| 69 $('delete-profile-cancel').onclick = function(event) { | 69 $('delete-profile-cancel').onclick = function(event) { |
| 70 OptionsPage.closeOverlay(); | 70 OptionsPage.closeOverlay(); |
| 71 }; | 71 }; |
| 72 $('delete-profile-ok').onclick = function(event) { | 72 $('delete-profile-ok').onclick = function(event) { |
| 73 OptionsPage.closeOverlay(); | 73 OptionsPage.closeOverlay(); |
| 74 if (BrowserOptions.getCurrentProfile().isManaged) | 74 if (BrowserOptions.getCurrentProfile().isSupervised) |
| 75 return; | 75 return; |
| 76 chrome.send('deleteProfile', [self.profileInfo_.filePath]); | 76 chrome.send('deleteProfile', [self.profileInfo_.filePath]); |
| 77 options.ManagedUserListData.resetPromise(); | 77 options.SupervisedUserListData.resetPromise(); |
| 78 }; | 78 }; |
| 79 $('add-shortcut-button').onclick = function(event) { | 79 $('add-shortcut-button').onclick = function(event) { |
| 80 chrome.send('addProfileShortcut', [self.profileInfo_.filePath]); | 80 chrome.send('addProfileShortcut', [self.profileInfo_.filePath]); |
| 81 }; | 81 }; |
| 82 $('remove-shortcut-button').onclick = function(event) { | 82 $('remove-shortcut-button').onclick = function(event) { |
| 83 chrome.send('removeProfileShortcut', [self.profileInfo_.filePath]); | 83 chrome.send('removeProfileShortcut', [self.profileInfo_.filePath]); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 $('disconnect-managed-profile-ok').onclick = function(event) { | 86 $('disconnect-managed-profile-ok').onclick = function(event) { |
| 87 OptionsPage.closeOverlay(); | 87 OptionsPage.closeOverlay(); |
| 88 chrome.send('deleteProfile', | 88 chrome.send('deleteProfile', |
| 89 [BrowserOptions.getCurrentProfile().filePath]); | 89 [BrowserOptions.getCurrentProfile().filePath]); |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 $('create-profile-managed-signed-in-learn-more-link').onclick = | 92 $('create-profile-supervised-signed-in-learn-more-link').onclick = |
| 93 function(event) { | 93 function(event) { |
| 94 OptionsPage.navigateToPage('managedUserLearnMore'); | 94 OptionsPage.navigateToPage('supervisedUserLearnMore'); |
| 95 return false; | 95 return false; |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 $('create-profile-managed-not-signed-in-link').onclick = function(event) { | 98 $('create-profile-supervised-not-signed-in-link').onclick = |
| 99 function(event) { |
| 99 // The signin process will open an overlay to configure sync, which | 100 // The signin process will open an overlay to configure sync, which |
| 100 // would replace this overlay. It's smoother to close this one now. | 101 // would replace this overlay. It's smoother to close this one now. |
| 101 // TODO(pamg): Move the sync-setup overlay to a higher layer so this one | 102 // TODO(pamg): Move the sync-setup overlay to a higher layer so this one |
| 102 // can stay open under it, after making sure that doesn't break anything | 103 // can stay open under it, after making sure that doesn't break anything |
| 103 // else. | 104 // else. |
| 104 OptionsPage.closeOverlay(); | 105 OptionsPage.closeOverlay(); |
| 105 SyncSetupOverlay.startSignIn(); | 106 SyncSetupOverlay.startSignIn(); |
| 106 }; | 107 }; |
| 107 | 108 |
| 108 $('create-profile-managed-sign-in-again-link').onclick = function(event) { | 109 $('create-profile-supervised-sign-in-again-link').onclick = |
| 110 function(event) { |
| 109 OptionsPage.closeOverlay(); | 111 OptionsPage.closeOverlay(); |
| 110 SyncSetupOverlay.showSetupUI(); | 112 SyncSetupOverlay.showSetupUI(); |
| 111 }; | 113 }; |
| 112 | 114 |
| 113 $('import-existing-managed-user-link').onclick = function(event) { | 115 $('import-existing-supervised-user-link').onclick = function(event) { |
| 114 // Hide the import button to trigger a cursor update. The import button | 116 // Hide the import button to trigger a cursor update. The import button |
| 115 // is shown again when the import overlay loads. TODO(akuegel): Remove | 117 // is shown again when the import overlay loads. TODO(akuegel): Remove |
| 116 // this temporary fix when crbug/246304 is resolved. | 118 // this temporary fix when crbug/246304 is resolved. |
| 117 $('import-existing-managed-user-link').hidden = true; | 119 $('import-existing-supervised-user-link').hidden = true; |
| 118 OptionsPage.navigateToPage('managedUserImport'); | 120 OptionsPage.navigateToPage('supervisedUserImport'); |
| 119 }; | 121 }; |
| 120 }, | 122 }, |
| 121 | 123 |
| 122 /** @override */ | 124 /** @override */ |
| 123 didShowPage: function() { | 125 didShowPage: function() { |
| 124 chrome.send('requestDefaultProfileIcons', ['manage']); | 126 chrome.send('requestDefaultProfileIcons', ['manage']); |
| 125 | 127 |
| 126 // Just ignore the manage profile dialog on Chrome OS, they use /accounts. | 128 // Just ignore the manage profile dialog on Chrome OS, they use /accounts. |
| 127 if (!cr.isChromeOS && window.location.pathname == '/manageProfile') | 129 if (!cr.isChromeOS && window.location.pathname == '/manageProfile') |
| 128 ManageProfileOverlay.getInstance().prepareForManageDialog_(); | 130 ManageProfileOverlay.getInstance().prepareForManageDialog_(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 }, | 173 }, |
| 172 | 174 |
| 173 /** | 175 /** |
| 174 * Set the profile info used in the dialog. | 176 * Set the profile info used in the dialog. |
| 175 * @param {Object} profileInfo An object of the form: | 177 * @param {Object} profileInfo An object of the form: |
| 176 * profileInfo = { | 178 * profileInfo = { |
| 177 * name: "Profile Name", | 179 * name: "Profile Name", |
| 178 * iconURL: "chrome://path/to/icon/image", | 180 * iconURL: "chrome://path/to/icon/image", |
| 179 * filePath: "/path/to/profile/data/on/disk", | 181 * filePath: "/path/to/profile/data/on/disk", |
| 180 * isCurrentProfile: false, | 182 * isCurrentProfile: false, |
| 181 * isManaged: false | 183 * isSupervised: false |
| 182 * }; | 184 * }; |
| 183 * @param {string} mode A label that specifies the type of dialog box which | 185 * @param {string} mode A label that specifies the type of dialog box which |
| 184 * is currently being viewed (i.e. 'create' or 'manage'). | 186 * is currently being viewed (i.e. 'create' or 'manage'). |
| 185 * @private | 187 * @private |
| 186 */ | 188 */ |
| 187 setProfileInfo_: function(profileInfo, mode) { | 189 setProfileInfo_: function(profileInfo, mode) { |
| 188 this.iconGridSelectedURL_ = profileInfo.iconURL; | 190 this.iconGridSelectedURL_ = profileInfo.iconURL; |
| 189 this.profileInfo_ = profileInfo; | 191 this.profileInfo_ = profileInfo; |
| 190 $(mode + '-profile-name').value = profileInfo.name; | 192 $(mode + '-profile-name').value = profileInfo.name; |
| 191 $(mode + '-profile-icon-grid').selectedItem = profileInfo.iconURL; | 193 $(mode + '-profile-icon-grid').selectedItem = profileInfo.iconURL; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 * @param {string} mode A label that specifies the type of dialog box which | 318 * @param {string} mode A label that specifies the type of dialog box which |
| 317 * is currently being viewed (i.e. 'create' or 'manage'). | 319 * is currently being viewed (i.e. 'create' or 'manage'). |
| 318 * @private | 320 * @private |
| 319 */ | 321 */ |
| 320 onNameChanged_: function(mode) { | 322 onNameChanged_: function(mode) { |
| 321 this.profileNameIsDefault_ = false; | 323 this.profileNameIsDefault_ = false; |
| 322 this.updateCreateOrImport_(mode); | 324 this.updateCreateOrImport_(mode); |
| 323 }, | 325 }, |
| 324 | 326 |
| 325 /** | 327 /** |
| 326 * Called when the profile name is changed or the 'create managed' checkbox | 328 * Called when the profile name is changed or the 'create supervised' |
| 327 * is toggled. Updates the 'ok' button and the 'import existing supervised | 329 * checkbox is toggled. Updates the 'ok' button and the 'import existing |
| 328 * user' link. | 330 * supervised user' link. |
| 329 * @param {string} mode A label that specifies the type of dialog box which | 331 * @param {string} mode A label that specifies the type of dialog box which |
| 330 * is currently being viewed (i.e. 'create' or 'manage'). | 332 * is currently being viewed (i.e. 'create' or 'manage'). |
| 331 * @private | 333 * @private |
| 332 */ | 334 */ |
| 333 updateCreateOrImport_: function(mode) { | 335 updateCreateOrImport_: function(mode) { |
| 334 // In 'create' mode, check for existing managed users with the same name. | 336 // In 'create' mode, check for existing supervised users with the same |
| 335 if (mode == 'create' && $('create-profile-managed').checked) { | 337 // name. |
| 336 options.ManagedUserListData.requestExistingManagedUsers().then( | 338 if (mode == 'create' && $('create-profile-supervised').checked) { |
| 337 this.receiveExistingManagedUsers_.bind(this), | 339 options.SupervisedUserListData.requestExistingSupervisedUsers().then( |
| 340 this.receiveExistingSupervisedUsers_.bind(this), |
| 338 this.onSigninError_.bind(this)); | 341 this.onSigninError_.bind(this)); |
| 339 } else { | 342 } else { |
| 340 this.updateOkButton_(mode); | 343 this.updateOkButton_(mode); |
| 341 } | 344 } |
| 342 }, | 345 }, |
| 343 | 346 |
| 344 /** | 347 /** |
| 345 * Callback which receives the list of existing managed users. Checks if the | 348 * Callback which receives the list of existing supervised users. Checks if |
| 346 * currently entered name is the name of an already existing managed user. | 349 * the currently entered name is the name of an already existing supervised |
| 347 * If yes, the user is prompted to import the existing managed user, and the | 350 * user. If yes, the user is prompted to import the existing supervised |
| 348 * create button is disabled. | 351 * user, and the create button is disabled. |
| 349 * @param {Array.<Object>} The list of existing managed users. | 352 * @param {Array.<Object>} The list of existing supervised users. |
| 350 * @private | 353 * @private |
| 351 */ | 354 */ |
| 352 receiveExistingManagedUsers_: function(managedUsers) { | 355 receiveExistingSupervisedUsers_: function(supervisedUsers) { |
| 353 var newName = $('create-profile-name').value; | 356 var newName = $('create-profile-name').value; |
| 354 var i; | 357 var i; |
| 355 for (i = 0; i < managedUsers.length; ++i) { | 358 for (i = 0; i < supervisedUsers.length; ++i) { |
| 356 if (managedUsers[i].name == newName && | 359 if (supervisedUsers[i].name == newName && |
| 357 !managedUsers[i].onCurrentDevice) { | 360 !supervisedUsers[i].onCurrentDevice) { |
| 358 var errorHtml = loadTimeData.getStringF( | 361 var errorHtml = loadTimeData.getStringF( |
| 359 'manageProfilesExistingSupervisedUser', | 362 'manageProfilesExistingSupervisedUser', |
| 360 HTMLEscape(elide(newName, /* maxLength */ 50))); | 363 HTMLEscape(elide(newName, /* maxLength */ 50))); |
| 361 this.showErrorBubble_(errorHtml, 'create', true); | 364 this.showErrorBubble_(errorHtml, 'create', true); |
| 362 | 365 |
| 363 // Check if another supervised user also exists with that name. | 366 // Check if another supervised user also exists with that name. |
| 364 var nameIsUnique = true; | 367 var nameIsUnique = true; |
| 365 var j; | 368 var j; |
| 366 for (j = i + 1; j < managedUsers.length; ++j) { | 369 for (j = i + 1; j < supervisedUsers.length; ++j) { |
| 367 if (managedUsers[j].name == newName) { | 370 if (supervisedUsers[j].name == newName) { |
| 368 nameIsUnique = false; | 371 nameIsUnique = false; |
| 369 break; | 372 break; |
| 370 } | 373 } |
| 371 } | 374 } |
| 372 var self = this; | 375 var self = this; |
| 373 function getImportHandler(managedUser, nameIsUnique) { | 376 function getImportHandler(supervisedUser, nameIsUnique) { |
| 374 return function() { | 377 return function() { |
| 375 if (managedUser.needAvatar || !nameIsUnique) { | 378 if (supervisedUser.needAvatar || !nameIsUnique) { |
| 376 OptionsPage.navigateToPage('managedUserImport'); | 379 OptionsPage.navigateToPage('supervisedUserImport'); |
| 377 } else { | 380 } else { |
| 378 self.hideErrorBubble_('create'); | 381 self.hideErrorBubble_('create'); |
| 379 CreateProfileOverlay.updateCreateInProgress(true); | 382 CreateProfileOverlay.updateCreateInProgress(true); |
| 380 chrome.send('createProfile', | 383 chrome.send('createProfile', |
| 381 [managedUser.name, managedUser.iconURL, false, true, | 384 [supervisedUser.name, supervisedUser.iconURL, false, true, |
| 382 managedUser.id]); | 385 supervisedUser.id]); |
| 383 } | 386 } |
| 384 } | 387 } |
| 385 }; | 388 }; |
| 386 $('supervised-user-import').onclick = | 389 $('supervised-user-import-existing').onclick = |
| 387 getImportHandler(managedUsers[i], nameIsUnique); | 390 getImportHandler(supervisedUsers[i], nameIsUnique); |
| 388 $('create-profile-ok').disabled = true; | 391 $('create-profile-ok').disabled = true; |
| 389 return; | 392 return; |
| 390 } | 393 } |
| 391 } | 394 } |
| 392 this.updateOkButton_('create'); | 395 this.updateOkButton_('create'); |
| 393 }, | 396 }, |
| 394 | 397 |
| 395 /** | 398 /** |
| 396 * Called in case the request for the list of managed users fails because of | 399 * Called in case the request for the list of supervised users fails because |
| 397 * a signin error. | 400 * of a signin error. |
| 398 * @private | 401 * @private |
| 399 */ | 402 */ |
| 400 onSigninError_: function() { | 403 onSigninError_: function() { |
| 401 this.updateImportExistingManagedUserLink_(false); | 404 this.updateImportExistingSupervisedUserLink_(false); |
| 402 }, | 405 }, |
| 403 | 406 |
| 404 /** | 407 /** |
| 405 * Called to update the state of the ok button depending if the name is | 408 * Called to update the state of the ok button depending if the name is |
| 406 * already used or not. | 409 * already used or not. |
| 407 * @param {string} mode A label that specifies the type of dialog box which | 410 * @param {string} mode A label that specifies the type of dialog box which |
| 408 * is currently being viewed (i.e. 'create' or 'manage'). | 411 * is currently being viewed (i.e. 'create' or 'manage'). |
| 409 * @private | 412 * @private |
| 410 */ | 413 */ |
| 411 updateOkButton_: function(mode) { | 414 updateOkButton_: function(mode) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 431 * profile info. | 434 * profile info. |
| 432 * @private | 435 * @private |
| 433 */ | 436 */ |
| 434 submitManageChanges_: function() { | 437 submitManageChanges_: function() { |
| 435 var name = $('manage-profile-name').value; | 438 var name = $('manage-profile-name').value; |
| 436 var iconURL = $('manage-profile-icon-grid').selectedItem; | 439 var iconURL = $('manage-profile-icon-grid').selectedItem; |
| 437 | 440 |
| 438 chrome.send('setProfileIconAndName', | 441 chrome.send('setProfileIconAndName', |
| 439 [this.profileInfo_.filePath, iconURL, name]); | 442 [this.profileInfo_.filePath, iconURL, name]); |
| 440 if (name != this.profileInfo_.name) | 443 if (name != this.profileInfo_.name) |
| 441 options.ManagedUserListData.resetPromise(); | 444 options.SupervisedUserListData.resetPromise(); |
| 442 }, | 445 }, |
| 443 | 446 |
| 444 /** | 447 /** |
| 445 * Called when the user clicks "OK" or hits enter. Creates the profile | 448 * Called when the user clicks "OK" or hits enter. Creates the profile |
| 446 * using the information in the dialog. | 449 * using the information in the dialog. |
| 447 * @private | 450 * @private |
| 448 */ | 451 */ |
| 449 submitCreateProfile_: function() { | 452 submitCreateProfile_: function() { |
| 450 // This is visual polish: the UI to access this should be disabled for | 453 // This is visual polish: the UI to access this should be disabled for |
| 451 // managed users, and the back end will prevent user creation anyway. | 454 // supervised users, and the back end will prevent user creation anyway. |
| 452 if (this.profileInfo_ && this.profileInfo_.isManaged) | 455 if (this.profileInfo_ && this.profileInfo_.isSupervised) |
| 453 return; | 456 return; |
| 454 | 457 |
| 455 this.hideErrorBubble_('create'); | 458 this.hideErrorBubble_('create'); |
| 456 CreateProfileOverlay.updateCreateInProgress(true); | 459 CreateProfileOverlay.updateCreateInProgress(true); |
| 457 | 460 |
| 458 // Get the user's chosen name and icon, or default if they do not | 461 // Get the user's chosen name and icon, or default if they do not |
| 459 // wish to customize their profile. | 462 // wish to customize their profile. |
| 460 var name = $('create-profile-name').value; | 463 var name = $('create-profile-name').value; |
| 461 var iconUrl = $('create-profile-icon-grid').selectedItem; | 464 var iconUrl = $('create-profile-icon-grid').selectedItem; |
| 462 var createShortcut = $('create-shortcut').checked; | 465 var createShortcut = $('create-shortcut').checked; |
| 463 var isManaged = $('create-profile-managed').checked; | 466 var isSupervised = $('create-profile-supervised').checked; |
| 464 var existingManagedUserId = ''; | 467 var existingSupervisedUserId = ''; |
| 465 | 468 |
| 466 // 'createProfile' is handled by the CreateProfileHandler. | 469 // 'createProfile' is handled by the CreateProfileHandler. |
| 467 chrome.send('createProfile', | 470 chrome.send('createProfile', |
| 468 [name, iconUrl, createShortcut, | 471 [name, iconUrl, createShortcut, |
| 469 isManaged, existingManagedUserId]); | 472 isSupervised, existingSupervisedUserId]); |
| 470 }, | 473 }, |
| 471 | 474 |
| 472 /** | 475 /** |
| 473 * Called when the selected icon in the icon grid changes. | 476 * Called when the selected icon in the icon grid changes. |
| 474 * @param {string} mode A label that specifies the type of dialog box which | 477 * @param {string} mode A label that specifies the type of dialog box which |
| 475 * is currently being viewed (i.e. 'create' or 'manage'). | 478 * is currently being viewed (i.e. 'create' or 'manage'). |
| 476 * @private | 479 * @private |
| 477 */ | 480 */ |
| 478 onIconGridSelectionChanged_: function(mode) { | 481 onIconGridSelectionChanged_: function(mode) { |
| 479 var iconURL = $(mode + '-profile-icon-grid').selectedItem; | 482 var iconURL = $(mode + '-profile-icon-grid').selectedItem; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 499 * @private | 502 * @private |
| 500 */ | 503 */ |
| 501 prepareForManageDialog_: function() { | 504 prepareForManageDialog_: function() { |
| 502 chrome.send('refreshGaiaPicture'); | 505 chrome.send('refreshGaiaPicture'); |
| 503 var profileInfo = BrowserOptions.getCurrentProfile(); | 506 var profileInfo = BrowserOptions.getCurrentProfile(); |
| 504 ManageProfileOverlay.setProfileInfo(profileInfo, 'manage'); | 507 ManageProfileOverlay.setProfileInfo(profileInfo, 'manage'); |
| 505 $('manage-profile-overlay-create').hidden = true; | 508 $('manage-profile-overlay-create').hidden = true; |
| 506 $('manage-profile-overlay-manage').hidden = false; | 509 $('manage-profile-overlay-manage').hidden = false; |
| 507 $('manage-profile-overlay-delete').hidden = true; | 510 $('manage-profile-overlay-delete').hidden = true; |
| 508 $('manage-profile-overlay-disconnect-managed').hidden = true; | 511 $('manage-profile-overlay-disconnect-managed').hidden = true; |
| 509 $('manage-profile-name').disabled = profileInfo.isManaged; | 512 $('manage-profile-name').disabled = profileInfo.isSupervised; |
| 510 this.hideErrorBubble_('manage'); | 513 this.hideErrorBubble_('manage'); |
| 511 }, | 514 }, |
| 512 | 515 |
| 513 /** | 516 /** |
| 514 * Display the "Manage Profile" dialog. | 517 * Display the "Manage Profile" dialog. |
| 515 * @private | 518 * @private |
| 516 */ | 519 */ |
| 517 showManageDialog_: function() { | 520 showManageDialog_: function() { |
| 518 this.prepareForManageDialog_(); | 521 this.prepareForManageDialog_(); |
| 519 OptionsPage.navigateToPage('manageProfile'); | 522 OptionsPage.navigateToPage('manageProfile'); |
| 520 }, | 523 }, |
| 521 | 524 |
| 522 /** | 525 /** |
| 523 * Display the "Delete Profile" dialog. | 526 * Display the "Delete Profile" dialog. |
| 524 * @param {Object} profileInfo The profile object of the profile to delete. | 527 * @param {Object} profileInfo The profile object of the profile to delete. |
| 525 * @private | 528 * @private |
| 526 */ | 529 */ |
| 527 showDeleteDialog_: function(profileInfo) { | 530 showDeleteDialog_: function(profileInfo) { |
| 528 if (BrowserOptions.getCurrentProfile().isManaged) | 531 if (BrowserOptions.getCurrentProfile().isSupervised) |
| 529 return; | 532 return; |
| 530 | 533 |
| 531 ManageProfileOverlay.setProfileInfo(profileInfo, 'manage'); | 534 ManageProfileOverlay.setProfileInfo(profileInfo, 'manage'); |
| 532 $('manage-profile-overlay-create').hidden = true; | 535 $('manage-profile-overlay-create').hidden = true; |
| 533 $('manage-profile-overlay-manage').hidden = true; | 536 $('manage-profile-overlay-manage').hidden = true; |
| 534 $('manage-profile-overlay-delete').hidden = false; | 537 $('manage-profile-overlay-delete').hidden = false; |
| 535 $('manage-profile-overlay-disconnect-managed').hidden = true; | 538 $('manage-profile-overlay-disconnect-managed').hidden = true; |
| 536 $('delete-profile-icon').style.content = | 539 $('delete-profile-icon').style.content = |
| 537 getProfileAvatarIcon(profileInfo.iconURL); | 540 getProfileAvatarIcon(profileInfo.iconURL); |
| 538 $('delete-profile-text').textContent = | 541 $('delete-profile-text').textContent = |
| 539 loadTimeData.getStringF('deleteProfileMessage', | 542 loadTimeData.getStringF('deleteProfileMessage', |
| 540 elide(profileInfo.name, /* maxLength */ 50)); | 543 elide(profileInfo.name, /* maxLength */ 50)); |
| 541 $('delete-managed-profile-addendum').hidden = !profileInfo.isManaged; | 544 $('delete-supervised-profile-addendum').hidden = |
| 545 !profileInfo.isSupervised; |
| 542 | 546 |
| 543 // Because this dialog isn't useful when refreshing or as part of the | 547 // Because this dialog isn't useful when refreshing or as part of the |
| 544 // history, don't create a history entry for it when showing. | 548 // history, don't create a history entry for it when showing. |
| 545 OptionsPage.showPageByName('manageProfile', false); | 549 OptionsPage.showPageByName('manageProfile', false); |
| 546 }, | 550 }, |
| 547 | 551 |
| 548 /** | 552 /** |
| 549 * Display the "Disconnect Managed Profile" dialog. | 553 * Display the "Disconnect Managed Profile" dialog. |
| 550 * @private | 554 * @private |
| 551 */ | 555 */ |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 CreateProfileOverlay.prototype = { | 608 CreateProfileOverlay.prototype = { |
| 605 // Inherit from ManageProfileOverlay. | 609 // Inherit from ManageProfileOverlay. |
| 606 __proto__: ManageProfileOverlay.prototype, | 610 __proto__: ManageProfileOverlay.prototype, |
| 607 | 611 |
| 608 // The signed-in email address of the current profile, or empty if they're | 612 // The signed-in email address of the current profile, or empty if they're |
| 609 // not signed in. | 613 // not signed in. |
| 610 signedInEmail_: '', | 614 signedInEmail_: '', |
| 611 | 615 |
| 612 /** @override */ | 616 /** @override */ |
| 613 canShowPage: function() { | 617 canShowPage: function() { |
| 614 return !BrowserOptions.getCurrentProfile().isManaged; | 618 return !BrowserOptions.getCurrentProfile().isSupervised; |
| 615 }, | 619 }, |
| 616 | 620 |
| 617 /** | 621 /** |
| 618 * Configures the overlay to the "create user" mode. | 622 * Configures the overlay to the "create user" mode. |
| 619 * @override | 623 * @override |
| 620 */ | 624 */ |
| 621 didShowPage: function() { | 625 didShowPage: function() { |
| 622 chrome.send('requestCreateProfileUpdate'); | 626 chrome.send('requestCreateProfileUpdate'); |
| 623 chrome.send('requestDefaultProfileIcons', ['create']); | 627 chrome.send('requestDefaultProfileIcons', ['create']); |
| 624 chrome.send('requestNewProfileDefaults'); | 628 chrome.send('requestNewProfileDefaults'); |
| 625 | 629 |
| 626 $('manage-profile-overlay-create').hidden = false; | 630 $('manage-profile-overlay-create').hidden = false; |
| 627 $('manage-profile-overlay-manage').hidden = true; | 631 $('manage-profile-overlay-manage').hidden = true; |
| 628 $('manage-profile-overlay-delete').hidden = true; | 632 $('manage-profile-overlay-delete').hidden = true; |
| 629 $('manage-profile-overlay-disconnect-managed').hidden = true; | 633 $('manage-profile-overlay-disconnect-managed').hidden = true; |
| 630 $('create-profile-instructions').textContent = | 634 $('create-profile-instructions').textContent = |
| 631 loadTimeData.getStringF('createProfileInstructions'); | 635 loadTimeData.getStringF('createProfileInstructions'); |
| 632 this.hideErrorBubble_(); | 636 this.hideErrorBubble_(); |
| 633 this.updateCreateInProgress_(false); | 637 this.updateCreateInProgress_(false); |
| 634 | 638 |
| 635 var shortcutsEnabled = loadTimeData.getBoolean('profileShortcutsEnabled'); | 639 var shortcutsEnabled = loadTimeData.getBoolean('profileShortcutsEnabled'); |
| 636 $('create-shortcut-container').hidden = !shortcutsEnabled; | 640 $('create-shortcut-container').hidden = !shortcutsEnabled; |
| 637 $('create-shortcut').checked = shortcutsEnabled; | 641 $('create-shortcut').checked = shortcutsEnabled; |
| 638 | 642 |
| 639 $('create-profile-name-label').hidden = true; | 643 $('create-profile-name-label').hidden = true; |
| 640 $('create-profile-name').hidden = true; | 644 $('create-profile-name').hidden = true; |
| 641 $('create-profile-ok').disabled = true; | 645 $('create-profile-ok').disabled = true; |
| 642 | 646 |
| 643 $('create-profile-managed').checked = false; | 647 $('create-profile-supervised').checked = false; |
| 644 $('import-existing-managed-user-link').hidden = true; | 648 $('import-existing-supervised-user-link').hidden = true; |
| 645 $('create-profile-managed').onchange = function() { | 649 $('create-profile-supervised').onchange = function() { |
| 646 ManageProfileOverlay.getInstance().updateCreateOrImport_('create'); | 650 ManageProfileOverlay.getInstance().updateCreateOrImport_('create'); |
| 647 }; | 651 }; |
| 648 $('create-profile-managed-signed-in').disabled = true; | 652 $('create-profile-supervised-signed-in').disabled = true; |
| 649 $('create-profile-managed-signed-in').hidden = true; | 653 $('create-profile-supervised-signed-in').hidden = true; |
| 650 $('create-profile-managed-not-signed-in').hidden = true; | 654 $('create-profile-supervised-not-signed-in').hidden = true; |
| 651 | 655 |
| 652 this.profileNameIsDefault_ = false; | 656 this.profileNameIsDefault_ = false; |
| 653 }, | 657 }, |
| 654 | 658 |
| 655 /** @override */ | 659 /** @override */ |
| 656 handleCancel: function() { | 660 handleCancel: function() { |
| 657 this.cancelCreateProfile_(); | 661 this.cancelCreateProfile_(); |
| 658 }, | 662 }, |
| 659 | 663 |
| 660 /** @override */ | 664 /** @override */ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 672 /** | 676 /** |
| 673 * Updates the UI when a profile create step begins or ends. | 677 * Updates the UI when a profile create step begins or ends. |
| 674 * Note that hideErrorBubble_() also enables the "OK" button, so it | 678 * Note that hideErrorBubble_() also enables the "OK" button, so it |
| 675 * must be called before this function if both are used. | 679 * must be called before this function if both are used. |
| 676 * @param {boolean} inProgress True if the UI should be updated to show that | 680 * @param {boolean} inProgress True if the UI should be updated to show that |
| 677 * profile creation is now in progress. | 681 * profile creation is now in progress. |
| 678 * @private | 682 * @private |
| 679 */ | 683 */ |
| 680 updateCreateInProgress_: function(inProgress) { | 684 updateCreateInProgress_: function(inProgress) { |
| 681 this.createInProgress_ = inProgress; | 685 this.createInProgress_ = inProgress; |
| 682 this.updateCreateManagedUserCheckbox_(); | 686 this.updateCreateSupervisedUserCheckbox_(); |
| 683 | 687 |
| 684 $('create-profile-icon-grid').disabled = inProgress; | 688 $('create-profile-icon-grid').disabled = inProgress; |
| 685 $('create-profile-name').disabled = inProgress; | 689 $('create-profile-name').disabled = inProgress; |
| 686 $('create-shortcut').disabled = inProgress; | 690 $('create-shortcut').disabled = inProgress; |
| 687 $('create-profile-ok').disabled = inProgress; | 691 $('create-profile-ok').disabled = inProgress; |
| 688 $('import-existing-managed-user-link').disabled = inProgress; | 692 $('import-existing-supervised-user-link').disabled = inProgress; |
| 689 | 693 |
| 690 $('create-profile-throbber').hidden = !inProgress; | 694 $('create-profile-throbber').hidden = !inProgress; |
| 691 }, | 695 }, |
| 692 | 696 |
| 693 /** | 697 /** |
| 694 * Cancels the creation of the a profile. It is safe to call this even | 698 * Cancels the creation of the a profile. It is safe to call this even |
| 695 * when no profile is in the process of being created. | 699 * when no profile is in the process of being created. |
| 696 * @private | 700 * @private |
| 697 */ | 701 */ |
| 698 cancelCreateProfile_: function() { | 702 cancelCreateProfile_: function() { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 724 this.showErrorBubble_(warning); | 728 this.showErrorBubble_(warning); |
| 725 }, | 729 }, |
| 726 | 730 |
| 727 /** | 731 /** |
| 728 * For new supervised users, shows a confirmation page after successfully | 732 * For new supervised users, shows a confirmation page after successfully |
| 729 * creating a new profile; otherwise, the handler will open a new window. | 733 * creating a new profile; otherwise, the handler will open a new window. |
| 730 * @param {Object} profileInfo An object of the form: | 734 * @param {Object} profileInfo An object of the form: |
| 731 * profileInfo = { | 735 * profileInfo = { |
| 732 * name: "Profile Name", | 736 * name: "Profile Name", |
| 733 * filePath: "/path/to/profile/data/on/disk" | 737 * filePath: "/path/to/profile/data/on/disk" |
| 734 * isManaged: (true|false), | 738 * isSupervised: (true|false), |
| 735 * }; | 739 * }; |
| 736 * @private | 740 * @private |
| 737 */ | 741 */ |
| 738 onSuccess_: function(profileInfo) { | 742 onSuccess_: function(profileInfo) { |
| 739 this.updateCreateInProgress_(false); | 743 this.updateCreateInProgress_(false); |
| 740 OptionsPage.closeOverlay(); | 744 OptionsPage.closeOverlay(); |
| 741 if (profileInfo.isManaged) { | 745 if (profileInfo.isSupervised) { |
| 742 options.ManagedUserListData.resetPromise(); | 746 options.SupervisedUserListData.resetPromise(); |
| 743 profileInfo.custodianEmail = this.signedInEmail_; | 747 profileInfo.custodianEmail = this.signedInEmail_; |
| 744 ManagedUserCreateConfirmOverlay.setProfileInfo(profileInfo); | 748 SupervisedUserCreateConfirmOverlay.setProfileInfo(profileInfo); |
| 745 OptionsPage.showPageByName('managedUserCreateConfirm', false); | 749 OptionsPage.showPageByName('supervisedUserCreateConfirm', false); |
| 746 BrowserOptions.updateManagesSupervisedUsers(true); | 750 BrowserOptions.updateManagesSupervisedUsers(true); |
| 747 } | 751 } |
| 748 }, | 752 }, |
| 749 | 753 |
| 750 /** | 754 /** |
| 751 * Updates the signed-in or not-signed-in UI when in create mode. Called by | 755 * Updates the signed-in or not-signed-in UI when in create mode. Called by |
| 752 * the handler in response to the 'requestCreateProfileUpdate' message. | 756 * the handler in response to the 'requestCreateProfileUpdate' message. |
| 753 * updateManagedUsersAllowed_ is expected to be called after this is, and | 757 * updateSupervisedUsersAllowed_ is expected to be called after this is, and |
| 754 * will update additional UI elements. | 758 * will update additional UI elements. |
| 755 * @param {string} email The email address of the currently signed-in user. | 759 * @param {string} email The email address of the currently signed-in user. |
| 756 * An empty string indicates that the user is not signed in. | 760 * An empty string indicates that the user is not signed in. |
| 757 * @param {boolean} hasError Whether the user's sign-in credentials are | 761 * @param {boolean} hasError Whether the user's sign-in credentials are |
| 758 * still valid. | 762 * still valid. |
| 759 * @private | 763 * @private |
| 760 */ | 764 */ |
| 761 updateSignedInStatus_: function(email, hasError) { | 765 updateSignedInStatus_: function(email, hasError) { |
| 762 this.signedInEmail_ = email; | 766 this.signedInEmail_ = email; |
| 763 this.hasError_ = hasError; | 767 this.hasError_ = hasError; |
| 764 var isSignedIn = email !== ''; | 768 var isSignedIn = email !== ''; |
| 765 $('create-profile-managed-signed-in').hidden = !isSignedIn; | 769 $('create-profile-supervised-signed-in').hidden = !isSignedIn; |
| 766 $('create-profile-managed-not-signed-in').hidden = isSignedIn; | 770 $('create-profile-supervised-not-signed-in').hidden = isSignedIn; |
| 767 | 771 |
| 768 if (isSignedIn) { | 772 if (isSignedIn) { |
| 769 var accountDetailsOutOfDate = | 773 var accountDetailsOutOfDate = |
| 770 $('create-profile-managed-account-details-out-of-date-label'); | 774 $('create-profile-supervised-account-details-out-of-date-label'); |
| 771 accountDetailsOutOfDate.textContent = loadTimeData.getStringF( | 775 accountDetailsOutOfDate.textContent = loadTimeData.getStringF( |
| 772 'manageProfilesManagedAccountDetailsOutOfDate', email); | 776 'manageProfilesSupervisedAccountDetailsOutOfDate', email); |
| 773 accountDetailsOutOfDate.hidden = !hasError; | 777 accountDetailsOutOfDate.hidden = !hasError; |
| 774 | 778 |
| 775 $('create-profile-managed-signed-in-label').textContent = | 779 $('create-profile-supervised-signed-in-label').textContent = |
| 776 loadTimeData.getStringF( | 780 loadTimeData.getStringF( |
| 777 'manageProfilesManagedSignedInLabel', email); | 781 'manageProfilesSupervisedSignedInLabel', email); |
| 778 $('create-profile-managed-signed-in-label').hidden = hasError; | 782 $('create-profile-supervised-signed-in-label').hidden = hasError; |
| 779 | 783 |
| 780 $('create-profile-managed-sign-in-again-link').hidden = !hasError; | 784 $('create-profile-supervised-sign-in-again-link').hidden = !hasError; |
| 781 $('create-profile-managed-signed-in-learn-more-link').hidden = hasError; | 785 $('create-profile-supervised-signed-in-learn-more-link').hidden = |
| 786 hasError; |
| 782 } | 787 } |
| 783 | 788 |
| 784 this.updateImportExistingManagedUserLink_(isSignedIn && !hasError); | 789 this.updateImportExistingSupervisedUserLink_(isSignedIn && !hasError); |
| 785 }, | 790 }, |
| 786 | 791 |
| 787 /** | 792 /** |
| 788 * Enables/disables the 'import existing managed users' link button. | 793 * Enables/disables the 'import existing supervised users' link button. |
| 789 * It also updates the button text. | 794 * It also updates the button text. |
| 790 * @param {boolean} enable True to enable the link button and | 795 * @param {boolean} enable True to enable the link button and |
| 791 * false otherwise. | 796 * false otherwise. |
| 792 * @private | 797 * @private |
| 793 */ | 798 */ |
| 794 updateImportExistingManagedUserLink_: function(enable) { | 799 updateImportExistingSupervisedUserLink_: function(enable) { |
| 795 var importManagedUserElement = $('import-existing-managed-user-link'); | 800 var importSupervisedUserElement = |
| 796 importManagedUserElement.hidden = false; | 801 $('import-existing-supervised-user-link'); |
| 797 importManagedUserElement.disabled = !enable || this.createInProgress_; | 802 importSupervisedUserElement.hidden = false; |
| 798 importManagedUserElement.textContent = enable ? | 803 importSupervisedUserElement.disabled = !enable || this.createInProgress_; |
| 799 loadTimeData.getString('importExistingManagedUserLink') : | 804 importSupervisedUserElement.textContent = enable ? |
| 800 loadTimeData.getString('signInToImportManagedUsers'); | 805 loadTimeData.getString('importExistingSupervisedUserLink') : |
| 806 loadTimeData.getString('signInToImportSupervisedUsers'); |
| 801 }, | 807 }, |
| 802 | 808 |
| 803 /** | 809 /** |
| 804 * Sets whether creating managed users is allowed or not. Called by the | 810 * Sets whether creating supervised users is allowed or not. Called by the |
| 805 * handler in response to the 'requestCreateProfileUpdate' message or a | 811 * handler in response to the 'requestCreateProfileUpdate' message or a |
| 806 * change in the (policy-controlled) pref that prohibits creating managed | 812 * change in the (policy-controlled) pref that prohibits creating supervised |
| 807 * users, after the signed-in status has been updated. | 813 * users, after the signed-in status has been updated. |
| 808 * @param {boolean} allowed True if creating managed users should be | 814 * @param {boolean} allowed True if creating supervised users should be |
| 809 * allowed. | 815 * allowed. |
| 810 * @private | 816 * @private |
| 811 */ | 817 */ |
| 812 updateManagedUsersAllowed_: function(allowed) { | 818 updateSupervisedUsersAllowed_: function(allowed) { |
| 813 this.managedUsersAllowed_ = allowed; | 819 this.supervisedUsersAllowed_ = allowed; |
| 814 this.updateCreateManagedUserCheckbox_(); | 820 this.updateCreateSupervisedUserCheckbox_(); |
| 815 | 821 |
| 816 $('create-profile-managed-not-signed-in-link').hidden = !allowed; | 822 $('create-profile-supervised-not-signed-in-link').hidden = !allowed; |
| 817 if (!allowed) { | 823 if (!allowed) { |
| 818 $('create-profile-managed-indicator').setAttribute('controlled-by', | 824 $('create-profile-supervised-indicator').setAttribute('controlled-by', |
| 819 'policy'); | 825 'policy'); |
| 820 } else { | 826 } else { |
| 821 $('create-profile-managed-indicator').removeAttribute('controlled-by'); | 827 $('create-profile-supervised-indicator').removeAttribute( |
| 828 'controlled-by'); |
| 822 } | 829 } |
| 823 }, | 830 }, |
| 824 | 831 |
| 825 /** | 832 /** |
| 826 * Updates the status of the "create managed user" checkbox. Called from | 833 * Updates the status of the "create supervised user" checkbox. Called from |
| 827 * updateManagedUsersAllowed_() or updateCreateInProgress_(). | 834 * updateSupervisedUsersAllowed_() or updateCreateInProgress_(). |
| 828 * updateSignedInStatus_() does not call this method directly, because it | 835 * updateSignedInStatus_() does not call this method directly, because it |
| 829 * will be followed by a call to updateManagedUsersAllowed_(). | 836 * will be followed by a call to updateSupervisedUsersAllowed_(). |
| 830 * @private | 837 * @private |
| 831 */ | 838 */ |
| 832 updateCreateManagedUserCheckbox_: function() { | 839 updateCreateSupervisedUserCheckbox_: function() { |
| 833 $('create-profile-managed').disabled = | 840 $('create-profile-supervised').disabled = |
| 834 !this.managedUsersAllowed_ || this.createInProgress_ || | 841 !this.supervisedUsersAllowed_ || this.createInProgress_ || |
| 835 this.signedInEmail_ == '' || this.hasError_; | 842 this.signedInEmail_ == '' || this.hasError_; |
| 836 }, | 843 }, |
| 837 }; | 844 }; |
| 838 | 845 |
| 839 // Forward public APIs to private implementations. | 846 // Forward public APIs to private implementations. |
| 840 [ | 847 [ |
| 841 'cancelCreateProfile', | 848 'cancelCreateProfile', |
| 842 'onError', | 849 'onError', |
| 843 'onSuccess', | 850 'onSuccess', |
| 844 'onWarning', | 851 'onWarning', |
| 845 'updateCreateInProgress', | 852 'updateCreateInProgress', |
| 846 'updateManagedUsersAllowed', | |
| 847 'updateSignedInStatus', | 853 'updateSignedInStatus', |
| 854 'updateSupervisedUsersAllowed', |
| 848 ].forEach(function(name) { | 855 ].forEach(function(name) { |
| 849 CreateProfileOverlay[name] = function() { | 856 CreateProfileOverlay[name] = function() { |
| 850 var instance = CreateProfileOverlay.getInstance(); | 857 var instance = CreateProfileOverlay.getInstance(); |
| 851 return instance[name + '_'].apply(instance, arguments); | 858 return instance[name + '_'].apply(instance, arguments); |
| 852 }; | 859 }; |
| 853 }); | 860 }); |
| 854 | 861 |
| 855 // Export | 862 // Export |
| 856 return { | 863 return { |
| 857 ManageProfileOverlay: ManageProfileOverlay, | 864 ManageProfileOverlay: ManageProfileOverlay, |
| 858 CreateProfileOverlay: CreateProfileOverlay, | 865 CreateProfileOverlay: CreateProfileOverlay, |
| 859 }; | 866 }; |
| 860 }); | 867 }); |
| OLD | NEW |