| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 options.ProfilesIconGrid.decorate($('manage-profile-icon-grid')); | 44 options.ProfilesIconGrid.decorate($('manage-profile-icon-grid')); |
| 45 options.ProfilesIconGrid.decorate($('create-profile-icon-grid')); | 45 options.ProfilesIconGrid.decorate($('create-profile-icon-grid')); |
| 46 self.registerCommonEventHandlers_('create', | 46 self.registerCommonEventHandlers_('create', |
| 47 self.submitCreateProfile_.bind(self)); | 47 self.submitCreateProfile_.bind(self)); |
| 48 self.registerCommonEventHandlers_('manage', | 48 self.registerCommonEventHandlers_('manage', |
| 49 self.submitManageChanges_.bind(self)); | 49 self.submitManageChanges_.bind(self)); |
| 50 | 50 |
| 51 // Override the create-profile-ok handler, to avoid closing the overlay | 51 // Override the create-profile-ok handler, to avoid closing the overlay |
| 52 // until we finish creating the profile. | 52 // until we finish creating the profile. |
| 53 $('create-profile-ok').onclick = function(event) { | 53 $('create-profile-ok').onclick = function(event) { |
| 54 CreateProfileOverlay.updateCreateInProgress(true); |
| 54 ManageProfileOverlay.getInstance().hideErrorBubble_('create'); | 55 ManageProfileOverlay.getInstance().hideErrorBubble_('create'); |
| 55 $('create-profile-ok').disabled = true; | |
| 56 self.submitCreateProfile_(); | 56 self.submitCreateProfile_(); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 if (loadTimeData.getBoolean('managedUsersEnabled')) { | 59 if (loadTimeData.getBoolean('managedUsersEnabled')) { |
| 60 $('create-profile-limited-container').hidden = false; | 60 $('create-profile-limited-container').hidden = false; |
| 61 } | 61 } |
| 62 $('manage-profile-cancel').onclick = | 62 $('manage-profile-cancel').onclick = |
| 63 $('delete-profile-cancel').onclick = | 63 $('delete-profile-cancel').onclick = |
| 64 $('create-profile-cancel').onclick = function(event) { | 64 $('create-profile-cancel').onclick = function(event) { |
| 65 OptionsPage.closeOverlay(); | 65 OptionsPage.closeOverlay(); |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 chrome.send('requestSignedInText'); | 426 chrome.send('requestSignedInText'); |
| 427 chrome.send('requestDefaultProfileIcons'); | 427 chrome.send('requestDefaultProfileIcons'); |
| 428 chrome.send('requestNewProfileDefaults'); | 428 chrome.send('requestNewProfileDefaults'); |
| 429 | 429 |
| 430 $('manage-profile-overlay-create').hidden = false; | 430 $('manage-profile-overlay-create').hidden = false; |
| 431 $('manage-profile-overlay-manage').hidden = true; | 431 $('manage-profile-overlay-manage').hidden = true; |
| 432 $('manage-profile-overlay-delete').hidden = true; | 432 $('manage-profile-overlay-delete').hidden = true; |
| 433 $('create-profile-instructions').textContent = | 433 $('create-profile-instructions').textContent = |
| 434 loadTimeData.getStringF('createProfileInstructions'); | 434 loadTimeData.getStringF('createProfileInstructions'); |
| 435 this.hideErrorBubble_(); | 435 this.hideErrorBubble_(); |
| 436 this.updateCreateInProgress_(false); |
| 436 | 437 |
| 437 var shortcutsEnabled = loadTimeData.getBoolean('profileShortcutsEnabled'); | 438 var shortcutsEnabled = loadTimeData.getBoolean('profileShortcutsEnabled'); |
| 438 $('create-shortcut-container').hidden = !shortcutsEnabled; | 439 $('create-shortcut-container').hidden = !shortcutsEnabled; |
| 439 $('create-shortcut').checked = shortcutsEnabled; | 440 $('create-shortcut').checked = shortcutsEnabled; |
| 440 | 441 |
| 441 $('create-profile-name-label').hidden = true; | 442 $('create-profile-name-label').hidden = true; |
| 442 $('create-profile-name').hidden = true; | 443 $('create-profile-name').hidden = true; |
| 443 $('create-profile-ok').disabled = true; | 444 $('create-profile-ok').disabled = true; |
| 444 }, | 445 }, |
| 445 | 446 |
| 446 /** @override */ | 447 /** @override */ |
| 447 showErrorBubble_: function(errorText) { | 448 showErrorBubble_: function(errorText) { |
| 448 ManageProfileOverlay.getInstance().showErrorBubble_(errorText, | 449 ManageProfileOverlay.getInstance().showErrorBubble_(errorText, |
| 449 'create', | 450 'create', |
| 450 false); | 451 false); |
| 451 }, | 452 }, |
| 452 | 453 |
| 453 /** @override */ | 454 /** @override */ |
| 454 hideErrorBubble_: function() { | 455 hideErrorBubble_: function() { |
| 455 ManageProfileOverlay.getInstance().hideErrorBubble_('create'); | 456 ManageProfileOverlay.getInstance().hideErrorBubble_('create'); |
| 456 }, | 457 }, |
| 457 | 458 |
| 458 /** | 459 /** |
| 460 * Updates the UI when a profile create step begins or ends. |
| 461 * @param {boolean} inProgress Whether the step is newly in progress, or |
| 462 * has just completed. |
| 463 * @private |
| 464 */ |
| 465 updateCreateInProgress_: function(inProgress) { |
| 466 $('create-profile-ok').disabled = inProgress; |
| 467 $('create-profile-throbber').hidden = !inProgress; |
| 468 }, |
| 469 |
| 470 /** |
| 459 * Shows an error message describing a local error (most likely a disk | 471 * Shows an error message describing a local error (most likely a disk |
| 460 * error) when creating a new profile. Called by BrowserOptions via the | 472 * error) when creating a new profile. Called by BrowserOptions via the |
| 461 * BrowserOptionsHandler. | 473 * BrowserOptionsHandler. |
| 462 * @private | 474 * @private |
| 463 */ | 475 */ |
| 464 onLocalError_: function() { | 476 onLocalError_: function() { |
| 465 $('create-profile-ok').disabled = false; | 477 this.updateCreateInProgress_(false); |
| 466 this.showErrorBubble_('createProfileLocalError'); | 478 this.showErrorBubble_('createProfileLocalError'); |
| 467 }, | 479 }, |
| 468 | 480 |
| 469 /** | 481 /** |
| 482 * Shows an error message describing a remote error (most likely a network |
| 483 * error) when creating a new profile. Called by BrowserOptions via the |
| 484 * BrowserOptionsHandler. |
| 485 * @private |
| 486 */ |
| 487 onRemoteError_: function() { |
| 488 this.updateCreateInProgress_(false); |
| 489 this.showErrorBubble_('createProfileRemoteError'); |
| 490 }, |
| 491 |
| 492 /** |
| 470 * For new limited users, shows a confirmation page after successfully | 493 * For new limited users, shows a confirmation page after successfully |
| 471 * creating a new profile; otherwise, the handler will open a new window. | 494 * creating a new profile; otherwise, the handler will open a new window. |
| 472 * @param {Object} profileInfo An object of the form: | 495 * @param {Object} profileInfo An object of the form: |
| 473 * profileInfo = { | 496 * profileInfo = { |
| 474 * name: "Profile Name", | 497 * name: "Profile Name", |
| 475 * filePath: "/path/to/profile/data/on/disk" | 498 * filePath: "/path/to/profile/data/on/disk" |
| 476 * isManaged: (true|false), | 499 * isManaged: (true|false), |
| 477 * }; | 500 * }; |
| 478 * @private | 501 * @private |
| 479 */ | 502 */ |
| 480 onSuccess_: function(profileInfo) { | 503 onSuccess_: function(profileInfo) { |
| 504 this.updateCreateInProgress_(false); |
| 481 OptionsPage.closeOverlay(); | 505 OptionsPage.closeOverlay(); |
| 482 $('create-profile-ok').disabled = false; | |
| 483 if (profileInfo.isManaged) { | 506 if (profileInfo.isManaged) { |
| 484 ManagedUserCreateConfirmOverlay.setProfileInfo(profileInfo); | 507 ManagedUserCreateConfirmOverlay.setProfileInfo(profileInfo); |
| 485 OptionsPage.navigateToPage('managedUserCreateConfirm'); | 508 OptionsPage.navigateToPage('managedUserCreateConfirm'); |
| 486 } | 509 } |
| 487 }, | 510 }, |
| 488 | 511 |
| 489 /** | 512 /** |
| 490 * Updates the signed-in or not-signed-in UI when in create mode. Called by | 513 * Updates the signed-in or not-signed-in UI when in create mode. Called by |
| 491 * the handler in response to the 'requestSignedInText' message. | 514 * the handler in response to the 'requestSignedInText' message. |
| 492 * @param {string} text The text to show for a signed-in user. An empty | 515 * @param {string} text The text to show for a signed-in user. An empty |
| 493 * string indicates that the user is not signed in. | 516 * string indicates that the user is not signed in. |
| 494 * @private | 517 * @private |
| 495 */ | 518 */ |
| 496 updateSignedInStatus_: function(text) { | 519 updateSignedInStatus_: function(text) { |
| 497 var isSignedIn = text !== ''; | 520 var isSignedIn = text !== ''; |
| 498 $('create-profile-limited-signed-in').hidden = !isSignedIn; | 521 $('create-profile-limited-signed-in').hidden = !isSignedIn; |
| 499 $('create-profile-limited-not-signed-in').hidden = isSignedIn; | 522 $('create-profile-limited-not-signed-in').hidden = isSignedIn; |
| 500 $('create-profile-limited').disabled = !isSignedIn; | 523 $('create-profile-limited').disabled = !isSignedIn; |
| 501 | 524 |
| 502 $('create-profile-limited-signed-in-label').textContent = text; | 525 $('create-profile-limited-signed-in-label').textContent = text; |
| 503 }, | 526 }, |
| 504 }; | 527 }; |
| 505 | 528 |
| 506 // Forward public APIs to private implementations. | 529 // Forward public APIs to private implementations. |
| 507 [ | 530 [ |
| 508 'onLocalError', | 531 'onLocalError', |
| 532 'onRemoteError', |
| 509 'onSuccess', | 533 'onSuccess', |
| 534 'updateCreateInProgress', |
| 510 'updateSignedInStatus', | 535 'updateSignedInStatus', |
| 511 ].forEach(function(name) { | 536 ].forEach(function(name) { |
| 512 CreateProfileOverlay[name] = function() { | 537 CreateProfileOverlay[name] = function() { |
| 513 var instance = CreateProfileOverlay.getInstance(); | 538 var instance = CreateProfileOverlay.getInstance(); |
| 514 return instance[name + '_'].apply(instance, arguments); | 539 return instance[name + '_'].apply(instance, arguments); |
| 515 }; | 540 }; |
| 516 }); | 541 }); |
| 517 | 542 |
| 518 // Export | 543 // Export |
| 519 return { | 544 return { |
| 520 ManageProfileOverlay: ManageProfileOverlay, | 545 ManageProfileOverlay: ManageProfileOverlay, |
| 521 CreateProfileOverlay: CreateProfileOverlay, | 546 CreateProfileOverlay: CreateProfileOverlay, |
| 522 }; | 547 }; |
| 523 }); | 548 }); |
| OLD | NEW |