Bug 78745 - nsIPromptService::ConfirmEx needs to be more flexible. r=valeski, sr=sfraser

This commit is contained in:
ccarlen%netscape.com 2001-05-06 15:03:55 +00:00
parent cbf360b0b9
commit ac8ff4c8ea
24 changed files with 103 additions and 477 deletions

View File

@ -1221,7 +1221,7 @@ CheckConfirmDialog(JSContext* cx, const PRUnichar *szMessage, const PRUnichar *s
res = prompter->ConfirmEx(dialogTitle.GetUnicode(), szMessage,
(nsIPrompt::BUTTON_TITLE_YES * nsIPrompt::BUTTON_POS_0) +
(nsIPrompt::BUTTON_TITLE_NO * nsIPrompt::BUTTON_POS_1),
nsnull, szCheckMessage, checkValue, &buttonPressed);
nsnull, nsnull, nsnull, szCheckMessage, checkValue, &buttonPressed);
if (NS_FAILED(res)) {
*checkValue = 0;

View File

@ -389,7 +389,7 @@ var nsRevertCommand =
promptService.confirmEx(window, window.editorShell.GetString("RevertCaption"), msg,
(promptService.BUTTON_TITLE_REVERT * promptService.BUTTON_POS_0) +
(promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
null, null, {value:0}, result);
null, null, null, null, {value:0}, result);
// Reload page if first button (Revert) was pressed
if(result.value == 0)

View File

@ -395,7 +395,9 @@ function CheckAndSaveDocument(reasonToSave, allowDontSave)
var result = {value:0};
promptService.confirmEx(window, dialogTitle, dialogMsg,
(promptService.BUTTON_TITLE_SAVE * promptService.BUTTON_POS_0) +
(promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
(promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1) +
(allowDontSave ? (promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2) : 0),
null, null,
(allowDontSave ? window.editorShell.GetString("DontSave") : null),
null, {value:0}, result);
if (result.value == 0)

View File

@ -60,7 +60,6 @@ NS_INTERFACE_MAP_BEGIN(CWebBrowserContainer)
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
NS_INTERFACE_MAP_ENTRY(nsIPrompt)
NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener)
// NS_INTERFACE_MAP_ENTRY(nsICommandHandler)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
@ -72,13 +71,6 @@ NS_INTERFACE_MAP_END
NS_IMETHODIMP CWebBrowserContainer::GetInterface(const nsIID & uuid, void * *result)
{
const nsIID &iid = NS_GET_IID(nsIPrompt);
if (memcmp(&uuid, &iid, sizeof(nsIID)) == 0)
{
*result = (nsIPrompt *) this;
AddRef();
return NS_OK;
}
return QueryInterface(uuid, result);
}
@ -92,89 +84,6 @@ NS_IMETHODIMP CWebBrowserContainer::OnShowContextMenu(PRUint32 aContextFlags, ns
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIPrompt
/* void alert (in wstring text); */
NS_IMETHODIMP CWebBrowserContainer::Alert(const PRUnichar* dialogTitle, const PRUnichar *text)
{
USES_CONVERSION;
m_pOwner->MessageBox(W2T(text), W2T(dialogTitle), MB_OK | MB_ICONEXCLAMATION);
return NS_OK;
}
/* boolean confirmCheck (in wstring text, in wstring checkMsg, out boolean checkValue); */
NS_IMETHODIMP CWebBrowserContainer::AlertCheck(const PRUnichar* dialogTitle, const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue)
{
// TODO show dialog with check box
USES_CONVERSION;
m_pOwner->MessageBox(W2T(text), W2T(dialogTitle), MB_OK | MB_ICONEXCLAMATION);
return NS_OK;
}
/* boolean confirm (in wstring text); */
NS_IMETHODIMP CWebBrowserContainer::Confirm(const PRUnichar* dialogTitle, const PRUnichar *text, PRBool *_retval)
{
USES_CONVERSION;
int nAnswer = m_pOwner->MessageBox(W2T(text), W2T(dialogTitle), MB_YESNO | MB_ICONQUESTION);
*_retval = (nAnswer == IDYES) ? PR_TRUE : PR_FALSE;
return NS_OK;
}
/* boolean confirmCheck (in wstring text, in wstring checkMsg, out boolean checkValue); */
NS_IMETHODIMP CWebBrowserContainer::ConfirmCheck(const PRUnichar* dialogTitle, const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
{
USES_CONVERSION;
// TODO show dialog with check box
int nAnswer = m_pOwner->MessageBox(W2T(text), W2T(dialogTitle), MB_YESNO | MB_ICONQUESTION);
*_retval = (nAnswer == IDYES) ? PR_TRUE : PR_FALSE;
return NS_OK;
}
/* void confirmEx (in wstring dialogTitle, in wstring text, in unsigned long button0And1Flags, in wstring button2Title, in wstring checkMsg, inout boolean checkValue, out PRInt32 buttonPressed); */
NS_IMETHODIMP CWebBrowserContainer::ConfirmEx(const PRUnichar *dialogTitle, const PRUnichar *text, PRUint32 button0And1Flags, const PRUnichar *button2Title, const PRUnichar *checkMsg, PRBool *checkValue, PRInt32 *buttonPressed)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean prompt (in wstring dialogTitle, in wstring text, inout wstring answer, in wstring checkMsg, inout boolean checkValue); */
NS_IMETHODIMP CWebBrowserContainer::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **answer, const PRUnichar *checkMsg,
PRBool *checkValue, PRBool *_retval)
{
// TODO show dialog with entry field
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean promptUsernameAndPassword (in wstring dialogTitle, in wstring text, inout wstring username, inout wstring password, in wstring checkMsg, inout boolean checkValue); */
NS_IMETHODIMP CWebBrowserContainer::PromptUsernameAndPassword(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **username, PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
// TODO show dialog with entry field and password field
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean promptPassword (in wstring dialogTitle, in wstring text, inout wstring password, in wstring checkMsg, inout boolean checkValue); */
NS_IMETHODIMP CWebBrowserContainer::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
// TODO show dialog with password field
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean select (in wstring inDialogTitle, in wstring inMsg, in PRUint32 inCount, [array, size_is (inCount)] in wstring inList, out long outSelection); */
NS_IMETHODIMP CWebBrowserContainer::Select(const PRUnichar *inDialogTitle, const PRUnichar *inMsg, PRUint32 inCount, const PRUnichar **inList, PRInt32 *outSelection, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
///////////////////////////////////////////////////////////////////////////////
// nsIWebProgressListener

View File

@ -42,7 +42,6 @@ class CWebBrowserContainer :
public nsIURIContentListener,
public nsIDocShellTreeOwner,
public nsIInterfaceRequestor,
public nsIPrompt,
public nsIContextMenuListener,
public nsICommandHandler,
public nsSupportsWeakReference
@ -75,9 +74,6 @@ public:
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSICONTEXTMENULISTENER
NS_DECL_NSICOMMANDHANDLER
// "Services" accessed through nsIInterfaceRequestor
NS_DECL_NSIPROMPT
};
#endif

View File

@ -258,7 +258,10 @@ NS_IMETHODIMP CPromptService::ConfirmCheck(nsIDOMWindow *parent, const PRUnichar
NS_IMETHODIMP CPromptService::ConfirmEx(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUint32 button0And1Flags, const PRUnichar *button2Title,
PRUint32 buttonFlags,
const PRUnichar *button0Title,
const PRUnichar *button1Title,
const PRUnichar *button2Title,
const PRUnichar *checkMsg, PRBool *checkValue,
PRInt32 *buttonPressed)
{

View File

@ -78,8 +78,10 @@ interface nsIPromptService : nsISupports
*
* @param dialogTitle
* @param text
* @param button0And1Flags The titles and positions for buttons 0 and 1
* @param button2Title The title for button 2 or null if no button
* @param buttonFlags Title flags for each button.
* @param button0Title Used when button 0 uses TITLE_IS_STRING
* @param button1Title Used when button 1 uses TITLE_IS_STRING
* @param button2Title Used when button 2 uses TITLE_IS_STRING
* @param checkMsg null if no checkbox
* @param checkValue
* @param buttonPressed
@ -88,22 +90,28 @@ interface nsIPromptService : nsISupports
* the sequence goes from right to left or left to right.
* Button 0 will be the default button.
*
* Buttons 0 and 1 use predefined titles which are specified by the
* following flags. Each title constant can be multiplied by the button
* position value to assign a title to that particular button.
* A button may use a predefined title, specified by one of the
* constants below. Each title constant can be multiplied by a
* position constant to assign the title to a particular button.
* If BUTTON_TITLE_IS_STRING is used for a button, the string
* parameter for that button will be used. If the value for a button
* position is zero, the button will not be shown
*
* Button 2, if present, is specified by a string
*/
const unsigned long BUTTON_POS_0 = 1;
const unsigned long BUTTON_POS_1 = 1 << 8;
const unsigned long BUTTON_POS_2 = 1 << 16;
const unsigned long BUTTON_TITLE_OK = 1;
const unsigned long BUTTON_TITLE_CANCEL = 2;
const unsigned long BUTTON_TITLE_YES = 3;
const unsigned long BUTTON_TITLE_NO = 4;
const unsigned long BUTTON_TITLE_SAVE = 5;
const unsigned long BUTTON_TITLE_REVERT = 6;
const unsigned long BUTTON_TITLE_DONT_SAVE = 6;
const unsigned long BUTTON_TITLE_REVERT = 7;
const unsigned long BUTTON_TITLE_IS_STRING = 127;
const unsigned long STD_OK_CANCEL_BUTTONS = (BUTTON_TITLE_OK * BUTTON_POS_0) +
(BUTTON_TITLE_CANCEL * BUTTON_POS_1);
@ -111,7 +119,9 @@ interface nsIPromptService : nsISupports
void confirmEx(in nsIDOMWindow parent,
in wstring dialogTitle,
in wstring text,
in unsigned long button0And1Flags,
in unsigned long buttonFlags,
in wstring button0Title,
in wstring button1Title,
in wstring button2Title,
in wstring checkMsg,
inout boolean checkValue,

View File

@ -137,14 +137,16 @@ nsPrompt::ConfirmCheck(const PRUnichar* dialogTitle,
NS_IMETHODIMP
nsPrompt::ConfirmEx(const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUint32 button0And1Flags,
PRUint32 buttonFlags,
const PRUnichar *button0Title,
const PRUnichar *button1Title,
const PRUnichar *button2Title,
const PRUnichar *checkMsg,
PRBool *checkValue,
PRInt32 *buttonPressed)
{
return mPromptService->ConfirmEx(mParent, dialogTitle, text,
button0And1Flags, button2Title,
buttonFlags, button0Title, button1Title, button2Title,
checkMsg, checkValue, buttonPressed);
}

View File

@ -244,7 +244,8 @@ nsPromptService::ConfirmCheck(nsIDOMWindow *parent,
NS_IMETHODIMP
nsPromptService::ConfirmEx(nsIDOMWindow *parent,
const PRUnichar *dialogTitle, const PRUnichar *text,
PRUint32 button0And1Flags, const PRUnichar *button2Title,
PRUint32 buttonFlags, const PRUnichar *button0Title,
const PRUnichar *button1Title, const PRUnichar *button2Title,
const PRUnichar *checkMsg, PRBool *checkValue,
PRInt32 *buttonPressed)
{
@ -265,39 +266,44 @@ nsPromptService::ConfirmEx(nsIDOMWindow *parent,
block->SetString(eDialogTitle, dialogTitle);
block->SetString(eMsg, text);
int buttonIDs[] = { eButton0Text, eButton1Text, eButton2Text };
const PRUnichar* buttonStrings[] = { button0Title, button1Title, button2Title };
PRInt32 numberButtons = 0;
for (int buttonID = eButton0Text; buttonID <= eButton1Text; buttonID++) {
for (int i = 0; i < 3; i++) {
PRUnichar *buttonText = nsnull;
switch (button0And1Flags & 0xff) {
nsXPIDLString buttonText;
switch (buttonFlags & 0xff) {
case BUTTON_TITLE_OK:
GetLocaleString("OK", &buttonText);
GetLocaleString("OK", getter_Copies(buttonText));
break;
case BUTTON_TITLE_CANCEL:
GetLocaleString("Cancel", &buttonText);
GetLocaleString("Cancel", getter_Copies(buttonText));
break;
case BUTTON_TITLE_YES:
GetLocaleString("Yes", &buttonText);
GetLocaleString("Yes", getter_Copies(buttonText));
break;
case BUTTON_TITLE_NO:
GetLocaleString("No", &buttonText);
GetLocaleString("No", getter_Copies(buttonText));
break;
case BUTTON_TITLE_SAVE:
GetLocaleString("Save", &buttonText);
GetLocaleString("Save", getter_Copies(buttonText));
break;
case BUTTON_TITLE_DONT_SAVE:
GetLocaleString("DontSave", getter_Copies(buttonText));
break;
case BUTTON_TITLE_REVERT:
GetLocaleString("Revert", &buttonText);
GetLocaleString("Revert", getter_Copies(buttonText));
break;
case BUTTON_TITLE_IS_STRING:
*getter_Shares(buttonText) = buttonStrings[i];
break;
}
if (buttonText) {
block->SetString(buttonID, buttonText);
if (buttonText.get()) {
block->SetString(buttonIDs[i], buttonText.get());
++numberButtons;
}
button0And1Flags >>= 8;
}
if (button2Title) {
block->SetString(eButton2Text, button2Title);
++numberButtons;
buttonFlags >>= 8;
}
block->SetInt(eNumberButtons, numberButtons);

View File

@ -131,7 +131,8 @@ CBrowserImpl::ConfirmCheck(const PRUnichar *dialogTitle,
NS_IMETHODIMP
CBrowserImpl::ConfirmEx(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUint32 button0And1Flags, const PRUnichar *button2Title,
PRUint32 buttonFlags, const PRUnichar *button0Title,
const PRUnichar *button1Title, const PRUnichar *button2Title,
const PRUnichar *checkMsg, PRBool *checkValue,
PRInt32 *buttonPressed)
{

View File

@ -301,7 +301,9 @@ NS_IMETHODIMP CPromptService::Select(nsIDOMWindow *parent,
NS_IMETHODIMP CPromptService::ConfirmEx(nsIDOMWindow *parent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUint32 button0And1Flags,
PRUint32 buttonFlags,
const PRUnichar *button0Title,
const PRUnichar *button1Title,
const PRUnichar *button2Title,
const PRUnichar *checkMsg,
PRBool *checkValue,

View File

@ -78,7 +78,7 @@ permission_CheckConfirmYN(nsIPrompt *aPrompter, PRUnichar * szMessage, PRUnichar
res = dialog->ConfirmEx(confirm_string, szMessage,
(nsIPrompt::BUTTON_TITLE_YES * nsIPrompt::BUTTON_POS_0) +
(nsIPrompt::BUTTON_TITLE_NO * nsIPrompt::BUTTON_POS_1),
nsnull, szCheckMessage, checkValue, &buttonPressed);
nsnull, nsnull, nsnull, szCheckMessage, checkValue, &buttonPressed);
if (NS_FAILED(res)) {
*checkValue = 0;

View File

@ -533,7 +533,7 @@ Wallet_ConfirmYN(PRUnichar * szMessage, nsIDOMWindowInternal* window) {
res = dialog->ConfirmEx(confirm_string, szMessage,
(nsIPrompt::BUTTON_TITLE_YES * nsIPrompt::BUTTON_POS_0) +
(nsIPrompt::BUTTON_TITLE_NO * nsIPrompt::BUTTON_POS_1),
nsnull, nsnull, nsnull, &buttonPressed);
nsnull, nsnull, nsnull, nsnull, nsnull, &buttonPressed);
Recycle(confirm_string);
return (buttonPressed == 0);
@ -555,8 +555,9 @@ Wallet_3ButtonConfirm(PRUnichar * szMessage, nsIDOMWindowInternal* window)
res = dialog->ConfirmEx(confirm_string, szMessage,
(nsIPrompt::BUTTON_TITLE_YES * nsIPrompt::BUTTON_POS_0) +
(nsIPrompt::BUTTON_TITLE_NO * nsIPrompt::BUTTON_POS_1),
never_string, nsnull, nsnull, &buttonPressed);
(nsIPrompt::BUTTON_TITLE_NO * nsIPrompt::BUTTON_POS_1) +
(nsIPrompt::BUTTON_TITLE_IS_STRING * nsIPrompt::BUTTON_POS_2),
nsnull, nsnull, never_string, nsnull, nsnull, &buttonPressed);
Recycle(never_string);
Recycle(confirm_string);
@ -609,7 +610,7 @@ Wallet_CheckConfirmYN
res = dialog->ConfirmEx(confirm_string, szMessage,
(nsIPrompt::BUTTON_TITLE_YES * nsIPrompt::BUTTON_POS_0) +
(nsIPrompt::BUTTON_TITLE_NO * nsIPrompt::BUTTON_POS_1),
nsnull, szCheckMessage, checkValue, &buttonPressed);
nsnull, nsnull, nsnull, szCheckMessage, checkValue, &buttonPressed);
if (NS_FAILED(res)) {
*checkValue = 0;

View File

@ -1452,8 +1452,9 @@ function ComposeCanClose()
gComposeMsgsBundle.getString("saveDlogTitle"),
gComposeMsgsBundle.getString("saveDlogMessage"),
(promptService.BUTTON_TITLE_SAVE * promptService.BUTTON_POS_0) +
(promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
gComposeMsgsBundle.getString("saveDlogDontSaveBtn"),
(promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1) +
(promptService.BUTTON_TITLE_DONT_SAVE * promptService.BUTTON_POS_2),
null, null, null,
null, {value:0}, result);
if (result)

View File

@ -267,7 +267,8 @@ void DisplayNoDefaultPluginDialog(const char *mimeType)
PRInt32 buttonPressed;
rv = prompt->ConfirmEx(titleUni, messageUni,
nsIPrompt::BUTTON_TITLE_OK * nsIPrompt::BUTTON_POS_0, nsnull,
nsIPrompt::BUTTON_TITLE_OK * nsIPrompt::BUTTON_POS_0,
nsnull, nsnull, nsnull,
checkboxMessageUni, &checkboxState, &buttonPressed);
// if the user checked the checkbox, make it so the dialog doesn't
@ -4461,7 +4462,8 @@ NS_IMETHODIMP nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary)
}
rv = prompt->ConfirmEx(title, message,
nsIPrompt::BUTTON_TITLE_OK * nsIPrompt::BUTTON_POS_0, nsnull,
nsIPrompt::BUTTON_TITLE_OK * nsIPrompt::BUTTON_POS_0,
nsnull, nsnull, nsnull,
checkboxMessage, &checkboxState, &buttonPressed);

View File

@ -267,7 +267,8 @@ void DisplayNoDefaultPluginDialog(const char *mimeType)
PRInt32 buttonPressed;
rv = prompt->ConfirmEx(titleUni, messageUni,
nsIPrompt::BUTTON_TITLE_OK * nsIPrompt::BUTTON_POS_0, nsnull,
nsIPrompt::BUTTON_TITLE_OK * nsIPrompt::BUTTON_POS_0,
nsnull, nsnull, nsnull,
checkboxMessageUni, &checkboxState, &buttonPressed);
// if the user checked the checkbox, make it so the dialog doesn't
@ -4461,7 +4462,8 @@ NS_IMETHODIMP nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary)
}
rv = prompt->ConfirmEx(title, message,
nsIPrompt::BUTTON_TITLE_OK * nsIPrompt::BUTTON_POS_0, nsnull,
nsIPrompt::BUTTON_TITLE_OK * nsIPrompt::BUTTON_POS_0,
nsnull, nsnull, nsnull,
checkboxMessage, &checkboxState, &buttonPressed);

View File

@ -55,24 +55,30 @@ interface nsIPrompt : nsISupports
const unsigned long BUTTON_POS_0 = 1;
const unsigned long BUTTON_POS_1 = 1 << 8;
const unsigned long BUTTON_POS_2 = 1 << 16;
const unsigned long BUTTON_TITLE_OK = 1;
const unsigned long BUTTON_TITLE_CANCEL = 2;
const unsigned long BUTTON_TITLE_YES = 3;
const unsigned long BUTTON_TITLE_NO = 4;
const unsigned long BUTTON_TITLE_SAVE = 5;
const unsigned long BUTTON_TITLE_REVERT = 6;
const unsigned long BUTTON_TITLE_DONT_SAVE = 6;
const unsigned long BUTTON_TITLE_REVERT = 7;
const unsigned long BUTTON_TITLE_IS_STRING = 127;
const unsigned long STD_OK_CANCEL_BUTTONS = (BUTTON_TITLE_OK * BUTTON_POS_0) +
(BUTTON_TITLE_CANCEL * BUTTON_POS_1);
void confirmEx(in wstring dialogTitle,
in wstring text,
in unsigned long button0And1Flags,
in wstring button2Title,
in wstring checkMsg,
inout boolean checkValue,
out PRInt32 buttonPressed);
void confirmEx(in wstring dialogTitle,
in wstring text,
in unsigned long buttonFlags,
in wstring button0Title,
in wstring button1Title,
in wstring button2Title,
in wstring checkMsg,
inout boolean checkValue,
out PRInt32 buttonPressed);
boolean prompt(in wstring dialogTitle,
in wstring text,

View File

@ -189,7 +189,6 @@ static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID);
static NS_DEFINE_IID(kIPromptIID, NS_IPROMPT_IID);
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
static NS_DEFINE_CID(kXPBaseWindowCID, NS_XPBASE_WINDOW_CID);
static NS_DEFINE_IID(kIStringBundleServiceIID, NS_ISTRINGBUNDLESERVICE_IID);
@ -1362,11 +1361,6 @@ nsBrowserWindow::QueryInterface(const nsIID& aIID,
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIPromptIID)) {
*aInstancePtrResult = (void*) ((nsIPrompt*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) ((nsISupports*)((nsIWebShellContainer*)this));
NS_ADDREF_THIS();
@ -2132,245 +2126,6 @@ nsBrowserWindow::OnStatus(nsIRequest* request, nsISupports *ctxt,
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::Alert(const PRUnichar *dialogTitle, const PRUnichar *text)
{
nsCAutoString str; str.AssignWithConversion(text);
printf("%cBrowser Window Alert: %s\n", '\007', str.get());
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::AlertCheck(const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkMsg,
PRBool *checkValue)
{
nsCAutoString str; str.AssignWithConversion(text);
printf("%cBrowser Window AlertCheck: %s\n", '\007', str.get());
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::Confirm(const PRUnichar *dialogTitle,
const PRUnichar *text,
PRBool *result)
{
nsCAutoString str; str.AssignWithConversion(text);
const char* msg= nsnull;
msg = str.get();
if (nsnull != msg) {
printf("Browser Window Confirm: %s (y/n)? ", msg);
char c;
for (;;) {
c = getchar();
if (tolower(c) == 'y') {
*result = PR_TRUE;
}
if (tolower(c) == 'n') {
*result = PR_FALSE;
}
}
}
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::ConfirmCheck(const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkMsg,
PRBool *checkValue,
PRBool *result)
{
return Confirm(dialogTitle, text, result);
}
NS_IMETHODIMP
nsBrowserWindow::ConfirmEx(const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUint32 button0And1Flags,
const PRUnichar *button2Title,
const PRUnichar *checkMsg,
PRBool *checkValue,
PRInt32 *buttonPressed)
{
nsCAutoString str; str.AssignWithConversion(text);
const char* msg= nsnull;
msg = str.get();
if (nsnull != msg) {
printf("Browser Window Confirm: %s (", msg);
int numberButtons = 0;
for (int buttonID = 0; buttonID < 2; buttonID++) {
const char *buttonText = nsnull;
switch (button0And1Flags & 0xff) {
case nsIPrompt::BUTTON_TITLE_OK:
buttonText = "OK";
break;
case nsIPrompt::BUTTON_TITLE_CANCEL:
buttonText = "Cancel";
break;
case nsIPrompt::BUTTON_TITLE_YES:
buttonText = "Yes";
break;
case nsIPrompt::BUTTON_TITLE_NO:
buttonText = "No";
break;
case nsIPrompt::BUTTON_TITLE_SAVE:
buttonText = "Save";
break;
case nsIPrompt::BUTTON_TITLE_REVERT:
buttonText = "Revert";
break;
}
if (buttonText) {
if (numberButtons)
putchar(',');
printf("%s=%d", buttonText, numberButtons++);
}
button0And1Flags >>= 8;
}
if (button2Title) {
if (numberButtons)
putchar(',');
nsCAutoString buttonTitle; buttonTitle.AssignWithConversion(button2Title);
printf("%s=%d", buttonTitle.get(), numberButtons++);
}
printf(")? ");
char c;
for (;;) {
c = getchar();
if (isdigit(c) && c - '0' < numberButtons) {
*buttonPressed = c - '0';
break;
}
}
}
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::Prompt(const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **answer,
const PRUnichar *checkMsg,
PRBool *checkValue,
PRBool *_retval)
{
nsCAutoString str; str.AssignWithConversion(text);
const char* msg= nsnull;
char buf[256];
msg = str.get();
if (nsnull != msg && nsnull != answer) {
printf("Browser Window: %s\n", msg);
printf("%cPrompt: ", '\007');
scanf("%s", buf);
nsAutoString response; response.AssignWithConversion(buf);
if (*answer) {
nsMemory::Free(*answer);
*answer = nsnull;
}
*answer = response.ToNewUnicode();
*_retval = (*answer && nsCRT::strlen(*answer) > 0);
}
else
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::PromptPassword(const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **password,
const PRUnichar *checkMsg,
PRBool *checkValue,
PRBool *_retval)
{
nsCAutoString str; str.AssignWithConversion(text);
const char* msg = nsnull;
char buf[256];
msg = str.get();
if (nsnull != msg && nsnull != password) {
printf("Browser Window: %s\n", msg);
printf("%cPassword: ", '\007');
scanf("%s", buf);
nsAutoString response; response.AssignWithConversion(buf);
if (*password) {
nsMemory::Free(*password);
*password = nsnull;
}
*password = response.ToNewUnicode();
*_retval = (*password && nsCRT::strlen(*password) > 0);
}
else
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::PromptUsernameAndPassword(const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **username,
PRUnichar **password,
const PRUnichar *checkMsg,
PRBool *checkValue,
PRBool *_retval)
{
nsCAutoString str; str.AssignWithConversion(text);
const char* msg = nsnull;
char buf[256];
msg = str.get();
if (nsnull != msg && nsnull != username && nsnull != password) {
nsAutoString response;
printf("Browser Window: %s\n", msg);
printf("%cUser: ", '\007');
scanf("%s", buf);
response.AssignWithConversion(buf);
if (*username) {
nsMemory::Free(*username);
*username = nsnull;
}
*username = response.ToNewUnicode();
printf("%cPassword: ", '\007');
scanf("%s", buf);
response.AssignWithConversion(buf);
if (*password) {
nsMemory::Free(*password);
*password = nsnull;
}
*password = response.ToNewUnicode();
*_retval = (*username && nsCRT::strlen(*username) > 0 &&
*password && nsCRT::strlen(*password) > 0);
}
else
*_retval = PR_FALSE;
return NS_OK;
}
nsresult nsBrowserWindow::Select(const PRUnichar *, const PRUnichar *, PRUint32 , const PRUnichar **, PRInt32 *, PRBool *_retval)
{
return NS_OK;
}
//----------------------------------------
// Toolbar support

View File

@ -47,7 +47,6 @@
#include "nsPrintSetupDialog.h"
#include "nsTableInspectorDialog.h"
#include "nsImageInspectorDialog.h"
#include "nsIPrompt.h"
#include "nsITextWidget.h"
class nsILabel;
@ -68,8 +67,7 @@ class nsWebCrawler;
*/
class nsBrowserWindow : public nsIBaseWindow,
public nsIProgressEventSink,
public nsIWebShellContainer,
public nsIPrompt
public nsIWebShellContainer
{
friend class nsWebBrowserChrome;
@ -126,9 +124,6 @@ public:
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult);
NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken);
// nsIPrompt
NS_DECL_NSIPROMPT
// nsBrowserWindow
void SetWebCrawler(nsWebCrawler* aWebCrawler);
virtual nsresult CreateMenuBar(PRInt32 aWidth) = 0;

View File

@ -68,7 +68,6 @@ NS_INTERFACE_MAP_BEGIN(nsWebBrowserChrome)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
NS_INTERFACE_MAP_ENTRY(nsIPrompt)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_END
@ -578,60 +577,3 @@ void nsWebBrowserChrome::OnWindowActivityFinished()
mBrowserWindow->mThrobber->Stop();
}
// nsIPrompt
/* void alert (in wstring dialogTitle, in wstring text); */
NS_IMETHODIMP nsWebBrowserChrome::Alert(const PRUnichar *dialogTitle, const PRUnichar *text)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void alertCheck (in wstring dialogTitle, in wstring text, in wstring checkMsg, out boolean checkValue); */
NS_IMETHODIMP nsWebBrowserChrome::AlertCheck(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean confirm (in wstring dialogTitle, in wstring text); */
NS_IMETHODIMP nsWebBrowserChrome::Confirm(const PRUnichar *dialogTitle, const PRUnichar *text, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean confirmCheck (in wstring dialogTitle, in wstring text, in wstring checkMsg, out boolean checkValue); */
NS_IMETHODIMP nsWebBrowserChrome::ConfirmCheck(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void confirmEx (in wstring dialogTitle, in wstring text, in unsigned long button0And1Flags, in wstring button2Title, in wstring checkMsg, inout boolean checkValue, out PRInt32 buttonPressed); */
NS_IMETHODIMP nsWebBrowserChrome::ConfirmEx(const PRUnichar *dialogTitle, const PRUnichar *text, PRUint32 button0And1Flags, const PRUnichar *button2Title, const PRUnichar *checkMsg, PRBool *checkValue, PRInt32 *buttonPressed)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean prompt (in wstring dialogTitle, in wstring text, inout wstring answer, in wstring checkMsg, inout boolean checkValue); */
NS_IMETHODIMP nsWebBrowserChrome::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **answer, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean promptUsernameAndPassword (in wstring dialogTitle, in wstring text, inout wstring username, inout wstring password, in wstring checkMsg, inout boolean checkValue); */
NS_IMETHODIMP nsWebBrowserChrome::PromptUsernameAndPassword(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **username, PRUnichar **password, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean promptPassword (in wstring dialogTitle, in wstring text, inout wstring password, in wstring checkMsg, inout boolean checkValue); */
NS_IMETHODIMP nsWebBrowserChrome::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **password, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean select (in wstring dialogTitle, in wstring text, in PRUint32 count, [array, size_is (count)] in wstring selectList, out long outSelection); */
NS_IMETHODIMP nsWebBrowserChrome::Select(const PRUnichar *dialogTitle, const PRUnichar *text, PRUint32 count, const PRUnichar **selectList, PRInt32 *outSelection, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -33,7 +33,6 @@
#include "nsIInterfaceRequestor.h"
#include "nsIWebProgressListener.h"
#include "nsTimer.h"
#include "nsIPrompt.h"
#include "nsWeakReference.h"
class nsBrowserWindow;
@ -42,7 +41,6 @@ class nsWebBrowserChrome : public nsIWebBrowserChrome,
public nsIEmbeddingSiteWindow,
public nsIWebProgressListener,
public nsIInterfaceRequestor,
public nsIPrompt,
public nsSupportsWeakReference
{
friend class nsBrowserWindow;
@ -54,7 +52,6 @@ public:
NS_DECL_NSIEMBEDDINGSITEWINDOW
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIPROMPT
protected:
nsWebBrowserChrome();

View File

@ -323,11 +323,12 @@ var homeButtonObserver = {
var pressedVal = { };
var promptTitle = gNavigatorBundle.getString("droponhometitle");
var promptMsg = gNavigatorBundle.getString("droponhomemsg");
var okButton = gNavigatorBundle.getString("droponhomeokbutton");
promptService.confirmEx(window, promptTitle, promptMsg,
(promptService.BUTTON_TITLE_YES * promptService.BUTTON_POS_0) +
(promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0) +
(promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
null, null, {value:0}, pressedVal);
okButton, null, null, null, {value:0}, pressedVal);
if (pressedVal.value == 0) {
nsPreferences.setUnicharPref("browser.startup.homepage", url);

View File

@ -291,7 +291,7 @@ nsWindowsHooks::CheckSettings( nsIDOMWindowInternal *aParent ) {
if ( !settings->mHaveBeenSet ) {
textKey = "initialPromptText";
}
nsXPIDLString text, label, title, yesButtonLabel, noButtonLabel, cancelButtonLabel;
nsXPIDLString text, label, title;
if ( NS_SUCCEEDED( ( rv = bundle->GetStringFromName( NS_ConvertASCIItoUCS2( textKey ).get(),
getter_Copies( text ) ) ) )
&&
@ -299,16 +299,7 @@ nsWindowsHooks::CheckSettings( nsIDOMWindowInternal *aParent ) {
getter_Copies( label ) ) ) )
&&
NS_SUCCEEDED( ( rv = bundle->GetStringFromName( NS_LITERAL_STRING( "title" ).get(),
getter_Copies( title ) ) ) )
&&
NS_SUCCEEDED( ( rv = bundle->GetStringFromName( NS_LITERAL_STRING( "yesButtonLabel" ).get(),
getter_Copies( yesButtonLabel ) ) ) )
&&
NS_SUCCEEDED( ( rv = bundle->GetStringFromName( NS_LITERAL_STRING( "noButtonLabel" ).get(),
getter_Copies( noButtonLabel ) ) ) )
&&
NS_SUCCEEDED( ( rv = bundle->GetStringFromName( NS_LITERAL_STRING( "cancelButtonLabel" ).get(),
getter_Copies( cancelButtonLabel ) ) ) ) ) {
getter_Copies( title ) ) ) ) ) {
// Got the text, now show dialog.
PRBool showDialog = settings->mShowDialog;
PRInt32 dlgResult = -1;
@ -324,8 +315,9 @@ nsWindowsHooks::CheckSettings( nsIDOMWindowInternal *aParent ) {
// o No
rv = promptService->ConfirmEx(aParent, title, text,
(nsIPromptService::BUTTON_TITLE_YES * nsIPromptService::BUTTON_POS_0) +
(nsIPromptService::BUTTON_TITLE_NO * nsIPromptService::BUTTON_POS_1),
cancelButtonLabel, labelArg, &showDialog, &dlgResult);
(nsIPromptService::BUTTON_TITLE_CANCEL * nsIPromptService::BUTTON_POS_1) +
(nsIPromptService::BUTTON_TITLE_NO * nsIPromptService::BUTTON_POS_2),
nsnull, nsnull, nsnull, labelArg, &showDialog, &dlgResult);
if ( NS_SUCCEEDED( rv ) ) {
// Did they say go ahead?

View File

@ -11,3 +11,4 @@ Yes=Yes
No=No
Save=Save
Revert=Revert
DontSave=Don't Save