From 9ec275a85be8aaf656aa961e0e58ea7aac7368a4 Mon Sep 17 00:00:00 2001 From: Margaret Leibovic Date: Thu, 9 Sep 2010 19:08:26 -0700 Subject: [PATCH] Bug 588309 - Convert change password to a doorhanger panel. r=dolske, a=blocking2.0 --- .../themes/gnomestripe/browser/browser.css | 3 +- browser/themes/pinstripe/browser/browser.css | 3 +- browser/themes/winstripe/browser/browser.css | 3 +- .../passwordmgr/src/nsLoginManagerPrompter.js | 75 +++++++++++++------ 4 files changed, 57 insertions(+), 27 deletions(-) diff --git a/browser/themes/gnomestripe/browser/browser.css b/browser/themes/gnomestripe/browser/browser.css index 6df8bc187420..2db2159af3f3 100644 --- a/browser/themes/gnomestripe/browser/browser.css +++ b/browser/themes/gnomestripe/browser/browser.css @@ -1039,7 +1039,8 @@ toolbar[iconsize="small"] #fullscreen-button { list-style-image: url(chrome://global/skin/icons/question-64.png); } -.popup-notification-icon[popupid="password-save"] { +.popup-notification-icon[popupid="password-save"], +.popup-notification-icon[popupid="password-change"] { list-style-image: url(chrome://mozapps/skin/passwordmgr/key-64.png); } diff --git a/browser/themes/pinstripe/browser/browser.css b/browser/themes/pinstripe/browser/browser.css index 825f592858c3..78f70805012b 100644 --- a/browser/themes/pinstripe/browser/browser.css +++ b/browser/themes/pinstripe/browser/browser.css @@ -1975,7 +1975,8 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker { list-style-image: url(chrome://global/skin/icons/question-64.png); } -.popup-notification-icon[popupid="password-save"] { +.popup-notification-icon[popupid="password-save"], +.popup-notification-icon[popupid="password-change"] { list-style-image: url(chrome://mozapps/skin/passwordmgr/key-64.png); } diff --git a/browser/themes/winstripe/browser/browser.css b/browser/themes/winstripe/browser/browser.css index fdaf70dbffdb..982ba276f629 100644 --- a/browser/themes/winstripe/browser/browser.css +++ b/browser/themes/winstripe/browser/browser.css @@ -1890,7 +1890,8 @@ toolbarbutton.bookmark-item[dragover="true"][open="true"] { list-style-image: url(chrome://global/skin/icons/question-64.png); } -.popup-notification-icon[popupid="password-save"] { +.popup-notification-icon[popupid="password-save"], +.popup-notification-icon[popupid="password-change"] { list-style-image: url(chrome://mozapps/skin/passwordmgr/key-64.png); } diff --git a/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js b/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js index ecca59158451..0ea3c55f3c77 100644 --- a/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js +++ b/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js @@ -21,6 +21,7 @@ * Justin Dolske (original author) * Ehsan Akhgari * Frank Yan + * Margaret Leibovic * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -663,8 +664,9 @@ LoginManagerPrompter.prototype = { this.log("Updating password for " + username + " @ " + hostname + " (" + httpRealm + ")"); - if (notifyBox) - this._showChangeLoginNotification(notifyBox, + var notifyObj = this._getPopupNote() || notifyBox; + if (notifyObj) + this._showChangeLoginNotification(notifyObj, selectedLogin, password); else this._updateLogin(selectedLogin, password); @@ -1011,10 +1013,11 @@ LoginManagerPrompter.prototype = { * */ promptToChangePassword : function (aOldLogin, aNewLogin) { - var notifyBox = this._getNotifyBox(); + var notifyObj = this._getPopupNote() || this._getNotifyBox(); - if (notifyBox) - this._showChangeLoginNotification(notifyBox, aOldLogin, aNewLogin.password); + if (notifyObj) + this._showChangeLoginNotification(notifyObj, aOldLogin, + aNewLogin.password); else this._showChangeLoginDialog(aOldLogin, aNewLogin.password); }, @@ -1023,10 +1026,12 @@ LoginManagerPrompter.prototype = { /* * _showChangeLoginNotification * - * Shows the Change Password notification bar. + * Shows the Change Password notification bar or popup notification. * + * @param aNotifyObj + * A notification box or a popup notification. */ - _showChangeLoginNotification : function (aNotifyBox, aOldLogin, aNewPassword) { + _showChangeLoginNotification : function (aNotifyObj, aOldLogin, aNewPassword) { var notificationText; if (aOldLogin.username) notificationText = this._getLocalizedString( @@ -1050,30 +1055,52 @@ LoginManagerPrompter.prototype = { // without a getService() call. var self = this; - var buttons = [ + // Notification is a PopupNotification + if (aNotifyObj == this._getPopupNote()) { // "Yes" button - { + var mainAction = { label: changeButtonText, accessKey: changeButtonAccessKey, popup: null, - callback: function(aNotificationBar, aButton) { + callback: function(aNotifyObj, aButton) { self._updateLogin(aOldLogin, aNewPassword); } - }, - - // "No" button - { - label: dontChangeButtonText, - accessKey: dontChangeButtonAccessKey, - popup: null, - callback: function(aNotificationBar, aButton) { - // do nothing + }; + + var notifyWin = this._getNotifyWindow(); + var chromeWin = this._getChromeWindow(notifyWin).wrappedJSObject; + var browser = chromeWin.gBrowser. + getBrowserForDocument(this._window.top.document); + + aNotifyObj.show(browser, "password-change", notificationText, + "password-notification-icon", mainAction, + null, { timeout: Date.now() + 30000 }); + } else { + var buttons = [ + // "Yes" button + { + label: changeButtonText, + accessKey: changeButtonAccessKey, + popup: null, + callback: function(aNotifyObj, aButton) { + self._updateLogin(aOldLogin, aNewPassword); + } + }, + + // "No" button + { + label: dontChangeButtonText, + accessKey: dontChangeButtonAccessKey, + popup: null, + callback: function(aNotifyObj, aButton) { + // do nothing + } } - } - ]; - - this._showLoginNotification(aNotifyBox, "password-change", - notificationText, buttons); + ]; + + this._showLoginNotification(aNotifyObj, "password-change", + notificationText, buttons); + } },