From 2ba030b5915dd234752e655ac3ed72159a9fb6b1 Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Sun, 20 Jun 2004 20:48:30 +0000 Subject: [PATCH] Merging changes on MOZILLA_1_7_BRANCH between AVIARY_1_0_20040515_BASE and MOZILLA_1_7_RELEASE: bug 162020. git-svn-id: svn://10.0.0.236/branches/AVIARY_1_0_20040515_BRANCH@158214 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/caps/src/nsScriptSecurityManager.cpp | 1 + .../windowwatcher/public/nsIPromptService.idl | 5 ++- .../public/nsPIPromptService.idl | 3 +- .../windowwatcher/src/nsPromptService.cpp | 1 + mozilla/modules/libpref/src/init/all.js | 2 + mozilla/netwerk/base/public/nsIPrompt.idl | 7 +++- .../global/resources/content/commonDialog.js | 37 +++++++++++++++++-- mozilla/xpinstall/res/content/institems.js | 17 +++++++++ 8 files changed, 65 insertions(+), 8 deletions(-) diff --git a/mozilla/caps/src/nsScriptSecurityManager.cpp b/mozilla/caps/src/nsScriptSecurityManager.cpp index f64547768b7..1caba6ac857 100644 --- a/mozilla/caps/src/nsScriptSecurityManager.cpp +++ b/mozilla/caps/src/nsScriptSecurityManager.cpp @@ -2113,6 +2113,7 @@ nsScriptSecurityManager::CheckConfirmDialog(JSContext* cx, nsIPrincipal* aPrinci PRInt32 buttonPressed = 1; // If the user exits by clicking the close box, assume No (button 1) rv = prompter->ConfirmEx(title.get(), message.get(), + (nsIPrompt::BUTTON_DELAY_ENABLE) + (nsIPrompt::BUTTON_POS_1_DEFAULT) + (nsIPrompt::BUTTON_TITLE_YES * nsIPrompt::BUTTON_POS_0) + (nsIPrompt::BUTTON_TITLE_NO * nsIPrompt::BUTTON_POS_1), diff --git a/mozilla/embedding/components/windowwatcher/public/nsIPromptService.idl b/mozilla/embedding/components/windowwatcher/public/nsIPromptService.idl index 58081fc653b..c37966f3dc3 100644 --- a/mozilla/embedding/components/windowwatcher/public/nsIPromptService.idl +++ b/mozilla/embedding/components/windowwatcher/public/nsIPromptService.idl @@ -134,7 +134,10 @@ interface nsIPromptService : nsISupports const unsigned long BUTTON_POS_0_DEFAULT = 0 << 24; const unsigned long BUTTON_POS_1_DEFAULT = 1 << 24; - const unsigned long BUTTON_POS_2_DEFAULT = 2 << 24; + const unsigned long BUTTON_POS_2_DEFAULT = 2 << 24; + + /* used for security dialogs, buttons are initially disabled */ + const unsigned long BUTTON_DELAY_ENABLE = 1 << 26; const unsigned long STD_OK_CANCEL_BUTTONS = (BUTTON_TITLE_OK * BUTTON_POS_0) + (BUTTON_TITLE_CANCEL * BUTTON_POS_1); diff --git a/mozilla/embedding/components/windowwatcher/public/nsPIPromptService.idl b/mozilla/embedding/components/windowwatcher/public/nsPIPromptService.idl index b5a4464b190..e192a20841c 100644 --- a/mozilla/embedding/components/windowwatcher/public/nsPIPromptService.idl +++ b/mozilla/embedding/components/windowwatcher/public/nsPIPromptService.idl @@ -53,7 +53,8 @@ interface nsPIPromptService : nsISupports eButton0Text=8, eButton1Text=9, eButton2Text=10, eButton3Text=11, eDialogTitle=12}; enum {eButtonPressed=0, eCheckboxState=1, eNumberButtons=2, - eNumberEditfields=3, eEditField1Password=4, eDefaultButton=5}; + eNumberEditfields=3, eEditField1Password=4, eDefaultButton=5, + eDelayButtonEnable=6}; %} void doDialog(in nsIDOMWindow aParent, in nsIDialogParamBlock aParamBlock, in string aChromeURL); diff --git a/mozilla/embedding/components/windowwatcher/src/nsPromptService.cpp b/mozilla/embedding/components/windowwatcher/src/nsPromptService.cpp index 4f9bb2306ae..2f029a580dd 100644 --- a/mozilla/embedding/components/windowwatcher/src/nsPromptService.cpp +++ b/mozilla/embedding/components/windowwatcher/src/nsPromptService.cpp @@ -302,6 +302,7 @@ nsPromptService::ConfirmEx(nsIDOMWindow *parent, block->SetInt(eDefaultButton, 0); break; } + block->SetInt(eDelayButtonEnable, buttonFlags & BUTTON_DELAY_ENABLE); PRInt32 numberButtons = 0; for (int i = 0; i < 3; i++) { diff --git a/mozilla/modules/libpref/src/init/all.js b/mozilla/modules/libpref/src/init/all.js index aaf5063ab48..04236f410e0 100644 --- a/mozilla/modules/libpref/src/init/all.js +++ b/mozilla/modules/libpref/src/init/all.js @@ -648,6 +648,8 @@ pref("security.directory", ""); pref("signed.applets.codebase_principal_support", false); pref("security.checkloaduri", true); pref("security.xpconnect.plugin.unrestricted", true); +// security-sensitive dialogs should delay button enabling. In milliseconds. +pref("security.dialog_enable_delay", 2000); // Modifier key prefs: default to Windows settings, // menu access key = alt, accelerator key = control. diff --git a/mozilla/netwerk/base/public/nsIPrompt.idl b/mozilla/netwerk/base/public/nsIPrompt.idl index 42582d6ed1d..486bce0473d 100644 --- a/mozilla/netwerk/base/public/nsIPrompt.idl +++ b/mozilla/netwerk/base/public/nsIPrompt.idl @@ -87,8 +87,11 @@ interface nsIPrompt : nsISupports const unsigned long BUTTON_POS_0_DEFAULT = 0 << 24; const unsigned long BUTTON_POS_1_DEFAULT = 1 << 24; - const unsigned long BUTTON_POS_2_DEFAULT = 2 << 24; - + const unsigned long BUTTON_POS_2_DEFAULT = 2 << 24; + + /* used for security dialogs, buttons are initially disabled */ + const unsigned long BUTTON_DELAY_ENABLE = 1 << 26; + const unsigned long STD_OK_CANCEL_BUTTONS = (BUTTON_TITLE_OK * BUTTON_POS_0) + (BUTTON_TITLE_CANCEL * BUTTON_POS_1); diff --git a/mozilla/xpfe/global/resources/content/commonDialog.js b/mozilla/xpfe/global/resources/content/commonDialog.js index 582dbf9586e..ef781bb23d5 100644 --- a/mozilla/xpfe/global/resources/content/commonDialog.js +++ b/mozilla/xpfe/global/resources/content/commonDialog.js @@ -163,27 +163,56 @@ function commonDialogOnLoad() if (gCommonDialogParam.GetInt(3) == 0) // If no text fields { + var dButton; var defaultButton = gCommonDialogParam.GetInt(5); switch (defaultButton) { case 3: - document.documentElement.getButton("extra2").focus(); + dButton = document.documentElement.getButton("extra2"); break; case 2: - document.documentElement.getButton("extra1").focus(); + dButton = document.documentElement.getButton("extra1"); break; case 1: - document.documentElement.getButton("cancel").focus(); + dButton = document.documentElement.getButton("cancel"); break; default: case 0: - document.documentElement.getButton("accept").focus(); + dButton = document.documentElement.getButton("accept"); break; } + // move the default attribute and focus from the accept button + // to the one specified in the dialog params + document.documentElement.getButton("accept").setAttribute("default",false); + dButton.setAttribute("default", true); + dButton.focus(); + } + + if (gCommonDialogParam.GetInt(6) != 0) // delay button enable + { + var delayInterval = 2000; + try { + var prefs = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); + delayInterval = prefs.getIntPref("security.dialog_enable_delay"); + } catch (e) {} + + document.documentElement.getButton("accept").disabled = true; + document.documentElement.getButton("extra1").disabled = true; + document.documentElement.getButton("extra2").disabled = true; + + setTimeout(commonDialogReenableButtons, delayInterval); } getAttention(); } +function commonDialogReenableButtons() +{ + document.documentElement.getButton("accept").disabled = false; + document.documentElement.getButton("extra1").disabled = false; + document.documentElement.getButton("extra2").disabled = false; +} + function initTextbox(aName, aLabelIndex, aValueIndex, aAlwaysLabel) { unHideElementById(aName+"Container"); diff --git a/mozilla/xpinstall/res/content/institems.js b/mozilla/xpinstall/res/content/institems.js index 9a860f345e2..bf57ed1b9f8 100644 --- a/mozilla/xpinstall/res/content/institems.js +++ b/mozilla/xpinstall/res/content/institems.js @@ -80,9 +80,26 @@ function onLoad() // Move default+focus from |accept| to |cancel| button. var aButton = document.documentElement.getButton("accept"); aButton.setAttribute("default", false); + aButton.setAttribute("label", gBundle.getString("OK")); + aButton.setAttribute("disabled", true); + aButton = document.documentElement.getButton("cancel"); aButton.focus(); aButton.setAttribute("default", true); + + // start timer to re-enable buttons + var delayInterval = 2000; + try { + var prefs = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); + delayInterval = prefs.getIntPref("security.dialog_enable_delay"); + } catch (e) {} + setTimeout(reenableInstallButtons, delayInterval); +} + +function reenableInstallButtons() +{ + document.documentElement.getButton("accept").setAttribute("disabled", false); } function onAccept()