Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: chrome/browser/resources/options2/manage_profile_overlay.js

Issue 10834142: [options2] Fix issue when deleting a user and pressing back. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/options2/manage_profile_overlay.js
diff --git a/chrome/browser/resources/options2/manage_profile_overlay.js b/chrome/browser/resources/options2/manage_profile_overlay.js
index f8cdda6c8b9b9046138c4ff66bdea54c96382021..aea0e5782d550c8aa0903207347e2fccaf807724 100644
--- a/chrome/browser/resources/options2/manage_profile_overlay.js
+++ b/chrome/browser/resources/options2/manage_profile_overlay.js
@@ -85,13 +85,17 @@ cr.define('options', function() {
didShowPage: function() {
chrome.send('requestDefaultProfileIcons');
- // Use the hash to specify the profile index. Note: the actual index
- // is ignored. Only the current profile may be edited.
- if (window.location.hash.length > 1)
+ // didShowPage happens when a page is visited via explicit user action
+ // (e.g. a user clicks "Add User" or "Edit User") or when going back or
+ // forward in history. If the user goes back to a #create page, generate a
+ // new profile info suggestion. Additionally, #edit is assumed as the
+ // default case for anything other than #create with a path of
+ // /manageProfile (as delete explicitly doesn't change the path nor
+ // generate any history events).
+ if (window.location.hash == '#create')
+ ManageProfileOverlay.getInstance().prepareForCreateDialog_();
+ else if (window.location.pathname == '/manageProfile')
ManageProfileOverlay.getInstance().prepareForManageDialog_();
-
- $('manage-profile-name').focus();
- $('create-profile-name').focus();
},
/**
@@ -233,17 +237,16 @@ cr.define('options', function() {
},
/**
- * Updates the contents of the "Manage Profile" section of the dialog,
+ * Updates the contents of the "Manage Profile" section of the dialog
* and shows that section.
* @private
*/
prepareForManageDialog_: function() {
var profileInfo = BrowserOptions.getCurrentProfile();
ManageProfileOverlay.setProfileInfo(profileInfo, 'manage');
- $('manage-profile-overlay-create').hidden = true;
- $('manage-profile-overlay-manage').hidden = false;
- $('manage-profile-overlay-delete').hidden = true;
+ this.hideAllDialogSections_($('manage-profile-overlay-manage'));
this.hideErrorBubble_('manage');
+ $('manage-profile-name').focus();
},
/**
@@ -252,7 +255,21 @@ cr.define('options', function() {
*/
showManageDialog_: function() {
this.prepareForManageDialog_();
- OptionsPage.navigateToPage('manageProfile');
+ OptionsPage.showPageByName('manageProfile', true, {hash: '#edit'});
+ },
+
+ /**
+ * Hides all dialog sections.
+ * @param {Element=} opt_exceptDialog An optional dialog to show.
+ * @private
+ */
+ hideAllDialogSections_: function(opt_exceptDialog) {
+ ['manage-profile-overlay-create',
+ 'manage-profile-overlay-manage',
+ 'manage-profile-overlay-delete'].forEach(function(id) {
+ var section = getRequiredElement(id);
+ section.hidden = opt_exceptDialog != section;
+ });
},
/**
@@ -262,9 +279,7 @@ cr.define('options', function() {
*/
showDeleteDialog_: function(profileInfo) {
ManageProfileOverlay.setProfileInfo(profileInfo, 'manage');
- $('manage-profile-overlay-create').hidden = true;
- $('manage-profile-overlay-manage').hidden = true;
- $('manage-profile-overlay-delete').hidden = false;
+ this.hideAllDialogSections_($('manage-profile-overlay-delete'));
$('delete-profile-message').textContent =
loadTimeData.getStringF('deleteProfileMessage', profileInfo.name);
$('delete-profile-message').style.backgroundImage = 'url("' +
@@ -276,23 +291,28 @@ cr.define('options', function() {
},
/**
- * Display the "Create Profile" dialog.
- * @param {Object} profileInfo The profile object of the profile to
- * create. Upon creation, this object only needs a name and an avatar.
+ * Readies the manage profile overlay to show create section of the dialog.
* @private
*/
- showCreateDialog_: function(profileInfo) {
- ManageProfileOverlay.setProfileInfo(profileInfo, 'create');
- $('manage-profile-overlay-create').hidden = false;
- $('manage-profile-overlay-manage').hidden = true;
- $('manage-profile-overlay-delete').hidden = true;
+ prepareForCreateDialog_: function() {
+ chrome.send('createProfileInfo');
+ this.hideAllDialogSections_($('manage-profile-overlay-create'));
$('create-profile-instructions').textContent =
loadTimeData.getStringF('createProfileInstructions');
ManageProfileOverlay.getInstance().hideErrorBubble_('create');
-
- OptionsPage.navigateToPage('manageProfile');
+ $('create-profile-name').focus();
},
+ /**
+ * Display the "Create Profile" dialog.
+ * @param {Object} profileInfo The profile object of the profile to
+ * create. Upon creation, this object only needs a name and an avatar.
+ * @private
+ */
+ showCreateDialog_: function() {
+ this.prepareForCreateDialog_();
+ OptionsPage.showPageByName('manageProfile', true, {hash: '#create'});
+ },
};
// Forward public APIs to private implementations.

Powered by Google App Engine
This is Rietveld 408576698