From 661e25c2c5c4986023ba581574fcc3dbba0f7f3c Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Wed, 31 Dec 2003 23:03:08 +0000 Subject: [PATCH] Fix the security warning dialogs to work as designed for Firebird: - All dialogs will appear the first time a user encounters them - The "show every time" checkbox will default to off - If the user checks the checkbox to see the dialogs every time, the choice will be remembered. Because of the change in default prefs, this will cause Firebird users to see these dialogs again (but defaulted to not show after that) when upgrading. Bug 172091, r=brendan, sr=ben. git-svn-id: svn://10.0.0.236/trunk@150816 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/browser/app/profile/all.js | 12 ++++---- mozilla/browser/app/profile/firebird.js | 12 ++++---- .../boot/src/nsSecurityWarningDialogs.cpp | 28 +++++++++++++++++++ 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/mozilla/browser/app/profile/all.js b/mozilla/browser/app/profile/all.js index 3794dbd2c25..c91b069bb16 100644 --- a/mozilla/browser/app/profile/all.js +++ b/mozilla/browser/app/profile/all.js @@ -651,9 +651,9 @@ pref("network.protocol-handler.external.news" , true); // for news // failing over to the system handlers. pref("network.protocol-handler.expose-all", true); -// Default security warning dialogs to off -pref("security.warn_entering_secure", false); -pref("security.warn_entering_weak", false); -pref("security.warn_leaving_secure", false); -pref("security.warn_viewing_mixed", false); -pref("security.warn_submit_insecure", false); +// Default security warning dialogs to show once. +pref("security.warn_entering_secure.show_once", true); +pref("security.warn_entering_weak.show_once", true); +pref("security.warn_leaving_secure.show_once", true); +pref("security.warn_viewing_mixed.show_once", true); +pref("security.warn_submit_insecure.show_once", true); diff --git a/mozilla/browser/app/profile/firebird.js b/mozilla/browser/app/profile/firebird.js index 3794dbd2c25..c91b069bb16 100644 --- a/mozilla/browser/app/profile/firebird.js +++ b/mozilla/browser/app/profile/firebird.js @@ -651,9 +651,9 @@ pref("network.protocol-handler.external.news" , true); // for news // failing over to the system handlers. pref("network.protocol-handler.expose-all", true); -// Default security warning dialogs to off -pref("security.warn_entering_secure", false); -pref("security.warn_entering_weak", false); -pref("security.warn_leaving_secure", false); -pref("security.warn_viewing_mixed", false); -pref("security.warn_submit_insecure", false); +// Default security warning dialogs to show once. +pref("security.warn_entering_secure.show_once", true); +pref("security.warn_entering_weak.show_once", true); +pref("security.warn_leaving_secure.show_once", true); +pref("security.warn_viewing_mixed.show_once", true); +pref("security.warn_submit_insecure.show_once", true); diff --git a/mozilla/security/manager/boot/src/nsSecurityWarningDialogs.cpp b/mozilla/security/manager/boot/src/nsSecurityWarningDialogs.cpp index 1855b68f12f..d9c0d437b1f 100644 --- a/mozilla/security/manager/boot/src/nsSecurityWarningDialogs.cpp +++ b/mozilla/security/manager/boot/src/nsSecurityWarningDialogs.cpp @@ -137,6 +137,20 @@ nsSecurityWarningDialogs::AlertDialog(nsIInterfaceRequestor *ctx, const char *pr // Stop if alert is not requested if (!prefValue) return NS_OK; + // Check for a show-once pref for this dialog. + // If the show-once pref is set to true: + // - The default value of the "show every time" checkbox is unchecked + // - If the user checks the checkbox, we clear the show-once pref. + + nsCAutoString showOncePref(prefName); + showOncePref += ".show_once"; + + PRBool showOnce = PR_FALSE; + mPref->GetBoolPref(showOncePref.get(), &showOnce); + + if (showOnce) + prefValue = PR_FALSE; + // Get Prompt to use nsCOMPtr prompt = do_GetInterface(ctx); if (!prompt) return NS_ERROR_FAILURE; @@ -157,6 +171,8 @@ nsSecurityWarningDialogs::AlertDialog(nsIInterfaceRequestor *ctx, const char *pr if (!prefValue) { mPref->SetBoolPref(prefName, PR_FALSE); + } else if (showOnce) { + mPref->SetBoolPref(showOncePref.get(), PR_FALSE); } return rv; @@ -211,6 +227,16 @@ nsSecurityWarningDialogs::ConfirmDialog(nsIInterfaceRequestor *ctx, const char * return NS_OK; } + // See AlertDialog() for a description of how showOnce works. + nsCAutoString showOncePref(prefName); + showOncePref += ".show_once"; + + PRBool showOnce = PR_FALSE; + mPref->GetBoolPref(showOncePref.get(), &showOnce); + + if (showOnce) + prefValue = PR_FALSE; + // Get Prompt to use nsCOMPtr prompt = do_GetInterface(ctx); if (!prompt) return NS_ERROR_FAILURE; @@ -260,6 +286,8 @@ nsSecurityWarningDialogs::ConfirmDialog(nsIInterfaceRequestor *ctx, const char * if (!prefValue && prefName != nsnull) { mPref->SetBoolPref(prefName, PR_FALSE); + } else if (prefValue && showOnce) { + mPref->SetBoolPref(showOncePref.get(), PR_TRUE); } return rv;