зеркало из https://github.com/mozilla/gecko-dev.git
add SelectDialog, bug=3110, coded by davidm, r=morse, a=chofmann
This commit is contained in:
Родитель
e765050567
Коммит
f4b2441812
|
@ -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<nsIPrompt> 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<nsIPrompt> 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<nsIPrompt> 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<nsIPrompt> 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<nsIPrompt> 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<nsIPrompt> 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<nsIPrompt> 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<nsIPrompt> prompter;
|
||||
|
||||
if (mContainer) {
|
||||
prompter = do_QueryInterface(mContainer);
|
||||
if (prompter) {
|
||||
rv = prompter->PromptPassword(text, pwd, _retval);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::CanCutSelection(PRBool* aResult)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<nsIWebShellWindow> webshellwindow;
|
||||
appshellservice->GetHiddenWindow(getter_AddRefs(webshellwindow));
|
||||
nsCOMPtr<nsIPrompt> 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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
};
|
||||
|
|
|
@ -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<nsIPrompt> 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<nsIPrompt> 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<nsIPrompt> 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<nsIPrompt> 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<nsIPrompt> 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<nsIPrompt> 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<nsIPrompt> 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<nsIPrompt> prompter;
|
||||
|
||||
if (mContainer) {
|
||||
prompter = do_QueryInterface(mContainer);
|
||||
if (prompter) {
|
||||
rv = prompter->PromptPassword(text, pwd, _retval);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::CanCutSelection(PRBool* aResult)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<nsIWebShellWindow> webshellwindow;
|
||||
appshellservice->GetHiddenWindow(getter_AddRefs( webshellwindow ) );
|
||||
nsCOMPtr<nsIPrompt> 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)
|
||||
|
|
|
@ -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<nsIDOMWindow> domWindow;
|
||||
nsIWebShell* tempWebShell;
|
||||
GetWebShell(tempWebShell );
|
||||
nsCOMPtr<nsIWebShell> 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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
<!DOCTYPE window SYSTEM "chrome://global/locale/commonDialog.dtd">
|
||||
|
||||
|
@ -8,7 +9,7 @@
|
|||
align="vertical"
|
||||
onload="selectDialogOnLoad()"
|
||||
class="dialog"
|
||||
height ="200">
|
||||
height ="250">
|
||||
<html:script language="JavaScript" src="chrome://global/content/selectDialog.js" />
|
||||
|
||||
<keyset id="keyset"/>
|
||||
|
|
Загрузка…
Ссылка в новой задаче