Bug 563274 - Overhaul nsIPrompt-related prompting code. r=gavin, sr=bs
authorJustin Dolske <dolske@mozilla.com>
Wed, 16 Jun 2010 17:06:17 -0700
changeset 43706 dbe1e5c26aa3c4fecc5d31160fcfd21f0041af3f
parent 43705 9e30f01745880bb289371fba29ad7a12eca3acd8
child 43707 372676dd201a30f995461184b4c73f32cead7419
push idunknown
push userunknown
push dateunknown
reviewersgavin, bs
bugs563274
milestone1.9.3a6pre
Bug 563274 - Overhaul nsIPrompt-related prompting code. r=gavin, sr=bs
embedding/components/build/nsEmbeddingModule.cpp
embedding/components/windowwatcher/public/Makefile.in
embedding/components/windowwatcher/public/nsIAuthPromptWrapper.idl
embedding/components/windowwatcher/src/Makefile.in
embedding/components/windowwatcher/src/nsPrompt.cpp
embedding/components/windowwatcher/src/nsPrompt.h
embedding/components/windowwatcher/src/nsPromptService.cpp
embedding/components/windowwatcher/src/nsPromptService.h
embedding/components/windowwatcher/src/nsWindowWatcher.cpp
embedding/components/windowwatcher/src/nsWindowWatcher.h
netwerk/base/src/nsPACMan.cpp
netwerk/build/nsNetCID.h
netwerk/test/unit/test_authentication.js
netwerk/test/unit/test_authpromptwrapper.js
toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js
toolkit/components/prompts/content/commonDialog.css
toolkit/components/prompts/content/commonDialog.js
toolkit/components/prompts/content/commonDialog.xul
toolkit/components/prompts/content/selectDialog.js
toolkit/components/prompts/content/selectDialog.xul
toolkit/components/prompts/jar.mn
toolkit/components/prompts/src/nsPrompter.js
toolkit/components/prompts/test/test_modal_prompts.html
toolkit/content/commonDialog.css
toolkit/content/commonDialog.js
toolkit/content/commonDialog.xul
toolkit/content/jar.mn
toolkit/content/selectDialog.js
toolkit/content/selectDialog.xul
toolkit/locales/en-US/chrome/global/commonDialog.dtd
--- a/embedding/components/build/nsEmbeddingModule.cpp
+++ b/embedding/components/build/nsEmbeddingModule.cpp
@@ -32,28 +32,26 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIGenericFactory.h"
 #include "nsDialogParamBlock.h"
-#include "nsPromptService.h"
 #include "nsWindowWatcher.h"
 #include "nsAppStartupNotifier.h"
 #include "nsFind.h"
 #include "nsWebBrowserFind.h"
 #include "nsWebBrowserPersist.h"
 #include "nsCommandManager.h"
 #include "nsControllerCommandTable.h"
 #include "nsCommandParams.h"
 #include "nsCommandGroup.h"
 #include "nsBaseCommandController.h"
-#include "nsPrompt.h"
 #include "nsNetCID.h"
 #include "nsEmbedCID.h"
 
 #ifdef NS_PRINTING
 #ifndef WINCE
 #include "nsPrintingPromptService.h"
 #endif
 #endif
@@ -65,93 +63,40 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsFind)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebBrowserFind)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebBrowserPersist)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsControllerCommandTable)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCommandManager)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCommandParams, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsControllerCommandGroup)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBaseCommandController)
 
-#define NS_DEFAULTPROMPT_CLASSNAME \
-    "nsDefaultPrompt"
-#define NS_DEFAULTPROMPT_CID                         \
-{ /* 2e41ada0-62b7-4902-b9a6-e4542aa458ba */         \
-    0x2e41ada0,                                      \
-    0x62b7,                                          \
-    0x4902,                                          \
-    {0xb9, 0xa6, 0xe4, 0x54, 0x2a, 0xa4, 0x58, 0xba} \
-}
-
-#define NS_DEFAULTAUTHPROMPT_CLASSNAME \
-    "nsDefaultAuthPrompt"
-#define NS_DEFAULTAUTHPROMPT_CID                     \
-{ /* ca200860-4696-40d7-88fa-4490d423a8ef */         \
-    0xca200860,                                      \
-    0x4696,                                          \
-    0x40d7,                                          \
-    {0x88, 0xfa, 0x44, 0x90, 0xd4, 0x23, 0xa8, 0xef} \
-}
-
-static NS_METHOD
-nsDefaultPromptConstructor(nsISupports *outer, const nsIID &iid, void **result)
-{
-  if (outer)
-    return NS_ERROR_NO_AGGREGATION;
-
-  nsCOMPtr<nsIPrompt> prompt;
-  nsresult rv = NS_NewPrompter(getter_AddRefs(prompt), nsnull);
-  if (NS_FAILED(rv))
-    return rv;
-
-  return prompt->QueryInterface(iid, result);
-}
-
-static NS_METHOD
-nsDefaultAuthPromptConstructor(nsISupports *outer, const nsIID &iid, void **result)
-{
-  if (outer)
-    return NS_ERROR_NO_AGGREGATION;
-
-  nsCOMPtr<nsIAuthPrompt> prompt;
-  nsresult rv = NS_NewAuthPrompter(getter_AddRefs(prompt), nsnull);
-  if (NS_FAILED(rv))
-    return rv;
-
-  return prompt->QueryInterface(iid, result);
-}
-
 #ifdef MOZ_XUL
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDialogParamBlock)
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPromptService, Init)
 #ifdef NS_PRINTING
 #ifndef WINCE
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintingPromptService, Init)
 #endif
 #endif
 #endif
 
 static const nsModuleComponentInfo gComponents[] = {
 
 #ifdef MOZ_XUL
   { "Dialog ParamBlock", NS_DIALOGPARAMBLOCK_CID, NS_DIALOGPARAMBLOCK_CONTRACTID, nsDialogParamBlockConstructor },
-  { "Prompt Service", NS_PROMPTSERVICE_CID, NS_PROMPTSERVICE_CONTRACTID, nsPromptServiceConstructor },
 #ifdef NS_PRINTING
 #ifndef WINCE
   { "Printing Prompt Service", NS_PRINTINGPROMPTSERVICE_CID, NS_PRINTINGPROMPTSERVICE_CONTRACTID, nsPrintingPromptServiceConstructor },
 #endif
 #endif
 #endif
   { "Window Watcher", NS_WINDOWWATCHER_CID, NS_WINDOWWATCHER_CONTRACTID, nsWindowWatcherConstructor },
-  { "Window Watcher", NS_WINDOWWATCHER_CID, NS_AUTHPROMPT_ADAPTER_FACTORY_CONTRACTID, nsWindowWatcherConstructor },
   { "Find",           NS_FIND_CID, NS_FIND_CONTRACTID, nsFindConstructor },
   { "WebBrowserFind",           NS_WEB_BROWSER_FIND_CID, NS_WEB_BROWSER_FIND_CONTRACTID, nsWebBrowserFindConstructor },
   { NS_APPSTARTUPNOTIFIER_CLASSNAME, NS_APPSTARTUPNOTIFIER_CID, NS_APPSTARTUPNOTIFIER_CONTRACTID, nsAppStartupNotifierConstructor },
   { "WebBrowserPersist Component", NS_WEBBROWSERPERSIST_CID, NS_WEBBROWSERPERSIST_CONTRACTID, nsWebBrowserPersistConstructor },
   { "Controller Command Table", NS_CONTROLLERCOMMANDTABLE_CID, NS_CONTROLLERCOMMANDTABLE_CONTRACTID, nsControllerCommandTableConstructor },
   { "Command Manager", NS_COMMAND_MANAGER_CID, NS_COMMAND_MANAGER_CONTRACTID, nsCommandManagerConstructor },
   { "Command Params", NS_COMMAND_PARAMS_CID, NS_COMMAND_PARAMS_CONTRACTID, nsCommandParamsConstructor },
   { "Command Group", NS_CONTROLLER_COMMAND_GROUP_CID, NS_CONTROLLER_COMMAND_GROUP_CONTRACTID, nsControllerCommandGroupConstructor },
   { "Base Command Controller", NS_BASECOMMANDCONTROLLER_CID, NS_BASECOMMANDCONTROLLER_CONTRACTID, nsBaseCommandControllerConstructor },
-  { NS_DEFAULTPROMPT_CLASSNAME, NS_DEFAULTPROMPT_CID, NS_DEFAULTPROMPT_CONTRACTID, nsDefaultPromptConstructor },
-  { NS_DEFAULTAUTHPROMPT_CLASSNAME, NS_DEFAULTAUTHPROMPT_CID, NS_DEFAULTAUTHPROMPT_CONTRACTID, nsDefaultAuthPromptConstructor }
 };
 
 NS_IMPL_NSGETMODULE(embedcomponents, gComponents)
--- a/embedding/components/windowwatcher/public/Makefile.in
+++ b/embedding/components/windowwatcher/public/Makefile.in
@@ -50,17 +50,16 @@ GRE_MODULE	= 1
 SDK_XPIDLSRCS   = nsIWindowWatcher.idl \
 		  nsIPromptService.idl \
 		  $(NULL)
 
 XPIDLSRCS	= nsIDialogParamBlock.idl \
                   nsIPromptService2.idl \
                   nsPIPromptService.idl \
                   nsPIWindowWatcher.idl \
-                  nsIAuthPromptWrapper.idl \
                   nsIPromptFactory.idl \
                   $(NULL)
 
 EXPORTS		= nsPromptUtils.h \
                   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
deleted file mode 100644
--- a/embedding/components/windowwatcher/public/nsIAuthPromptWrapper.idl
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * 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
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsIAuthPrompt.idl"
-
-interface nsIPrompt;
-
-/**
- * nsIAuthPromptWrapper
- *
- * An override of nsIAuthPrompt which performs some action
- * on the data going through nsIAuthPrompt methods. Persisting
- * data from the prompts and using it to pre-fill subsequent prompts
- * would be one such action.
- *
- * @status
- */
-
-[scriptable, uuid(7708b352-35e0-47f6-a1c2-ccdd3319d0ab)]
-interface nsIAuthPromptWrapper : nsIAuthPrompt
-{
-    /**
-     * setPromptDialogs
-     *
-     * @param dialogs  the dialog implementation which will
-     *                 be used to display the prompts
-     */ 
-    void setPromptDialogs(in nsIPrompt dialogs);
-};
--- a/embedding/components/windowwatcher/src/Makefile.in
+++ b/embedding/components/windowwatcher/src/Makefile.in
@@ -42,25 +42,24 @@ VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= embedcomponents
 LIBRARY_NAME	= windowwatcher_s
 LIBXUL_LIBRARY	= 1
 
 
-CPPSRCS		= nsPrompt.cpp \
+CPPSRCS		= \
                   nsWWJSUtils.cpp \
                   nsWindowWatcher.cpp  \
                   nsAutoWindowStateHelper.cpp \
                   $(NULL)
 
 ifdef MOZ_XUL
 CPPSRCS		+= nsDialogParamBlock.cpp \
-		   nsPromptService.cpp \
 		   $(NULL)
 endif
 
 # we don't want the shared lib, but we want to force the creation of a
 # static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/embedding/components/windowwatcher/src/nsPrompt.cpp
