From a251f3d522fc13c15449667c44000ee9c8f2e7c3 Mon Sep 17 00:00:00 2001 From: Javi Rueda Date: Tue, 21 Aug 2012 11:03:46 -0400 Subject: [PATCH] Bug 503761 - 'Remember passwords' check box is broken when no history - in Private Browsing mode or when Firefox set to never remember any history; r=ehsan --- .../preferences/in-content/security.js | 18 ++++++++++++++---- browser/components/preferences/security.js | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/browser/components/preferences/in-content/security.js b/browser/components/preferences/in-content/security.js index d65081e0ada..5f384df98d8 100644 --- a/browser/components/preferences/in-content/security.js +++ b/browser/components/preferences/in-content/security.js @@ -82,17 +82,27 @@ var gSecurityPane = { /** * Enables/disables the Exceptions button used to configure sites where - * passwords are never saved. + * passwords are never saved. When browser is set to start in Private + * Browsing mode, the "Remember passwords" UI is useless, so we disable it. */ readSavePasswords: function () { var pref = document.getElementById("signon.rememberSignons"); var excepts = document.getElementById("passwordExceptions"); - excepts.disabled = !pref.value; + const Cc = Components.classes, Ci = Components.interfaces; + var pbs = Cc["@mozilla.org/privatebrowsing;1"]. + getService(Ci.nsIPrivateBrowsingService); - // don't override pref value in UI - return undefined; + if (pbs.autoStarted) { + document.getElementById("savePasswords").disabled = true; + excepts.disabled = true; + return false; + } else { + excepts.disabled = !pref.value; + // don't override pref value in UI + return undefined; + } }, /** diff --git a/browser/components/preferences/security.js b/browser/components/preferences/security.js index 8ee13f889f8..4c9945c25d5 100644 --- a/browser/components/preferences/security.js +++ b/browser/components/preferences/security.js @@ -82,17 +82,27 @@ var gSecurityPane = { /** * Enables/disables the Exceptions button used to configure sites where - * passwords are never saved. + * passwords are never saved. When browser is set to start in Private + * Browsing mode, the "Remember passwords" UI is useless, so we disable it. */ readSavePasswords: function () { var pref = document.getElementById("signon.rememberSignons"); var excepts = document.getElementById("passwordExceptions"); - excepts.disabled = !pref.value; + const Cc = Components.classes, Ci = Components.interfaces; + var pbs = Cc["@mozilla.org/privatebrowsing;1"]. + getService(Ci.nsIPrivateBrowsingService); - // don't override pref value in UI - return undefined; + if (pbs.autoStarted) { + document.getElementById("savePasswords").disabled = true; + excepts.disabled = true; + return false; + } else { + excepts.disabled = !pref.value; + // don't override pref value in UI + return undefined; + } }, /**