Chromium Code Reviews| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 // closing the overlay until we finish creating the profile. | 52 // closing the overlay until we finish creating the profile. |
| 53 $('create-profile-ok').onclick = function(event) { | 53 $('create-profile-ok').onclick = function(event) { |
| 54 self.submitCreateProfile_(); | 54 self.submitCreateProfile_(); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 $('create-profile-cancel').onclick = function(event) { | 57 $('create-profile-cancel').onclick = function(event) { |
| 58 CreateProfileOverlay.cancelCreateProfile(); | 58 CreateProfileOverlay.cancelCreateProfile(); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 if (loadTimeData.getBoolean('managedUsersEnabled')) { | 61 if (loadTimeData.getBoolean('managedUsersEnabled')) { |
| 62 $('create-profile-limited-container').hidden = false; | 62 $('create-profile-managed-container').hidden = false; |
| 63 } | 63 } |
| 64 $('manage-profile-cancel').onclick = | 64 $('manage-profile-cancel').onclick = |
| 65 $('delete-profile-cancel').onclick = function(event) { | 65 $('delete-profile-cancel').onclick = function(event) { |
| 66 OptionsPage.closeOverlay(); | 66 OptionsPage.closeOverlay(); |
| 67 }; | 67 }; |
| 68 $('delete-profile-ok').onclick = function(event) { | 68 $('delete-profile-ok').onclick = function(event) { |
| 69 OptionsPage.closeOverlay(); | 69 OptionsPage.closeOverlay(); |
| 70 chrome.send('deleteProfile', [self.profileInfo_.filePath]); | 70 chrome.send('deleteProfile', [self.profileInfo_.filePath]); |
| 71 }; | 71 }; |
| 72 $('add-shortcut-button').onclick = function(event) { | 72 $('add-shortcut-button').onclick = function(event) { |
| 73 chrome.send('addProfileShortcut', [self.profileInfo_.filePath]); | 73 chrome.send('addProfileShortcut', [self.profileInfo_.filePath]); |
| 74 }; | 74 }; |
| 75 $('remove-shortcut-button').onclick = function(event) { | 75 $('remove-shortcut-button').onclick = function(event) { |
| 76 chrome.send('removeProfileShortcut', [self.profileInfo_.filePath]); | 76 chrome.send('removeProfileShortcut', [self.profileInfo_.filePath]); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 $('create-profile-limited-signed-in-link').onclick = function(event) { | 79 $('create-profile-managed-signed-in-link').onclick = function(event) { |
| 80 OptionsPage.navigateToPage('managedUserLearnMore'); | 80 OptionsPage.navigateToPage('managedUserLearnMore'); |
| 81 return false; | 81 return false; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 $('create-profile-limited-not-signed-in-link').onclick = function(event) { | 84 $('create-profile-managed-not-signed-in-link').onclick = function(event) { |
| 85 // The signin process will open an overlay to configure sync, which | 85 // The signin process will open an overlay to configure sync, which |
| 86 // would replace this overlay. It's smoother to close this one now. | 86 // would replace this overlay. It's smoother to close this one now. |
| 87 // TODO(pamg): Move the sync-setup overlay to a higher layer so this one | 87 // TODO(pamg): Move the sync-setup overlay to a higher layer so this one |
| 88 // can stay open under it, after making sure that doesn't break anything | 88 // can stay open under it, after making sure that doesn't break anything |
| 89 // else. | 89 // else. |
| 90 OptionsPage.closeOverlay(); | 90 OptionsPage.closeOverlay(); |
| 91 SyncSetupOverlay.startSignIn(); | 91 SyncSetupOverlay.startSignIn(); |
| 92 }; | 92 }; |
| 93 }, | 93 }, |
| 94 | 94 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 submitFunction(); | 136 submitFunction(); |
| 137 }; | 137 }; |
| 138 }, | 138 }, |
| 139 | 139 |
| 140 /** | 140 /** |
| 141 * Set the profile info used in the dialog. | 141 * Set the profile info used in the dialog. |
| 142 * @param {Object} profileInfo An object of the form: | 142 * @param {Object} profileInfo An object of the form: |
| 143 * profileInfo = { | 143 * profileInfo = { |
| 144 * name: "Profile Name", | 144 * name: "Profile Name", |
| 145 * iconURL: "chrome://path/to/icon/image", | 145 * iconURL: "chrome://path/to/icon/image", |
| 146 * filePath: "/path/to/profile/data/on/disk" | 146 * filePath: "/path/to/profile/data/on/disk", |
| 147 * isCurrentProfile: false, | 147 * isCurrentProfile: false, |
| 148 * isManaged: false | |
| 148 * }; | 149 * }; |
| 149 * @param {string} mode A label that specifies the type of dialog | 150 * @param {string} mode A label that specifies the type of dialog |
| 150 * box which is currently being viewed (i.e. 'create' or | 151 * box which is currently being viewed (i.e. 'create' or |
| 151 * 'manage'). | 152 * 'manage'). |
| 152 * @private | 153 * @private |
| 153 */ | 154 */ |
| 154 setProfileInfo_: function(profileInfo, mode) { | 155 setProfileInfo_: function(profileInfo, mode) { |
| 155 this.iconGridSelectedURL_ = profileInfo.iconURL; | 156 this.iconGridSelectedURL_ = profileInfo.iconURL; |
| 156 this.profileInfo_ = profileInfo; | 157 this.profileInfo_ = profileInfo; |
| 157 $(mode + '-profile-name').value = profileInfo.name; | 158 $(mode + '-profile-name').value = profileInfo.name; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 */ | 302 */ |
| 302 submitCreateProfile_: function() { | 303 submitCreateProfile_: function() { |
| 303 this.hideErrorBubble_('create'); | 304 this.hideErrorBubble_('create'); |
| 304 CreateProfileOverlay.updateCreateInProgress(true); | 305 CreateProfileOverlay.updateCreateInProgress(true); |
| 305 | 306 |
| 306 // Get the user's chosen name and icon, or default if they do not | 307 // Get the user's chosen name and icon, or default if they do not |
| 307 // wish to customize their profile. | 308 // wish to customize their profile. |
| 308 var name = $('create-profile-name').value; | 309 var name = $('create-profile-name').value; |
| 309 var iconUrl = $('create-profile-icon-grid').selectedItem; | 310 var iconUrl = $('create-profile-icon-grid').selectedItem; |
| 310 var createShortcut = $('create-shortcut').checked; | 311 var createShortcut = $('create-shortcut').checked; |
| 311 var isManaged = $('create-profile-limited').checked; | 312 var isManaged = $('create-profile-managed').checked; |
| 312 | 313 |
| 313 // 'createProfile' is handled by the BrowserOptionsHandler. | 314 // 'createProfile' is handled by the BrowserOptionsHandler. |
| 314 chrome.send('createProfile', | 315 chrome.send('createProfile', |
| 315 [name, iconUrl, createShortcut, isManaged]); | 316 [name, iconUrl, createShortcut, isManaged]); |
| 316 }, | 317 }, |
| 317 | 318 |
| 318 /** | 319 /** |
| 319 * Called when the selected icon in the icon grid changes. | 320 * Called when the selected icon in the icon grid changes. |
| 320 * @param {string} mode A label that specifies the type of dialog | 321 * @param {string} mode A label that specifies the type of dialog |
| 321 * box which is currently being viewed (i.e. 'create' or | 322 * box which is currently being viewed (i.e. 'create' or |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 */ | 364 */ |
| 364 showDeleteDialog_: function(profileInfo) { | 365 showDeleteDialog_: function(profileInfo) { |
| 365 ManageProfileOverlay.setProfileInfo(profileInfo, 'manage'); | 366 ManageProfileOverlay.setProfileInfo(profileInfo, 'manage'); |
| 366 $('manage-profile-overlay-create').hidden = true; | 367 $('manage-profile-overlay-create').hidden = true; |
| 367 $('manage-profile-overlay-manage').hidden = true; | 368 $('manage-profile-overlay-manage').hidden = true; |
| 368 $('manage-profile-overlay-delete').hidden = false; | 369 $('manage-profile-overlay-delete').hidden = false; |
| 369 $('delete-profile-message').textContent = | 370 $('delete-profile-message').textContent = |
| 370 loadTimeData.getStringF('deleteProfileMessage', profileInfo.name); | 371 loadTimeData.getStringF('deleteProfileMessage', profileInfo.name); |
| 371 $('delete-profile-message').style.backgroundImage = 'url("' + | 372 $('delete-profile-message').style.backgroundImage = 'url("' + |
| 372 profileInfo.iconURL + '")'; | 373 profileInfo.iconURL + '")'; |
| 374 $('delete-managed-profile-addendum').hidden = !profileInfo.isManaged; | |
| 373 | 375 |
| 374 // Because this dialog isn't useful when refreshing or as part of the | 376 // Because this dialog isn't useful when refreshing or as part of the |
| 375 // history, don't create a history entry for it when showing. | 377 // history, don't create a history entry for it when showing. |
| 376 OptionsPage.showPageByName('manageProfile', false); | 378 OptionsPage.showPageByName('manageProfile', false); |
| 377 }, | 379 }, |
| 378 | 380 |
| 379 /** | 381 /** |
| 380 * Display the "Create Profile" dialog. | 382 * Display the "Create Profile" dialog. |
| 381 * @private | 383 * @private |
| 382 */ | 384 */ |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 * Note that hideErrorBubble_() also enables the "OK" button, so it | 465 * Note that hideErrorBubble_() also enables the "OK" button, so it |
| 464 * must be called before this function if both are used. | 466 * must be called before this function if both are used. |
| 465 * @param {boolean} inProgress True if the UI should be updated to show that | 467 * @param {boolean} inProgress True if the UI should be updated to show that |
| 466 * profile creation is now in progress. | 468 * profile creation is now in progress. |
| 467 * @private | 469 * @private |
| 468 */ | 470 */ |
| 469 updateCreateInProgress_: function(inProgress) { | 471 updateCreateInProgress_: function(inProgress) { |
| 470 $('create-profile-icon-grid').disabled = inProgress; | 472 $('create-profile-icon-grid').disabled = inProgress; |
| 471 $('create-profile-name').disabled = inProgress; | 473 $('create-profile-name').disabled = inProgress; |
| 472 $('create-shortcut').disabled = inProgress; | 474 $('create-shortcut').disabled = inProgress; |
| 473 $('create-profile-limited').disabled = inProgress; | 475 $('create-profile-managed').disabled = inProgress; |
| 474 $('create-profile-ok').disabled = inProgress; | 476 $('create-profile-ok').disabled = inProgress; |
| 475 | 477 |
| 476 $('create-profile-throbber').hidden = !inProgress; | 478 $('create-profile-throbber').hidden = !inProgress; |
| 477 }, | 479 }, |
| 478 | 480 |
| 479 /** | 481 /** |
| 480 * Cancels the creation of the a profile. It is safe to call this even | 482 * Cancels the creation of the a profile. It is safe to call this even |
| 481 * when no profile is in the process of being created. | 483 * when no profile is in the process of being created. |
| 482 * @private | 484 * @private |
| 483 */ | 485 */ |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 504 * error) when creating a new profile. Called by BrowserOptions via the | 506 * error) when creating a new profile. Called by BrowserOptions via the |
| 505 * BrowserOptionsHandler. | 507 * BrowserOptionsHandler. |
| 506 * @private | 508 * @private |
| 507 */ | 509 */ |
| 508 onRemoteError_: function() { | 510 onRemoteError_: function() { |
| 509 this.updateCreateInProgress_(false); | 511 this.updateCreateInProgress_(false); |
| 510 this.showErrorBubble_('createProfileRemoteError'); | 512 this.showErrorBubble_('createProfileRemoteError'); |
| 511 }, | 513 }, |
| 512 | 514 |
| 513 /** | 515 /** |
| 514 * For new limited users, shows a confirmation page after successfully | 516 * For new supervised users, shows a confirmation page after successfully |
| 515 * creating a new profile; otherwise, the handler will open a new window. | 517 * creating a new profile; otherwise, the handler will open a new window. |
| 516 * @param {Object} profileInfo An object of the form: | 518 * @param {Object} profileInfo An object of the form: |
| 517 * profileInfo = { | 519 * profileInfo = { |
| 518 * name: "Profile Name", | 520 * name: "Profile Name", |
| 519 * filePath: "/path/to/profile/data/on/disk" | 521 * filePath: "/path/to/profile/data/on/disk" |
| 520 * isManaged: (true|false), | 522 * isManaged: (true|false), |
| 521 * }; | 523 * }; |
| 522 * @private | 524 * @private |
| 523 */ | 525 */ |
| 524 onSuccess_: function(profileInfo) { | 526 onSuccess_: function(profileInfo) { |
| 525 this.updateCreateInProgress_(false); | 527 this.updateCreateInProgress_(false); |
| 526 OptionsPage.closeOverlay(); | 528 OptionsPage.closeOverlay(); |
| 527 if (profileInfo.isManaged) { | 529 if (profileInfo.isManaged) { |
| 528 ManagedUserCreateConfirmOverlay.setProfileInfo(profileInfo); | 530 ManagedUserCreateConfirmOverlay.setProfileInfo(profileInfo); |
| 529 OptionsPage.navigateToPage('managedUserCreateConfirm'); | 531 OptionsPage.navigateToPage('managedUserCreateConfirm'); |
| 530 } | 532 } |
| 531 }, | 533 }, |
| 532 | 534 |
| 533 /** | 535 /** |
| 534 * Updates the signed-in or not-signed-in UI when in create mode. Called by | 536 * Updates the signed-in or not-signed-in UI when in create mode. Called by |
| 535 * the handler in response to the 'requestSignedInText' message. | 537 * the handler in response to the 'requestSignedInText' message. |
| 536 * @param {string} text The text to show for a signed-in user. An empty | 538 * @param {string} text The text to show for a signed-in user. An empty |
| 537 * string indicates that the user is not signed in. | 539 * string indicates that the user is not signed in. |
| 538 * @private | 540 * @private |
| 539 */ | 541 */ |
| 540 updateSignedInStatus_: function(text) { | 542 updateSignedInStatus_: function(text) { |
| 541 var isSignedIn = text !== ''; | 543 var isSignedIn = text !== ''; |
| 542 $('create-profile-limited-signed-in').hidden = !isSignedIn; | 544 $('create-profile-managed-signed-in').hidden = !isSignedIn; |
| 543 $('create-profile-limited-not-signed-in').hidden = isSignedIn; | 545 $('create-profile-managed-not-signed-in').hidden = isSignedIn; |
| 544 $('create-profile-limited').disabled = !isSignedIn; | 546 $('create-profile-managed').disabled = !isSignedIn; |
| 547 if (!isSignedIn) | |
| 548 $('create-profile-managed').checked = false; | |
| 545 if (!isSignedIn) | 549 if (!isSignedIn) |
|
Sergiu
2013/06/21 13:21:22
Think you forgot to delete this "if" clause.
Pam (message me for reviews)
2013/06/21 13:29:38
Oh, bad merging. Thanks.
| |
| 546 $('create-profile-limited').checked = false; | 550 $('create-profile-limited').checked = false; |
| 547 | 551 |
| 548 $('create-profile-limited-signed-in-label').textContent = text; | 552 $('create-profile-managed-signed-in-label').textContent = text; |
| 549 }, | 553 }, |
| 550 }; | 554 }; |
| 551 | 555 |
| 552 // Forward public APIs to private implementations. | 556 // Forward public APIs to private implementations. |
| 553 [ | 557 [ |
| 554 'cancelCreateProfile', | 558 'cancelCreateProfile', |
| 555 'onLocalError', | 559 'onLocalError', |
| 556 'onRemoteError', | 560 'onRemoteError', |
| 557 'onSuccess', | 561 'onSuccess', |
| 558 'updateCreateInProgress', | 562 'updateCreateInProgress', |
| 559 'updateSignedInStatus', | 563 'updateSignedInStatus', |
| 560 ].forEach(function(name) { | 564 ].forEach(function(name) { |
| 561 CreateProfileOverlay[name] = function() { | 565 CreateProfileOverlay[name] = function() { |
| 562 var instance = CreateProfileOverlay.getInstance(); | 566 var instance = CreateProfileOverlay.getInstance(); |
| 563 return instance[name + '_'].apply(instance, arguments); | 567 return instance[name + '_'].apply(instance, arguments); |
| 564 }; | 568 }; |
| 565 }); | 569 }); |
| 566 | 570 |
| 567 // Export | 571 // Export |
| 568 return { | 572 return { |
| 569 ManageProfileOverlay: ManageProfileOverlay, | 573 ManageProfileOverlay: ManageProfileOverlay, |
| 570 CreateProfileOverlay: CreateProfileOverlay, | 574 CreateProfileOverlay: CreateProfileOverlay, |
| 571 }; | 575 }; |
| 572 }); | 576 }); |
| OLD | NEW |