diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index b7e2fd47e04..0abfffefd04 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -30,7 +30,6 @@ #include "nsIDeviceContext.h" #include "nsILinkHandler.h" #include "nsIStreamListener.h" -#include "nsIPrompt.h" #include "nsNetUtil.h" #include "nsIProtocolHandler.h" #include "nsIDNSService.h" @@ -167,7 +166,6 @@ class nsWebShell : public nsDocShell, public nsILinkHandler, public nsIDocumentLoaderObserver, public nsIProgressEventSink, // should go away (nsIDocLoaderObs) - public nsIPrompt, public nsIRefreshURI, public nsIURIContentListener, public nsIClipboardCommands @@ -339,9 +337,6 @@ public: NS_IMETHOD RefreshURI(nsIURI* aURI, PRInt32 aMillis, PRBool aRepeat); NS_IMETHOD CancelRefreshURITimers(void); - // nsIPrompt - NS_DECL_NSIPROMPT - // nsIProgressEventSink NS_DECL_NSIPROGRESSEVENTSINK @@ -751,7 +746,6 @@ NS_INTERFACE_MAP_BEGIN(nsWebShell) NS_INTERFACE_MAP_ENTRY(nsIProgressEventSink) NS_INTERFACE_MAP_ENTRY(nsIWebShellContainer) NS_INTERFACE_MAP_ENTRY(nsILinkHandler) - NS_INTERFACE_MAP_ENTRY(nsIPrompt) NS_INTERFACE_MAP_ENTRY(nsIRefreshURI) NS_INTERFACE_MAP_ENTRY(nsIClipboardCommands) NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor) @@ -3121,7 +3115,7 @@ nsWebShell::OnEndURLLoad(nsIDocumentLoader* loader, nsresult aStatus) { #if 0 - const char* spec; + const char* spec; aURL->GetSpec(&spec); printf("nsWebShell::OnEndURLLoad:%p: loader=%p url=%s status=%d\n", this, loader, spec, aStatus); #endif @@ -3132,6 +3126,11 @@ nsWebShell::OnEndURLLoad(nsIDocumentLoader* loader, { mDocLoaderObserver->OnEndURLLoad(mDocLoader, channel, aStatus); } + if(eCharsetReloadRequested == mCharsetReloadState) + mCharsetReloadState = eCharsetReloadStopOrigional; + else + mCharsetReloadState = eCharsetReloadInit; + return NS_OK; } @@ -3312,152 +3311,6 @@ nsresult nsWebShell::CheckForTrailingSlash(nsIURI* aURL) return NS_OK; } -//---------------------------------------------------------------------- - -NS_IMETHODIMP -nsWebShell::Alert(const PRUnichar *text) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->Alert(text); - } - } - - return rv; -} - -NS_IMETHODIMP -nsWebShell::Confirm(const PRUnichar *text, - PRBool *result) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->Confirm(text, result); - } - } - - return rv; -} - -NS_IMETHODIMP -nsWebShell::ConfirmYN(const PRUnichar *text, - PRBool *result) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->ConfirmYN(text, result); - } - } - - return rv; -} - -NS_IMETHODIMP -nsWebShell::ConfirmCheck(const PRUnichar *text, - const PRUnichar *checkMsg, - PRBool *checkValue, - PRBool *result) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->ConfirmCheck(text, checkMsg, checkValue, result); - } - } - - return rv; -} - -NS_IMETHODIMP -nsWebShell::ConfirmCheckYN(const PRUnichar *text, - const PRUnichar *checkMsg, - PRBool *checkValue, - PRBool *result) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->ConfirmCheckYN(text, checkMsg, checkValue, result); - } - } - - return rv; -} - -NS_IMETHODIMP -nsWebShell::Prompt(const PRUnichar *text, - const PRUnichar *defaultText, - PRUnichar **result, - PRBool *_retval) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->Prompt(text, defaultText, result, _retval); - } - } - - return rv; -} - -NS_IMETHODIMP -nsWebShell::PromptUsernameAndPassword(const PRUnichar *text, - PRUnichar **user, - PRUnichar **pwd, - PRBool *_retval) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->PromptUsernameAndPassword(text, user, pwd, _retval); - } - } - - return rv; -} - -NS_IMETHODIMP -nsWebShell::PromptPassword(const PRUnichar *text, - PRUnichar **pwd, - PRBool *_retval) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->PromptPassword(text, pwd, _retval); - } - } - - return rv; -} - //---------------------------------------------------- NS_IMETHODIMP nsWebShell::CanCutSelection(PRBool* aResult) diff --git a/mozilla/extensions/wallet/src/nsWalletService.cpp b/mozilla/extensions/wallet/src/nsWalletService.cpp index 90543130056..19e847232ac 100644 --- a/mozilla/extensions/wallet/src/nsWalletService.cpp +++ b/mozilla/extensions/wallet/src/nsWalletService.cpp @@ -272,6 +272,7 @@ nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* ch return rv; } + PRUint32 elementNumber = 0; PRUint32 numForms; forms->GetLength(&numForms); for (PRUint32 formX = 0; formX < numForms; formX++) { @@ -303,7 +304,7 @@ nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* ch char* nameString = field.ToNewCString(); if (nameString) { char* valueString = NULL; - SINGSIGN_RestoreSignonData(URLName, nameString, &valueString); + SINGSIGN_RestoreSignonData(URLName, nameString, &valueString, elementNumber++); if (valueString) { nsAutoString value(valueString); rv = inputElement->SetValue(value); diff --git a/mozilla/extensions/wallet/src/singsign.cpp b/mozilla/extensions/wallet/src/singsign.cpp index 28555e123dc..0882ad9fa5a 100644 --- a/mozilla/extensions/wallet/src/singsign.cpp +++ b/mozilla/extensions/wallet/src/singsign.cpp @@ -69,6 +69,7 @@ static int signon_lock_count = 0; static PRBool si_PartiallyLoaded = PR_FALSE; static PRBool si_FullyLoaded = PR_FALSE; +static PRBool si_UserHasBeenSelected = PR_FALSE; /* apple keychain stuff */ @@ -116,38 +117,34 @@ si_3ButtonConfirm(PRUnichar * szMessage) { return Wallet_3ButtonConfirm(szMessage); } +// This will go away once select is passed a prompter interface +#include "nsAppShellCIDs.h" // TODO remove later +#include "nsIAppShellService.h" // TODO remove later +#include "nsIWebShellWindow.h" // TODO remove later +static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); + PRIVATE PRBool si_SelectDialog(const PRUnichar* szMessage, char** pList, PRInt32* pCount) { - PRBool retval = PR_TRUE; /* default value */ - nsresult res; - NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &res); - if (NS_FAILED(res)) { - return PR_FALSE; /* failure value */ + if (si_UserHasBeenSelected) { + /* a user was already selected for this form, use same one again */ + *pCount = 0; /* last user selected is now at head of list */ + return PR_TRUE; } - const nsString message = szMessage; -#ifdef xxx - nsString users[10]; // need to make this dynamic ????? - for (int i=0; i<*pCount; i++) { - users[i] = pList[i]; + + nsresult rv; + NS_WITH_SERVICE(nsIAppShellService, appshellservice, kAppShellServiceCID, &rv); + if(NS_FAILED(rv)) { + return PR_FALSE; } - dialog->Select(message, users, pCount, &retval); -#else - for (int i=0; i<*pCount; i++) { - nsString msg = "user = "; - msg += pList[i]; - msg += "?"; -#ifdef YN_DIALOGS_FIXED - res = dialog->ConfirmYN(msg.GetUnicode(), &retval); -#else - res = dialog->Confirm(msg.GetUnicode(), &retval); -#endif - if (NS_SUCCEEDED(res) && retval) { - *pCount = i; - break; - } - } -#endif - return retval; + nsCOMPtr webshellwindow; + appshellservice->GetHiddenWindow(getter_AddRefs(webshellwindow)); + nsCOMPtr prompter(do_QueryInterface(webshellwindow)); + PRInt32 selectedIndex; + PRBool rtnValue; + rv = prompter->Select( NULL, szMessage, *pCount, (const char **)pList, &selectedIndex, &rtnValue ); + *pCount = selectedIndex; + si_UserHasBeenSelected = PR_TRUE; + return rtnValue; } @@ -2044,7 +2041,7 @@ SINGSIGN_RememberSignonData } PUBLIC void -SINGSIGN_RestoreSignonData (char* URLName, char* name, char** value) { +SINGSIGN_RestoreSignonData (char* URLName, char* name, char** value, PRUint32 elementNumber) { si_SignonUserStruct* user; si_SignonDataStruct* data; @@ -2054,6 +2051,9 @@ SINGSIGN_RestoreSignonData (char* URLName, char* name, char** value) { } si_lock_signon_list(); + if (elementNumber == 0) { + si_UserHasBeenSelected = PR_FALSE; + } /* determine if name has been saved (avoids unlocking the database if not) */ PRBool nameFound = PR_FALSE; diff --git a/mozilla/extensions/wallet/src/singsign.h b/mozilla/extensions/wallet/src/singsign.h index 84705b48455..63b9838e8bb 100644 --- a/mozilla/extensions/wallet/src/singsign.h +++ b/mozilla/extensions/wallet/src/singsign.h @@ -44,7 +44,7 @@ extern void SINGSIGN_SignonViewerReturn(nsAutoString results); extern void -SINGSIGN_RestoreSignonData(char* URLName, char* name, char** value); +SINGSIGN_RestoreSignonData(char* URLName, char* name, char** value, PRUint32 elementNumber); extern nsresult SINGSIGN_PromptUsernameAndPassword diff --git a/mozilla/netwerk/base/public/nsIPrompt.idl b/mozilla/netwerk/base/public/nsIPrompt.idl index 7a303925f17..bbc44a6eaf7 100644 --- a/mozilla/netwerk/base/public/nsIPrompt.idl +++ b/mozilla/netwerk/base/public/nsIPrompt.idl @@ -82,4 +82,13 @@ interface nsIPrompt : nsISupports */ boolean promptPassword(in wstring text, out wstring pwd); + + /* + Puts up a dialog box which has a list box of strings + */ + boolean Select( in wstring inDialogTitle, + in wstring inMsg, + in PRUint32 inCount, + [array,size_is(inCount) ] in string inList, + out long outSelection ); }; diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index b7e2fd47e04..0abfffefd04 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -30,7 +30,6 @@ #include "nsIDeviceContext.h" #include "nsILinkHandler.h" #include "nsIStreamListener.h" -#include "nsIPrompt.h" #include "nsNetUtil.h" #include "nsIProtocolHandler.h" #include "nsIDNSService.h" @@ -167,7 +166,6 @@ class nsWebShell : public nsDocShell, public nsILinkHandler, public nsIDocumentLoaderObserver, public nsIProgressEventSink, // should go away (nsIDocLoaderObs) - public nsIPrompt, public nsIRefreshURI, public nsIURIContentListener, public nsIClipboardCommands @@ -339,9 +337,6 @@ public: NS_IMETHOD RefreshURI(nsIURI* aURI, PRInt32 aMillis, PRBool aRepeat); NS_IMETHOD CancelRefreshURITimers(void); - // nsIPrompt - NS_DECL_NSIPROMPT - // nsIProgressEventSink NS_DECL_NSIPROGRESSEVENTSINK @@ -751,7 +746,6 @@ NS_INTERFACE_MAP_BEGIN(nsWebShell) NS_INTERFACE_MAP_ENTRY(nsIProgressEventSink) NS_INTERFACE_MAP_ENTRY(nsIWebShellContainer) NS_INTERFACE_MAP_ENTRY(nsILinkHandler) - NS_INTERFACE_MAP_ENTRY(nsIPrompt) NS_INTERFACE_MAP_ENTRY(nsIRefreshURI) NS_INTERFACE_MAP_ENTRY(nsIClipboardCommands) NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor) @@ -3121,7 +3115,7 @@ nsWebShell::OnEndURLLoad(nsIDocumentLoader* loader, nsresult aStatus) { #if 0 - const char* spec; + const char* spec; aURL->GetSpec(&spec); printf("nsWebShell::OnEndURLLoad:%p: loader=%p url=%s status=%d\n", this, loader, spec, aStatus); #endif @@ -3132,6 +3126,11 @@ nsWebShell::OnEndURLLoad(nsIDocumentLoader* loader, { mDocLoaderObserver->OnEndURLLoad(mDocLoader, channel, aStatus); } + if(eCharsetReloadRequested == mCharsetReloadState) + mCharsetReloadState = eCharsetReloadStopOrigional; + else + mCharsetReloadState = eCharsetReloadInit; + return NS_OK; } @@ -3312,152 +3311,6 @@ nsresult nsWebShell::CheckForTrailingSlash(nsIURI* aURL) return NS_OK; } -//---------------------------------------------------------------------- - -NS_IMETHODIMP -nsWebShell::Alert(const PRUnichar *text) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->Alert(text); - } - } - - return rv; -} - -NS_IMETHODIMP -nsWebShell::Confirm(const PRUnichar *text, - PRBool *result) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->Confirm(text, result); - } - } - - return rv; -} - -NS_IMETHODIMP -nsWebShell::ConfirmYN(const PRUnichar *text, - PRBool *result) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->ConfirmYN(text, result); - } - } - - return rv; -} - -NS_IMETHODIMP -nsWebShell::ConfirmCheck(const PRUnichar *text, - const PRUnichar *checkMsg, - PRBool *checkValue, - PRBool *result) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->ConfirmCheck(text, checkMsg, checkValue, result); - } - } - - return rv; -} - -NS_IMETHODIMP -nsWebShell::ConfirmCheckYN(const PRUnichar *text, - const PRUnichar *checkMsg, - PRBool *checkValue, - PRBool *result) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->ConfirmCheckYN(text, checkMsg, checkValue, result); - } - } - - return rv; -} - -NS_IMETHODIMP -nsWebShell::Prompt(const PRUnichar *text, - const PRUnichar *defaultText, - PRUnichar **result, - PRBool *_retval) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->Prompt(text, defaultText, result, _retval); - } - } - - return rv; -} - -NS_IMETHODIMP -nsWebShell::PromptUsernameAndPassword(const PRUnichar *text, - PRUnichar **user, - PRUnichar **pwd, - PRBool *_retval) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->PromptUsernameAndPassword(text, user, pwd, _retval); - } - } - - return rv; -} - -NS_IMETHODIMP -nsWebShell::PromptPassword(const PRUnichar *text, - PRUnichar **pwd, - PRBool *_retval) -{ - nsresult rv = NS_OK; - nsCOMPtr prompter; - - if (mContainer) { - prompter = do_QueryInterface(mContainer); - if (prompter) { - rv = prompter->PromptPassword(text, pwd, _retval); - } - } - - return rv; -} - //---------------------------------------------------- NS_IMETHODIMP nsWebShell::CanCutSelection(PRBool* aResult) diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index 6971b52c5f8..30ed80f5933 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -2293,6 +2293,10 @@ nsBrowserWindow::PromptPassword(const PRUnichar *text, return NS_OK; } +nsresult nsBrowserWindow::Select(const PRUnichar *, const PRUnichar *, PRUint32 , const char **, PRInt32 *, PRBool *_retval) +{ + return NS_OK; +} //---------------------------------------- diff --git a/mozilla/xpfe/appshell/public/nsICommonDialogs.idl b/mozilla/xpfe/appshell/public/nsICommonDialogs.idl index 326b1883dab..f35a12fdf65 100644 --- a/mozilla/xpfe/appshell/public/nsICommonDialogs.idl +++ b/mozilla/xpfe/appshell/public/nsICommonDialogs.idl @@ -86,6 +86,16 @@ enum { eButtonPressed = 0, eCheckboxState = 1, eNumberButtons = 2, eNumberEditfi in wstring inDialogTitle, in wstring inMsg, out wstring outPassword); + /* + Puts up a dialog box which has a list box of strings. return true/false for OK/Cancel + */ + + boolean Select( in nsIDOMWindow inParent, + in wstring inDialogTitle, + in wstring inMsg, + in PRUint32 inCount, + [array,size_is(inCount) ] in string inList, + out long outSelection ); /* Core Dialog function */ diff --git a/mozilla/xpfe/appshell/src/nsCommonDialogs.cpp b/mozilla/xpfe/appshell/src/nsCommonDialogs.cpp index ad809b2fa0c..be9e43c2da0 100644 --- a/mozilla/xpfe/appshell/src/nsCommonDialogs.cpp +++ b/mozilla/xpfe/appshell/src/nsCommonDialogs.cpp @@ -27,43 +27,7 @@ #include "nsIComponentManager.h" #include "nsIServiceManager.h" static NS_DEFINE_CID( kDialogParamBlockCID, NS_DialogParamBlock_CID); - -#if 0 -nsresult FE_Select( nsIDOMWindow* inParent, const PRUnichar* inTitle, const PRUnichar* inMsg, PRUnichar** inList , PRInt32& ioCount, PRInt32* _retval ) -{ - nsresult rv; - const PRInt32 eSelection = 2 ; - nsIDialogParamBlock* block = NULL; - rv = nsComponentManager::CreateInstance( kDialogParamBlockCID, - 0, - nsIDialogParamBlock::GetIID(), - (void**)&block ); - - if ( NS_FAILED( rv ) ) - return rv; - block->SetNumberStrings( ioCount + 2 ); - block->SetString( 0, inMsg ); - block->SetString(1, inMsg ); - block->SetInt( eSelection, ioCount ); - for ( int32 i =2; i<= ioCount+1; i++ ) - { - block->SetString( i, inList[i-2] ); - } - static NS_DEFINE_CID( kCommonDialogsCID, NS_CommonDialog_CID ); - NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv); - if ( NS_SUCCEEDED( rv ) ) - { - rv = dialog->DoDialog( inParent, block, "chrome://global/content/selectDialog.xul" ); - - PRInt32 buttonPressed = 0; - block->GetInt( nsICommonDialogs::eButtonPressed, &buttonPressed ); - block->GetInt( eSelection, &ioCount ); - *_retval = buttonPressed ? PR_FALSE : PR_TRUE; - NS_IF_RELEASE( block ); - } - return rv; -} -#endif + class nsCommonDialogs: public nsICommonDialogs @@ -271,6 +235,47 @@ NS_IMETHODIMP nsCommonDialogs::PromptPassword(nsIDOMWindow *inParent, const PRU } + +nsresult nsCommonDialogs::Select(nsIDOMWindow *inParent, const PRUnichar *inDialogTitle, const PRUnichar* inMsg, PRUint32 inCount, const char **inList, PRInt32 *outSelection, PRBool *_retval) +{ + nsresult rv; + const PRInt32 eSelection = 2 ; + nsIDialogParamBlock* block = NULL; + rv = nsComponentManager::CreateInstance( kDialogParamBlockCID, + 0, + nsIDialogParamBlock::GetIID(), + (void**)&block ); + + if ( NS_FAILED( rv ) ) + return rv; + block->SetNumberStrings( inCount + 2 ); + block->SetString( 0, inDialogTitle ); + block->SetString(1, inMsg ); + block->SetInt( eSelection, inCount ); + for ( PRInt32 i = 2; i<= inCount+1; i++ ) + { + nsAutoString temp(inList[i-2] ); + const PRUnichar* text = temp.GetUnicode(); + + block->SetString( i, text); + } + *outSelection = -1; + static NS_DEFINE_CID( kCommonDialogsCID, NS_CommonDialog_CID ); + NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv); + if ( NS_SUCCEEDED( rv ) ) + { + rv = dialog->DoDialog( inParent, block, "chrome://global/content/selectDialog.xul" ); + + PRInt32 buttonPressed = 0; + block->GetInt( nsICommonDialogs::eButtonPressed, &buttonPressed ); + block->GetInt( eSelection, outSelection ); + *_retval = buttonPressed ? PR_FALSE : PR_TRUE; + NS_IF_RELEASE( block ); + } + return rv; +} + + NS_IMETHODIMP nsCommonDialogs::DoDialog(nsIDOMWindow* inParent, nsIDialogParamBlock *ioParamBlock, const char *inChromeURL) { nsresult rv = NS_OK; diff --git a/mozilla/xpfe/appshell/src/nsNetSupportDialog.cpp b/mozilla/xpfe/appshell/src/nsNetSupportDialog.cpp index 87e5dc4e634..489c8d2fd92 100644 --- a/mozilla/xpfe/appshell/src/nsNetSupportDialog.cpp +++ b/mozilla/xpfe/appshell/src/nsNetSupportDialog.cpp @@ -550,6 +550,21 @@ NS_IMETHODIMP nsNetSupportDialog::PromptPassword(const PRUnichar *text, #endif } +nsresult nsNetSupportDialog::Select(const PRUnichar *inDialogTitle, const PRUnichar *inMsg, PRUint32 inCount, const char **inList, PRInt32 *outSelection, PRBool *_retval) +{ + nsresult rv; + NS_WITH_SERVICE(nsIAppShellService, appshellservice, kAppShellServiceCID, &rv); + if(NS_FAILED(rv)) + return rv; + nsCOMPtr webshellwindow; + appshellservice->GetHiddenWindow(getter_AddRefs( webshellwindow ) ); + nsCOMPtr prompter(do_QueryInterface( webshellwindow )); + PRInt32 selectedIndex; + PRBool rtnValue; + rv = prompter->Select( inDialogTitle, inMsg, inCount, inList, outSelection,_retval ); + *outSelection = selectedIndex; + return rv; +} nsresult nsNetSupportDialog::ConstructBeforeJavaScript(nsIWebShell *aWebShell) diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index a031aeafa5b..1963808716c 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -3034,7 +3034,24 @@ NS_IMETHODIMP nsWebShellWindow::ConfirmCheckYN(const PRUnichar *text, const PRUn return NS_ERROR_NOT_IMPLEMENTED; } - +NS_IMETHODIMP nsWebShellWindow::Select( const PRUnichar *inDialogTitle, const PRUnichar* inMsg, PRUint32 inCount, const char **inList, PRInt32 *outSelection, PRBool *_retval) +{ + nsresult rv; + nsCOMPtr domWindow; + nsIWebShell* tempWebShell; + GetWebShell(tempWebShell ); + nsCOMPtr webShell( dont_AddRef(tempWebShell) ); + if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow)))) + { + NS_ERROR("Unable to retrieve the DOM window from the new web shell."); + return rv; + } + + NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv); + if ( NS_SUCCEEDED( rv ) ) + rv = dialog->Select(domWindow, inDialogTitle, inMsg, inCount,inList, outSelection, _retval); + return rv; +} NS_IMETHODIMP nsWebShellWindow::Alert(const char *url, const PRUnichar *title, const PRUnichar *text) { diff --git a/mozilla/xpfe/global/resources/content/MANIFEST b/mozilla/xpfe/global/resources/content/MANIFEST index 6717a141097..facab313adc 100644 --- a/mozilla/xpfe/global/resources/content/MANIFEST +++ b/mozilla/xpfe/global/resources/content/MANIFEST @@ -17,12 +17,11 @@ charsetOverlay.xul charsetOverlay.js charsetDetectorsOverlay.js charsetDetectorsOverlay.xul +selectDialog.js +selectDialog.xul widgetStateManager.js wizardHandlerSet.js wizardManager.js wizardOverlay.js wizardOverlay.xul treePopups.js - - - diff --git a/mozilla/xpfe/global/resources/content/Makefile.in b/mozilla/xpfe/global/resources/content/Makefile.in index aee37f010f4..09839e7bdbd 100644 --- a/mozilla/xpfe/global/resources/content/Makefile.in +++ b/mozilla/xpfe/global/resources/content/Makefile.in @@ -48,6 +48,8 @@ EXPORT_RESOURCE_CONTENT = \ $(srcdir)/about.html \ $(srcdir)/charsetDetectorsOverlay.js \ $(srcdir)/charsetDetectorsOverlay.xul \ + $(srcdir)/selectDialog.js \ + $(srcdir)/selectDialog.xul \ $(srcdir)/widgetStateManager.js \ $(srcdir)/wizardHandlerSet.js \ $(srcdir)/wizardManager.js \ diff --git a/mozilla/xpfe/global/resources/content/makefile.win b/mozilla/xpfe/global/resources/content/makefile.win index c579e8e6282..2552ae3b14c 100644 --- a/mozilla/xpfe/global/resources/content/makefile.win +++ b/mozilla/xpfe/global/resources/content/makefile.win @@ -47,6 +47,8 @@ install:: $(MAKE_INSTALL) charsetOverlay.js $(DISTBROWSER) $(MAKE_INSTALL) charsetDetectorsOverlay.js $(DISTBROWSER) $(MAKE_INSTALL) charsetDetectorsOverlay.xul $(DISTBROWSER) + $(MAKE_INSTALL) selectDialog.js $(DISTBROWSER) + $(MAKE_INSTALL) selectDialog.xul $(DISTBROWSER) $(MAKE_INSTALL) widgetStateManager.js $(DISTBROWSER) $(MAKE_INSTALL) wizardHandlerSet.js $(DISTBROWSER) $(MAKE_INSTALL) wizardManager.js $(DISTBROWSER) diff --git a/mozilla/xpfe/global/resources/content/selectDialog.js b/mozilla/xpfe/global/resources/content/selectDialog.js index 6959101ecf0..16f6d23fe6a 100644 --- a/mozilla/xpfe/global/resources/content/selectDialog.js +++ b/mozilla/xpfe/global/resources/content/selectDialog.js @@ -7,7 +7,7 @@ function selectDialogOnLoad() if( !param ) dump( " error getting param block interface\n" ); - var messageText = param.GetString( 0 ); + var messageText = param.GetString( 1 ); dump("message: "+ messageText +"\n"); { var messageFragment; @@ -45,7 +45,7 @@ function selectDialogOnLoad() } } - var windowTitle = param.GetString( 1 ); + var windowTitle = param.GetString( 0 ); window.title = windowTitle; listBox = document.getElementById("list"); @@ -61,6 +61,9 @@ function selectDialogOnLoad() dump("number of items "+ listBox.options.length +" "+listBox.length+"\n"); listBox.selectedIndex = 0; + // resize the window to the content + window.sizeToContent(); + // Move to the right location moveToAlertPosition(); param.SetInt(0, 1 ); diff --git a/mozilla/xpfe/global/resources/content/selectDialog.xul b/mozilla/xpfe/global/resources/content/selectDialog.xul index 6d900ee596f..193d4ac1573 100644 --- a/mozilla/xpfe/global/resources/content/selectDialog.xul +++ b/mozilla/xpfe/global/resources/content/selectDialog.xul @@ -1,4 +1,5 @@ + @@ -8,7 +9,7 @@ align="vertical" onload="selectDialogOnLoad()" class="dialog" - height ="200"> + height ="250">