+++ /dev/null
@@ -1,590 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sts=2 sw=2 et cin: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *     Google Inc.
- *
- * 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
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsIServiceManager.h"
-#include "nsIAuthPromptWrapper.h"
-#include "nsIAuthInformation.h"
-#include "nsPrompt.h"
-#include "nsReadableUtils.h"
-#include "nsDependentString.h"
-#include "nsIStringBundle.h"
-#include "nsIChannel.h"
-#include "nsIURI.h"
-#include "nsEmbedCID.h"
-#include "nsNetCID.h"
-#include "nsPIDOMWindow.h"
-#include "nsIPromptFactory.h"
-#include "nsIProxiedChannel.h"
-#include "nsIProxyInfo.h"
-#include "nsIIDNService.h"
-#include "nsNetUtil.h"
-#include "nsPromptUtils.h"
-#include "nsIPrefService.h"
-#include "nsIPrefLocalizedString.h"
-
-
-nsresult
-NS_NewPrompter(nsIPrompt **result, nsIDOMWindow *aParent)
-{
-  nsresult rv;
-  *result = 0;
-
-  nsPrompt *prompter = new nsPrompt(aParent);
-  if (!prompter)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  NS_ADDREF(prompter);
-  rv = prompter->Init();
-  if (NS_FAILED(rv)) {
-    NS_RELEASE(prompter);
-    return rv;
-  }
-
-  *result = prompter;
-  return NS_OK;
-}
-
-nsresult
-NS_NewAuthPrompter(nsIAuthPrompt **result, nsIDOMWindow *aParent)
-{
-  nsresult rv;
-  nsCOMPtr<nsIPromptFactory> factory =
-    do_GetService(NS_PWMGR_AUTHPROMPTFACTORY);
-  if (factory) {
-    // We just delegate everything to the pw mgr if we can
-    rv = factory->GetPrompt(aParent,
-                            NS_GET_IID(nsIAuthPrompt),
-                            reinterpret_cast<void**>(result));
-    // If the password manager doesn't support the interface, fall back to the
-    // old way of doing things. This will allow older apps that haven't updated
-    // to work still.
-    if (rv != NS_NOINTERFACE)
-      return rv;
-  }
-
-  *result = 0;
-
-  nsPrompt *prompter = new nsPrompt(aParent);
-  if (!prompter)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  NS_ADDREF(prompter);
-  rv = prompter->Init();
-  if (NS_FAILED(rv)) {
-    NS_RELEASE(prompter);
-    return rv;
-  }
-
-  *result = prompter;
-  // wrap the base prompt in an nsIAuthPromptWrapper, if available
-  // the impl used here persists prompt data and pre-fills the dialogs
-  nsCOMPtr<nsIAuthPromptWrapper> siPrompt =
-    do_CreateInstance("@mozilla.org/wallet/single-sign-on-prompt;1");
-  if (siPrompt) {
-    // then single sign-on is installed
-    rv = siPrompt->SetPromptDialogs(prompter);
-    if (NS_SUCCEEDED(rv)) {
-      *result = siPrompt;
-      NS_RELEASE(prompter); // siPrompt is a strong owner
-      NS_ADDREF(*result);
-    }
-  }
-  return NS_OK;
-}
-
-nsresult
-NS_NewAuthPrompter2(nsIAuthPrompt2 **result, nsIDOMWindow *aParent)
-{
-  nsresult rv;
-
-  nsCOMPtr<nsIPromptFactory> factory =
-    do_GetService(NS_PWMGR_AUTHPROMPTFACTORY);
-  if (factory) {
-    // We just delegate everything to the pw mgr.
-    rv = factory->GetPrompt(aParent,
-                              NS_GET_IID(nsIAuthPrompt2),
-                              reinterpret_cast<void**>(result));
-    // Bug 403115. Don't suppress error if interface isn't supported.
-    if (NS_SUCCEEDED(rv) || rv == NS_NOINTERFACE)
-        return rv;
-  }
-
-  *result = 0;
-
-  nsPrompt *prompter = new nsPrompt(aParent);
-  if (!prompter)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  NS_ADDREF(prompter);
-  rv = prompter->Init();
-  if (NS_FAILED(rv)) {
-    NS_RELEASE(prompter);
-    return rv;
-  }
-
-  *result = prompter;
-  return NS_OK;
-}
-
-NS_IMPL_THREADSAFE_ISUPPORTS3(nsPrompt, nsIPrompt, nsIAuthPrompt, nsIAuthPrompt2)
-
-nsPrompt::nsPrompt(nsIDOMWindow *aParent)
-  : mParent(aParent)
-{
-#ifdef DEBUG
-  {
-    nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(aParent));
-
-    NS_ASSERTION(!win || win->IsOuterWindow(),
-                 "Inner window passed as nsPrompt parent!");
-  }
-#endif
-}
-
-nsresult
-nsPrompt::Init()
-{
-  mPromptService = do_GetService(NS_PROMPTSERVICE_CONTRACTID);
-  mPromptService2 = do_QueryInterface(mPromptService);
-  // A null mPromptService2 is not fatal, we have to deal with that
-  // (for compatibility with embeddors who only implement the old version)
-  return mPromptService ? NS_OK : NS_ERROR_FAILURE;
-}
-
-//*****************************************************************************
-// nsPrompt::nsIPrompt
-//*****************************************************************************
-
-NS_IMETHODIMP
-nsPrompt::Alert(const PRUnichar* dialogTitle, 
-                const PRUnichar* text)
-{
-  return mPromptService->Alert(mParent, dialogTitle, text);
-}
-
-NS_IMETHODIMP
-nsPrompt::AlertCheck(const PRUnichar* dialogTitle, 
-                     const PRUnichar* text,
-                     const PRUnichar* checkMsg,
-                     PRBool *checkValue)
-{
-  return mPromptService->AlertCheck(mParent, dialogTitle, text, checkMsg,
-                                    checkValue);
-}
-
-NS_IMETHODIMP
-nsPrompt::Confirm(const PRUnichar* dialogTitle, 
-                  const PRUnichar* text,
-                  PRBool *_retval)
-{
-  return mPromptService->Confirm(mParent, dialogTitle, text, _retval);
-}
-
-NS_IMETHODIMP
-nsPrompt::ConfirmCheck(const PRUnichar* dialogTitle, 
-                       const PRUnichar* text,
-                       const PRUnichar* checkMsg,
-                       PRBool *checkValue,
-                       PRBool *_retval)
-{
-  return mPromptService->ConfirmCheck(mParent, dialogTitle, text, checkMsg,
-                                      checkValue, _retval);
-}
-
-NS_IMETHODIMP
-nsPrompt::ConfirmEx(const PRUnichar *dialogTitle,
-                    const PRUnichar *text,
-                    PRUint32 buttonFlags,
-                    const PRUnichar *button0Title,
-                    const PRUnichar *button1Title,
-                    const PRUnichar *button2Title,
-                    const PRUnichar *checkMsg,
-                    PRBool *checkValue,
-                    PRInt32 *buttonPressed)
-{
-  return mPromptService->ConfirmEx(mParent, dialogTitle, text, buttonFlags,
-                                   button0Title, button1Title, button2Title,
-                                   checkMsg, checkValue, buttonPressed);
-}
-
-NS_IMETHODIMP
-nsPrompt::Prompt(const PRUnichar *dialogTitle,
-                 const PRUnichar *text,
-                 PRUnichar **answer,
-                 const PRUnichar *checkMsg,
-                 PRBool *checkValue,
-                 PRBool *_retval)
-{
-  return mPromptService->Prompt(mParent, dialogTitle, text, answer, checkMsg,
-                                checkValue, _retval);
-}
-
-NS_IMETHODIMP
-nsPrompt::PromptUsernameAndPassword(const PRUnichar *dialogTitle,
-                                    const PRUnichar *text,
-                                    PRUnichar **username,
-                                    PRUnichar **password,
-                                    const PRUnichar *checkMsg,
-                                    PRBool *checkValue,
-                                    PRBool *_retval)
-{
-  return mPromptService->PromptUsernameAndPassword(mParent, dialogTitle, text,
-                                                   username, password,
-                                                   checkMsg, checkValue,
-                                                   _retval);
-}
-
-NS_IMETHODIMP
-nsPrompt::PromptPassword(const PRUnichar *dialogTitle,
-                         const PRUnichar *text,
-                         PRUnichar **password,
-                         const PRUnichar *checkMsg,
-                         PRBool *checkValue,
-                         PRBool *_retval)
-{
-  return mPromptService->PromptPassword(mParent, dialogTitle, text, password,
-                                        checkMsg, checkValue, _retval);
-}
-
-NS_IMETHODIMP
-nsPrompt::Select(const PRUnichar *dialogTitle,
-                 const PRUnichar* inMsg,
-                 PRUint32 inCount, 
-                 const PRUnichar **inList,
-                 PRInt32 *outSelection,
-                 PRBool *_retval)
-{
-  return mPromptService->Select(mParent, dialogTitle, inMsg, inCount, inList,
-                                outSelection, _retval);
-}
-
-//*****************************************************************************
-// nsPrompt::nsIAuthPrompt
-// This implementation serves as glue between nsIAuthPrompt and nsIPrompt
-// when a single-signon was not available.
-//*****************************************************************************   
-
-NS_IMETHODIMP
-nsPrompt::Prompt(const PRUnichar* dialogTitle,
-                 const PRUnichar* text,
-                 const PRUnichar* passwordRealm,
-                 PRUint32 savePassword,
-                 const PRUnichar* defaultText,
-                 PRUnichar* *result,
-                 PRBool *_retval)
-{
-  // Ignore passwordRealm and savePassword
-  if (defaultText) {
-    *result = ToNewUnicode(nsDependentString(defaultText));
-
-    if (!*result) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-  }
-
-  return mPromptService->Prompt(mParent, dialogTitle, text, result, nsnull,
-                                nsnull, _retval);
-}
-
-NS_IMETHODIMP
-nsPrompt::PromptUsernameAndPassword(const PRUnichar* dialogTitle, 
-                                    const PRUnichar* text,
-                                    const PRUnichar* passwordRealm,
-                                    PRUint32 savePassword,
-                                    PRUnichar* *user,
-                                    PRUnichar* *pwd,
-                                    PRBool *_retval)
-{
-  // Ignore passwordRealm and savePassword
-  return mPromptService->PromptUsernameAndPassword(mParent, dialogTitle, text,
-                                                   user, pwd, nsnull, nsnull,
-                                                   _retval);
-}
-
-NS_IMETHODIMP
-nsPrompt::PromptPassword(const PRUnichar* dialogTitle, 
-                         const PRUnichar* text,
-                         const PRUnichar* passwordRealm,
-                         PRUint32 savePassword,
-                         PRUnichar* *pwd,
-                         PRBool *_retval)
-{
-  // Ignore passwordRealm and savePassword
-  return mPromptService->PromptPassword(mParent, dialogTitle, text, pwd,
-                                        nsnull, nsnull, _retval);
-}
-NS_IMETHODIMP
-nsPrompt::PromptAuth(nsIChannel* aChannel,
-                     PRUint32 aLevel,
-                     nsIAuthInformation* aAuthInfo,
-                     PRBool* retval)
-{
-  if (mPromptService2) {
-    return mPromptService2->PromptAuth(mParent, aChannel,
-                                       aLevel, aAuthInfo,
-                                       nsnull, nsnull, retval);
-  }
-
-  return PromptPasswordAdapter(mPromptService, mParent, aChannel,
-                               aLevel, aAuthInfo, nsnull, nsnull, retval);
-}
-
-NS_IMETHODIMP
-nsPrompt::AsyncPromptAuth(nsIChannel* aChannel,
-                          nsIAuthPromptCallback* aCallback,
-                          nsISupports* aContext,
-                          PRUint32 aLevel,
-                          nsIAuthInformation* aAuthInfo,
-                          nsICancelable** retval)
-{
-  if (mPromptService2) {
-    return mPromptService2->AsyncPromptAuth(mParent, aChannel,
-                                            aCallback, aContext,
-                                            aLevel, aAuthInfo,
-                                            nsnull, nsnull, retval);
-  }
-
-  // Tell the caller to use the sync version
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-static nsresult
-MakeDialogText(nsIChannel* aChannel, nsIAuthInformation* aAuthInfo,
-               nsXPIDLString& message)
-{
-  nsresult rv;
-  nsCOMPtr<nsIStringBundleService> bundleSvc =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsIStringBundle> bundle;
-  rv = bundleSvc->CreateBundle("chrome://global/locale/commonDialogs.properties",
-                               getter_AddRefs(bundle));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // figure out what message to display...
-  nsCAutoString host;
-  PRInt32 port;
-  NS_GetAuthHostPort(aChannel, aAuthInfo, PR_FALSE, host, &port);
-
-  nsAutoString displayHost;
-  CopyUTF8toUTF16(host, displayHost);
-
-  nsCOMPtr<nsIURI> uri;
-  aChannel->GetURI(getter_AddRefs(uri));
-
-  nsCAutoString scheme;
-  uri->GetScheme(scheme);
-
-  nsAutoString username;
-  aAuthInfo->GetUsername(username);
-
-  PRUint32 flags;
-  aAuthInfo->GetFlags(&flags);
-  PRBool proxyAuth = (flags & nsIAuthInformation::AUTH_PROXY) != 0;
-
-  nsAutoString realm;
-  aAuthInfo->GetRealm(realm);
-  // Trim obnoxiously long realms.
-  if (realm.Length() > 150) {
-    realm.Truncate(150);
-
-    // Append "..." (or localized equivalent). Yay complexity.
-    nsAutoString ellipsis;
-    nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
-    if (prefs) {
-      nsCOMPtr<nsIPrefLocalizedString> prefString;
-      rv = prefs->GetComplexValue("intl.ellipsis",
-                                  NS_GET_IID(nsIPrefLocalizedString),
-                                  getter_AddRefs(prefString));
-      if (prefString)
-        prefString->ToString(getter_Copies(ellipsis));
-    }
-    if (ellipsis.IsEmpty())
-      ellipsis.AssignLiteral("...");
-
-    realm.Append(ellipsis);
-  }
-
-  // Append the port if it was specified
-  if (port != -1) {
-    displayHost.Append(PRUnichar(':'));
-    displayHost.AppendInt(port);
-  }
-
-  NS_NAMED_LITERAL_STRING(proxyText, "EnterLoginForProxy");
-  NS_NAMED_LITERAL_STRING(originText, "EnterLoginForRealm");
-  NS_NAMED_LITERAL_STRING(noRealmText, "EnterUserPasswordFor");
-  NS_NAMED_LITERAL_STRING(passwordText, "EnterPasswordFor");
-
-  const PRUnichar *text;
-  if (proxyAuth) {
-    text = proxyText.get();
-  } else {
-    text = originText.get();
-
-    // prepend "scheme://"
-    nsAutoString schemeU; 
-    CopyASCIItoUTF16(scheme, schemeU);
-    schemeU.AppendLiteral("://");
-    displayHost.Insert(schemeU, 0);
-  }
-
-  const PRUnichar *strings[] = { realm.get(), displayHost.get() };
-  PRUint32 count = NS_ARRAY_LENGTH(strings);
-
-  if (flags & nsIAuthInformation::ONLY_PASSWORD) {
-    text = passwordText.get();
-    strings[0] = username.get();
-  } else if (!proxyAuth && realm.IsEmpty()) {
-    text = noRealmText.get();
-    count--;
-    strings[0] = strings[1];
-  }
-
-  rv = bundle->FormatStringFromName(text, strings, count, getter_Copies(message));
-  return rv;
-}
-
-/* static */ nsresult
-nsPrompt::PromptPasswordAdapter(nsIPromptService* aService,
-                                nsIDOMWindow* aParent,
-                                nsIChannel* aChannel,
-                                PRUint32 aLevel,
-                                nsIAuthInformation* aAuthInfo,
-                                const PRUnichar* aCheckLabel,
-                                PRBool* aCheckValue,
-                                PRBool* retval)
-{
-  // construct the message string
-  nsXPIDLString message;
-  MakeDialogText(aChannel, aAuthInfo, message);
-
-  nsAutoString defaultUser, defaultDomain, defaultPass;
-  aAuthInfo->GetUsername(defaultUser);
-  aAuthInfo->GetDomain(defaultDomain);
-  aAuthInfo->GetPassword(defaultPass);
-
-  PRUint32 flags;
-  aAuthInfo->GetFlags(&flags);
-
-  if ((flags & nsIAuthInformation::NEED_DOMAIN) && !defaultDomain.IsEmpty()) {
-    defaultDomain.Append(PRUnichar('\\'));
-    defaultUser.Insert(defaultDomain, 0);
-  }
-
-  // NOTE: Allocation failure is not fatal here (just default to empty string
-  // if allocation fails)
-  PRUnichar *user = ToNewUnicode(defaultUser),
-            *pass = ToNewUnicode(defaultPass);
-  nsresult rv;
-  if (flags & nsIAuthInformation::ONLY_PASSWORD)
-    rv = aService->PromptPassword(aParent, nsnull, message.get(),
-                                  &pass, aCheckLabel,
-                                  aCheckValue, retval);
-  else
-    rv = aService->PromptUsernameAndPassword(aParent, nsnull, message.get(),
-                                             &user, &pass, aCheckLabel,
-                                             aCheckValue, retval);
-
-  nsAdoptingString userStr(user);
-  nsAdoptingString passStr(pass);
-  NS_SetAuthInfo(aAuthInfo, userStr, passStr);
-
-  return rv;
-}
-
-NS_IMPL_THREADSAFE_ISUPPORTS1(AuthPromptWrapper, nsIAuthPrompt2)
-
-NS_IMETHODIMP
-AuthPromptWrapper::PromptAuth(nsIChannel* aChannel,
-                              PRUint32 aLevel,
-                              nsIAuthInformation* aAuthInfo,
-                              PRBool* retval)
-{
-  nsCAutoString keyUTF8;
-  NS_GetAuthKey(aChannel, aAuthInfo, keyUTF8);
-
-  NS_ConvertUTF8toUTF16 key(keyUTF8);
-
-  nsXPIDLString text;
-  MakeDialogText(aChannel, aAuthInfo, text);
-
-  PRUint32 flags;
-  aAuthInfo->GetFlags(&flags);
-
-  nsresult rv;
-  nsXPIDLString user, password;
-  if (flags & nsIAuthInformation::ONLY_PASSWORD) {
-    rv = mAuthPrompt->PromptPassword(nsnull, text.get(), key.get(),
-                                     nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
-                                     getter_Copies(password), retval);
-    if (NS_SUCCEEDED(rv) && *retval) {
-      NS_ASSERTION(password, "password must not be null if retval is true");
-      aAuthInfo->SetPassword(password);
-    }
-  } else {
-    rv = mAuthPrompt->PromptUsernameAndPassword(nsnull, text.get(), key.get(),
-                                                nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
-                                                getter_Copies(user),
-                                                getter_Copies(password),
-                                                retval);
-    if (NS_SUCCEEDED(rv) && *retval) {
-      NS_ASSERTION(user && password, "out params must be nonnull");
-      NS_SetAuthInfo(aAuthInfo, user, password);
-    }
-  }
-  return rv;
-}
-
-NS_IMETHODIMP
-AuthPromptWrapper::AsyncPromptAuth(nsIChannel*,
-                                   nsIAuthPromptCallback*,
-                                   nsISupports*,
-                                   PRUint32,
-                                   nsIAuthInformation*,
-                                   nsICancelable**)
-{
-  // There is no way to implement this here. Just tell the caller
-  // to fall back to the synchronous version.
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-
-
deleted file mode 100644
--- a/embedding/components/windowwatcher/src/nsPrompt.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * 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
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsCOMPtr.h"
-#include "nsIDOMWindow.h"
-#include "nsIPrompt.h"
-#include "nsIAuthPrompt.h"
-#include "nsIAuthPrompt2.h"
-#include "nsIPromptService.h"
-#include "nsIPromptService2.h"
-
-class nsPrompt : public nsIPrompt,
-                 public nsIAuthPrompt,
-                 public nsIAuthPrompt2 {
-
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIPROMPT
-  NS_DECL_NSIAUTHPROMPT
-  NS_DECL_NSIAUTHPROMPT2
-
-  nsPrompt(nsIDOMWindow *window);
-  virtual ~nsPrompt() {}
-
-  nsresult Init();
-
-  /**
-   * This helper method can be used to implement nsIAuthPrompt2's
-   * PromptPassword function using nsIPromptService (as opposed to
-   * nsIPromptService2).
-   */
-  static nsresult PromptPasswordAdapter(nsIPromptService* aService,
-                                        nsIDOMWindow* aParent,
-                                        nsIChannel* aChannel,
-                                        PRUint32 aLevel,
-                                        nsIAuthInformation* aAuthInfo,
-                                        const PRUnichar* aCheckLabel,
-                                        PRBool* aCheckValue,
-                                        PRBool* retval);
-
-protected:
-  nsCOMPtr<nsIDOMWindow>        mParent;
-  nsCOMPtr<nsIPromptService>    mPromptService;
-  // This is the new prompt service version. May be null.
-  nsCOMPtr<nsIPromptService2>   mPromptService2;
-};
-
-/**
- * A class that wraps an nsIAuthPrompt so that it can be used as an
- * nsIAuthPrompt2.
- */
-class AuthPromptWrapper : public nsIAuthPrompt2
-{
-  public:
-    AuthPromptWrapper(nsIAuthPrompt* aAuthPrompt) :
-      mAuthPrompt(aAuthPrompt) {}
-
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIAUTHPROMPT2
-
-  private:
-    ~AuthPromptWrapper() {}
-
-    nsCOMPtr<nsIAuthPrompt> mAuthPrompt;
-};
-
-nsresult
-NS_NewPrompter(nsIPrompt **result, nsIDOMWindow *aParent);
-
-nsresult
-NS_NewAuthPrompter(nsIAuthPrompt **result, nsIDOMWindow *aParent);
-
-nsresult
-NS_NewAuthPrompter2(nsIAuthPrompt2 **result, nsIDOMWindow *aParent);
deleted file mode 100644
--- a/embedding/components/windowwatcher/src/nsPromptService.cpp
+++ /dev/null
@@ -1,786 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * 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
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsPromptService.h"
-#include "nsPrompt.h"
-
-#include "nsDialogParamBlock.h"
-#include "nsIComponentManager.h"
-#include "nsIDialogParamBlock.h"
-#include "nsIDOMWindow.h"
-#include "nsPIDOMWindow.h"
-#include "nsIDOMEventTarget.h"
-#include "nsIDOMEvent.h"
-#include "nsIPrivateDOMEvent.h"
-#include "nsIDOMDocumentEvent.h"
-#include "nsIServiceManager.h"
-#include "nsISupportsUtils.h"
-#include "nsString.h"
-#include "nsIStringBundle.h"
-#include "nsXPIDLString.h"
-#include "nsISound.h"
-
-static const char kPromptURL[] = "chrome://global/content/commonDialog.xul";
-static const char kSelectPromptURL[] = "chrome://global/content/selectDialog.xul";
-static const char kQuestionIconClass[] = "question-icon";
-static const char kAlertIconClass[] = "alert-icon";
-// We include question-icon for backwards compatibility
-static const char kAuthenticationIconClass[] = "authentication-icon question-icon";
-
-#define kCommonDialogsProperties "chrome://global/locale/commonDialogs.properties"
-
-/****************************************************************
- ************************* ParamBlock ***************************
- ****************************************************************/
-
-class ParamBlock {
-
-public:
-  ParamBlock() {
-    mBlock = 0;
-  }
-  ~ParamBlock() {
-    NS_IF_RELEASE(mBlock);
-  }
-  nsresult Init() {
-    return CallCreateInstance(NS_DIALOGPARAMBLOCK_CONTRACTID, &mBlock);
-  }
-  nsIDialogParamBlock * operator->() const { return mBlock; }
-  operator nsIDialogParamBlock * const () { return mBlock; }
-
-private:
-  nsIDialogParamBlock *mBlock;
-};
-
-/****************************************************************
- ************************ nsPromptService ***********************
- ****************************************************************/
-
-NS_IMPL_ISUPPORTS3(nsPromptService, nsIPromptService, nsIPromptService2,
-                   nsPIPromptService)
-
-nsPromptService::nsPromptService() {
-}
-
-nsPromptService::~nsPromptService() {
-}
-
-nsresult
-nsPromptService::Init()
-{
-  nsresult rv;
-  mWatcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
-  return rv;
-}
-
-NS_IMETHODIMP
-nsPromptService::Alert(nsIDOMWindow *parent,
-                   const PRUnichar *dialogTitle, const PRUnichar *text)
-{
-  nsAutoWindowStateHelper windowStateHelper(parent);
-
-  if (!windowStateHelper.DefaultEnabled()) {
-    return NS_OK;
-  }
-
-  nsresult rv;
-  nsXPIDLString stringOwner;
- 
-  if (!dialogTitle) {
-    rv = GetLocaleString("Alert", getter_Copies(stringOwner));
-    if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-    dialogTitle = stringOwner.get();
-  }
-
-  ParamBlock block;
-  rv = block.Init();
-  if (NS_FAILED(rv))
-    return rv;
-
-  block->SetInt(eNumberButtons, 1);
-  block->SetString(eMsg, text);
-
-  block->SetString(eDialogTitle, dialogTitle);
-
-  nsString url;
-  NS_ConvertASCIItoUTF16 styleClass(kAlertIconClass);
-  block->SetString(eIconClass, styleClass.get());
-  block->SetString(eOpeningSound, NS_SYSSOUND_ALERT_DIALOG.get());
-  block->SetInt(eSoundEventId, nsISound::EVENT_ALERT_DIALOG_OPEN);
-
-  rv = DoDialog(parent, block, kPromptURL);
-
-  return rv;
-}
-
-
-
-NS_IMETHODIMP
-nsPromptService::AlertCheck(nsIDOMWindow *parent,
-                            const PRUnichar *dialogTitle, const PRUnichar *text,
-                            const PRUnichar *checkMsg, PRBool *checkValue)
-
-{
-  nsAutoWindowStateHelper windowStateHelper(parent);
-
-  if (!windowStateHelper.DefaultEnabled()) {
-    // checkValue is an inout parameter, so we don't have to set it
-    return NS_OK;
-  }
-
-  nsresult rv;
-  nsXPIDLString stringOwner;
- 
-  if (!dialogTitle) {
-    rv = GetLocaleString("Alert", getter_Copies(stringOwner));
-    if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-    dialogTitle = stringOwner.get();
-  }
-
-  ParamBlock block;
-  rv = block.Init();
-  if (NS_FAILED(rv))
-    return rv;
-
-  block->SetInt( eNumberButtons,1 );
-  block->SetString(eMsg, text);
-
-  block->SetString(eDialogTitle, dialogTitle);
-
-  NS_ConvertASCIItoUTF16 styleClass(kAlertIconClass);
-  block->SetString(eIconClass, styleClass.get());
-  block->SetString(eCheckboxMsg, checkMsg);
-  block->SetInt(eCheckboxState, *checkValue);
-  block->SetString(eOpeningSound, NS_SYSSOUND_ALERT_DIALOG.get());
-  block->SetInt(eSoundEventId, nsISound::EVENT_ALERT_DIALOG_OPEN);
-
-  rv = DoDialog(parent, block, kPromptURL);
-  if (NS_FAILED(rv))
-    return rv;
-
-  block->GetInt(eCheckboxState, checkValue);
-
-  return rv;
-}
-
-NS_IMETHODIMP
-nsPromptService::Confirm(nsIDOMWindow *parent,
-                   const PRUnichar *dialogTitle, const PRUnichar *text,
-                   PRBool *_retval)
-{
-  nsAutoWindowStateHelper windowStateHelper(parent);
-
-  if (!windowStateHelper.DefaultEnabled()) {
-    // Default to cancel
-    *_retval = PR_FALSE;
-    return NS_OK;
-  }
-
-  nsresult rv;
-  nsXPIDLString stringOwner;
- 
-  if (!dialogTitle) {
-    rv = GetLocaleString("Confirm", getter_Copies(stringOwner));
-    if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-    dialogTitle = stringOwner.get();
-  }
-
-  ParamBlock block;
-  rv = block.Init();
-  if (NS_FAILED(rv))
-    return rv;
-
-  // Stuff in Parameters
-  block->SetInt(eNumberButtons, 2);
-  block->SetString(eMsg, text);
-  
-  block->SetString(eDialogTitle, dialogTitle);
-
-  NS_ConvertASCIItoUTF16 styleClass(kQuestionIconClass);
-  block->SetString(eIconClass, styleClass.get());
-  block->SetString(eOpeningSound, NS_SYSSOUND_CONFIRM_DIALOG.get());
-  block->SetInt(eSoundEventId, nsISound::EVENT_CONFIRM_DIALOG_OPEN);
-
-  rv = DoDialog(parent, block, kPromptURL);
-  if (NS_FAILED(rv))
-    return rv;
-  
-  PRInt32 buttonPressed = 0;
-  block->GetInt(eButtonPressed, &buttonPressed);
-  *_retval = buttonPressed ? PR_FALSE : PR_TRUE;
-
-  return rv;
-}
-
-NS_IMETHODIMP
-nsPromptService::ConfirmCheck(nsIDOMWindow *parent,
-                   const PRUnichar *dialogTitle, const PRUnichar *text,
-                   const PRUnichar *checkMsg, PRBool *checkValue,
-                   PRBool *_retval)
-{
-  nsAutoWindowStateHelper windowStateHelper(parent);
-
-  if (!windowStateHelper.DefaultEnabled()) {
-    // Default to cancel. checkValue is an inout parameter, so we don't have to set it
-    *_retval = PR_FALSE;
-    return NS_OK;
-  }
-
-  nsresult rv;
-  nsXPIDLString stringOwner;
- 
-  if (!dialogTitle) {
-    rv = GetLocaleString("ConfirmCheck", getter_Copies(stringOwner));
-    if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-    dialogTitle = stringOwner.get();
-  }
-
-  ParamBlock block;
-  rv = block.Init();
-  if (NS_FAILED(rv))
-    return rv;
-
-  block->SetInt( eNumberButtons,2 );
-  block->SetString(eMsg, text);
-
-  block->SetString(eDialogTitle, dialogTitle);
-
-  NS_ConvertASCIItoUTF16 styleClass(kQuestionIconClass);
-  block->SetString(eIconClass, styleClass.get());
-  block->SetString(eCheckboxMsg, checkMsg);
-  block->SetInt(eCheckboxState, *checkValue);
-  block->SetString(eOpeningSound, NS_SYSSOUND_CONFIRM_DIALOG.get());
-  block->SetInt(eSoundEventId, nsISound::EVENT_CONFIRM_DIALOG_OPEN);
-
-  rv = DoDialog(parent, block, kPromptURL);
-  if (NS_FAILED(rv))
-    return rv;
-
-  PRInt32 tempInt = 0;
-  block->GetInt(eButtonPressed, &tempInt);
-  *_retval = tempInt ? PR_FALSE : PR_TRUE;
-
-  block->GetInt(eCheckboxState, & tempInt);
-  *checkValue = !!tempInt;
-  
-  return rv;
-}
-
-NS_IMETHODIMP
-nsPromptService::ConfirmEx(nsIDOMWindow *parent,
-                    const PRUnichar *dialogTitle, const PRUnichar *text,
-                    PRUint32 buttonFlags, const PRUnichar *button0Title,
-                    const PRUnichar *button1Title, const PRUnichar *button2Title,
-                    const PRUnichar *checkMsg, PRBool *checkValue,
-                    PRInt32 *buttonPressed)
-{
-  nsAutoWindowStateHelper windowStateHelper(parent);
-
-  if (!windowStateHelper.DefaultEnabled()) {
-    // Return 1 to match what happens when the dialog is closed by the window
-    // manager (This is indeed independent of what the default button is).
-    // checkValue is an inout parameter, so we don't have to set it.
-    *buttonPressed = 1;
-    return NS_OK;
-  }
-
-  nsresult rv;
-  nsXPIDLString stringOwner;
- 
-  if (!dialogTitle) {
-    rv = GetLocaleString("Confirm", getter_Copies(stringOwner));
-    if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-    dialogTitle = stringOwner.get();
-  }
-
-  ParamBlock block;
-  rv = block.Init();
-  if (NS_FAILED(rv))
-    return rv;
-
-  block->SetString(eDialogTitle, dialogTitle);
-  block->SetString(eMsg, text);
-  
-  int buttonIDs[] = { eButton0Text, eButton1Text, eButton2Text };
-  const PRUnichar* buttonStrings[] = { button0Title, button1Title, button2Title };
-
-#define BUTTON_DEFAULT_MASK 0x03000000
-
-  block->SetInt(eDefaultButton, (buttonFlags & BUTTON_DEFAULT_MASK) >> 24);
-  block->SetInt(eDelayButtonEnable, buttonFlags & BUTTON_DELAY_ENABLE);
- 
-  PRInt32 numberButtons = 0;
-  for (int i = 0; i < 3; i++) { 
-    
-    nsXPIDLString buttonTextStr;
-    const PRUnichar* buttonText = 0;
-    switch (buttonFlags & 0xff) {
-      case BUTTON_TITLE_OK:
-        GetLocaleString("OK", getter_Copies(buttonTextStr));
-        break;
-      case BUTTON_TITLE_CANCEL:
-        GetLocaleString("Cancel", getter_Copies(buttonTextStr));
-        break;
-      case BUTTON_TITLE_YES:
-        GetLocaleString("Yes", getter_Copies(buttonTextStr));
-        break;
-      case BUTTON_TITLE_NO:
-        GetLocaleString("No", getter_Copies(buttonTextStr));
-        break;
-      case BUTTON_TITLE_SAVE:
-        GetLocaleString("Save", getter_Copies(buttonTextStr));
-        break;
-      case BUTTON_TITLE_DONT_SAVE:
-        GetLocaleString("DontSave", getter_Copies(buttonTextStr));
-        break;
-      case BUTTON_TITLE_REVERT:
-        GetLocaleString("Revert", getter_Copies(buttonTextStr));
-        break;
-      case BUTTON_TITLE_IS_STRING:
-        buttonText = buttonStrings[i];
-        break;
-    }
-    if (!buttonText)
-      buttonText = buttonTextStr.get();
-
-    if (buttonText) {
-      block->SetString(buttonIDs[i], buttonText);
-      ++numberButtons;
-    }
-    buttonFlags >>= 8;
-  }
-  block->SetInt(eNumberButtons, numberButtons);
-
-  block->SetString(eIconClass, NS_ConvertASCIItoUTF16(kQuestionIconClass).get());
-  block->SetString(eOpeningSound, NS_SYSSOUND_CONFIRM_DIALOG.get());
-  block->SetInt(eSoundEventId, nsISound::EVENT_CONFIRM_DIALOG_OPEN);
-
-  if (checkMsg && checkValue) {
-    block->SetString(eCheckboxMsg, checkMsg);
-    // since we're setting a PRInt32, we have to sanitize the PRBool first.
-    // (myBool != PR_FALSE) is guaranteed to return either 1 or 0.
-    block->SetInt(eCheckboxState, *checkValue != PR_FALSE);
-  }
-  
-  /* perform the dialog */
-
-  rv = DoDialog(parent, block, kPromptURL);
-  if (NS_FAILED(rv))
-    return rv;
-
-  /* get back output parameters */
-
-  if (buttonPressed)
-    block->GetInt(eButtonPressed, buttonPressed);
-
-  if (checkMsg && checkValue) {
-    // GetInt returns a PRInt32; we need to sanitize it into PRBool
-    PRInt32 tempValue;
-    block->GetInt(eCheckboxState, &tempValue);
-    *checkValue = (tempValue == 1);
-  }
-
-  return rv;
-}
-
-NS_IMETHODIMP
-nsPromptService::Prompt(nsIDOMWindow *parent,
-                        const PRUnichar *dialogTitle, const PRUnichar *text,
-                        PRUnichar **value,
-                        const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
-{
-  nsAutoWindowStateHelper windowStateHelper(parent);
-
-  if (!windowStateHelper.DefaultEnabled()) {
-    // Default to cancel. value and checkValue are inout parameters, so we
-    // don't have to set them.
-    *_retval = PR_FALSE;
-    return NS_OK;
-  }
-
-  NS_ENSURE_ARG(value);
-  NS_ENSURE_ARG(_retval);
-
-  nsresult rv;
-  nsXPIDLString stringOwner;
- 
-  if (!dialogTitle) {
-    rv = GetLocaleString("Prompt", getter_Copies(stringOwner));
-    if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-    dialogTitle = stringOwner.get();
-  }
-
-  ParamBlock block;
-  rv = block.Init();
-  if (NS_FAILED(rv))
-    return rv;
-
-  block->SetInt(eNumberButtons, 2);
-  block->SetString(eMsg, text);
-
-  block->SetString(eDialogTitle, dialogTitle);
-
-  NS_ConvertASCIItoUTF16 styleClass(kQuestionIconClass);
-  block->SetString(eIconClass, styleClass.get());
-  block->SetInt(eNumberEditfields, 1);
-  if (*value)
-    block->SetString(eEditfield1Value, *value);
-  if (checkMsg && checkValue) {
-    block->SetString(eCheckboxMsg, checkMsg);
-    block->SetInt(eCheckboxState, *checkValue);
-  }
-  block->SetString(eOpeningSound, NS_SYSSOUND_PROMPT_DIALOG.get());
-  block->SetInt(eSoundEventId, nsISound::EVENT_PROMPT_DIALOG_OPEN);
-
-  rv = DoDialog(parent, block, kPromptURL);
-  if (NS_FAILED(rv))
-    return rv;
-
-  PRInt32 tempInt = 0;
-  block->GetInt(eButtonPressed, &tempInt);
-  *_retval = tempInt ? PR_FALSE : PR_TRUE;
-
-  if (*_retval) {
-    PRUnichar *tempStr;
-    
-    rv = block->GetString(eEditfield1Value, &tempStr);
-    if (NS_FAILED(rv))
-      return rv;
-    if (*value)
-      nsMemory::Free(*value);
-    *value = tempStr;
-
-    if (checkValue)
-      block->GetInt(eCheckboxState, checkValue);  
-  }
-  return rv;
-}
-
-NS_IMETHODIMP
-nsPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent,
-                    const PRUnichar *dialogTitle, const PRUnichar *text,
-                    PRUnichar **username, PRUnichar **password,
-                    const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
-
-{
-  NS_ENSURE_ARG(username);
-  NS_ENSURE_ARG(password);
-  NS_ENSURE_ARG(_retval);
-
-  nsAutoWindowStateHelper windowStateHelper(parent);
-
-  if (!windowStateHelper.DefaultEnabled()) {
-    // Default to cancel
-    // username/password are inout, no need to set them
-    *_retval = PR_FALSE;
-    return NS_OK;
-  }
-
-  nsresult rv;
-  nsXPIDLString stringOwner;
- 
-  if (!dialogTitle) {
-    rv = GetLocaleString("PromptUsernameAndPassword2", getter_Copies(stringOwner));
-    if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-    dialogTitle = stringOwner.get();
-  }
-
-  ParamBlock block;
-  rv = block.Init();
-  if (NS_FAILED(rv))
-    return rv;
-
-  block->SetInt(eNumberButtons, 2);
-  block->SetString(eMsg, text);
-
-  block->SetString(eDialogTitle, dialogTitle);
-
-  NS_ConvertASCIItoUTF16 styleClass(kAuthenticationIconClass);
-  block->SetString(eIconClass, styleClass.get());
-  block->SetInt( eNumberEditfields, 2 );
-  if (*username)
-    block->SetString(eEditfield1Value, *username);
-  if (*password)
-    block->SetString(eEditfield2Value, *password);
-  if (checkMsg && checkValue) {
-    block->SetString(eCheckboxMsg, checkMsg);
-    block->SetInt(eCheckboxState, *checkValue);
-  }
-  block->SetString(eOpeningSound, NS_SYSSOUND_PROMPT_DIALOG.get());
-  block->SetInt(eSoundEventId, nsISound::EVENT_PROMPT_DIALOG_OPEN);
-
-  rv = DoDialog(parent, block, kPromptURL);
-  if (NS_FAILED(rv))
-    return rv;
-
-  PRInt32 tempInt = 0;
-  block->GetInt(eButtonPressed, &tempInt);
-  *_retval = tempInt ? PR_FALSE : PR_TRUE;
-  
-  if (*_retval) {
-    PRUnichar *tempStr;
-    
-    rv = block->GetString(eEditfield1Value, &tempStr);
-    if (NS_FAILED(rv))
-      return rv;
-    if (*username)
-      nsMemory::Free(*username);
-    *username = tempStr;
-
-    rv = block->GetString(eEditfield2Value, &tempStr);
-    if (NS_FAILED(rv))
-      return rv;
-    if (*password)
-      nsMemory::Free(*password);
-    *password = tempStr;
-
-    if (checkValue)
-      block->GetInt(eCheckboxState, checkValue);
-  }
-  return rv;
-}
-
-NS_IMETHODIMP nsPromptService::PromptPassword(nsIDOMWindow *parent,
-                                const PRUnichar *dialogTitle, const PRUnichar *text,
-                                PRUnichar **password,
-                                const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
-{
-  NS_ENSURE_ARG(password);
-  NS_ENSURE_ARG(_retval);
-
-  nsAutoWindowStateHelper windowStateHelper(parent);
-
-  if (!windowStateHelper.DefaultEnabled()) {
-    // Default to cancel. password and checkValue are inout parameters, so we
-    // don't have to touch them.
-    *_retval = PR_FALSE;
-    return NS_OK;
-  }
-
-  nsresult rv;
-  nsXPIDLString stringOwner;
- 
-  if (!dialogTitle) {
-    rv = GetLocaleString("PromptPassword2", getter_Copies(stringOwner));
-    if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-    dialogTitle = stringOwner.get();
-  }
-
-  ParamBlock block;
-  rv = block.Init();
-  if (NS_FAILED(rv))
-    return rv;
-
-  block->SetInt(eNumberButtons, 2);
-  block->SetString(eMsg, text);
-
-  block->SetString(eDialogTitle, dialogTitle);
-
-  nsString url;
-  NS_ConvertASCIItoUTF16 styleClass(kAuthenticationIconClass);
-  block->SetString(eIconClass, styleClass.get());
-  block->SetInt(eNumberEditfields, 1);
-  block->SetInt(eEditField1Password, 1);
-  if (*password)
-    block->SetString(eEditfield1Value, *password);
-  if (checkMsg && checkValue) {
-    block->SetString(eCheckboxMsg, checkMsg);
-    block->SetInt(eCheckboxState, *checkValue);
-  }
-  block->SetString(eOpeningSound, NS_SYSSOUND_PROMPT_DIALOG.get());
-  block->SetInt(eSoundEventId, nsISound::EVENT_PROMPT_DIALOG_OPEN);
-
-  rv = DoDialog(parent, block, kPromptURL);
-  if (NS_FAILED(rv))
-    return rv;
-
-  PRInt32 tempInt = 0;
-  block->GetInt(eButtonPressed, &tempInt);
-  *_retval = tempInt ? PR_FALSE : PR_TRUE;
-  if (*_retval) {
-    PRUnichar *tempStr;
-    
-    rv = block->GetString(eEditfield1Value, &tempStr);
-    if (NS_FAILED(rv))
-      return rv;
-    if (*password)
-      nsMemory::Free(*password);
-    *password = tempStr;
-
-    if (checkValue)
-      block->GetInt(eCheckboxState, checkValue);  
-  }
-  return rv;
-}
-
-
-NS_IMETHODIMP
-nsPromptService::PromptAuth(nsIDOMWindow* aParent,
-                            nsIChannel* aChannel,
-                            PRUint32 aLevel,
-                            nsIAuthInformation* aAuthInfo,
-                            const PRUnichar* aCheckLabel,
-                            PRBool* aCheckValue,
-                            PRBool *retval)
-{
-  nsAutoWindowStateHelper windowStateHelper(aParent);
-
-  if (!windowStateHelper.DefaultEnabled()) {
-    *retval = PR_FALSE;
-    return NS_OK;
-  }
- 
-  return nsPrompt::PromptPasswordAdapter(this, aParent, aChannel,
-                                         aLevel, aAuthInfo,
-                                         aCheckLabel, aCheckValue,
-                                         retval);
-}
-
-NS_IMETHODIMP
-nsPromptService::AsyncPromptAuth(nsIDOMWindow* aParent,
-                                 nsIChannel* aChannel,
-                                 nsIAuthPromptCallback* aCallback,
-                                 nsISupports* aContext,
-                                 PRUint32 aLevel,
-                                 nsIAuthInformation* aAuthInfo,
-                                 const PRUnichar* aCheckLabel,
-                                 PRBool* aCheckValue,
-                                 nsICancelable** retval)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-nsPromptService::Select(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
-                   const PRUnichar* text, PRUint32 count,
-                   const PRUnichar **selectList, PRInt32 *outSelection,
-                   PRBool *_retval)
-{	
-  nsAutoWindowStateHelper windowStateHelper(parent);
-
-  if (!windowStateHelper.DefaultEnabled()) {
-    // Default to cancel and item 0
-    *outSelection = 0;
-    *_retval = PR_FALSE;
-    return NS_OK;
-  }
-
-  nsresult rv;
-  nsXPIDLString stringOwner;
- 
-  if (!dialogTitle) {
-    rv = GetLocaleString("Select", getter_Copies(stringOwner));
-    if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-    dialogTitle = stringOwner.get();
-  }
-
-  const PRInt32 eSelection = 2;
-  ParamBlock block;
-  rv = block.Init();
-  if (NS_FAILED(rv))
-    return rv;
-
-  block->SetNumberStrings(count + 2);
-  if (dialogTitle)
-    block->SetString(0, dialogTitle);
-  
-  block->SetString(1, text);
-  block->SetInt(eSelection, count);
-  for (PRUint32 i = 2; i <= count+1; i++) {
-    nsAutoString temp(selectList[i-2]);
-    const PRUnichar* text = temp.get();
-    block->SetString(i, text);
-  }
-
-  *outSelection = -1;
-  rv = DoDialog(parent, block, kSelectPromptURL);
-  if (NS_FAILED(rv))
-    return rv;
-
-  PRInt32 buttonPressed = 0;
-  block->GetInt(eButtonPressed, &buttonPressed);
-  block->GetInt(eSelection, outSelection);
-  *_retval = buttonPressed ? PR_FALSE : PR_TRUE;
-
-  return rv;
-}
-
-nsresult
-nsPromptService::DoDialog(nsIDOMWindow *aParent,
-                   nsIDialogParamBlock *aParamBlock, const char *aChromeURL)
-{
-  NS_ENSURE_ARG(aParamBlock);
-  NS_ENSURE_ARG(aChromeURL);
-  if (!mWatcher)
-    return NS_ERROR_FAILURE;
-
-  nsresult rv = NS_OK;
-
-  // get a parent, if at all possible
-  // (though we'd rather this didn't fail, it's OK if it does. so there's
-  // no failure or null check.)
-  nsCOMPtr<nsIDOMWindow> activeParent; // retain ownership for method lifetime
-  if (!aParent) {
-    mWatcher->GetActiveWindow(getter_AddRefs(activeParent));
-    aParent = activeParent;
-  }
-
-  nsCOMPtr<nsISupports> arguments(do_QueryInterface(aParamBlock));
-  nsCOMPtr<nsIDOMWindow> dialog;
-  rv = mWatcher->OpenWindow(aParent, aChromeURL, "_blank",
-                            "centerscreen,chrome,modal,titlebar", arguments,
-                            getter_AddRefs(dialog));
-
-  return rv;
-}
-
-nsresult
-nsPromptService::GetLocaleString(const char *aKey, PRUnichar **aResult)
-{
-  nsresult rv;
-
-  nsCOMPtr<nsIStringBundleService> stringService = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
-  nsCOMPtr<nsIStringBundle> stringBundle;
- 
-  rv = stringService->CreateBundle(kCommonDialogsProperties, getter_AddRefs(stringBundle));
-  if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-
-  rv = stringBundle->GetStringFromName(NS_ConvertASCIItoUTF16(aKey).get(), aResult);
-
-  return rv;
-}
- 
deleted file mode 100644
--- a/embedding/components/windowwatcher/src/nsPromptService.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * 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
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __nsPromptService_h
-#define __nsPromptService_h
-
-// {A2112D6A-0E28-421f-B46A-25C0B308CBD0}
-#define NS_PROMPTSERVICE_CID \
- {0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}}
-// {150E7415-72D7-11DA-A924-00039386357A}
-#define NS_NONBLOCKINGALERTSERVICE_CID \
- {0x150e7415, 0x72d7, 0x11da, {0xa9, 0x24, 0x00, 0x03, 0x93, 0x86, 0x35, 0x7a}}
-
-#include "nsCOMPtr.h"
-#include "nsIPromptService2.h"
-#include "nsPIPromptService.h"
-#include "nsIWindowWatcher.h"
-#include "nsAutoWindowStateHelper.h"
-
-class nsIDOMWindow;
-class nsIDialogParamBlock;
-
-class nsPromptService: public nsIPromptService2,
-                       public nsPIPromptService {
-
-public:
-
-  nsPromptService();
-  virtual ~nsPromptService();
-
-  nsresult Init();
-
-  NS_DECL_NSIPROMPTSERVICE
-  NS_DECL_NSIPROMPTSERVICE2
-  NS_DECL_NSPIPROMPTSERVICE
-  NS_DECL_ISUPPORTS
-
-private:
-  nsresult GetLocaleString(const char *aKey, PRUnichar **aResult);
-
-  nsCOMPtr<nsIWindowWatcher> mWatcher;
-};
-
-#endif
-
--- a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
+++ b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
@@ -35,38 +35,38 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 //#define USEWEAKREFS // (haven't quite figured that out yet)
 
 #include "nsWindowWatcher.h"
+#include "nsAutoWindowStateHelper.h"
 
 #include "nsAutoLock.h"
 #include "nsCRT.h"
 #include "nsNetUtil.h"
-#include "nsPrompt.h"
-#include "nsPromptService.h"
 #include "nsWWJSUtils.h"
 #include "plstr.h"
 #include "nsIContentUtils.h"
 
 #include "nsIBaseWindow.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellLoadInfo.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIDocumentLoader.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMWindow.h"
 #include "nsIDOMChromeWindow.h"
 #include "nsIDOMWindowInternal.h"
 #include "nsIDOMModalContentWindow.h"
+#include "nsIPrompt.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIScreen.h"
 #include "nsIScreenManager.h"
 #include "nsIScriptContext.h"
 #include "nsIGenericFactory.h"
 #include "nsIJSContextStack.h"
 #include "nsIObserverService.h"
 #include "nsIScriptGlobalObject.h"
@@ -324,20 +324,19 @@ nsresult JSContextAutoPopper::Push(JSCon
 }
 
 /****************************************************************
  *********************** nsWindowWatcher ************************
  ****************************************************************/
 
 NS_IMPL_ADDREF(nsWindowWatcher)
 NS_IMPL_RELEASE(nsWindowWatcher)
-NS_IMPL_QUERY_INTERFACE4(nsWindowWatcher,
+NS_IMPL_QUERY_INTERFACE3(nsWindowWatcher,
                          nsIWindowWatcher,
                          nsIPromptFactory,
-                         nsIAuthPromptAdapterFactory,
                          nsPIWindowWatcher)
 
 nsWindowWatcher::nsWindowWatcher() :
         mEnumeratorList(),
         mOldestWindow(0),
         mListLock(0)
 {
 }
@@ -1060,64 +1059,56 @@ nsWindowWatcher::GetWindowEnumerator(nsI
     return CallQueryInterface(enumerator, _retval);
 
   return NS_ERROR_OUT_OF_MEMORY;
 }
     
 NS_IMETHODIMP
 nsWindowWatcher::GetNewPrompter(nsIDOMWindow *aParent, nsIPrompt **_retval)
 {
-  return NS_NewPrompter(_retval, aParent);
+  // This is for backwards compat only. Callers should just use the prompt service directly.
+  nsresult rv;
+  nsCOMPtr<nsIPromptFactory> factory = do_GetService("@mozilla.org/prompter;1", &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+  return factory->GetPrompt(aParent, NS_GET_IID(nsIPrompt), reinterpret_cast<void**>(_retval));
 }
 
 NS_IMETHODIMP
 nsWindowWatcher::GetNewAuthPrompter(nsIDOMWindow *aParent, nsIAuthPrompt **_retval)
 {
-  return NS_NewAuthPrompter(_retval, aParent);
+  // This is for backwards compat only. Callers should just use the prompt service directly.
+  nsresult rv;
+  nsCOMPtr<nsIPromptFactory> factory = do_GetService("@mozilla.org/prompter;1", &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+  return factory->GetPrompt(aParent, NS_GET_IID(nsIAuthPrompt), reinterpret_cast<void**>(_retval));
 }
 
 NS_IMETHODIMP
 nsWindowWatcher::GetPrompt(nsIDOMWindow *aParent, const nsIID& aIID,
                            void **_retval)
 {
-  if (aIID.Equals(NS_GET_IID(nsIPrompt)))
-    return NS_NewPrompter(reinterpret_cast<nsIPrompt**>(_retval), aParent);
-  if (aIID.Equals(NS_GET_IID(nsIAuthPrompt)))
-    return NS_NewAuthPrompter(reinterpret_cast<nsIAuthPrompt**>(_retval),
-                              aParent);
-  if (aIID.Equals(NS_GET_IID(nsIAuthPrompt2))) {
-    nsresult rv = NS_NewAuthPrompter2(reinterpret_cast<nsIAuthPrompt2**>
-                                                      (_retval),
-                                      aParent);
-    if (rv == NS_NOINTERFACE) {
-      // Return an wrapped nsIAuthPrompt (if we can)
-      nsCOMPtr<nsIAuthPrompt> prompt;
-      rv = NS_NewAuthPrompter(getter_AddRefs(prompt), aParent);
-      if (NS_SUCCEEDED(rv)) {
-        NS_WrapAuthPrompt(prompt,
-                          reinterpret_cast<nsIAuthPrompt2**>(_retval));
-        if (!*_retval)
-          rv = NS_ERROR_NOT_AVAILABLE;
-      }
-    }
+  // This is for backwards compat only. Callers should just use the prompt service directly.
+  nsresult rv;
+  nsCOMPtr<nsIPromptFactory> factory = do_GetService("@mozilla.org/prompter;1", &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+  rv = factory->GetPrompt(aParent, aIID, _retval);
 
-    return rv;
-  }
-
-  return NS_NOINTERFACE;
-}
+  // Allow for an embedding implementation to not support nsIAuthPrompt2.
+  if (rv == NS_NOINTERFACE && aIID.Equals(NS_GET_IID(nsIAuthPrompt2))) {
+    nsCOMPtr<nsIAuthPrompt> oldPrompt;
+    rv = factory->GetPrompt(aParent,
+                            NS_GET_IID(nsIAuthPrompt),
+                            getter_AddRefs(oldPrompt));
+    NS_ENSURE_SUCCESS(rv, rv);
 
-NS_IMETHODIMP
-nsWindowWatcher::CreateAdapter(nsIAuthPrompt* aPrompt, nsIAuthPrompt2** _retval)
-{
-  *_retval = new AuthPromptWrapper(aPrompt);
-  if (!*_retval)
-    return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*_retval);
-  return NS_OK;
+    NS_WrapAuthPrompt(oldPrompt, reinterpret_cast<nsIAuthPrompt2**>(_retval));
+    if (!*_retval)
+      rv = NS_ERROR_NOT_AVAILABLE;
+  }
+  return rv;
 }
 
 NS_IMETHODIMP
 nsWindowWatcher::SetWindowCreator(nsIWindowCreator *creator)
 {
   mWindowCreator = creator; // it's an nsCOMPtr, so this is an ownership ref
   return NS_OK;
 }
--- a/embedding/components/windowwatcher/src/nsWindowWatcher.h
+++ b/embedding/components/windowwatcher/src/nsWindowWatcher.h
@@ -42,17 +42,16 @@
 #define NS_WINDOWWATCHER_CID \
  {0xa21bfa01, 0xf349, 0x4394, {0xa8, 0x4c, 0x8d, 0xe5, 0xcf, 0x7, 0x37, 0xd0}}
 
 #include "nsCOMPtr.h"
 #include "jspubtd.h"
 #include "nsIWindowCreator.h" // for stupid compilers
 #include "nsIWindowWatcher.h"
 #include "nsIPromptFactory.h"
-#include "nsIAuthPromptAdapterFactory.h"
 #include "nsPIWindowWatcher.h"
 #include "nsTArray.h"
 
 class  nsIURI;
 class  nsIDocShellTreeItem;
 class  nsIDocShellTreeOwner;
 class  nsIWebBrowserChrome;
 class  nsString;
@@ -62,33 +61,31 @@ struct JSContext;
 struct JSObject;
 struct nsWatcherWindowEntry;
 struct PRLock;
 struct SizeSpec;
 
 class nsWindowWatcher :
       public nsIWindowWatcher,
       public nsPIWindowWatcher,
-      public nsIPromptFactory,
-      public nsIAuthPromptAdapterFactory
+      public nsIPromptFactory
 {
 friend class nsWatcherWindowEnumerator;
 
 public:
   nsWindowWatcher();
   virtual ~nsWindowWatcher();
 
   nsresult Init();
 
   NS_DECL_ISUPPORTS
 
   NS_DECL_NSIWINDOWWATCHER
   NS_DECL_NSPIWINDOWWATCHER
   NS_DECL_NSIPROMPTFACTORY
-  NS_DECL_NSIAUTHPROMPTADAPTERFACTORY
 
 private:
   PRBool AddEnumerator(nsWatcherWindowEnumerator* inEnumerator);
   PRBool RemoveEnumerator(nsWatcherWindowEnumerator* inEnumerator);
 
   nsWatcherWindowEntry *FindWindowEntry(nsIDOMWindow *aWindow);
   nsresult RemoveWindow(nsWatcherWindowEntry *inInfo);
 
--- a/netwerk/base/src/nsPACMan.cpp
+++ b/netwerk/base/src/nsPACMan.cpp
@@ -37,16 +37,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsPACMan.h"
 #include "nsThreadUtils.h"
 #include "nsIDNSService.h"
 #include "nsIDNSListener.h"
 #include "nsICancelable.h"
 #include "nsIAuthPrompt.h"
+#include "nsIPromptFactory.h"
 #include "nsIHttpChannel.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsNetUtil.h"
 #include "nsAutoLock.h"
 #include "nsAutoPtr.h"
 #include "nsCRT.h"
 #include "prmon.h"
@@ -454,19 +455,21 @@ nsPACMan::OnStreamComplete(nsIStreamLoad
   ProcessPendingQ(status);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPACMan::GetInterface(const nsIID &iid, void **result)
 {
   // In case loading the PAC file requires authentication.
-  if (iid.Equals(NS_GET_IID(nsIAuthPrompt)))
-    return CallCreateInstance(NS_DEFAULTAUTHPROMPT_CONTRACTID,
-                              nsnull, iid, result);
+  if (iid.Equals(NS_GET_IID(nsIAuthPrompt))) {
+    nsCOMPtr<nsIPromptFactory> promptFac = do_GetService("@mozilla.org/prompter;1");
+    NS_ENSURE_TRUE(promptFac, NS_ERROR_FAILURE);
+    return promptFac->GetPrompt(nsnull, iid, reinterpret_cast<void**>(result));
+  }
 
   // In case loading the PAC file results in a redirect.
   if (iid.Equals(NS_GET_IID(nsIChannelEventSink))) {
     NS_ADDREF_THIS();
     *result = static_cast<nsIChannelEventSink *>(this);
     return NS_OK;
   }
 
--- a/netwerk/build/nsNetCID.h
+++ b/netwerk/build/nsNetCID.h
@@ -446,34 +446,16 @@
 #define NS_PRIVATE_BROWSING_SERVICE_CID              \
 { /* c31f4883-839b-45f6-82ad-a6a9bc5ad599 */         \
     0xc31f4883,                                      \
     0x839b,                                          \
     0x45f6,                                          \
     {0x82, 0xad, 0xa6, 0xa9, 0xbc, 0x5a, 0xd5, 0x99} \
 }
 
-// component implementing nsIPrompt
-//
-// NOTE: this implementation does not have any way to correctly parent itself,
-//       it is almost always wrong to get a prompt via this interface.
-//       use nsIWindowWatcher instead whenever possible.
-//
-#define NS_DEFAULTPROMPT_CONTRACTID \
-    "@mozilla.org/network/default-prompt;1"
-
-// component implementing nsIAuthPrompt
-//
-// NOTE: this implementation does not have any way to correctly parent itself,
-//       it is almost always wrong to get an auth prompt via this interface.
-//       use nsIWindowWatcher instead whenever possible.
-//
-#define NS_DEFAULTAUTHPROMPT_CONTRACTID \
-    "@mozilla.org/network/default-auth-prompt;1"
-
 /**
  * Contract ID for a service implementing nsIURIClassifier that identifies
  * phishing and malware sites.
  */
 #define NS_URICLASSIFIERSERVICE_CONTRACTID \
     "@mozilla.org/uriclassifierservice"
 
 /******************************************************************************
--- a/netwerk/test/unit/test_authentication.js
+++ b/netwerk/test/unit/test_authentication.js
@@ -32,17 +32,17 @@ AuthPrompt1.prototype = {
   prompt: function ap1_prompt(title, text, realm, save, defaultText, result) {
     do_throw("unexpected prompt call");
   },
 
   promptUsernameAndPassword:
     function ap1_promptUP(title, text, realm, savePW, user, pw)
   {
     // Note that the realm here isn't actually the realm. it's a pw mgr key.
-    do_check_eq("localhost:4444 (" + this.expectedRealm + ")", realm);
+    do_check_eq("http://localhost:4444 (" + this.expectedRealm + ")", realm);
     if (text.indexOf(this.expectedRealm) == -1)
       do_throw("Text must indicate the realm");
     if (text.indexOf("localhost") == -1)
       do_throw("Text must indicate the hostname");
     if (text.indexOf("4444") == -1)
       do_throw("Text must indicate the port");
     if (text.indexOf("-1") != -1)
       do_throw("Text must contain negative numbers");
--- a/netwerk/test/unit/test_authpromptwrapper.js
+++ b/netwerk/test/unit/test_authpromptwrapper.js
@@ -73,20 +73,17 @@ function run_test() {
     promptPassword: function ap1_promptPW(title, text, realm, save, pwd) {
       this.called |= CALLED_PROMPTP;
       this.doChecks(text, realm);
       pwd.value = this.pw;
       return this.rv;
     },
 
     doChecks: function ap1_check(text, realm) {
-      if (this.scheme == "http")
-        do_check_eq(host + ":80 (" + info.realm + ")", realm);
-      else
-        do_check_eq(this.scheme + "://" + host, realm);
+      do_check_eq(this.scheme + "://" + host + " (" + info.realm + ")", realm);
 
       do_check_neq(text.indexOf(host), -1);
       if (info.flags & nsIAuthInformation.ONLY_PASSWORD) {
         // Should have the username in the text
         do_check_neq(text.indexOf(info.username), -1);
       } else {
         // Make sure that we show the realm if we have one and that we don't
         // show "" otherwise
--- a/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js
@@ -43,18 +43,17 @@ const Cr = Components.results;
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 /*
  * LoginManagerPromptFactory
  *
  * Implements nsIPromptFactory
  *
- * Invoked by NS_NewAuthPrompter2()
- * [embedding/components/windowwatcher/src/nsPrompt.cpp]
+ * Invoked by [toolkit/components/prompts/src/nsPrompter.js]
  */
 function LoginManagerPromptFactory() {
     Services.obs.addObserver(this, "quit-application-granted", true);
 }
 
 LoginManagerPromptFactory.prototype = {
 
     classDescription : "LoginManagerPromptFactory",
rename from toolkit/content/commonDialog.css
rename to toolkit/components/prompts/content/commonDialog.css
--- a/toolkit/content/commonDialog.css
+++ b/toolkit/components/prompts/content/commonDialog.css
@@ -43,12 +43,12 @@
 
 #info\.body {
   -moz-user-focus: normal;
   -moz-user-select: text;
   cursor: text !important;
   white-space: pre-wrap;
 }
 
-#loginLabel, #password1Label, #password2Label {
+#loginLabel, #password1Label {
   text-align: right;
 }
 
rename from toolkit/content/commonDialog.js
rename to toolkit/components/prompts/content/commonDialog.js
--- a/toolkit/content/commonDialog.js
+++ b/toolkit/components/prompts/content/commonDialog.js
@@ -1,9 +1,8 @@
-/* -*- Mode: C;  c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil; -*- */
 /* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
@@ -19,16 +18,17 @@
  * Portions created by the Initial Developer are Copyright (C) 1998
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Alec Flett  <alecf@netscape.com>
  *   Ben Goodger <ben@netscape.com>
  *   Blake Ross  <blakeross@telocity.com>
  *   Joe Hewitt <hewitt@netscape.com>
+ *   Justin Dolske <dolske@mozilla.com>
  *
  * 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
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -37,353 +37,329 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cc = Components.classes;
+const Cu = Components.utils;
 
-// parameters to gCommonDialogParam.Get() are defined in nsPIPromptService.idl
-var gCommonDialogParam = 
-  window.arguments[0].QueryInterface(Ci.nsIDialogParamBlock);
-  
-function showControls()
-{
-  // This is called before onload fires, so we can't be certain that any elements
-  // in the document have their bindings ready, so don't call any methods/properties
-  // here on xul elements that come from xbl bindings.
-  
-  // show the required textboxes and set their initial values
-  var nTextBoxes = gCommonDialogParam.GetInt(3);
-  if (nTextBoxes == 2) {
-    if (gCommonDialogParam.GetInt(4) == 1) {
-      initTextbox("password1", 4, 6, false);
-      initTextbox("password2", 5, 7, false);
+Cu.import("resource://gre/modules/Services.jsm");
+
+let gArgs = window.arguments[0].QueryInterface(Ci.nsIWritablePropertyBag2)
+                               .QueryInterface(Ci.nsIWritablePropertyBag);
+
+let promptType, numButtons, iconClass, soundID, hasInputField = true;
+
+
+function earlyInit() {
+    // This is called before onload fires, so we can't be certain that any elements
+    // in the document have their bindings ready, so don't call any methods/properties
+    // here on xul elements that come from xbl bindings.
+
+    promptType = gArgs.getProperty("promptType");
+
+    switch (promptType) {
+      case "alert":
+      case "alertCheck":
+        hasInputField = false;
+        numButtons    = 1;
+        iconClass     = "alert-icon";
+        soundID       = Ci.nsISound.EVENT_ALERT_DIALOG_OPEN;
+        break;
+      case "confirmCheck":
+      case "confirm":
+        hasInputField = false;
+        numButtons    = 2;
+        iconClass     = "question-icon";
+        soundID       = Ci.nsISound.EVENT_CONFIRM_DIALOG_OPEN;
+        break;
+      case "confirmEx":
+        numButtons = 0;
+        if (gArgs.hasKey("button0Label"))
+            numButtons++;
+        if (gArgs.hasKey("button1Label"))
+            numButtons++;
+        if (gArgs.hasKey("button2Label"))
+            numButtons++;
+        if (gArgs.hasKey("button3Label"))
+            numButtons++;
+        if (numButtons == 0)
+            throw "A dialog with no buttons? Can not haz.";
+        hasInputField = false;
+        iconClass     = "question-icon";
+        soundID       = Ci.nsISound.EVENT_CONFIRM_DIALOG_OPEN;
+        break;
+      case "prompt":
+        numButtons = 2;
+        iconClass  = "question-icon";
+        soundID    = Ci.nsISound.EVENT_PROMPT_DIALOG_OPEN;
+        initTextbox("login", gArgs.getProperty("value"));
+        // Clear the label, since this isn't really a username prompt.
+        document.getElementById("loginLabel").setAttribute("value", "");
+        break;
+      case "promptUserAndPass":
+        numButtons = 2;
+        iconClass  = "authentication-icon question-icon";
+        soundID    = Ci.nsISound.EVENT_PROMPT_DIALOG_OPEN;
+        initTextbox("login",     gArgs.getProperty("user"));
+        initTextbox("password1", gArgs.getProperty("pass"));
+        break;
+      case "promptPassword":
+        numButtons = 2;
+        iconClass  = "authentication-icon question-icon";
+        soundID    = Ci.nsISound.EVENT_PROMPT_DIALOG_OPEN;
+        initTextbox("password1", gArgs.getProperty("pass"));
+        break;
+      default:
+        Cu.reportError("commonDialog opened for unknown type: " + promptType);
+        window.close();
     }
-    else {
-      initTextbox("login", 4, 6, false);
-      initTextbox("password1", 5, 7, false);
-    }
-  } else if (nTextBoxes == 1) {
-    if (gCommonDialogParam.GetInt(4) == 1)
-      initTextbox("password1", -1, 6, true);
-    else
-      initTextbox("login", 4, 6, true);
-  }
 }
 
-function setLabelForNode(aNode, aLabel, aIsLabelFlag)
-{
-  // This is for labels which may contain embedded access keys.
-  // If we end in (&X) where X represents the access key, optionally preceded
-  // by spaces and/or followed by the ':' character, store the access key and
-  // remove the access key placeholder + leading spaces from the label.
-  // Otherwise a character preceded by one but not two &s is the access key.
-  // Store it and remove the &.
-
-  // Note that if you change the following code, see the comment of
-  // nsTextBoxFrame::UpdateAccessTitle.
-  var accessKey = null;
-  if (/ *\(\&([^&])\)(:)?$/.test(aLabel)) {
-    aLabel = RegExp.leftContext + RegExp.$2;
-    accessKey = RegExp.$1;
-  } else if (/^(.*[^&])?\&(([^&]).*$)/.test(aLabel)) {
-    aLabel = RegExp.$1 + RegExp.$2;
-    accessKey = RegExp.$3;
-  }
-
-  // && is the magic sequence to embed an & in your label.
-  aLabel = aLabel.replace(/\&\&/g, "&");
-  if (aIsLabelFlag) {    // Set text for <label> element
-    aNode.setAttribute("value", aLabel);
-  } else {    // Set text for other xul elements
-    aNode.label = aLabel;
-  }
-
-  // XXXjag bug 325251
-  // Need to set this after aNode.setAttribute("value", aLabel);
-  if (accessKey)
-    aNode.accessKey = accessKey;
+function initTextbox(aName, aValue) {
+    document.getElementById(aName + "Container").hidden = false;
+    document.getElementById(aName + "Textbox").setAttribute("value", aValue);
 }
 
-var softkbObserver = {
- QueryInterface: function (aIID) {
-    if (aIID.equals(Ci.nsISupports) ||
-        aIID.equals(Ci.nsIObserver))
-      return this;
-    throw Cr.NS_ERROR_NO_INTERFACE;
-  },
- observe: function(subject, topic, data) {
-    if (topic === "softkb-change") {
-      var rect = JSON.parse(data);
-      if (rect) {
-        var height = rect.bottom - rect.top;
-        var width = rect.right - rect.left;
-        var top = (rect.top + (height - window.innerHeight) / 2);
-        var left = (rect.left + (width - window.innerWidth) / 2);
+function setLabelForNode(aNode, aLabel, aIsLabelFlag) {
+    // This is for labels which may contain embedded access keys.
+    // If we end in (&X) where X represents the access key, optionally preceded
+    // by spaces and/or followed by the ':' character, store the access key and
+    // remove the access key placeholder + leading spaces from the label.
+    // Otherwise a character preceded by one but not two &s is the access key.
+    // Store it and remove the &.
+
+    // Note that if you change the following code, see the comment of
+    // nsTextBoxFrame::UpdateAccessTitle.
+    var accessKey = null;
+    if (/ *\(\&([^&])\)(:)?$/.test(aLabel)) {
+        aLabel = RegExp.leftContext + RegExp.$2;
+        accessKey = RegExp.$1;
+    } else if (/^(.*[^&])?\&(([^&]).*$)/.test(aLabel)) {
+        aLabel = RegExp.$1 + RegExp.$2;
+        accessKey = RegExp.$3;
+    }
+
+    // && is the magic sequence to embed an & in your label.
+    aLabel = aLabel.replace(/\&\&/g, "&");
+    if (aIsLabelFlag) {    // Set text for <label> element
+        aNode.setAttribute("value", aLabel);
+    } else {    // Set text for other xul elements
+        aNode.label = aLabel;
+    }
+
+    // XXXjag bug 325251
+    // Need to set this after aNode.setAttribute("value", aLabel);
+    if (accessKey)
+        aNode.accessKey = accessKey;
+}
+
+function softkbObserver(subject, topic, data) {
+    let rect = JSON.parse(data);
+    if (rect) {
+        let height = rect.bottom - rect.top;
+        let width  = rect.right - rect.left;
+        let top    = (rect.top + (height - window.innerHeight) / 2);
+        let left   = (rect.left + (width - window.innerWidth) / 2);
         window.moveTo(left, top);
-      }
     }
-  }
-};
+}
+
+function commonDialogOnLoad() {
+    // limit the dialog to the screen width
+    document.getElementById("filler").maxWidth = screen.availWidth;
 
-function commonDialogOnLoad()
-{
-  // limit the dialog to the screen width
-  document.getElementById("filler").maxWidth = screen.availWidth;
-
-  // set the document title
+    // set the document title
+    let title = gArgs.getProperty("title");
 #ifdef XP_MACOSX
-  setElementText("info.title", gCommonDialogParam.GetString(12), true);
+    document.getElementById("info.title").appendChild(document.createTextNode(title));
 #else
-  document.title = gCommonDialogParam.GetString(12);
+    document.title = title;
 #endif
 
-  var observerService = Cc["@mozilla.org/observer-service;1"]
-                          .getService(Ci.nsIObserverService);
-  observerService.addObserver(softkbObserver, "softkb-change", false);
+    Services.obs.addObserver(softkbObserver, "softkb-change", false);
 
-  // set the number of command buttons
-  var nButtons = gCommonDialogParam.GetInt(2);
-  var dialog = document.documentElement;
-  switch (nButtons) {
-    case 1:
-      dialog.getButton("cancel").hidden = true;
-      break;
-    case 4:
-      dialog.getButton("extra2").hidden = false;
-    case 3:
-      dialog.getButton("extra1").hidden = false;
-  }
-
-  // display the main text
-  // XXX the substr(0, 10000) part is a workaround for bug 317334
-  var croppedMessage = gCommonDialogParam.GetString(0).substr(0, 10000);
-  setElementText("info.body", croppedMessage, true);
-
-  setElementText("info.header", gCommonDialogParam.GetString(3), true);
+    // Set button visibility
+    let dialog = document.documentElement;
+    switch (numButtons) {
+      case 1:
+        dialog.getButton("cancel").hidden = true;
+        break;
+      case 4:
+        dialog.getButton("extra2").hidden = false;
+      case 3:
+        dialog.getButton("extra1").hidden = false;
+    }
 
-  // set the icon
-  var iconElement = document.getElementById("info.icon");
-  var iconClasses = gCommonDialogParam.GetString(2);
-  if (iconClasses)
-    iconElement.className += " " + iconClasses;
+    // Set button labels
+    switch (numButtons) {
+      case 4:
+        setLabelForNode(document.documentElement.getButton("extra2"), gArgs.getProperty("button3Label"));
+        // fall through
+      case 3:
+        setLabelForNode(document.documentElement.getButton("extra1"), gArgs.getProperty("button2Label"));
+        // fall through
+      default:
+      case 2:
+        if (gArgs.hasKey("button1Label"))
+            setLabelForNode(document.documentElement.getButton("cancel"), gArgs.getProperty("button1Label"));
+        // fall through
+      case 1:
+        if (gArgs.hasKey("button0Label"))
+            setLabelForNode(document.documentElement.getButton("accept"), gArgs.getProperty("button0Label"));
+        break;
+    }
 
-  switch (nButtons) {
-    case 4:
-      setLabelForNode(document.documentElement.getButton("extra2"), gCommonDialogParam.GetString(11));
-      // fall through
-    case 3:
-      setLabelForNode(document.documentElement.getButton("extra1"), gCommonDialogParam.GetString(10));
-      // fall through
-    default:
-    case 2:
-      var string = gCommonDialogParam.GetString(9);
-      if (string)
-        setLabelForNode(document.documentElement.getButton("cancel"), string);
-      // fall through
-    case 1:
-      string = gCommonDialogParam.GetString(8);
-      if (string)
-        setLabelForNode(document.documentElement.getButton("accept"), string);
-      break;
-  }
+    // display the main text
+    // Bug 317334 - crop string length as a workaround.
+    let croppedMessage = gArgs.getProperty("text").substr(0, 10000);
+    document.getElementById("info.body").appendChild(document.createTextNode(croppedMessage));
 
-  // set default result to cancelled
-  gCommonDialogParam.SetInt(0, 1); 
+    if (gArgs.hasKey("checkLabel")) {
+        let label = gArgs.getProperty("checkLabel")
+        // Only show the checkbox if label has a value.
+        if (label) {
+            document.getElementById("checkboxContainer").hidden = false;
+            let checkboxElement = document.getElementById("checkbox");
+            setLabelForNode(checkboxElement, label);
+            checkboxElement.checked = gArgs.getProperty("checked");
+        }
+    }
+
+    // set the icon
+    document.getElementById("info.icon").className += " " + iconClass;
 
-  // initialize the checkbox
-  setCheckbox(gCommonDialogParam.GetString(1), gCommonDialogParam.GetInt(1));
+    // set default result to cancelled
+    gArgs.setProperty("ok", false);
+    gArgs.setProperty("buttonNumClicked", 1);
+
 
-  if (gCommonDialogParam.GetInt(3) == 0) // If no text fields
-  {
-    var dlgButtons = ['accept', 'cancel', 'extra1', 'extra2'];
+    // If there are no input fields on the dialog, select the default button.
+    // Otherwise, select the appropriate input field.
+    if (!hasInputField) {
+        let dlgButtons = ['accept', 'cancel', 'extra1', 'extra2'];
 
-    // Set the default button and focus it on non-OS X systems
-    var dButton = dlgButtons[gCommonDialogParam.GetInt(5)];
-    document.documentElement.defaultButton = dButton;
+        // Set the default button and focus it on non-OS X systems
+        let b = 0;
+        if (gArgs.hasKey("defaultButtonNum"))
+            b = gArgs.getProperty("defaultButtonNum");
+        let dButton = dlgButtons[b];
+        // XXX shouldn't we set the default even when a textbox is focused?
+        document.documentElement.defaultButton = dButton;
 #ifndef XP_MACOSX
-    document.documentElement.getButton(dButton).focus();
+        document.documentElement.getButton(dButton).focus();
 #endif
-  }
-  else {
-    if (gCommonDialogParam.GetInt(4) == 1)
-      document.getElementById("password1Textbox").select();
-    else
-      document.getElementById("loginTextbox").select();
-  }
+    } else {
+        if (promptType == "promptPassword")
+            document.getElementById("password1Textbox").select();
+        else
+            document.getElementById("loginTextbox").select();
+    }
+
+    if (gArgs.hasKey("enableDelay") && gArgs.getProperty("enableDelay")) {
+        let delayInterval = Services.prefs.getIntPref("security.dialog_enable_delay");
 
-  if (gCommonDialogParam.GetInt(6) != 0) // delay button enable
-  {
-    var delayInterval = 2000;
+        document.documentElement.getButton("accept").disabled = true;
+        document.documentElement.getButton("extra1").disabled = true;
+        document.documentElement.getButton("extra2").disabled = true;
+
+        setTimeout(commonDialogReenableButtons, delayInterval);
+
+        addEventListener("blur", commonDialogBlur, false);
+        addEventListener("focus", commonDialogFocus, false);
+    }
+
+    window.getAttention();
+
+    // play sound
     try {
-      var prefs = Cc["@mozilla.org/preferences-service;1"]
-                    .getService(Ci.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;
+        if (soundID) {
+            Cc["@mozilla.org/sound;1"].
+            createInstance(Ci.nsISound).
+            playEventSound(soundID);
+        }
+    } catch (e) { }
 
-    setTimeout(commonDialogReenableButtons, delayInterval);
-    
-    addEventListener("blur", commonDialogBlur, false);
-    addEventListener("focus", commonDialogFocus, false);
-  }
-
-  getAttention();
-
-  // play sound
-  try {
-    var sound = gCommonDialogParam.GetInt(7);
-    if (sound) {
-      Cc["@mozilla.org/sound;1"]
-        .createInstance(Ci.nsISound)
-        .playEventSound(sound);
-    }
-  } catch (e) { }
-
-  observerService.notifyObservers(window, "common-dialog-loaded", null);
+    Services.obs.notifyObservers(window, "common-dialog-loaded", null);
 }
 
-function commonDialogOnUnload(){
-  var observerService = Cc["@mozilla.org/observer-service;1"]
-                          .getService(Ci.nsIObserverService);
-  observerService.removeObserver(softkbObserver, "softkb-change");
+function commonDialogOnUnload() {
+    Services.obs.removeObserver(softkbObserver, "softkb-change");
 }
 
+
 var gDelayExpired = false;
 var gBlurred = false;
 
-function commonDialogBlur(aEvent)
-{
-  if (aEvent.target != document)
-    return;
-  gBlurred = true;
-  document.documentElement.getButton("accept").disabled = true;
-  document.documentElement.getButton("extra1").disabled = true;
-  document.documentElement.getButton("extra2").disabled = true;
-}
-
-function commonDialogFocus(aEvent)
-{
-  if (aEvent.target != document)
-    return;
-  gBlurred = false;
-  // When refocusing the window, don't enable the buttons unless the countdown
-  // delay has expired. 
-  if (gDelayExpired) {
-    var script = "document.documentElement.getButton('accept').disabled = false; ";
-    script += "document.documentElement.getButton('extra1').disabled = false; ";
-    script += "document.documentElement.getButton('extra2').disabled = false;";
-    setTimeout(script, 250);
-  }
+function commonDialogBlur(aEvent) {
+    if (aEvent.target != document)
+        return;
+    gBlurred = true;
+    document.documentElement.getButton("accept").disabled = true;
+    document.documentElement.getButton("extra1").disabled = true;
+    document.documentElement.getButton("extra2").disabled = true;
 }
 
-function commonDialogReenableButtons()
-{
-  // Don't automatically enable the buttons if we're not in the foreground
-  if (!gBlurred) {
-    document.documentElement.getButton("accept").disabled = false;
-    document.documentElement.getButton("extra1").disabled = false;
-    document.documentElement.getButton("extra2").disabled = false;
-  }
-  gDelayExpired = true;
+function commonDialogFocus(aEvent) {
+    if (aEvent.target != document)
+        return;
+    gBlurred = false;
+    // When refocusing the window, don't enable the buttons unless the countdown
+    // delay has expired.
+    if (gDelayExpired) {
+        let script;
+        script  = "document.documentElement.getButton('accept').disabled = false; ";
+        script += "document.documentElement.getButton('extra1').disabled = false; ";
+        script += "document.documentElement.getButton('extra2').disabled = false;";
+        setTimeout(script, 250);
+    }
 }
 
-function initTextbox(aName, aLabelIndex, aValueIndex, aAlwaysLabel)
-{
-  unHideElementById(aName+"Container");
-
-  var label = aLabelIndex < 0 ? "" : gCommonDialogParam.GetString(aLabelIndex);
-  if (label || aAlwaysLabel && !label)
-    setElementText(aName+"Label", label);
-    
-  var value = aValueIndex < 0 ? "" : gCommonDialogParam.GetString(aValueIndex);
-  var textbox = document.getElementById(aName + "Textbox");
-  textbox.setAttribute("value", value);
-}
-
-function setElementText(aElementID, aValue, aChildNodeFlag)
-{
-  var element = document.getElementById(aElementID);
-  if (!aChildNodeFlag && element) {
-    setLabelForNode(element, aValue, true);
-  } else if (aChildNodeFlag && element) {
-    element.appendChild(document.createTextNode(aValue));
-  }
+function commonDialogReenableButtons() {
+    // Don't automatically enable the buttons if we're not in the foreground
+    if (!gBlurred) {
+        document.documentElement.getButton("accept").disabled = false;
+        document.documentElement.getButton("extra1").disabled = false;
+        document.documentElement.getButton("extra2").disabled = false;
+    }
+    gDelayExpired = true;
 }
 
-function setCheckbox(aChkMsg, aChkValue)
-{
-  if (aChkMsg) {
-    unHideElementById("checkboxContainer");
-    
-    var checkboxElement = document.getElementById("checkbox");
-    setLabelForNode(checkboxElement, aChkMsg);
-    checkboxElement.checked = aChkValue > 0;
-  }
-}
-
-function unHideElementById(aElementID)
-{
-  var element = document.getElementById(aElementID);
-  element.hidden = false;
-}
-
-function hideElementById(aElementID)
-{
-  var element = document.getElementById(aElementID)
-  element.hidden = true;
-}
-
-function isVisible(aElementId)
-{
-  return document.getElementById(aElementId).hasAttribute("hidden");
-}
-
-function onCheckboxClick(aCheckboxElement)
-{
-  gCommonDialogParam.SetInt(1, aCheckboxElement.checked);
+function onCheckboxClick(aCheckboxElement) {
+    gArgs.setProperty("checked", aCheckboxElement.checked);
 }
 
-function commonDialogOnAccept()
-{
-  gCommonDialogParam.SetInt(0, 0); // say that ok was pressed
+function commonDialogOnAccept() {
+    gArgs.setProperty("ok", true);
+    gArgs.setProperty("buttonNumClicked", 0);
+
+    let username = document.getElementById("loginTextbox").value;
+    let password = document.getElementById("password1Textbox").value;
 
-  var numTextBoxes = gCommonDialogParam.GetInt(3);
-  var textboxIsPassword1 = gCommonDialogParam.GetInt(4) == 1;
-  
-  if (numTextBoxes >= 1) {
-    var editField1;
-    if (textboxIsPassword1)
-      editField1 = document.getElementById("password1Textbox");
-    else
-      editField1 = document.getElementById("loginTextbox");
-    gCommonDialogParam.SetString(6, editField1.value);
-  }
-
-  if (numTextBoxes == 2) {
-    var editField2;
-    if (textboxIsPassword1)
-      // we had two password fields
-      editField2 = document.getElementById("password2Textbox");
-    else
-      // we only had one password field (and one login field)
-      editField2 = document.getElementById("password1Textbox");
-    gCommonDialogParam.SetString(7, editField2.value);
-  }
+    // Return textfield values
+    switch (promptType) {
+      case "prompt":
+        gArgs.setProperty("value", username);
+        break;
+      case "promptUserAndPass":
+        gArgs.setProperty("user", username);
+        gArgs.setProperty("pass", password);
+        break;
+      case "promptPassword":
+        gArgs.setProperty("pass", password);
+        break;
+    }
 }
 
-function commonDialogOnExtra1()
-{
-  gCommonDialogParam.SetInt(0, 2);
-  window.close();
+function commonDialogOnExtra1() {
+    // .setProperty("ok", true)?
+    gArgs.setProperty("buttonNumClicked", 2);
+    window.close();
 }
 
-function commonDialogOnExtra2()
-{
-  gCommonDialogParam.SetInt(0, 3);
-  window.close();
+function commonDialogOnExtra2() {
+    // .setProperty("ok", true)?
+    gArgs.setProperty("buttonNumClicked", 3);
+    window.close();
 }
rename from toolkit/content/commonDialog.xul
rename to toolkit/components/prompts/content/commonDialog.xul
--- a/toolkit/content/commonDialog.xul
+++ b/toolkit/components/prompts/content/commonDialog.xul
@@ -54,39 +54,35 @@
         <hbox align="start">
           <image id="info.icon" class="spaced"/>
         </hbox>
         <vbox id="infoContainer">
 #ifdef XP_MACOSX
           <!-- Dialog title is inside dialog for OS X -->
           <description id="info.title"/>
 #endif
-          <description id="info.header" class="header"/>
+          <spacer style="height: 1em"/>
           <description id="info.body" context="contentAreaContextMenu" noinitialfocus="true"/>
         </vbox>
       </row>
       <row id="loginContainer" hidden="true" align="center">
         <label id="loginLabel" value="&editfield0.label;" control="loginTextbox"/>
         <textbox id="loginTextbox"/>
       </row>
       <row id ="password1Container" hidden="true" align="center">
         <label id="password1Label" value="&editfield1.label;" control="password1Textbox"/>
         <textbox type="password" id="password1Textbox"/>
       </row>
-      <row id="password2Container" hidden="true" align="center">
-        <label id="password2Label" value="&editfield2.label;" control="password2Textbox"/>
-        <textbox type="password" id="password2Textbox"/>
-      </row>
       <row id="checkboxContainer" hidden="true">
         <spacer/>
         <checkbox id="checkbox" oncommand="onCheckboxClick(this);"/>
       </row>
     </rows>
   </grid>
 
 
   <!-- This method is called inline because it may unset hidden="true" on the
        above boxes, causing their frames to be build and bindings to load.  
        So, by calling this inline, we guarantee the textboxes and checkboxes 
        above will have their bindings before initButtons is called, and the
        dialog will be intrinsically sized correctly. -->
-  <script type="application/javascript">showControls();</script>
+  <script type="application/javascript">earlyInit();</script>
 </dialog>
rename from toolkit/content/selectDialog.js
rename to toolkit/components/prompts/content/selectDialog.js
--- a/toolkit/content/selectDialog.js
+++ b/toolkit/components/prompts/content/selectDialog.js
@@ -1,9 +1,8 @@
-/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
@@ -16,144 +15,88 @@
  *
  * The Initial Developer of the Original Code is
  * Netscape Communications Corporation.
  * Portions created by the Initial Developer are Copyright (C) 1998
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Alec Flett <alecf@netscape.com>
+ *   Justin Dolske <dolske@mozilla.com>
  *
  * 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
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-var elements = [];
-var numItems;
-var list;
-var param;
+const Ci = Components.interfaces;
+const Cr = Components.results;
+const Cc = Components.classes;
+const Cu = Components.utils;
 
-function selectDialogOnLoad() {
-  param = window.arguments[0].QueryInterface( Components.interfaces.nsIDialogParamBlock  );
-  if( !param )
-  dump( " error getting param block interface\n" );
+let gArgs = window.arguments[0].QueryInterface(Ci.nsIWritablePropertyBag2)
+                               .QueryInterface(Ci.nsIWritablePropertyBag);
 
-  var messageText = param.GetString( 1 );
-  {
-    var messageFragment;
+let listBox;
 
-    // Let the caller use "\n" to cause breaks
-    // Translate these into <br> tags
-    var messageParent = (document.getElementById("info.txt"));
-    var done = false;
-    while (!done) {
-      var breakIndex = messageText.indexOf('\n');
-      if (breakIndex == 0) {
-        // Ignore break at the first character
-        messageText = messageText.slice(1);
-        messageFragment = "";
-      } else if (breakIndex > 0) {
-        // The fragment up to the break
-        messageFragment = messageText.slice(0, breakIndex);
+function dialogOnLoad() {
+    let promptType = gArgs.getProperty("promptType");
+    if (promptType != "select") {
+        Cu.reportError("selectDialog opened for unknown type: " + promptType);
+        window.close();
+    }
+
+    // Default to canceled.
+    gArgs.setProperty("ok", false);
+
+    document.title = gArgs.getProperty("title");
+
+    let text = gArgs.getProperty("text");
+    document.getElementById("info.txt").setAttribute("value", text);
 
-        // Chop off fragment we just found from remaining string
-        messageText = messageText.slice(breakIndex+1);
-      } else {
-        // "\n" not found. We're done
-        done = true;
-        messageFragment = messageText;
-      }
-      messageParent.setAttribute("value", messageFragment);
+    let items = gArgs.getProperty("list");
+    listBox = document.getElementById("list");
+
+    for (let i = 0; i < items.length; i++) {
+        let str = items[i];
+        if (str == "")
+            str = "<>";
+        listBox.appendItem(str);
+        listBox.getItemAtIndex(i).addEventListener("dblclick", dialogDoubleClick, false);
     }
-  }
-
-  document.title = param.GetString( 0 );
-
-  list = document.getElementById("list");
-  numItems = param.GetInt( 2 );
+    listBox.selectedIndex = 0;
+    listBox.focus();
 
-  var i;
-  for ( i = 2; i <= numItems+1; i++ ) {
-    var newString = param.GetString( i );
-    if (newString == "") {
-      newString = "<>";
-    }
-    elements[i-2] = AppendStringToListbox(list, newString);
-  }
-  list.selectItem(elements[0]);
-  list.focus();
+    // resize the window to the content
+    window.sizeToContent();
+
+    // Move to the right location
+    moveToAlertPosition();
+    centerWindowOnScreen();
 
-  // resize the window to the content
-  window.sizeToContent();
-
-  // Move to the right location
-  moveToAlertPosition();
-  param.SetInt(0, 1 );
-  centerWindowOnScreen();
-
-  // play sound
-  try {
-    const nsISound = Components.interfaces.nsISound;
-    Components.classes["@mozilla.org/sound;1"]
-              .createInstance(nsISound)
-              .playEventSound(nsISound.EVENT_SELECT_DIALOG_OPEN);
-  } catch (e) { }
+    // play sound
+    try {
+        Cc["@mozilla.org/sound;1"].
+        createInstance(Ci.nsISound).
+        playEventSound(Ci.nsISound.EVENT_SELECT_DIALOG_OPEN);
+    } catch (e) { }
 }
 
-function commonDialogOnOK() {
-  for (var i=0; i<numItems; i++) {
-    if (elements[i] == list.selectedItems[0]) {
-      param.SetInt(2, i );
-      break;
-    }
-  }
-  param.SetInt(0, 0 );
-  return true;
-}
-
-function commonDialogOnCancel() {
-  for (var i=0; i<numItems; i++) {
-    if (elements[i]) {
-      param.SetInt(2, i );
-      break;
-    }
-  }
-  param.SetInt(0, 1 );
-  return true;
+function dialogOK() {
+    let selected = listBox.selectedIndex;
+    gArgs.setProperty("selected", listBox.selectedIndex);
+    gArgs.setProperty("ok", true);
+    return true;
 }
 
-function commonDialogOnDoubleClick() {
-  commonDialogOnOK();
-  window.close();
+function dialogDoubleClick() {
+    dialogOK();
+    window.close();
 }
-
-// following routine should really be in a global utilities package
-
-function AppendStringToListbox(tree, string)
-{
-  if (tree)
-  {
-    var listbox = document.getElementById('list');
-
-    var listitem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "listitem");
-    if (listitem)
-    {
-      listitem.setAttribute("label", string);
-      listitem.setAttribute("ondblclick","commonDialogOnDoubleClick()");
-      listbox.appendChild(listitem)
-      var len = Number(tree.getAttribute("length"));
-      if (!len) len = -1;
-      tree.setAttribute("length",len+1);
-      return listitem;
-    }
-  }
-  return null;
-}
rename from toolkit/content/selectDialog.xul
rename to toolkit/components/prompts/content/selectDialog.xul
--- a/toolkit/content/selectDialog.xul
+++ b/toolkit/components/prompts/content/selectDialog.xul
@@ -36,19 +36,18 @@
  the terms of any one of the MPL, the GPL or the LGPL.
 
  ***** END LICENSE BLOCK ***** -->
 
 <?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?> 
 <!DOCTYPE dialog SYSTEM "chrome://global/locale/commonDialog.dtd">
  
 <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
-      onload="selectDialogOnLoad()"
-      ondialogaccept="return commonDialogOnOK();"
-      ondialogcancel="return commonDialogOnCancel();">
+      onload="dialogOnLoad()"
+      ondialogaccept="return dialogOK();">
 
   <script type="application/javascript" src="chrome://global/content/selectDialog.js" />
   <keyset id="dialogKeys"/>
   <vbox style="width: 24em;margin: 5px;">
     <label id="info.txt"/>
     <vbox>
       <listbox id="list" rows="4" flex="1"/>
     </vbox>
new file mode 100644
--- /dev/null
+++ b/toolkit/components/prompts/jar.mn
@@ -0,0 +1,6 @@
+toolkit.jar:
+*+ content/global/commonDialog.js             (content/commonDialog.js)
+*+ content/global/commonDialog.xul            (content/commonDialog.xul)
+   content/global/commonDialog.css            (content/commonDialog.css)
++  content/global/selectDialog.js             (content/selectDialog.js)
++  content/global/selectDialog.xul            (content/selectDialog.xul)
--- a/toolkit/components/prompts/src/nsPrompter.js
+++ b/toolkit/components/prompts/src/nsPrompter.js
@@ -33,49 +33,744 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
+const Cu = Components.utils;
 
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-Components.utils.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
 
 function Prompter() {
     this.init();
 }
 
 Prompter.prototype = {
     classDescription : "Prompter",
     contractID       : "@mozilla.org/prompter;1",
     classID          : Components.ID("{1c978d25-b37f-43a8-a2d6-0c7a239ead87}"),
-    QueryInterface   : XPCOMUtils.generateQI([Ci.nsISupports]),
+    QueryInterface   : XPCOMUtils.generateQI([Ci.nsIPromptFactory, Ci.nsIPromptService, Ci.nsIPromptService2]),
 
 
     /* ----------  private memebers  ---------- */
 
 
-    debug    : true,
-
-    init : function () {
-        this.log("initialized!");
-    },
-
+    debug : true,
 
     log : function (message) {
         if (!this.debug)
             return;
         dump("Prompter: " + message + "\n");
         Services.console.logStringMessage("Prompter: " + message);
     },
 
+    init : function () {
+        this.log("initialized!");
+    },
 
-    /* ----------  nsIPrompter  ---------- */
+    pickPrompter : function (domWin) {
+        return new ModalPrompter(domWin);
+    },
+
+
+    /* ----------  nsIPromptFactory  ---------- */
+
+
+    getPrompt : function (domWin, iid) {
+        this.log("getPrompt() for iid=" + iid);
+        // This is still kind of dumb; the C++ code delegated to login manager
+        // here, which in turn calls back into us via nsIPromptService2.
+        if (iid.equals(Ci.nsIAuthPrompt2) || iid.equals(Ci.nsIAuthPrompt)) {
+            try {
+                this.log("Delegating getPrompt() to login manager.");
+                let pwmgr = Cc["@mozilla.org/passwordmanager/authpromptfactory;1"].
+                            getService(Ci.nsIPromptFactory);
+                return pwmgr.getPrompt(domWin, iid);
+            } catch (e) { this.log("Delegation failed: " + e); }
+        }
+
+        let p = new ModalPrompter(domWin);
+        p.QueryInterface(iid);
+        return p;
+    },
+
+
+    /* ----------  nsIPromptService  ---------- */
+
+
+    alert : function (domWin, title, text) {
+        let p = this.pickPrompter(domWin);
+        p.alert(title, text);
+    },
+
+    alertCheck : function (domWin, title, text, checkLabel, checkValue) {
+        let p = this.pickPrompter(domWin);
+        p.alertCheck(title, text, checkLabel, checkValue);
+    },
+
+    confirm : function (domWin, title, text) {
+        let p = this.pickPrompter(domWin);
+        return p.confirm(title, text);
+    },
+
+    confirmCheck : function (domWin, title, text, checkLabel, checkValue) {
+        let p = this.pickPrompter(domWin);
+        return p.confirmCheck(title, text, checkLabel, checkValue);
+    },
+
+    confirmEx : function (domWin, title, text, flags, button0, button1, button2, checkLabel, checkValue) {
+        let p = this.pickPrompter(domWin);
+        return p.confirmEx(title, text,  flags, button0, button1, button2, checkLabel, checkValue);
+    },
+
+    prompt : function (domWin, title, text, value, checkLabel, checkValue) {
+        let p = this.pickPrompter(domWin);
+        return p.nsIPrompt_prompt(title, text, value, checkLabel, checkValue);
+    },
+
+    promptUsernameAndPassword : function (domWin, title, text, user, pass, checkLabel, checkValue) {
+        let p = this.pickPrompter(domWin);
+        return p.nsIPrompt_promptUsernameAndPassword(title, text, user, pass, checkLabel, checkValue);
+    },
+
+    promptPassword : function (domWin, title, text, pass, checkLabel, checkValue) {
+        let p = this.pickPrompter(domWin);
+        return p.nsIPrompt_promptPassword(title, text, pass, checkLabel, checkValue);
+    },
+
+    select : function (domWin, title, text, count, list, selected) {
+        let p = this.pickPrompter(domWin);
+        return p.select(title, text, count, list, selected);
+    },
+
+
+    /* ----------  nsIPromptService2  ---------- */
+
+
+    promptAuth : function (domWin, channel, level, authInfo, checkLabel, checkValue) {
+        let p = this.pickPrompter(domWin);
+        return p.promptAuth(channel, level, authInfo, checkLabel, checkValue);
+    },
+
+    asyncPromptAuth : function (domWin, channel, callback, context, level, authInfo, checkLabel, checkValue) {
+        let p = this.pickPrompter(domWin);
+        return p.asyncPromptAuth(channel, callback, context, level, authInfo, checkLabel, checkValue);
+    },
+
 };
 
 
-var component = [Prompter];
+// Common utils not specific to a particular prompter style.
+let PromptUtils = {
+
+    getLocalizedString : function (key, formatArgs) {
+        if (formatArgs)
+            return this.strBundle.formatStringFromName(key, formatArgs, formatArgs.length);
+        else
+            return this.strBundle.GetStringFromName(key);
+    },
+
+    confirmExHelper : function (flags, button0, button1, button2) {
+        const BUTTON_DEFAULT_MASK = 0x03000000;
+        let defaultButtonNum = (flags & BUTTON_DEFAULT_MASK) >> 24;
+        let isDelayEnabled = (flags & Ci.nsIPrompt.BUTTON_DELAY_ENABLE);
+
+        // Flags can be used to select a specific pre-defined button label or
+        // a caller-supplied string (button0/button1/button2). If no flags are
+        // set for a button, then the button won't be shown.
+        let argText = [button0, button1, button2];
+        let buttonLabels = [null, null, null];
+        for (let i = 0; i < 3; i++) {
+            let buttonLabel;
+            switch (flags & 0xff) {
+              case Ci.nsIPrompt.BUTTON_TITLE_OK:
+                buttonLabel = PromptUtils.getLocalizedString("OK");
+                break;
+              case Ci.nsIPrompt.BUTTON_TITLE_CANCEL:
+                buttonLabel = PromptUtils.getLocalizedString("Cancel");
+                break;
+              case Ci.nsIPrompt.BUTTON_TITLE_YES:
+                buttonLabel = PromptUtils.getLocalizedString("Yes");
+                break;
+              case Ci.nsIPrompt.BUTTON_TITLE_NO:
+                buttonLabel = PromptUtils.getLocalizedString("No");
+                break;
+              case Ci.nsIPrompt.BUTTON_TITLE_SAVE:
+                buttonLabel = PromptUtils.getLocalizedString("Save");
+                break;
+              case Ci.nsIPrompt.BUTTON_TITLE_DONT_SAVE:
+                buttonLabel = PromptUtils.getLocalizedString("DontSave");
+                break;
+              case Ci.nsIPrompt.BUTTON_TITLE_REVERT:
+                buttonLabel = PromptUtils.getLocalizedString("Revert");
+                break;
+              case Ci.nsIPrompt.BUTTON_TITLE_IS_STRING:
+                buttonLabel = argText[i];
+                break;
+            }
+            if (buttonLabel)
+                buttonLabels[i] = buttonLabel;
+            flags >>= 8;
+        }
+
+        return [buttonLabels[0], buttonLabels[1], buttonLabels[2], defaultButtonNum, isDelayEnabled];
+    },
+
+    // Returns true if some listener requested that the default action be prevented.
+    fireEvent : function (domWin, eventType) {
+        // XXX main use of DOMWillOpenModalDialog is so tabbrowser can focus
+        //     the tab opening the modal prompt. DOMModalDialogClosed is
+        //     unused (until bug 429287).
+        // XXX Maybe make these observer notifications instead?
+        //     oh, content can see these? That seems unfortunate. Esp. for auth.
+        let event = domWin.document.createEvent("Events");
+        event.initEvent(eventType, true, true);
+        return !domWin.dispatchEvent(event);
+    },
+
+    getAuthInfo : function (authInfo) {
+        let username, password;
+
+        let flags = authInfo.flags;
+        if (flags & Ci.nsIAuthInformation.NEED_DOMAIN && authInfo.domain)
+            username = authInfo.domain + "\\" + authInfo.username;
+        else
+            username = authInfo.username;
+
+        password = authInfo.password;
+
+        return [username, password];
+    },
+
+    setAuthInfo : function (authInfo, username, password) {
+        let flags = authInfo.flags;
+        if (flags & Ci.nsIAuthInformation.NEED_DOMAIN) {
+            // Domain is separated from username by a backslash
+            let idx = username.indexOf("\\");
+            if (idx == -1) {
+                authInfo.username = username;
+            } else {
+                authInfo.domain   =  username.substring(0, idx);
+                authInfo.username =  username.substring(idx+1);
+            }
+        } else {
+            authInfo.username = username;
+        }
+        authInfo.password = password;
+    },
+
+    // Copied from login manager
+    getFormattedHostname : function (uri) {
+        let scheme = uri.scheme;
+        let hostname = scheme + "://" + uri.host;
+
+        // If the URI explicitly specified a port, only include it when
+        // it's not the default. (We never want "http://foo.com:80")
+        port = uri.port;
+        if (port != -1) {
+            let handler = Services.io.getProtocolHandler(scheme);
+            if (port != handler.defaultPort)
+                hostname += ":" + port;
+        }
+
+        return hostname;
+    },
+
+    // Copied from login manager
+    getAuthTarget : function (aChannel, aAuthInfo) {
+        let hostname, realm;
+
+        // If our proxy is demanding authentication, don't use the
+        // channel's actual destination.
+        if (aAuthInfo.flags & Ci.nsIAuthInformation.AUTH_PROXY) {
+            if (!(aChannel instanceof Ci.nsIProxiedChannel))
+                throw "proxy auth needs nsIProxiedChannel";
+
+            let info = aChannel.proxyInfo;
+            if (!info)
+                throw "proxy auth needs nsIProxyInfo";
+
+            // Proxies don't have a scheme, but we'll use "moz-proxy://"
+            // so that it's more obvious what the login is for.
+            let idnService = Cc["@mozilla.org/network/idn-service;1"].
+                             getService(Ci.nsIIDNService);
+            hostname = "moz-proxy://" +
+                        idnService.convertUTF8toACE(info.host) +
+                        ":" + info.port;
+            realm = aAuthInfo.realm;
+            if (!realm)
+                realm = hostname;
+
+            return [hostname, realm];
+        }
+
+        hostname = this.getFormattedHostname(aChannel.URI);
+
+        // If a HTTP WWW-Authenticate header specified a realm, that value
+        // will be available here. If it wasn't set or wasn't HTTP, we'll use
+        // the formatted hostname instead.
+        realm = aAuthInfo.realm;
+        if (!realm)
+            realm = hostname;
+
+        return [hostname, realm];
+    },
+
+
+    makeAuthMessage : function (channel, authInfo) {
+        let isProxy    = (authInfo.flags & Ci.nsIAuthInformation.AUTH_PROXY);
+        let isPassOnly = (authInfo.flags & Ci.nsIAuthInformation.ONLY_PASSWORD);
+
+        let username = authInfo.username;
+        let [displayHost, realm] = this.getAuthTarget(channel, authInfo);
+
+        // Suppress "the site says: $realm" when we synthesized a missing realm.
+        if (!authInfo.realm && !isProxy)
+            realm = null;
+
+        // Trim obnoxiously long realms.
+        if (realm.length > 150) {
+            realm = realm.substring(0, 150);
+            // Append "..." (or localized equivalent).
+            realm += this.ellipsis;
+        }
+
+        let text;
+        if (isProxy)
+            text = PromptUtils.getLocalizedString("EnterLoginForProxy", [realm, displayHost]);
+        else if (isPassOnly)
+            text = PromptUtils.getLocalizedString("EnterPasswordFor", [username, displayHost]);
+        else if (!realm)
+            text = PromptUtils.getLocalizedString("EnterUserPasswordFor", [displayHost]);
+        else
+            text = PromptUtils.getLocalizedString("EnterLoginForRealm", [realm, displayHost]);
+
+        return text;
+    },
+
+};
+
+XPCOMUtils.defineLazyGetter(PromptUtils, "strBundle", function () {
+    let bunService = Cc["@mozilla.org/intl/stringbundle;1"].
+                     getService(Ci.nsIStringBundleService);
+    let bundle = bunService.createBundle("chrome://global/locale/commonDialogs.properties");
+    if (!bundle)
+        throw "String bundle for Prompter not present!";
+    return bundle;
+});
+
+XPCOMUtils.defineLazyGetter(PromptUtils, "ellipsis", function () {
+    let ellipsis = "\u2026";
+    try {
+        ellipsis = Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data;
+    } catch (e) { }
+    return ellipsis;
+});
+
+
+
+const COMMON_DIALOG = "chrome://global/content/commonDialog.xul";
+const SELECT_DIALOG = "chrome://global/content/selectDialog.xul";
+
+function ModalPrompter(domWin) {
+    this.domWin = domWin;
+}
+ModalPrompter.prototype = {
+    domWin : null,
+
+    QueryInterface : XPCOMUtils.generateQI([Ci.nsIPrompt, Ci.nsIAuthPrompt, Ci.nsIAuthPrompt2]),
+
+
+    /* ---------- internal methods ---------- */
+
+
+    newPropBag : function () {
+        let bag = Cc["@mozilla.org/hash-property-bag;1"].
+                  createInstance(Ci.nsIWritablePropertyBag2);
+        return bag.QueryInterface(Ci.nsIWritablePropertyBag);
+    },
+
+    openPrompt : function (uri, args) {
+        // XXX do we want to do modal state if we fall back to .activeWindow?
+        let domWin = this.domWin;
+        if (!domWin)
+            domWin = Services.ww.activeWindow;
+
+        // Note that we don't need to fire DOMWillOpenModalDialog and
+        // DOMModalDialogClosed events here, wwatcher's OpenWindowJSInternal
+        // will do that. Similarly for enterModalState / leaveModalState.
+
+        let winUtils = domWin.QueryInterface(Ci.nsIInterfaceRequestor)
+                             .getInterface(Ci.nsIDOMWindowUtils);
+
+        Services.ww.openWindow(domWin, uri, "_blank", "centerscreen,chrome,modal,titlebar", args);
+    },
+
+
+
+    /*
+     * ---------- interface disambiguation ----------
+     *
+     * nsIPrompt and nsIAuthPrompt share 3 method names with slightly
+     * different arguments. All but prompt() have the same number of
+     * arguments, so look at the arg types to figure out how we're being
+     * called. :-(
+     */
+    prompt : function() {
+        // also, the nsIPrompt flavor has 5 args instead of 6.
+        if (typeof arguments[2] == "object")
+            return this.nsIPrompt_prompt.apply(this, arguments);
+        else
+            return this.nsIAuthPrompt_prompt.apply(this, arguments);
+    },
+
+    promptUsernameAndPassword : function() {
+        // Both have 6 args, so use types.
+        if (typeof arguments[2] == "object")
+            return this.nsIPrompt_promptUsernameAndPassword.apply(this, arguments);
+        else
+            return this.nsIAuthPrompt_promptUsernameAndPassword.apply(this, arguments);
+    },
+
+    promptPassword : function() {
+        // Both have 5 args, so use types.
+        if (typeof arguments[2] == "object")
+            return this.nsIPrompt_promptPassword.apply(this, arguments);
+        else
+            return this.nsIAuthPrompt_promptPassword.apply(this, arguments);
+    },
+
+
+    /* ----------  nsIPrompt  ---------- */
+
+
+    alert : function (title, text) {
+        if (!title)
+            title = PromptUtils.getLocalizedString("Alert");
+
+        let args = this.newPropBag();
+        args.setProperty("promptType", "alert");
+        args.setProperty("title", title);
+        args.setProperty("text",  text);
+
+        this.openPrompt(COMMON_DIALOG, args);
+    },
+
+    alertCheck : function (title, text, checkLabel, checkValue) {
+        if (!title)
+            title = PromptUtils.getLocalizedString("Alert");
+
+        let args = this.newPropBag();
+        args.setProperty("promptType", "alertCheck");
+        args.setProperty("title",      title);
+        args.setProperty("text",       text);
+        args.setProperty("checkLabel", checkLabel);
+        args.setProperty("checked",    checkValue.value);
+
+        this.openPrompt(COMMON_DIALOG, args);
+
+        // Checkbox state always returned, even if cancel clicked.
+        checkValue.value = args.getProperty("checked");
+    },
+
+    confirm : function (title, text) {
+        if (!title)
+            title = PromptUtils.getLocalizedString("Confirm");
+
+        let args = this.newPropBag();
+        args.setProperty("promptType", "confirm");
+        args.setProperty("title",      title);
+        args.setProperty("text",       text);
+        args.setProperty("ok",         false);
+
+        this.openPrompt(COMMON_DIALOG, args);
+
+        // Did user click Ok or Cancel?
+        return args.getProperty("ok");
+    },
+
+    confirmCheck : function (title, text, checkLabel, checkValue) {
+        if (!title)
+            title = PromptUtils.getLocalizedString("ConfirmCheck");
+
+        let args = this.newPropBag();
+        args.setProperty("promptType", "confirmCheck");
+        args.setProperty("title",      title);
+        args.setProperty("text",       text);
+        args.setProperty("checkLabel", checkLabel);
+        args.setProperty("checked",    checkValue.value);
+        args.setProperty("ok",         false);
+
+        this.openPrompt(COMMON_DIALOG, args);
+
+        // Checkbox state always returned, even if cancel clicked.
+        checkValue.value = args.getProperty("checked");
+
+        // Did user click Ok or Cancel?
+        return args.getProperty("ok");
+    },
+
+    confirmEx : function (title, text, flags, button0, button1, button2,
+                          checkLabel, checkValue) {
+
+        if (!title)
+            title = PromptUtils.getLocalizedString("Confirm");
+
+        let args = this.newPropBag();
+        args.setProperty("promptType", "confirmEx");
+        args.setProperty("title",      title);
+        args.setProperty("text",       text);
+        args.setProperty("checkLabel", checkLabel);
+        args.setProperty("checked",    checkValue.value);
+        args.setProperty("ok",         false);
+        args.setProperty("buttonNumClicked", 1);
+
+        let [label0, label1, label2, defaultButtonNum, isDelayEnabled] =
+            PromptUtils.confirmExHelper(flags, button0, button1, button2);
+
+        args.setProperty("defaultButtonNum", defaultButtonNum);
+        args.setProperty("enableDelay", isDelayEnabled);
+
+        if (label0) {
+            args.setProperty("button0Label", label0);
+            if (label1) {
+                args.setProperty("button1Label", label1);
+                if (label2) {
+                    args.setProperty("button2Label", label2);
+                }
+            }
+        }
+
+        this.openPrompt(COMMON_DIALOG, args);
+
+        // Checkbox state always returned, even if cancel clicked.
+        checkValue.value = args.getProperty("checked");
+
+        // Get the number of the button the user clicked.
+        return args.getProperty("buttonNumClicked");
+    },
+
+    nsIPrompt_prompt : function (title, text, value, checkLabel, checkValue) {
+        if (!title)
+            title = PromptUtils.getLocalizedString("Prompt");
+
+        let args = this.newPropBag();
+        args.setProperty("promptType", "prompt");
+        args.setProperty("title",      title);
+        args.setProperty("text",       text);
+        args.setProperty("value",      value.value);
+        args.setProperty("checkLabel", checkLabel);
+        args.setProperty("checked",    checkValue.value);
+        args.setProperty("ok",         false);
+
+        this.openPrompt(COMMON_DIALOG, args);
+
+        // Did user click Ok or Cancel?
+        let ok  = args.getProperty("ok");
+        if (ok) {
+            checkValue.value = args.getProperty("checked");
+            value.value      = args.getProperty("value");
+        }
+
+        return ok;
+    },
+
+    nsIPrompt_promptUsernameAndPassword : function (title, text, user, pass, checkLabel, checkValue) {
+        if (!title)
+            title = PromptUtils.getLocalizedString("PromptUsernameAndPassword2");
+
+        let args = this.newPropBag();
+        args.setProperty("promptType", "promptUserAndPass");
+        args.setProperty("title",      title);
+        args.setProperty("text",       text);
+        args.setProperty("user",       user.value);
+        args.setProperty("pass",       pass.value);
+        args.setProperty("checkLabel", checkLabel);
+        args.setProperty("checked",    checkValue.value);
+        args.setProperty("ok",         false);
+
+        this.openPrompt(COMMON_DIALOG, args);
+
+        // Did user click Ok or Cancel?
+        let ok  = args.getProperty("ok");
+        if (ok) {
+            checkValue.value = args.getProperty("checked");
+            user.value       = args.getProperty("user");
+            pass.value       = args.getProperty("pass");
+        }
+
+        return ok;
+    },
+
+    nsIPrompt_promptPassword : function (title, text, pass, checkLabel, checkValue) {
+        if (!title)
+            title = PromptUtils.getLocalizedString("PromptPassword2");
+
+        let args = this.newPropBag();
+        args.setProperty("promptType", "promptPassword");
+        args.setProperty("title",      title);
+        args.setProperty("text",       text);
+        args.setProperty("pass",       pass.value);
+        args.setProperty("checkLabel", checkLabel);
+        args.setProperty("checked",    checkValue.value);
+        args.setProperty("ok",         false);
+
+        this.openPrompt(COMMON_DIALOG, args);
+
+        // Did user click Ok or Cancel?
+        let ok  = args.getProperty("ok");
+        if (ok) {
+            checkValue.value = args.getProperty("checked");
+            pass.value       = args.getProperty("pass");
+        }
+
+        return ok;
+    },
+
+    select : function (title, text, count, list, selected) {
+        if (!title)
+            title = PromptUtils.getLocalizedString("Select");
+
+        let args = this.newPropBag();
+        args.setProperty("promptType", "select");
+        args.setProperty("title",      title);
+        args.setProperty("text",       text);
+        args.setProperty("list",       list);
+        args.setProperty("ok",         false);
+
+        this.openPrompt(SELECT_DIALOG, args);
+
+        // Did user click Ok or Cancel?
+        let ok  = args.getProperty("ok");
+        if (ok)
+            selected.value = args.getProperty("selected");
+
+        return ok;
+    },
+
+
+    /* ----------  nsIAuthPrompt  ---------- */
+
+
+    nsIAuthPrompt_prompt : function (title, text, passwordRealm, savePassword, defaultText, result) {
+        // The passwordRealm and savePassword args were ignored by nsPrompt.cpp
+        if (defaultText)
+            result.value = defaultText;
+        return this.nsIPrompt_prompt(title, text, result, null, {});
+    },
+
+    nsIAuthPrompt_promptUsernameAndPassword : function (title, text, passwordRealm, savePassword, user, pass) {
+        // The passwordRealm and savePassword args were ignored by nsPrompt.cpp
+        return this.nsIPrompt_promptUsernameAndPassword(title, text, user, pass, null, {});
+    },
+
+    nsIAuthPrompt_promptPassword : function (title, text, passwordRealm, savePassword, pass) {
+        // The passwordRealm and savePassword args were ignored by nsPrompt.cpp
+        return this.nsIPrompt_promptPassword(title, text, pass, null, {});
+    },
+
+
+    /* ----------  nsIAuthPrompt2  ---------- */
+
+
+    promptAuth : function (channel, level, authInfo, checkLabel, checkValue) {
+        let message = PromptUtils.makeAuthMessage(channel, authInfo);
+
+        let [username, password] = PromptUtils.getAuthInfo(authInfo);
+
+        let userParam = { value: username };
+        let passParam = { value: password };
+
+        let ok;
+        if (authInfo.flags & Ci.nsIAuthInformation.ONLY_PASSWORD)
+            ok = this.nsIPrompt_promptPassword(null, message, passParam, checkLabel, checkValue);
+        else
+            ok = this.nsIPrompt_promptUsernameAndPassword(null, message, userParam, passParam, checkLabel, checkValue);
+
+        if (ok)
+            PromptUtils.setAuthInfo(authInfo, userParam.value, passParam.value);
+        return ok;
+    },
+
+    asyncPromptAuth : function (channel, callback, context, level, authInfo, checkLabel, checkValue) {
+        // Nothing calls this directly; netwerk ends up going through
+        // nsIPromptService::GetPrompt, which delegates to login manager.
+        // Login manger handles the async bits itself, and only calls out
+        // promptAuth, never asyncPromptAuth.
+        //
+        // Bug 565582 will change this.
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
+    },
+};
+
+
+function AuthPromptAdapterFactory() {
+}
+AuthPromptAdapterFactory.prototype = {
+    classDescription : "AuthPromptAdapterFactory",
+    contractID       : "@mozilla.org/network/authprompt-adapter-factory;1",
+    classID          : Components.ID("{6e134924-6c3a-4d86-81ac-69432dd971dc}"),
+    QueryInterface   : XPCOMUtils.generateQI([Ci.nsIAuthPromptAdapterFactory]),
+
+    /* ----------  nsIAuthPromptAdapterFactory ---------- */
+
+    createAdapter : function (oldPrompter) {
+        return new AuthPromptAdapter(oldPrompter);
+    }
+};
+
+
+// Takes an nsIAuthPrompt implementation, wraps it with a nsIAuthPrompt2 shell.
+function AuthPromptAdapter(oldPrompter) {
+    this.oldPrompter = oldPrompter;
+}
+AuthPromptAdapter.prototype = {
+    QueryInterface : XPCOMUtils.generateQI([Ci.nsIAuthPrompt2]),
+    oldPrompter    : null,
+
+    /* ----------  nsIAuthPrompt2 ---------- */
+
+    promptAuth : function (channel, level, authInfo, checkLabel, checkValue) {
+        let message = PromptUtils.makeAuthMessage(channel, authInfo);
+
+        let [username, password] = PromptUtils.getAuthInfo(authInfo);
+        let userParam = { value: username };
+        let passParam = { value: password };
+
+        let [host, realm]  = PromptUtils.getAuthTarget(channel, authInfo);
+        let authTarget = host + " (" + realm + ")";
+
+        let ok;
+        if (authInfo.flags & Ci.nsIAuthInformation.ONLY_PASSWORD)
+            ok = this.oldPrompter.promptPassword(null, message, authTarget, Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, passParam);
+        else
+            ok = this.oldPrompter.promptUsernameAndPassword(null, message, authTarget, Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, userParam, passParam);
+
+        if (ok)
+            PromptUtils.setAuthInfo(authInfo, userParam.value, passParam.value);
+        return ok;
+    },
+
+    asyncPromptAuth : function (channel, callback, context, level, authInfo, checkLabel, checkValue) {
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
+    }
+};
+
+
+// Wrapper using the old embedding contractID, since it's already common in
+// the addon ecosystem.
+function EmbedPrompter() {
+    this.init();
+}
+EmbedPrompter.prototype = new Prompter();
+EmbedPrompter.prototype.classDescription = "EmbedPrompter";
+EmbedPrompter.prototype.contractID       = "@mozilla.org/embedcomp/prompt-service;1"; // NS_PROMPTSERVICE_CONTRACTID
+EmbedPrompter.prototype.classID          = Components.ID("{7ad1b327-6dfa-46ec-9234-f2a620ea7e00}");
+
+
+var component = [Prompter, EmbedPrompter, AuthPromptAdapterFactory];
 function NSGetModule (compMgr, fileSpec) {
     return XPCOMUtils.generateModule(component);
 }
--- a/toolkit/components/prompts/test/test_modal_prompts.html
+++ b/toolkit/components/prompts/test/test_modal_prompts.html
@@ -865,17 +865,17 @@ ok(didDialog, "handleDialog was invoked"
 // ===== test 20 =====
 // Select (0 items, ok)
 testNum++;
 startCallbackTimer();
 items = [];
 selectVal.value = null; // outparam, just making sure.
 isOK = prompter.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal);
 is(isOK, true, "checked expected retval");
-is(selectVal.value, 0, "checking selected index");
+is(selectVal.value, -1, "checking selected index");
 ok(didDialog, "handleDialog was invoked");
 
 // ===== test 21 =====
 // Select (3 items, ok)
 testNum++;
 startCallbackTimer();
 items = ["one", "two", "three"];
 selectVal.value = null; // outparam, just making sure.
--- a/toolkit/content/jar.mn
+++ b/toolkit/content/jar.mn
@@ -17,36 +17,31 @@ toolkit.jar:
 *  content/global/aboutSupport.js
 *  content/global/aboutSupport.xhtml
    content/global/directionDetector.html
    content/global/plugins.html
    content/global/plugins.css
 *+  content/global/buildconfig.html            (buildconfig.html)
 +  content/global/charsetOverlay.js           (charsetOverlay.js)
 +  content/global/charsetOverlay.xul          (charsetOverlay.xul)
-*+ content/global/commonDialog.js             (commonDialog.js)
-*+ content/global/commonDialog.xul            (commonDialog.xul)
-   content/global/commonDialog.css            (commonDialog.css)
 *  content/global/contentAreaUtils.js         (contentAreaUtils.js)
 *  content/global/customizeCharset.js         (customizeCharset.js)
 *  content/global/customizeCharset.xul        (customizeCharset.xul)
    content/global/customizeToolbar.css        (customizeToolbar.css)
 *  content/global/customizeToolbar.js         (customizeToolbar.js)
 *  content/global/customizeToolbar.xul        (customizeToolbar.xul)
 *+ content/global/editMenuOverlay.js          (editMenuOverlay.js)
 *+ content/global/editMenuOverlay.xul         (editMenuOverlay.xul)
 *+ content/global/finddialog.js               (finddialog.js)
 *+ content/global/finddialog.xul              (finddialog.xul)
 *+ content/global/findUtils.js                (findUtils.js)
    content/global/filepicker.properties       (filepicker.properties)
 *+ content/global/globalOverlay.js            (globalOverlay.js)
 +  content/global/mozilla.xhtml               (mozilla.xhtml)
 *+ content/global/nsDragAndDrop.js            (nsDragAndDrop.js)
-+  content/global/selectDialog.js             (selectDialog.js)
-+  content/global/selectDialog.xul            (selectDialog.xul)
 *+ content/global/viewZoomOverlay.js          (viewZoomOverlay.js)
 *+ content/global/bindings/autocomplete.xml    (widgets/autocomplete.xml)
 *+ content/global/bindings/browser.xml         (widgets/browser.xml)
 *+ content/global/bindings/button.xml          (widgets/button.xml)
 *+ content/global/bindings/checkbox.xml        (widgets/checkbox.xml)
 *+ content/global/bindings/colorpicker.xml     (widgets/colorpicker.xml)
 *+ content/global/bindings/datetimepicker.xml  (widgets/datetimepicker.xml)
 *+ content/global/bindings/dialog.xml          (widgets/dialog.xml)
--- a/toolkit/locales/en-US/chrome/global/commonDialog.dtd
+++ b/toolkit/locales/en-US/chrome/global/commonDialog.dtd
@@ -1,10 +1,9 @@
 <!ENTITY header.label     "Brief Title"> 
 <!ENTITY message.label    "Some sample Text goes here.">
 <!ENTITY editfield0.label "User Name:"> 
 <!ENTITY editfield1.label "Password:"> 
-<!ENTITY editfield2.label "Confirm Password:"> 
 <!ENTITY checkbox.label   "check">
 <!ENTITY copyCmd.label    "Copy">
 <!ENTITY copyCmd.accesskey "C">
 <!ENTITY selectAllCmd.label "Select All">
 <!ENTITY selectAllCmd.accesskey "A">