Bugs 70379, 70380 - Hide nsISingleSignon from embedding apps, split auth prompting methods out of nsIPrompt into a new interface. r=valeski, sr=rpotts.
git-svn-id: svn://10.0.0.236/trunk@91893 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
64e2e50b2b
commit
d0cf8c7fff
@ -42,6 +42,7 @@
|
||||
#include "nsPoint.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsIHTTPEventSink.h"
|
||||
#include "nsISecurityEventSink.h"
|
||||
@ -241,7 +242,19 @@ NS_IMETHODIMP nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
|
||||
}
|
||||
else
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
else if(aIID.Equals(NS_GET_IID(nsIAuthPrompt)))
|
||||
{
|
||||
nsCOMPtr<nsIAuthPrompt> authPrompter(do_GetInterface(mTreeOwner));
|
||||
if (authPrompter)
|
||||
{
|
||||
*aSink = authPrompter;
|
||||
NS_ADDREF((nsISupports*)*aSink);
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
else if (aIID.Equals(NS_GET_IID(nsIProgressEventSink)) || aIID.Equals(NS_GET_IID(nsIHTTPEventSink)) ||
|
||||
aIID.Equals(NS_GET_IID(nsIWebProgress)) || aIID.Equals(NS_GET_IID(nsISecurityEventSink)) )
|
||||
{
|
||||
|
||||
@ -75,7 +75,7 @@
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIScriptGlobalObjectOwner.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
@ -1585,7 +1585,7 @@ NS_IMETHODIMP GlobalWindowImpl::Prompt(JSContext* cx, jsval* argv,
|
||||
|
||||
nsresult ret = NS_OK;
|
||||
nsAutoString message, initial, title;
|
||||
PRUint32 savePassword = nsIPrompt::SAVE_PASSWORD_NEVER;
|
||||
PRUint32 savePassword = nsIAuthPrompt::SAVE_PASSWORD_NEVER;
|
||||
|
||||
if (argc > 0) {
|
||||
nsJSUtils::nsConvertJSValToString(message, cx, argv[0]);
|
||||
@ -1603,7 +1603,7 @@ NS_IMETHODIMP GlobalWindowImpl::Prompt(JSContext* cx, jsval* argv,
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrompt> prompter(do_GetInterface(mDocShell));
|
||||
nsCOMPtr<nsIAuthPrompt> prompter(do_GetInterface(mDocShell));
|
||||
|
||||
NS_ENSURE_TRUE(prompter, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
@ -1743,7 +1743,7 @@ nsEditorShell::SaveDocument(PRBool aSaveAs, PRBool aSaveCopy, const PRUnichar* a
|
||||
nsCOMPtr<nsIPromptService> dialog(do_GetService("@mozilla.org/embedcomp/prompt-service;1"));
|
||||
if (dialog)
|
||||
{
|
||||
PRUnichar *titleUnicode;
|
||||
PRUnichar *titleUnicode = ToNewUnicode(nsLiteralString(title.get()));
|
||||
nsAutoString captionStr, msgStr1, msgStr2;
|
||||
|
||||
GetBundleString(NS_LITERAL_STRING("DocumentTitle"), captionStr);
|
||||
@ -1759,7 +1759,7 @@ nsEditorShell::SaveDocument(PRBool aSaveAs, PRBool aSaveCopy, const PRUnichar* a
|
||||
if (!cwP) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
res = dialog->Prompt(cwP, captionStr.GetUnicode(), msgStr1.GetUnicode(),
|
||||
title.GetUnicode(), 0, 0, &titleUnicode, &retVal);
|
||||
&titleUnicode, 0, 0, &retVal);
|
||||
|
||||
if( retVal == PR_FALSE)
|
||||
{
|
||||
|
||||
@ -1743,7 +1743,7 @@ nsEditorShell::SaveDocument(PRBool aSaveAs, PRBool aSaveCopy, const PRUnichar* a
|
||||
nsCOMPtr<nsIPromptService> dialog(do_GetService("@mozilla.org/embedcomp/prompt-service;1"));
|
||||
if (dialog)
|
||||
{
|
||||
PRUnichar *titleUnicode;
|
||||
PRUnichar *titleUnicode = ToNewUnicode(nsLiteralString(title.get()));
|
||||
nsAutoString captionStr, msgStr1, msgStr2;
|
||||
|
||||
GetBundleString(NS_LITERAL_STRING("DocumentTitle"), captionStr);
|
||||
@ -1759,7 +1759,7 @@ nsEditorShell::SaveDocument(PRBool aSaveAs, PRBool aSaveCopy, const PRUnichar* a
|
||||
if (!cwP) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
res = dialog->Prompt(cwP, captionStr.GetUnicode(), msgStr1.GetUnicode(),
|
||||
title.GetUnicode(), 0, 0, &titleUnicode, &retVal);
|
||||
&titleUnicode, 0, 0, &retVal);
|
||||
|
||||
if( retVal == PR_FALSE)
|
||||
{
|
||||
|
||||
@ -135,27 +135,30 @@ NS_IMETHODIMP CWebBrowserContainer::ConfirmCheck(const PRUnichar* dialogTitle, c
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean prompt (in wstring text, in wstring defaultText, out wstring result); */
|
||||
NS_IMETHODIMP CWebBrowserContainer::Prompt(const PRUnichar* dialogTitle, const PRUnichar *text, const PRUnichar* passwordRealm,
|
||||
PRUint32 savePassword, const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval)
|
||||
/* 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 text, out wstring user, out wstring pwd); */
|
||||
NS_IMETHODIMP CWebBrowserContainer::PromptUsernameAndPassword(const PRUnichar* dialogTitle, const PRUnichar *text,
|
||||
const PRUnichar* passwordRealm, PRUint32 savePassword,
|
||||
PRUnichar **user, PRUnichar **pwd, PRBool *_retval)
|
||||
/* 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 text, in wstring title, out wstring pwd); */
|
||||
NS_IMETHODIMP CWebBrowserContainer::PromptPassword(const PRUnichar* dialogTitle, const PRUnichar *text,
|
||||
const PRUnichar* passwordRealm, PRUint32 savePassword,
|
||||
PRUnichar **pwd, PRBool *_retval)
|
||||
/* 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;
|
||||
|
||||
@ -52,14 +52,21 @@ EmbedPrompter::~EmbedPrompter(void)
|
||||
nsresult
|
||||
EmbedPrompter::Create(PromptType aType)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
int includeCheckFlag = 0;
|
||||
|
||||
switch (aType) {
|
||||
case TYPE_PROMPT_USER_PASS:
|
||||
if (mCheckMessage.Length())
|
||||
includeCheckFlag = EmbedPrompter::INCLUDE_CHECKBOX;
|
||||
CreatePasswordPrompter(EmbedPrompter::INCLUDE_USERNAME |
|
||||
EmbedPrompter::INCLUDE_CHECKBOX);
|
||||
includeCheckFlag);
|
||||
break;
|
||||
case TYPE_PROMPT_PASS:
|
||||
CreatePasswordPrompter(EmbedPrompter::INCLUDE_CHECKBOX);
|
||||
if (mCheckMessage.Length())
|
||||
includeCheckFlag = EmbedPrompter::INCLUDE_CHECKBOX;
|
||||
CreatePasswordPrompter(includeCheckFlag);
|
||||
break;
|
||||
case TYPE_ALERT:
|
||||
CreateAlertPrompter(0);
|
||||
@ -75,8 +82,11 @@ EmbedPrompter::Create(PromptType aType)
|
||||
CreateAlertPrompter(EmbedPrompter::INCLUDE_CHECKBOX);
|
||||
break;
|
||||
case TYPE_PROMPT:
|
||||
if (mCheckMessage.Length())
|
||||
includeCheckFlag = EmbedPrompter::INCLUDE_CHECKBOX;
|
||||
CreateAlertPrompter(EmbedPrompter::INCLUDE_CANCEL |
|
||||
EmbedPrompter::INCLUDE_TEXTFIELD);
|
||||
EmbedPrompter::INCLUDE_TEXTFIELD |
|
||||
includeCheckFlag);
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
@ -92,16 +102,9 @@ EmbedPrompter::SetTitle(const PRUnichar *aTitle)
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetDefaultText (const PRUnichar *aDefaultText)
|
||||
EmbedPrompter::SetTextValue(const PRUnichar *aTextValue)
|
||||
{
|
||||
mDefaultText.AppendWithConversion(aDefaultText);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetPassRealm(const PRUnichar *aRealm)
|
||||
{
|
||||
mRealm.Assign("Enter Password for ");
|
||||
mRealm.AppendWithConversion(aRealm);
|
||||
mTextValue.AppendWithConversion(aTextValue);
|
||||
}
|
||||
|
||||
void
|
||||
@ -116,6 +119,18 @@ EmbedPrompter::SetMessageText(const PRUnichar *aMessageText)
|
||||
mMessageText.AppendWithConversion(aMessageText);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetUser(const PRUnichar *aUser)
|
||||
{
|
||||
mUser.AppendWithConversion(aUser);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetPassword(const PRUnichar *aPass)
|
||||
{
|
||||
mPass.AppendWithConversion(aPass);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetCheckValue(const PRBool aValue)
|
||||
{
|
||||
@ -137,7 +152,7 @@ EmbedPrompter::GetConfirmValue(PRBool *aConfirmValue)
|
||||
void
|
||||
EmbedPrompter::GetTextValue(PRUnichar **aTextValue)
|
||||
{
|
||||
*aTextValue = mText.ToNewUnicode();
|
||||
*aTextValue = mTextValue.ToNewUnicode();
|
||||
}
|
||||
|
||||
void
|
||||
@ -208,7 +223,7 @@ EmbedPrompter::UserOK(void)
|
||||
if (mTextField) {
|
||||
gchar *text;
|
||||
text = gtk_editable_get_chars(GTK_EDITABLE(mTextField), 0, -1);
|
||||
mText.Assign(text);
|
||||
mTextValue.Assign(text);
|
||||
g_free(text);
|
||||
}
|
||||
|
||||
@ -246,15 +261,16 @@ EmbedPrompter::CreatePasswordPrompter(int aFlags)
|
||||
gtk_container_set_border_width(GTK_CONTAINER(mWindow),
|
||||
4);
|
||||
|
||||
// the label that says "Enter Password..."
|
||||
GtkWidget *realmLabel = gtk_label_new(mRealm.get());
|
||||
GtkWidget *msgLabel = gtk_label_new(mMessageText.get());
|
||||
// add it
|
||||
gtk_box_pack_start(topLevelVBox,
|
||||
realmLabel,
|
||||
msgLabel,
|
||||
FALSE, /* expand */
|
||||
FALSE, /* fill */
|
||||
0); /* padding */
|
||||
|
||||
PRInt32 startPos;
|
||||
|
||||
if (aFlags & EmbedPrompter::INCLUDE_USERNAME) {
|
||||
// the username label
|
||||
GtkWidget *userLabel = gtk_label_new("User Name");
|
||||
@ -265,6 +281,12 @@ EmbedPrompter::CreatePasswordPrompter(int aFlags)
|
||||
0); /* padding */
|
||||
// the username text area
|
||||
mUserField = gtk_entry_new();
|
||||
if (mUser.Length()) {
|
||||
startPos = 0;
|
||||
gtk_editable_insert_text(GTK_EDITABLE(mUserField),
|
||||
mUser.get(), mUser.Length(),
|
||||
&startPos);
|
||||
}
|
||||
gtk_box_pack_start(topLevelVBox,
|
||||
mUserField,
|
||||
FALSE, /* expand */
|
||||
@ -284,6 +306,12 @@ EmbedPrompter::CreatePasswordPrompter(int aFlags)
|
||||
mPassField = gtk_entry_new();
|
||||
// it's a password field
|
||||
gtk_entry_set_visibility(GTK_ENTRY(mPassField), FALSE);
|
||||
if (mPass.Length()) {
|
||||
startPos = 0;
|
||||
gtk_editable_insert_text(GTK_EDITABLE(mPassField),
|
||||
mPass.get(), mPass.Length(),
|
||||
&startPos);
|
||||
}
|
||||
// add it
|
||||
gtk_box_pack_start(topLevelVBox,
|
||||
mPassField,
|
||||
@ -295,7 +323,10 @@ EmbedPrompter::CreatePasswordPrompter(int aFlags)
|
||||
if (aFlags & EmbedPrompter::INCLUDE_CHECKBOX) {
|
||||
// make it
|
||||
mCheckBox =
|
||||
gtk_check_button_new_with_label("Use Password Manager To Save Password");
|
||||
gtk_check_button_new_with_label(mCheckMessage.get());
|
||||
// set its state
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mCheckBox),
|
||||
mCheckValue);
|
||||
// add it
|
||||
gtk_box_pack_start(topLevelVBox,
|
||||
mCheckBox,
|
||||
@ -373,6 +404,12 @@ EmbedPrompter::CreateAlertPrompter(int aFlags)
|
||||
// text field
|
||||
if (aFlags & EmbedPrompter::INCLUDE_TEXTFIELD) {
|
||||
mTextField = gtk_entry_new();
|
||||
if (mTextValue.Length()) {
|
||||
int startPos = 0;
|
||||
gtk_editable_insert_text(GTK_EDITABLE(mTextField),
|
||||
mTextValue.get(), mTextValue.Length(),
|
||||
&startPos);
|
||||
}
|
||||
gtk_box_pack_start(topLevelVBox,
|
||||
mTextField,
|
||||
FALSE, /* expand */
|
||||
@ -383,6 +420,9 @@ EmbedPrompter::CreateAlertPrompter(int aFlags)
|
||||
if (aFlags & EmbedPrompter::INCLUDE_CHECKBOX) {
|
||||
// make it
|
||||
mCheckBox = gtk_check_button_new_with_label(mCheckMessage);
|
||||
// set its state
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mCheckBox),
|
||||
mCheckValue);
|
||||
// add it
|
||||
gtk_box_pack_start(topLevelVBox,
|
||||
mCheckBox,
|
||||
|
||||
@ -43,11 +43,12 @@ class EmbedPrompter {
|
||||
|
||||
nsresult Create(PromptType aType);
|
||||
void SetTitle(const PRUnichar *aTitle);
|
||||
void SetDefaultText (const PRUnichar *aDefaultText);
|
||||
void SetPassRealm(const PRUnichar *aRealm);
|
||||
void SetTextValue (const PRUnichar *aTextValue);
|
||||
void SetCheckMessage(const PRUnichar *aCheckMessage);
|
||||
void SetCheckValue(const PRBool aValue);
|
||||
void SetMessageText(const PRUnichar *aMessageText);
|
||||
void SetUser(const PRUnichar *aUser);
|
||||
void SetPassword(const PRUnichar *aPass);
|
||||
|
||||
void GetCheckValue(PRBool *aValue);
|
||||
void GetConfirmValue(PRBool *aConfirmValue);
|
||||
@ -74,9 +75,7 @@ class EmbedPrompter {
|
||||
|
||||
nsCString mTitle;
|
||||
nsCString mMessageText;
|
||||
nsCString mText;
|
||||
nsCString mDefaultText;
|
||||
nsCString mRealm;
|
||||
nsCString mTextValue;
|
||||
nsCString mCheckMessage;
|
||||
PRBool mCheckValue;
|
||||
|
||||
|
||||
@ -457,58 +457,107 @@ EmbedWindow::ConfirmCheck(const PRUnichar *aDialogTitle,
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::Prompt(const PRUnichar *aDialogTitle, const PRUnichar *aText,
|
||||
const PRUnichar *aPasswordRealm, PRUint32 aSavePassword,
|
||||
const PRUnichar *aDefaultText, PRUnichar **result,
|
||||
PRUnichar **result,
|
||||
const PRUnichar *aCheckMsg, PRBool *aCheckValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle);
|
||||
prompter.SetMessageText(aText);
|
||||
prompter.SetDefaultText(aDefaultText);
|
||||
if (result && *result)
|
||||
prompter.SetTextValue(*result);
|
||||
if (aCheckValue) {
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
else
|
||||
prompter.SetCheckMessage(NS_LITERAL_STRING("Save This Value").get());
|
||||
}
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT);
|
||||
prompter.Run();
|
||||
prompter.GetConfirmValue(_retval);
|
||||
if (*_retval)
|
||||
if (*_retval) {
|
||||
if (result && *result) {
|
||||
nsMemory::Free(*result);
|
||||
*result = nsnull;
|
||||
}
|
||||
prompter.GetTextValue(result);
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::PromptUsernameAndPassword(const PRUnichar *aDialogTitle,
|
||||
const PRUnichar *aText,
|
||||
const PRUnichar *aPasswordRealm,
|
||||
PRUint32 aSavePassword,
|
||||
PRUnichar **aUser, PRUnichar **aPwd,
|
||||
const PRUnichar *aCheckMsg, PRBool *aCheckValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle);
|
||||
prompter.SetPassRealm(aText);
|
||||
prompter.SetMessageText(aText);
|
||||
if (aUser && *aUser)
|
||||
prompter.SetUser(*aUser);
|
||||
if (aPwd && *aPwd)
|
||||
prompter.SetPassword(*aPwd);
|
||||
if (aCheckValue) {
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
else
|
||||
prompter.SetCheckMessage(NS_LITERAL_STRING("Save These Values").get());
|
||||
}
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT_USER_PASS);
|
||||
prompter.Run();
|
||||
prompter.GetConfirmValue(_retval);
|
||||
if (*_retval) {
|
||||
if (aUser && *aUser) {
|
||||
nsMemory::Free(*aUser);
|
||||
*aUser = nsnull;
|
||||
}
|
||||
prompter.GetUser(aUser);
|
||||
if (aPwd && *aPwd) {
|
||||
nsMemory::Free(*aPwd);
|
||||
*aPwd = nsnull;
|
||||
}
|
||||
prompter.GetPassword(aPwd);
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::PromptPassword(const PRUnichar *aDialogTitle,
|
||||
const PRUnichar *aText,
|
||||
const PRUnichar *aPasswordRealm,
|
||||
PRUint32 aSavePassword, PRUnichar **aPwd,
|
||||
const PRUnichar *aText, PRUnichar **aPwd,
|
||||
const PRUnichar *aCheckMsg, PRBool *aCheckValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle);
|
||||
prompter.SetPassRealm(aText);
|
||||
prompter.SetMessageText(aText);
|
||||
if (aPwd && *aPwd)
|
||||
prompter.SetPassword(*aPwd);
|
||||
if (aCheckValue) {
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
else
|
||||
prompter.SetCheckMessage(NS_LITERAL_STRING("Save Password").get());
|
||||
}
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT_PASS);
|
||||
prompter.Run();
|
||||
prompter.GetConfirmValue(_retval);
|
||||
if (*_retval) {
|
||||
if (aPwd && *aPwd) {
|
||||
nsMemory::Free(*aPwd);
|
||||
*aPwd = nsnull;
|
||||
}
|
||||
prompter.GetPassword(aPwd);
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -35,7 +35,6 @@
|
||||
#include "nsIRequest.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIWalletService.h"
|
||||
|
||||
#include "UMacUnicode.h"
|
||||
#include "ApplIDs.h"
|
||||
@ -122,29 +121,6 @@ NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMETHODIMP CWebBrowserChrome::GetInterface(const nsIID &aIID, void** aInstancePtr)
|
||||
{
|
||||
if (aIID.Equals(NS_GET_IID(nsIPrompt)))
|
||||
{
|
||||
if (!mPrompter)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIPrompt> prompt;
|
||||
prompt = new CWebBrowserPrompter(this);
|
||||
NS_ENSURE_TRUE(prompt, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsISingleSignOnPrompt> siPrompt = do_CreateInstance(NS_SINGLESIGNONPROMPT_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
siPrompt->SetPromptDialogs(prompt);
|
||||
mPrompter = siPrompt;
|
||||
}
|
||||
else
|
||||
mPrompter = prompt;
|
||||
}
|
||||
NS_ENSURE_TRUE(mPrompter, NS_ERROR_FAILURE);
|
||||
return mPrompter->QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMWindow)))
|
||||
{
|
||||
nsCOMPtr<nsIWebBrowser> browser;
|
||||
@ -669,20 +645,27 @@ NS_IMETHODIMP CWebBrowserChrome::ConfirmCheck(const PRUnichar *dialogTitle, cons
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWebBrowserChrome::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *passwordRealm, PRUint32 savePassword, const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval)
|
||||
NS_IMETHODIMP CWebBrowserChrome::Prompt(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
PRUnichar **answer,
|
||||
const PRUnichar *checkMsg,
|
||||
PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult resultErr = NS_OK;
|
||||
|
||||
StDialogHandler theHandler(dlog_Prompt, mBrowserWindow);
|
||||
LWindow *theDialog = theHandler.GetDialog();
|
||||
LCheckBox *checkbox = dynamic_cast<LCheckBox*>(theDialog->FindPaneByID('Chck'));
|
||||
nsCAutoString cStr;
|
||||
Str255 pStr;
|
||||
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(dialogTitle), pStr);
|
||||
theDialog->SetDescriptor(pStr);
|
||||
if (dialogTitle) {
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(dialogTitle), pStr);
|
||||
theDialog->SetDescriptor(pStr);
|
||||
}
|
||||
|
||||
LStaticText *msgText = dynamic_cast<LStaticText*>(theDialog->FindPaneByID('Msg '));
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(text), cStr);
|
||||
@ -690,8 +673,22 @@ NS_IMETHODIMP CWebBrowserChrome::Prompt(const PRUnichar *dialogTitle, const PRUn
|
||||
msgText->SetText(const_cast<char *>(cStr.get()), cStr.Length());
|
||||
|
||||
LEditText *responseText = dynamic_cast<LEditText*>(theDialog->FindPaneByID('Rslt'));
|
||||
theDialog->SetLatentSub(responseText);
|
||||
if (answer && *answer) {
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(*answer), pStr);
|
||||
responseText->SetDescriptor(pStr);
|
||||
}
|
||||
|
||||
if (checkValue) {
|
||||
checkbox->SetValue(*checkValue);
|
||||
if (checkMsg) {
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(checkMsg), pStr);
|
||||
checkbox->SetDescriptor(pStr);
|
||||
}
|
||||
}
|
||||
else
|
||||
checkbox->Hide();
|
||||
|
||||
theDialog->SetLatentSub(responseText);
|
||||
theDialog->Show();
|
||||
theDialog->Select();
|
||||
|
||||
@ -704,11 +701,19 @@ NS_IMETHODIMP CWebBrowserChrome::Prompt(const PRUnichar *dialogTitle, const PRUn
|
||||
nsAutoString ucStr;
|
||||
|
||||
*_retval = PR_TRUE;
|
||||
if (answer && *answer) {
|
||||
nsMemory::Free(*answer);
|
||||
*answer = nsnull;
|
||||
}
|
||||
responseText->GetDescriptor(pStr);
|
||||
CPlatformUCSConversion::GetInstance()->PlatformToUCS(pStr, ucStr);
|
||||
*result = ucStr.ToNewUnicode();
|
||||
if (!result)
|
||||
*answer = ucStr.ToNewUnicode();
|
||||
if (*answer == nsnull)
|
||||
resultErr = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (checkValue)
|
||||
*checkValue = checkbox->GetValue();
|
||||
|
||||
break;
|
||||
}
|
||||
else if (hitMessage == msg_Cancel)
|
||||
@ -721,21 +726,28 @@ NS_IMETHODIMP CWebBrowserChrome::Prompt(const PRUnichar *dialogTitle, const PRUn
|
||||
return resultErr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWebBrowserChrome::PromptUsernameAndPassword(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *passwordRealm, PRUint32 savePassword, PRUnichar **user, PRUnichar **pwd, PRBool *_retval)
|
||||
NS_IMETHODIMP CWebBrowserChrome::PromptUsernameAndPassword(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
PRUnichar **username,
|
||||
PRUnichar **password,
|
||||
const PRUnichar *checkMsg,
|
||||
PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(user);
|
||||
NS_ENSURE_ARG_POINTER(pwd);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult resultErr = NS_OK;
|
||||
|
||||
StDialogHandler theHandler(dlog_PromptNameAndPass, mBrowserWindow);
|
||||
LWindow *theDialog = theHandler.GetDialog();
|
||||
LCheckBox *checkbox = dynamic_cast<LCheckBox*>(theDialog->FindPaneByID('Chck'));
|
||||
nsCAutoString cStr;
|
||||
Str255 pStr;
|
||||
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(dialogTitle), pStr);
|
||||
theDialog->SetDescriptor(pStr);
|
||||
if (dialogTitle) {
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(dialogTitle), pStr);
|
||||
theDialog->SetDescriptor(pStr);
|
||||
}
|
||||
|
||||
LStaticText *msgText = dynamic_cast<LStaticText*>(theDialog->FindPaneByID('Msg '));
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(text), cStr);
|
||||
@ -743,7 +755,25 @@ NS_IMETHODIMP CWebBrowserChrome::PromptUsernameAndPassword(const PRUnichar *dial
|
||||
msgText->SetText(const_cast<char *>(cStr.get()), cStr.Length());
|
||||
|
||||
LEditText *userText = dynamic_cast<LEditText*>(theDialog->FindPaneByID('Name'));
|
||||
if (username && *username) {
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(*username), pStr);
|
||||
userText->SetDescriptor(pStr);
|
||||
}
|
||||
LEditText *pwdText = dynamic_cast<LEditText*>(theDialog->FindPaneByID('Pass'));
|
||||
if (password && *password) {
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(*password), pStr);
|
||||
pwdText->SetDescriptor(pStr);
|
||||
}
|
||||
|
||||
if (checkValue) {
|
||||
checkbox->SetValue(*checkValue);
|
||||
if (checkMsg) {
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(checkMsg), pStr);
|
||||
checkbox->SetDescriptor(pStr);
|
||||
}
|
||||
}
|
||||
else
|
||||
checkbox->Hide();
|
||||
|
||||
theDialog->SetLatentSub(userText);
|
||||
theDialog->Show();
|
||||
@ -757,17 +787,28 @@ NS_IMETHODIMP CWebBrowserChrome::PromptUsernameAndPassword(const PRUnichar *dial
|
||||
{
|
||||
nsAutoString ucStr;
|
||||
|
||||
if (username && *username) {
|
||||
nsMemory::Free(*username);
|
||||
*username = nsnull;
|
||||
}
|
||||
userText->GetDescriptor(pStr);
|
||||
CPlatformUCSConversion::GetInstance()->PlatformToUCS(pStr, ucStr);
|
||||
*user = ucStr.ToNewUnicode();
|
||||
if (*user == nsnull)
|
||||
*username = ucStr.ToNewUnicode();
|
||||
if (*username == nsnull)
|
||||
resultErr = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (password && *password) {
|
||||
nsMemory::Free(*password);
|
||||
*password = nsnull;
|
||||
}
|
||||
pwdText->GetDescriptor(pStr);
|
||||
CPlatformUCSConversion::GetInstance()->PlatformToUCS(pStr, ucStr);
|
||||
*pwd = ucStr.ToNewUnicode();
|
||||
if (*pwd == nsnull)
|
||||
*password = ucStr.ToNewUnicode();
|
||||
if (*password == nsnull)
|
||||
resultErr = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (checkValue)
|
||||
*checkValue = checkbox->GetValue();
|
||||
|
||||
*_retval = PR_TRUE;
|
||||
break;
|
||||
@ -782,20 +823,27 @@ NS_IMETHODIMP CWebBrowserChrome::PromptUsernameAndPassword(const PRUnichar *dial
|
||||
return resultErr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWebBrowserChrome::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *passwordRealm, PRUint32 savePassword, PRUnichar **pwd, PRBool *_retval)
|
||||
NS_IMETHODIMP CWebBrowserChrome::PromptPassword(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
PRUnichar **password,
|
||||
const PRUnichar *checkMsg,
|
||||
PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(pwd);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult resultErr = NS_OK;
|
||||
|
||||
StDialogHandler theHandler(dlog_PromptPassword, mBrowserWindow);
|
||||
LWindow *theDialog = theHandler.GetDialog();
|
||||
LCheckBox *checkbox = dynamic_cast<LCheckBox*>(theDialog->FindPaneByID('Chck'));
|
||||
nsCAutoString cStr;
|
||||
Str255 pStr;
|
||||
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(dialogTitle), pStr);
|
||||
theDialog->SetDescriptor(pStr);
|
||||
if (dialogTitle) {
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(dialogTitle), pStr);
|
||||
theDialog->SetDescriptor(pStr);
|
||||
}
|
||||
|
||||
LStaticText *msgText = dynamic_cast<LStaticText*>(theDialog->FindPaneByID('Msg '));
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(text), cStr);
|
||||
@ -803,6 +851,20 @@ NS_IMETHODIMP CWebBrowserChrome::PromptPassword(const PRUnichar *dialogTitle, co
|
||||
msgText->SetText(const_cast<char *>(cStr.get()), cStr.Length());
|
||||
|
||||
LEditText *pwdText = dynamic_cast<LEditText*>(theDialog->FindPaneByID('Pass'));
|
||||
if (password && *password) {
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(*password), pStr);
|
||||
pwdText->SetDescriptor(pStr);
|
||||
}
|
||||
|
||||
if (checkValue) {
|
||||
checkbox->SetValue(*checkValue);
|
||||
if (checkMsg) {
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(checkMsg), pStr);
|
||||
checkbox->SetDescriptor(pStr);
|
||||
}
|
||||
}
|
||||
else
|
||||
checkbox->Hide();
|
||||
|
||||
theDialog->SetLatentSub(pwdText);
|
||||
theDialog->Show();
|
||||
@ -816,11 +878,19 @@ NS_IMETHODIMP CWebBrowserChrome::PromptPassword(const PRUnichar *dialogTitle, co
|
||||
{
|
||||
nsAutoString ucStr;
|
||||
|
||||
if (password && *password) {
|
||||
nsMemory::Free(*password);
|
||||
*password = nsnull;
|
||||
}
|
||||
pwdText->GetDescriptor(pStr);
|
||||
CPlatformUCSConversion::GetInstance()->PlatformToUCS(pStr, ucStr);
|
||||
*pwd = ucStr.ToNewUnicode();
|
||||
if (*pwd == nsnull)
|
||||
*password = ucStr.ToNewUnicode();
|
||||
if (*password == nsnull)
|
||||
resultErr = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (checkValue)
|
||||
*checkValue = checkbox->GetValue();
|
||||
|
||||
*_retval = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ VPATH = @srcdir@
|
||||
MODULE = webbrwsr
|
||||
XPIDL_MODULE = webBrowser_core
|
||||
LIBRARY_NAME = nsWebBrowser_s
|
||||
REQUIRES = xpcom string docshell widget layout dom js locale necko uriloader shistory webshell mimetype exthandler timer windowwatcher txtsvc gfx2
|
||||
REQUIRES = xpcom string docshell widget layout dom js locale necko uriloader shistory webshell mimetype exthandler timer windowwatcher txtsvc gfx2 wallet
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
@ -52,6 +52,7 @@ CPPSRCS = \
|
||||
nsWebBrowserPersist.cpp \
|
||||
nsDOMWalker.cpp \
|
||||
nsWebBrowserFind.cpp \
|
||||
nsNonPersistAuthPrompt.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
|
||||
@ -46,6 +46,7 @@ CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsWebBrowserPersist.obj \
|
||||
.\$(OBJDIR)\nsDOMWalker.obj \
|
||||
.\$(OBJDIR)\nsWebBrowserFind.obj \
|
||||
.\$(OBJDIR)\nsNonPersistAuthPrompt.obj \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
// Local Includes
|
||||
#include "nsDocShellTreeOwner.h"
|
||||
#include "nsWebBrowser.h"
|
||||
#include "nsNonPersistAuthPrompt.h"
|
||||
|
||||
// Helper Classes
|
||||
#include "nsIGenericFactory.h"
|
||||
@ -53,6 +54,8 @@
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsPIWindowWatcher.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIWalletService.h"
|
||||
|
||||
static char *sWindowWatcherContractID = "@mozilla.org/embedcomp/window-watcher;1";
|
||||
|
||||
@ -108,8 +111,31 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
|
||||
if(NS_SUCCEEDED(QueryInterface(aIID, aSink)))
|
||||
return NS_OK;
|
||||
|
||||
if(mOwnerRequestor)
|
||||
if(mOwnerRequestor) {
|
||||
if (aIID.Equals(NS_GET_IID(nsIAuthPrompt))) {
|
||||
if (!mAuthPrompter) {
|
||||
|
||||
// Get the prompt UI from the owner
|
||||
nsCOMPtr<nsIPrompt> prompt;
|
||||
nsresult rv = mOwnerRequestor->GetInterface(NS_GET_IID(nsIPrompt), getter_AddRefs(prompt));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Attempt to create a single signon. If that fails, create a simple non-persistent nsIAuthPrompt.
|
||||
mAuthPrompter = do_CreateInstance(NS_SINGLESIGNONPROMPT_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
mAuthPrompter = new nsNonPersistAuthPrompt;
|
||||
NS_ENSURE_TRUE(mAuthPrompter, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISingleSignOnPrompt> siPrompt(do_QueryInterface(mAuthPrompter));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
siPrompt->SetPromptDialogs(prompt);
|
||||
}
|
||||
return mAuthPrompter->QueryInterface(aIID, aSink);
|
||||
}
|
||||
return mOwnerRequestor->GetInterface(aIID, aSink);
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
#include "nsIDOMMouseMotionListener.h"
|
||||
#include "nsIDOMContextMenuListener.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
|
||||
#include "nsCommandHandler.h"
|
||||
|
||||
@ -123,6 +124,8 @@ protected:
|
||||
// and the DOM. These are strong, owning refs.
|
||||
ChromeTooltipListener* mChromeTooltipListener;
|
||||
ChromeContextMenuListener* mChromeContextMenuListener;
|
||||
|
||||
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -67,27 +67,26 @@ interface nsIPromptService : nsISupports
|
||||
out boolean checkValue);
|
||||
|
||||
boolean prompt(in nsIDOMWindow parent,
|
||||
in wstring dialogTitle,
|
||||
in wstring text,
|
||||
in wstring passwordRealm,
|
||||
in PRUint32 savePassword,
|
||||
in wstring defaultText,
|
||||
out wstring result);
|
||||
in wstring dialogTitle,
|
||||
in wstring text,
|
||||
inout wstring value,
|
||||
in wstring checkMsg,
|
||||
inout boolean checkValue);
|
||||
|
||||
boolean promptUsernameAndPassword(in nsIDOMWindow parent,
|
||||
in wstring dialogTitle,
|
||||
in wstring text,
|
||||
in wstring passwordRealm,
|
||||
in PRUint32 savePassword,
|
||||
out wstring user,
|
||||
out wstring pwd);
|
||||
inout wstring username,
|
||||
inout wstring password,
|
||||
in wstring checkMsg,
|
||||
inout boolean checkValue);
|
||||
|
||||
boolean promptPassword(in nsIDOMWindow parent,
|
||||
in wstring dialogTitle,
|
||||
in wstring text,
|
||||
in wstring passwordRealm,
|
||||
in PRUint32 savePassword,
|
||||
out wstring pwd);
|
||||
in wstring dialogTitle,
|
||||
in wstring text,
|
||||
inout wstring password,
|
||||
in wstring checkMsg,
|
||||
inout boolean checkValue);
|
||||
|
||||
boolean select(in nsIDOMWindow parent,
|
||||
in wstring dialogTitle,
|
||||
|
||||
@ -46,6 +46,7 @@ and that windows remove themselves from the service when they are closed.
|
||||
interface nsIDOMWindow;
|
||||
interface nsIObserver;
|
||||
interface nsIPrompt;
|
||||
interface nsIAuthPrompt;
|
||||
interface nsISimpleEnumerator;
|
||||
interface nsIWindowCreator;
|
||||
|
||||
@ -109,6 +110,13 @@ interface nsIWindowWatcher : nsISupports {
|
||||
|
||||
nsIPrompt getNewPrompter(in nsIDOMWindow aParent);
|
||||
|
||||
/** Return a newly created nsIAuthPrompt implementation.
|
||||
@param aParent the parent window used for posing alerts. can be null.
|
||||
@return a new nsIAuthPrompt object
|
||||
*/
|
||||
|
||||
nsIAuthPrompt getNewAuthPrompter(in nsIDOMWindow aParent);
|
||||
|
||||
/** Set the window creator callback. It must be filled in by the app.
|
||||
openWindow will use it to create new windows.
|
||||
@param creator the callback. if null, the callback will be cleared
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIWalletService.h"
|
||||
#include "nsPrompt.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
static NS_DEFINE_CID(kSingleSignOnPromptCID, NS_SINGLESIGNONPROMPT_CID);
|
||||
@ -62,6 +63,28 @@ NS_NewPrompter(nsIPrompt **result, nsIDOMWindow *aParent)
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = prompter;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewAuthPrompter(nsIAuthPrompt **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;
|
||||
// wrap the base prompt in an nsISingleSignOnPrompt, if available
|
||||
nsCOMPtr<nsISingleSignOnPrompt> siPrompt = do_CreateInstance(kSingleSignOnPromptCID);
|
||||
@ -77,7 +100,7 @@ NS_NewPrompter(nsIPrompt **result, nsIDOMWindow *aParent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsPrompt, nsIPrompt)
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsPrompt, nsIPrompt, nsIAuthPrompt)
|
||||
|
||||
nsPrompt::nsPrompt(nsIDOMWindow *aParent)
|
||||
: mParent(aParent)
|
||||
@ -109,6 +132,10 @@ nsPrompt::GetLocaleString(const PRUnichar *aKey, PRUnichar **aResult)
|
||||
return rv;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsPrompt::nsIPrompt
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrompt::Alert(const PRUnichar* dialogTitle,
|
||||
const PRUnichar* text)
|
||||
@ -184,12 +211,11 @@ nsPrompt::ConfirmCheck(const PRUnichar* dialogTitle,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrompt::Prompt(const PRUnichar* dialogTitle,
|
||||
const PRUnichar* text,
|
||||
const PRUnichar* passwordRealm,
|
||||
PRUint32 savePassword,
|
||||
const PRUnichar* defaultText,
|
||||
PRUnichar* *result,
|
||||
nsPrompt::Prompt(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
PRUnichar **answer,
|
||||
const PRUnichar *checkMsg,
|
||||
PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -202,20 +228,19 @@ nsPrompt::Prompt(const PRUnichar* dialogTitle,
|
||||
stringOwner.TakeString(title);
|
||||
}
|
||||
|
||||
return mPromptService->Prompt(mParent, title, text,
|
||||
passwordRealm, savePassword,
|
||||
defaultText, result, _retval);
|
||||
return mPromptService->Prompt(mParent, title, text, answer,
|
||||
checkMsg, checkValue, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrompt::PromptUsernameAndPassword(const PRUnichar* dialogTitle,
|
||||
const PRUnichar* text,
|
||||
const PRUnichar* passwordRealm,
|
||||
PRUint32 savePassword,
|
||||
PRUnichar* *user,
|
||||
PRUnichar* *pwd,
|
||||
nsPrompt::PromptUsernameAndPassword(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
PRUnichar **username,
|
||||
PRUnichar **password,
|
||||
const PRUnichar *checkMsg,
|
||||
PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
{
|
||||
nsresult rv;
|
||||
AutoStringFree stringOwner;
|
||||
PRUnichar *title = NS_CONST_CAST(PRUnichar *, dialogTitle);
|
||||
@ -226,20 +251,18 @@ nsPrompt::PromptUsernameAndPassword(const PRUnichar* dialogTitle,
|
||||
stringOwner.TakeString(title);
|
||||
}
|
||||
|
||||
return mPromptService->PromptUsernameAndPassword(mParent, title, text,
|
||||
passwordRealm, savePassword,
|
||||
user, pwd, _retval);
|
||||
return mPromptService->PromptUsernameAndPassword(mParent, title, text, username, password,
|
||||
checkMsg, checkValue, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrompt::PromptPassword(const PRUnichar* dialogTitle,
|
||||
const PRUnichar* text,
|
||||
const PRUnichar* passwordRealm,
|
||||
PRUint32 savePassword,
|
||||
PRUnichar* *pwd,
|
||||
nsPrompt::PromptPassword(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
PRUnichar **password,
|
||||
const PRUnichar *checkMsg,
|
||||
PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
// XXX: ignore passwordRealm and savePassword here?
|
||||
nsresult rv;
|
||||
AutoStringFree stringOwner;
|
||||
PRUnichar *title = NS_CONST_CAST(PRUnichar *, dialogTitle);
|
||||
@ -250,9 +273,8 @@ nsPrompt::PromptPassword(const PRUnichar* dialogTitle,
|
||||
stringOwner.TakeString(title);
|
||||
}
|
||||
|
||||
return mPromptService->PromptPassword(mParent, title, text,
|
||||
passwordRealm, savePassword,
|
||||
pwd, _retval);
|
||||
return mPromptService->PromptPassword(mParent, title, text, password,
|
||||
checkMsg, checkValue, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -321,3 +343,81 @@ nsPrompt::UniversalDialog(const PRUnichar *inTitleMessage,
|
||||
return rv;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// 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
|
||||
nsresult rv;
|
||||
AutoStringFree stringOwner;
|
||||
PRUnichar *title = NS_CONST_CAST(PRUnichar *, dialogTitle);
|
||||
|
||||
if (!title) {
|
||||
rv = GetLocaleString(NS_LITERAL_STRING("Prompt").get(), &title);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
stringOwner.TakeString(title);
|
||||
}
|
||||
|
||||
if (defaultText)
|
||||
*result = ToNewUnicode(nsLiteralString(defaultText));
|
||||
return mPromptService->Prompt(mParent, title, 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
|
||||
nsresult rv;
|
||||
AutoStringFree stringOwner;
|
||||
PRUnichar *title = NS_CONST_CAST(PRUnichar *, dialogTitle);
|
||||
|
||||
if (!title) {
|
||||
rv = GetLocaleString(NS_LITERAL_STRING("PromptUsernameAndPassword").get(), &title);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
stringOwner.TakeString(title);
|
||||
}
|
||||
|
||||
return mPromptService->PromptUsernameAndPassword(mParent, title, 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
|
||||
nsresult rv;
|
||||
AutoStringFree stringOwner;
|
||||
PRUnichar *title = NS_CONST_CAST(PRUnichar *, dialogTitle);
|
||||
|
||||
if (!title) {
|
||||
rv = GetLocaleString(NS_LITERAL_STRING("PromptPassword").get(), &title);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
stringOwner.TakeString(title);
|
||||
}
|
||||
|
||||
return mPromptService->PromptPassword(mParent, title, text,
|
||||
pwd, nsnull, nsnull, _retval);
|
||||
}
|
||||
|
||||
@ -23,13 +23,16 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIPromptService.h"
|
||||
|
||||
class nsPrompt : public nsIPrompt {
|
||||
class nsPrompt : public nsIPrompt,
|
||||
public nsIAuthPrompt {
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROMPT
|
||||
NS_DECL_NSIAUTHPROMPT
|
||||
|
||||
nsPrompt(nsIDOMWindow *window);
|
||||
virtual ~nsPrompt() {}
|
||||
@ -46,3 +49,5 @@ protected:
|
||||
nsresult
|
||||
NS_NewPrompter(nsIPrompt **result, nsIDOMWindow *aParent);
|
||||
|
||||
nsresult
|
||||
NS_NewAuthPrompter(nsIAuthPrompt **result, nsIDOMWindow *aParent);
|
||||
|
||||
@ -286,14 +286,15 @@ nsPromptService::UniversalDialog(nsIDOMWindow *parent,
|
||||
return rv;
|
||||
}
|
||||
|
||||
// XXX use passwordRealm and savePassword, here and in
|
||||
// PromptUsernameAndPassword and PromptPassword
|
||||
NS_IMETHODIMP
|
||||
nsPromptService::Prompt(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text, const PRUnichar *passwordRealm,
|
||||
PRUint32 savePassword, const PRUnichar *defaultText,
|
||||
PRUnichar **result, PRBool *_retval)
|
||||
nsPromptService::Prompt(nsIDOMWindow *parent,
|
||||
const PRUnichar *dialogTitle, const PRUnichar *text,
|
||||
PRUnichar **value,
|
||||
const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG(value);
|
||||
NS_ENSURE_ARG(_retval);
|
||||
|
||||
nsresult rv;
|
||||
ParamBlock block;
|
||||
rv = block.Init();
|
||||
@ -308,25 +309,46 @@ nsPromptService::Prompt(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
|
||||
nsString url; url.AssignWithConversion(kQuestionIconURL);
|
||||
block->SetString(eIconURL, url.GetUnicode());
|
||||
block->SetInt(eNumberEditfields, 1);
|
||||
block->SetString(eEditfield1Value, defaultText);
|
||||
if (*value)
|
||||
block->SetString(eEditfield1Value, *value);
|
||||
if (checkMsg && checkValue) {
|
||||
block->SetString(eCheckboxMsg, checkMsg);
|
||||
block->SetInt(eCheckboxState, *checkValue);
|
||||
}
|
||||
|
||||
rv = DoDialog(parent, block, kPromptURL);
|
||||
|
||||
block->GetString(eEditfield1Value, result);
|
||||
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,
|
||||
const PRUnichar *passwordRealm, PRUint32 savePassword,
|
||||
PRUnichar **user, PRUnichar **pwd, PRBool *_retval)
|
||||
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);
|
||||
|
||||
nsresult rv;
|
||||
ParamBlock block;
|
||||
rv = block.Init();
|
||||
@ -342,25 +364,52 @@ nsPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent,
|
||||
url.AssignWithConversion(kQuestionIconURL);
|
||||
block->SetString(eIconURL, url.GetUnicode());
|
||||
block->SetInt( eNumberEditfields, 2 );
|
||||
block->SetString(eEditfield1Value, *user);
|
||||
block->SetString(eEditfield2Value, *pwd);
|
||||
|
||||
if (*username)
|
||||
block->SetString(eEditfield1Value, *username);
|
||||
if (*password)
|
||||
block->SetString(eEditfield2Value, *password);
|
||||
if (checkMsg && checkValue) {
|
||||
block->SetString(eCheckboxMsg, checkMsg);
|
||||
block->SetInt(eCheckboxState, *checkValue);
|
||||
}
|
||||
|
||||
rv = DoDialog(parent, block, kPromptURL);
|
||||
|
||||
block->GetString(eEditfield1Value, user);
|
||||
block->GetString(eEditfield2Value, pwd);
|
||||
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,
|
||||
const PRUnichar *passwordRealm, PRUint32 savePassword,
|
||||
PRUnichar **pwd, PRBool *_retval)
|
||||
{
|
||||
const PRUnichar *dialogTitle, const PRUnichar *text,
|
||||
PRUnichar **password,
|
||||
const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG(password);
|
||||
NS_ENSURE_ARG(_retval);
|
||||
|
||||
nsresult rv;
|
||||
ParamBlock block;
|
||||
rv = block.Init();
|
||||
@ -377,14 +426,31 @@ NS_IMETHODIMP nsPromptService::PromptPassword(nsIDOMWindow *parent,
|
||||
block->SetString(eIconURL, url.GetUnicode());
|
||||
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);
|
||||
}
|
||||
|
||||
rv = DoDialog(parent, block, kPromptURL);
|
||||
|
||||
block->GetString(eEditfield1Value, pwd);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -710,6 +710,12 @@ nsWindowWatcher::GetNewPrompter(nsIDOMWindow *aParent, nsIPrompt **_retval)
|
||||
return NS_NewPrompter(_retval, aParent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowWatcher::GetNewAuthPrompter(nsIDOMWindow *aParent, nsIAuthPrompt **_retval)
|
||||
{
|
||||
return NS_NewAuthPrompter(_retval, aParent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowWatcher::SetWindowCreator(nsIWindowCreator *creator)
|
||||
{
|
||||
|
||||
@ -407,20 +407,28 @@ void CBrowserFrame::BrowserFrameGlueObj::Confirm(const PRUnichar *dialogTitle, c
|
||||
}
|
||||
|
||||
void CBrowserFrame::BrowserFrameGlueObj::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text,
|
||||
const PRUnichar *defaultEditText, PRUnichar **result, PRBool *retval)
|
||||
PRUnichar **promptText,
|
||||
const PRUnichar *checkboxMsg, PRBool *checkboxState,
|
||||
PRBool *retval)
|
||||
{
|
||||
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
|
||||
|
||||
USES_CONVERSION;
|
||||
|
||||
CPromptDialog dlg(pThis, W2T(dialogTitle), W2T(text), W2T(defaultEditText));
|
||||
CPromptDialog dlg(pThis, W2T(dialogTitle), W2T(text),
|
||||
(promptText && *promptText) ? W2T(*promptText) : nsnull,
|
||||
(checkboxState != nsnull), W2T(checkboxMsg), checkboxState ? *checkboxState : 0);
|
||||
if(dlg.DoModal() == IDOK)
|
||||
{
|
||||
// Get the value entered in the editbox of the PromptDlg
|
||||
if (promptText && *promptText) {
|
||||
nsMemory::Free(*promptText);
|
||||
*promptText = nsnull;
|
||||
}
|
||||
nsString csPromptEditValue;
|
||||
csPromptEditValue.AssignWithConversion(dlg.m_csPromptAnswer.GetBuffer(0));
|
||||
|
||||
*result = csPromptEditValue.ToNewUnicode();
|
||||
*promptText = csPromptEditValue.ToNewUnicode();
|
||||
|
||||
*retval = PR_TRUE;
|
||||
}
|
||||
@ -430,24 +438,31 @@ void CBrowserFrame::BrowserFrameGlueObj::Prompt(const PRUnichar *dialogTitle, co
|
||||
}
|
||||
}
|
||||
|
||||
void CBrowserFrame::BrowserFrameGlueObj::PromptPassword(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text, const PRUnichar *checkboxMsg,
|
||||
PRBool *checkboxState, PRUnichar **result, PRBool *retval)
|
||||
void CBrowserFrame::BrowserFrameGlueObj::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text,
|
||||
PRUnichar **password,
|
||||
const PRUnichar *checkboxMsg, PRBool *checkboxState,
|
||||
PRBool *retval)
|
||||
{
|
||||
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
|
||||
|
||||
USES_CONVERSION;
|
||||
|
||||
CPromptPasswordDialog dlg(pThis, W2T(dialogTitle), W2T(text), W2T(checkboxMsg));
|
||||
CPromptPasswordDialog dlg(pThis, W2T(dialogTitle), W2T(text),
|
||||
(password && *password) ? W2T(*password) : nsnull,
|
||||
(checkboxState != nsnull), W2T(checkboxMsg), checkboxState ? *checkboxState : 0);
|
||||
if(dlg.DoModal() == IDOK)
|
||||
{
|
||||
// Get the password entered
|
||||
if (password && *password) {
|
||||
nsMemory::Free(*password);
|
||||
*password = nsnull;
|
||||
}
|
||||
nsString csPassword;
|
||||
csPassword.AssignWithConversion(dlg.m_csPassword.GetBuffer(0));
|
||||
*result = csPassword.ToNewUnicode();
|
||||
*password = csPassword.ToNewUnicode();
|
||||
|
||||
if(checkboxState) //Checkbox will be hidden in non single sign-on case
|
||||
*checkboxState = dlg.m_bSavePassword;
|
||||
if(checkboxState)
|
||||
*checkboxState = dlg.m_bCheckBoxValue;
|
||||
|
||||
*retval = PR_TRUE;
|
||||
}
|
||||
@ -457,35 +472,42 @@ void CBrowserFrame::BrowserFrameGlueObj::PromptPassword(const PRUnichar *dialogT
|
||||
}
|
||||
}
|
||||
|
||||
void CBrowserFrame::BrowserFrameGlueObj::PromptUserNamePassword(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text, const PRUnichar *userNameLabel,
|
||||
const PRUnichar *passwordLabel, const PRUnichar *checkboxMsg,
|
||||
PRBool *checkboxState, PRUnichar **username, PRUnichar **password,
|
||||
PRBool *retval)
|
||||
void CBrowserFrame::BrowserFrameGlueObj::PromptUserNamePassword(const PRUnichar *dialogTitle, const PRUnichar *text,
|
||||
PRUnichar **username, PRUnichar **password,
|
||||
const PRUnichar *checkboxMsg, PRBool *checkboxState,
|
||||
PRBool *retval)
|
||||
{
|
||||
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
|
||||
|
||||
USES_CONVERSION;
|
||||
|
||||
CPromptUsernamePasswordDialog dlg(pThis, W2T(dialogTitle), W2T(text),
|
||||
W2T(userNameLabel), W2T(passwordLabel),
|
||||
W2T(checkboxMsg), W2T(*username), W2T(*password),
|
||||
checkboxState ? (*checkboxState) : PR_FALSE);
|
||||
CPromptUsernamePasswordDialog dlg(pThis, W2T(dialogTitle), W2T(text),
|
||||
(username && *username) ? W2T(*username) : nsnull,
|
||||
(password && *password) ? W2T(*password) : nsnull,
|
||||
(checkboxState != nsnull), W2T(checkboxMsg), checkboxState ? *checkboxState : 0);
|
||||
|
||||
if(dlg.DoModal() == IDOK)
|
||||
{
|
||||
// Get the username entered
|
||||
if (username && *username) {
|
||||
nsMemory::Free(*username);
|
||||
*username = nsnull;
|
||||
}
|
||||
nsString csUserName;
|
||||
csUserName.AssignWithConversion(dlg.m_csUserName.GetBuffer(0));
|
||||
*username = csUserName.ToNewUnicode();
|
||||
|
||||
// Get the password entered
|
||||
if (password && *password) {
|
||||
nsMemory::Free(*password);
|
||||
*password = nsnull;
|
||||
}
|
||||
nsString csPassword;
|
||||
csPassword.AssignWithConversion(dlg.m_csPassword.GetBuffer(0));
|
||||
*password = csPassword.ToNewUnicode();
|
||||
|
||||
if(checkboxState) //Checkbox will be hidden in non single sign-on case
|
||||
*checkboxState = dlg.m_bSavePassword;
|
||||
if(checkboxState)
|
||||
*checkboxState = dlg.m_bCheckBoxValue;
|
||||
|
||||
*retval = PR_TRUE;
|
||||
|
||||
|
||||
@ -117,38 +117,6 @@ NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMETHODIMP CBrowserImpl::GetInterface(const nsIID &aIID, void** aInstancePtr)
|
||||
{
|
||||
// Note that we're wrapping our nsIPrompt impl. with the
|
||||
// nsISingleSignOnPrompt - if USE_SINGLE_SIGN_ON is defined
|
||||
// (and if single sign-on support dll's are present and enabled)
|
||||
// This allows the embedding app to use the password save
|
||||
// feature. When signing on to a host which needs authentication
|
||||
// the Single sign-on service will check to see if the auth. info
|
||||
// is already saved and if so uses it to pre-fill the sign-on form
|
||||
// If not, our nsIPrompt impl will be called
|
||||
// to present the auth UI and return the required auth info.
|
||||
// If we do not compile with single sign-on support or if that
|
||||
// service is missing we just fall back to the regular
|
||||
// implementation of nsIPrompt
|
||||
|
||||
if(aIID.Equals(NS_GET_IID(nsIPrompt)))
|
||||
{
|
||||
if (!mPrompter)
|
||||
{
|
||||
#ifdef USE_SINGLE_SIGN_ON
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISingleSignOnPrompt> siPrompt = do_CreateInstance(NS_SINGLESIGNONPROMPT_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
siPrompt->SetPromptDialogs(NS_STATIC_CAST(nsIPrompt*, this));
|
||||
mPrompter = siPrompt;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
mPrompter = NS_STATIC_CAST(nsIPrompt*, this);
|
||||
}
|
||||
NS_ENSURE_TRUE(mPrompter, NS_ERROR_FAILURE);
|
||||
return mPrompter->QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
if(aIID.Equals(NS_GET_IID(nsIDOMWindow)))
|
||||
{
|
||||
if (mWebBrowser)
|
||||
|
||||
@ -53,8 +53,6 @@ protected:
|
||||
PBROWSERFRAMEGLUE m_pBrowserFrameGlue;
|
||||
|
||||
nsCOMPtr<nsIWebBrowser> mWebBrowser;
|
||||
|
||||
nsCOMPtr<nsIPrompt> mPrompter;
|
||||
};
|
||||
|
||||
#endif //_BROWSERIMPL_H
|
||||
@ -25,32 +25,7 @@
|
||||
//
|
||||
// The nsIPrompt interface is mainly used to convey/get information
|
||||
// from a user via Alerts, Prompts etc.
|
||||
// There are two distinct scenarious to be aware of when implementing this
|
||||
// interface:
|
||||
// 1. When we want to support the single sign-on feature i.e. we're
|
||||
// "wrap"ing our nsIPrompt interface with nsISingleSignOnPrompt
|
||||
// (See BrowserImpl::GetInterface() on how we wrap it with
|
||||
// single sign-on)
|
||||
// 2. When we do not want single sign-on support or that support
|
||||
// is missing, for ex, not installed or disabled
|
||||
//
|
||||
// Depending on which of the above two scenarios we're operating on
|
||||
// different methods in this interface are called
|
||||
//
|
||||
// When operating *with* Single sign-on support:
|
||||
// nsIPrompt::Alert() - is called to show an alert
|
||||
// nsIPromtp::Confirm() - is called to show a confirmation msg
|
||||
// nsIPrompt::UniversalDlg() - is called for getting a password, getting
|
||||
// username/password and to Prompt the user
|
||||
// for some information, other cases??
|
||||
//
|
||||
// When operating *without* Single sign-on support:
|
||||
// nsIPrompt::Alert() - is called to show an alert
|
||||
// nsIPromtp::Confirm() - is called to show a confirmation msg
|
||||
// nsIPromtp::Prompt() - is called to prompt the user for some info.
|
||||
// nsIPromtp::PromptPassword() - is called to get the password
|
||||
// nsIPromtp::PromptUsernameAndPassword() - is called to get username/password
|
||||
//
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include "stdafx.h"
|
||||
@ -66,8 +41,6 @@
|
||||
// Needed for JavaScript and other cases where a msg needs to be
|
||||
// shown to the user. For ex, when a page has some JS such as
|
||||
// "Alert("Hello")" this method will be invoked
|
||||
// (This method will get called whether or not we're wrapping
|
||||
// our nsIPrompt with nsISingleSignonPrompt)
|
||||
NS_IMETHODIMP
|
||||
CBrowserImpl::Alert(const PRUnichar *dialogTitle, const PRUnichar *text)
|
||||
{
|
||||
@ -80,8 +53,6 @@ CBrowserImpl::Alert(const PRUnichar *dialogTitle, const PRUnichar *text)
|
||||
}
|
||||
|
||||
// Invoked in the case of a JS confirm() method invocation
|
||||
// (This method will get called whether or not we're wrapping
|
||||
// our nsIPrompt with nsISingleSignonPrompt)
|
||||
NS_IMETHODIMP
|
||||
CBrowserImpl::Confirm(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text, PRBool *retval)
|
||||
@ -94,73 +65,53 @@ CBrowserImpl::Confirm(const PRUnichar *dialogTitle,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// (This method will get called when we're *NOT* wrapping
|
||||
// our nsIPrompt with nsISingleSignonPrompt
|
||||
// However, when we're wrapping our nsIPrompt with
|
||||
// single sign-on then the UniversalDialog is being
|
||||
// invoked to put up a prompt.
|
||||
NS_IMETHODIMP
|
||||
CBrowserImpl::Prompt(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
const PRUnichar *passwordRealm,
|
||||
PRUint32 savePassword,
|
||||
const PRUnichar *defaultText,
|
||||
PRUnichar **result, PRBool *retval)
|
||||
CBrowserImpl::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text,
|
||||
PRUnichar **promptText,
|
||||
const PRUnichar *checkMsg, PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
if(! m_pBrowserFrameGlue)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
m_pBrowserFrameGlue->Prompt(dialogTitle, text, defaultText, result, retval);
|
||||
m_pBrowserFrameGlue->Prompt(dialogTitle, text, promptText, checkMsg, checkValue, _retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CBrowserImpl::PromptPassword(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
const PRUnichar *passwordRealm,
|
||||
PRUint32 savePassword, PRUnichar **pwd,
|
||||
PRBool *retval)
|
||||
CBrowserImpl::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text,
|
||||
PRUnichar **password,
|
||||
const PRUnichar *checkMsg, PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
if(! m_pBrowserFrameGlue)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Note that we're using the same PromptPassword method in
|
||||
// IBrowserFrameGlue for both the single sign-on and non-
|
||||
// single sign-on cases.
|
||||
// In the non-single sign-on case i.e. here, we do not
|
||||
// have a checkboxmsg or chkboxstate to worry about -
|
||||
// hence NULLs are being passed for those params below
|
||||
|
||||
m_pBrowserFrameGlue->PromptPassword(dialogTitle, text, NULL/*no chkbox msg*/,
|
||||
NULL/*no chkboxState*/, pwd, retval);
|
||||
m_pBrowserFrameGlue->PromptPassword(dialogTitle, text, password,
|
||||
checkMsg, checkValue, _retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CBrowserImpl::PromptUsernameAndPassword(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
const PRUnichar *passwordRealm,
|
||||
PRUint32 savePassword,
|
||||
PRUnichar **user,
|
||||
PRUnichar **pwd,
|
||||
PRBool *retval)
|
||||
CBrowserImpl::PromptUsernameAndPassword(const PRUnichar *dialogTitle, const PRUnichar *text,
|
||||
PRUnichar **username, PRUnichar **password,
|
||||
const PRUnichar *checkMsg, PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
if(! m_pBrowserFrameGlue)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
m_pBrowserFrameGlue->PromptUserNamePassword(dialogTitle, text,
|
||||
NULL/*UserName Label*/, NULL/*Password Label*/,
|
||||
NULL/*checkboxMsg*/, NULL/*checkboxState*/,
|
||||
user, pwd,
|
||||
retval);
|
||||
username, password,
|
||||
checkMsg, checkValue,
|
||||
_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// This method is evil/painful. This needs to go away and i think there's
|
||||
// already a bug w.r.t this
|
||||
// This method is evil/painful. It will be gone when bug 46859 is done
|
||||
//
|
||||
// So far these are the cases in which UniversalDialog seems to be
|
||||
// getting called when we wrap our nsIPrompt with nsISingleSignOnPrompt
|
||||
@ -216,12 +167,14 @@ CBrowserImpl::UniversalDialog(const PRUnichar *titleMessage,
|
||||
{
|
||||
if(! m_pBrowserFrameGlue)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool confirmed;
|
||||
|
||||
if(numberEditfields == 1 && checkboxMsg == NULL && editField1Password == 0)
|
||||
{
|
||||
// This is a Prompt()
|
||||
|
||||
m_pBrowserFrameGlue->Prompt(dialogTitle, text, *editfield1Value, editfield1Value, buttonPressed);
|
||||
m_pBrowserFrameGlue->Prompt(dialogTitle, text, editfield1Value, NULL, NULL, &confirmed);
|
||||
|
||||
// The Prompt() methods return PR_TRUE/PR_FALSE depending on whether
|
||||
// the OK/CANCEL was pressed. However, UniversalDialog checks
|
||||
@ -230,7 +183,7 @@ CBrowserImpl::UniversalDialog(const PRUnichar *titleMessage,
|
||||
|
||||
// So, now let's translate to what the UniversalDlg expects
|
||||
|
||||
if(*buttonPressed) //Will be TRUE i.e. 1 if the user chose OK
|
||||
if(confirmed) //Will be TRUE i.e. 1 if the user chose OK
|
||||
*buttonPressed = 0; //Set it to the OK button index i.e. to "0"
|
||||
else
|
||||
*buttonPressed = 1; //Set it to the Cancel button index i.e. to "1"
|
||||
@ -241,11 +194,11 @@ CBrowserImpl::UniversalDialog(const PRUnichar *titleMessage,
|
||||
{
|
||||
// This is a PromptPassword()
|
||||
|
||||
m_pBrowserFrameGlue->PromptPassword(dialogTitle, text, checkboxMsg,
|
||||
checkboxState, editfield1Value, buttonPressed);
|
||||
m_pBrowserFrameGlue->PromptPassword(dialogTitle, text, editfield1Value,
|
||||
checkboxMsg, checkboxState, &confirmed);
|
||||
|
||||
//See comments above on why we're doing this...
|
||||
if(*buttonPressed)
|
||||
if(confirmed)
|
||||
*buttonPressed = 0;
|
||||
else
|
||||
*buttonPressed = 1;
|
||||
@ -256,14 +209,13 @@ CBrowserImpl::UniversalDialog(const PRUnichar *titleMessage,
|
||||
{
|
||||
// This is a username/password dialog
|
||||
|
||||
m_pBrowserFrameGlue->PromptUserNamePassword(dialogTitle, text,
|
||||
editfield1Msg, editfield2Msg,
|
||||
checkboxMsg, checkboxState,
|
||||
editfield1Value, editfield2Value,
|
||||
buttonPressed);
|
||||
m_pBrowserFrameGlue->PromptUserNamePassword(dialogTitle, text,
|
||||
editfield1Value, editfield2Value,
|
||||
checkboxMsg, checkboxState,
|
||||
&confirmed);
|
||||
|
||||
//See comments above on why we're doing this...
|
||||
if(*buttonPressed)
|
||||
if(confirmed)
|
||||
*buttonPressed = 0;
|
||||
else
|
||||
*buttonPressed = 1;
|
||||
|
||||
@ -35,15 +35,20 @@
|
||||
// CPromptDialog Stuff
|
||||
//--------------------------------------------------------------------------//
|
||||
|
||||
CPromptDialog::CPromptDialog(CWnd* pParent, const char* pTitle, const char* pText, const char* pDefEditText)
|
||||
: CDialog(CPromptDialog::IDD, pParent)
|
||||
CPromptDialog::CPromptDialog(CWnd* pParent, const char* pTitle, const char* pText,
|
||||
const char* pInitPromptText,
|
||||
BOOL bHasCheck, const char* pCheckText, int initCheckVal)
|
||||
: CDialog(CPromptDialog::IDD, pParent),
|
||||
m_bHasCheckBox(bHasCheck)
|
||||
{
|
||||
if(pTitle)
|
||||
m_csDialogTitle = pTitle;
|
||||
if(pText)
|
||||
m_csPromptText = pText;
|
||||
if(pDefEditText)
|
||||
m_csPromptAnswer = pDefEditText;
|
||||
if(pInitPromptText)
|
||||
m_csPromptAnswer = pInitPromptText;
|
||||
if(pCheckText)
|
||||
m_csCheckBoxText = pCheckText;
|
||||
}
|
||||
|
||||
void CPromptDialog::DoDataExchange(CDataExchange* pDX)
|
||||
@ -51,6 +56,7 @@ void CPromptDialog::DoDataExchange(CDataExchange* pDX)
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CPromptDialog)
|
||||
DDX_Text(pDX, IDC_PROMPT_ANSWER, m_csPromptAnswer);
|
||||
DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
@ -68,6 +74,23 @@ int CPromptDialog::OnInitDialog()
|
||||
if(pWnd)
|
||||
pWnd->SetWindowText(m_csPromptText);
|
||||
|
||||
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
|
||||
if(pChk)
|
||||
{
|
||||
if (m_bHasCheckBox)
|
||||
{
|
||||
if(!m_csCheckBoxText.IsEmpty())
|
||||
pChk->SetWindowText(m_csCheckBoxText);
|
||||
pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hide the check box control if there's no label text
|
||||
// This will be the case when we're not using single sign-on
|
||||
pChk->ShowWindow(SW_HIDE);
|
||||
}
|
||||
}
|
||||
|
||||
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_PROMPT_ANSWER);
|
||||
if(pEdit)
|
||||
{
|
||||
@ -85,18 +108,20 @@ int CPromptDialog::OnInitDialog()
|
||||
// CPromptPasswordDialog Stuff
|
||||
//--------------------------------------------------------------------------//
|
||||
|
||||
CPromptPasswordDialog::CPromptPasswordDialog(CWnd* pParent, const char* pTitle, const char* pText, const char* pCheckText)
|
||||
: CDialog(CPromptPasswordDialog::IDD, pParent)
|
||||
CPromptPasswordDialog::CPromptPasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
|
||||
const char* pInitPasswordText,
|
||||
BOOL bHasCheck, const char* pCheckText, int initCheckVal)
|
||||
: CDialog(CPromptPasswordDialog::IDD, pParent),
|
||||
m_bHasCheckBox(bHasCheck), m_bCheckBoxValue(initCheckVal)
|
||||
{
|
||||
if(pTitle)
|
||||
m_csDialogTitle = pTitle;
|
||||
if(pText)
|
||||
m_csPromptText = pText;
|
||||
if(pInitPasswordText)
|
||||
m_csPassword = pInitPasswordText;
|
||||
if(pCheckText)
|
||||
m_csCheckBoxText = pCheckText;
|
||||
|
||||
m_csPassword = "";
|
||||
m_bSavePassword = PR_FALSE;
|
||||
}
|
||||
|
||||
void CPromptPasswordDialog::DoDataExchange(CDataExchange* pDX)
|
||||
@ -104,7 +129,7 @@ void CPromptPasswordDialog::DoDataExchange(CDataExchange* pDX)
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CPromptPasswordDialog)
|
||||
DDX_Text(pDX, IDC_PASSWORD, m_csPassword);
|
||||
DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bSavePassword);
|
||||
DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
@ -116,24 +141,26 @@ END_MESSAGE_MAP()
|
||||
|
||||
int CPromptPasswordDialog::OnInitDialog()
|
||||
{
|
||||
SetWindowText(m_csDialogTitle);
|
||||
SetWindowText(m_csDialogTitle);
|
||||
|
||||
CWnd *pWnd = GetDlgItem(IDC_PROMPT_TEXT);
|
||||
if(pWnd)
|
||||
pWnd->SetWindowText(m_csPromptText);
|
||||
|
||||
pWnd = GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
|
||||
if(pWnd)
|
||||
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
|
||||
if(pChk)
|
||||
{
|
||||
if(!m_csCheckBoxText.IsEmpty())
|
||||
{
|
||||
pWnd->SetWindowText(m_csCheckBoxText);
|
||||
if (m_bHasCheckBox)
|
||||
{
|
||||
if(!m_csCheckBoxText.IsEmpty())
|
||||
pChk->SetWindowText(m_csCheckBoxText);
|
||||
pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hide the check box control if there's no label text
|
||||
// This will be the case when we're not using single sign-on
|
||||
pWnd->ShowWindow(SW_HIDE);
|
||||
pChk->ShowWindow(SW_HIDE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,26 +179,22 @@ int CPromptPasswordDialog::OnInitDialog()
|
||||
// CPromptUsernamePasswordDialog Stuff
|
||||
//--------------------------------------------------------------------------//
|
||||
|
||||
CPromptUsernamePasswordDialog::CPromptUsernamePasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
|
||||
const char* pUserNameLabel, const char* pPasswordLabel,
|
||||
const char* pCheckText, const char* pInitUserName, const char* pInitPassword, PRBool bCheck)
|
||||
: CDialog(CPromptUsernamePasswordDialog::IDD, pParent)
|
||||
CPromptUsernamePasswordDialog::CPromptUsernamePasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
|
||||
const char* pInitUsername, const char* pInitPassword,
|
||||
BOOL bHasCheck, const char* pCheckText, int initCheckVal)
|
||||
: CDialog(CPromptUsernamePasswordDialog::IDD, pParent),
|
||||
m_bHasCheckBox(bHasCheck), m_bCheckBoxValue(initCheckVal)
|
||||
{
|
||||
if(pTitle)
|
||||
m_csDialogTitle = pTitle;
|
||||
if(pText)
|
||||
m_csPromptText = pText;
|
||||
if(pUserNameLabel)
|
||||
m_csUserNameLabel = pUserNameLabel;
|
||||
if(pPasswordLabel)
|
||||
m_csPasswordLabel = pPasswordLabel;
|
||||
if(pCheckText)
|
||||
m_csCheckBoxText = pCheckText;
|
||||
if(pInitUserName)
|
||||
m_csUserName = pInitUserName;
|
||||
if(pInitUsername)
|
||||
m_csUserName = pInitUsername;
|
||||
if(pInitPassword)
|
||||
m_csPassword = pInitPassword;
|
||||
m_bSavePassword = bCheck;
|
||||
if(pCheckText)
|
||||
m_csCheckBoxText = pCheckText;
|
||||
}
|
||||
|
||||
void CPromptUsernamePasswordDialog::DoDataExchange(CDataExchange* pDX)
|
||||
@ -180,7 +203,7 @@ void CPromptUsernamePasswordDialog::DoDataExchange(CDataExchange* pDX)
|
||||
//{{AFX_DATA_MAP(CPromptUsernamePasswordDialog)
|
||||
DDX_Text(pDX, IDC_USERNAME, m_csUserName);
|
||||
DDX_Text(pDX, IDC_PASSWORD, m_csPassword);
|
||||
DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bSavePassword);
|
||||
DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
@ -198,41 +221,17 @@ int CPromptUsernamePasswordDialog::OnInitDialog()
|
||||
if(pWnd)
|
||||
pWnd->SetWindowText(m_csPromptText);
|
||||
|
||||
// This empty check is required since in the case
|
||||
// of non single sign-on the interface methods do
|
||||
// not specify the label text for username(unlike in
|
||||
// in the single sign-on case where they are)
|
||||
// In the case where the labels are not specified
|
||||
// we just use whatever is in the dlg resource
|
||||
// Ditto for the password label also
|
||||
if(! m_csUserNameLabel.IsEmpty())
|
||||
{
|
||||
pWnd = GetDlgItem(IDC_USERNAME_LABEL);
|
||||
if(pWnd)
|
||||
pWnd->SetWindowText(m_csUserNameLabel);
|
||||
}
|
||||
|
||||
if(! m_csPasswordLabel.IsEmpty())
|
||||
{
|
||||
pWnd = GetDlgItem(IDC_PASSWORD_LABEL);
|
||||
if(pWnd)
|
||||
pWnd->SetWindowText(m_csPasswordLabel);
|
||||
}
|
||||
|
||||
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
|
||||
if(pChk)
|
||||
{
|
||||
if(!m_csCheckBoxText.IsEmpty())
|
||||
if(m_bHasCheckBox)
|
||||
{
|
||||
pChk->SetWindowText(m_csCheckBoxText);
|
||||
|
||||
pChk->SetCheck(m_bSavePassword ? BST_CHECKED : BST_UNCHECKED);
|
||||
if (!m_csCheckBoxText.IsEmpty())
|
||||
pChk->SetWindowText(m_csCheckBoxText);
|
||||
pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hide the check box control if there's no label text
|
||||
// This will be the case when we're not using single sign-on
|
||||
|
||||
pChk->ShowWindow(SW_HIDE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,9 @@
|
||||
class CPromptDialog : public CDialog
|
||||
{
|
||||
public:
|
||||
CPromptDialog(CWnd* pParent, const char* pTitle, const char* pText, const char* pDefEditText);
|
||||
CPromptDialog(CWnd* pParent, const char* pTitle, const char* pText,
|
||||
const char* pInitPromptText,
|
||||
BOOL bHasCheck, const char* pCheckText, int initCheckVal);
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CPromptDialog)
|
||||
@ -39,6 +41,9 @@ public:
|
||||
|
||||
CString m_csDialogTitle;
|
||||
CString m_csPromptText;
|
||||
BOOL m_bHasCheckBox;
|
||||
CString m_csCheckBoxText;
|
||||
int m_bCheckBoxValue;
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CPromptDialog)
|
||||
@ -55,7 +60,9 @@ public:
|
||||
class CPromptPasswordDialog : public CDialog
|
||||
{
|
||||
public:
|
||||
CPromptPasswordDialog(CWnd* pParent, const char* pTitle, const char* pText, const char* pCheckText);
|
||||
CPromptPasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
|
||||
const char* pInitPasswordText,
|
||||
BOOL bHasCheck, const char* pCheckText, int initCheckVal);
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CPromptPasswordDialog)
|
||||
@ -65,8 +72,9 @@ public:
|
||||
CString m_csDialogTitle;
|
||||
CString m_csPromptText;
|
||||
CString m_csPassword;
|
||||
BOOL m_bHasCheckBox;
|
||||
CString m_csCheckBoxText;
|
||||
int m_bSavePassword;
|
||||
int m_bCheckBoxValue;
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CPromptPasswordDialog)
|
||||
@ -83,9 +91,9 @@ public:
|
||||
class CPromptUsernamePasswordDialog : public CDialog
|
||||
{
|
||||
public:
|
||||
CPromptUsernamePasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
|
||||
const char* pUserNameLabel, const char* pPasswordLabel,
|
||||
const char* pCheckText, const char* pInitUserName, const char* pInitPassword, PRBool bCheck);
|
||||
CPromptUsernamePasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
|
||||
const char* pInitUsername, const char* pInitPassword,
|
||||
BOOL bHasCheck, const char* pCheckText, int initCheckVal);
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CPromptUsernamePasswordDialog)
|
||||
@ -98,8 +106,9 @@ public:
|
||||
CString m_csPasswordLabel;
|
||||
CString m_csPassword;
|
||||
CString m_csUserName;
|
||||
BOOL m_bHasCheckBox;
|
||||
CString m_csCheckBoxText;
|
||||
int m_bSavePassword;
|
||||
int m_bCheckBoxValue;
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CPromptUsernamePasswordDialog)
|
||||
|
||||
@ -69,16 +69,17 @@ struct IBrowserFrameGlue {
|
||||
virtual void Alert(const PRUnichar *dialogTitle, const PRUnichar *text) = 0;
|
||||
virtual void Confirm(const PRUnichar *dialogTitle, const PRUnichar *text, PRBool *_retval) = 0;
|
||||
virtual void Prompt(const PRUnichar *dialogTitle, const PRUnichar *text,
|
||||
const PRUnichar *defaultEditText, PRUnichar **result,
|
||||
PRBool *retval) = 0;
|
||||
PRUnichar **promptText,
|
||||
const PRUnichar *checkboxMsg, PRBool *checkboxState,
|
||||
PRBool *retval) = 0;
|
||||
virtual void PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text,
|
||||
const PRUnichar *checkboxMsg, PRBool *checkboxState,
|
||||
PRUnichar **result, PRBool *retval) = 0;
|
||||
PRUnichar **password,
|
||||
const PRUnichar *checkboxMsg, PRBool *checkboxState,
|
||||
PRBool *retval) = 0;
|
||||
virtual void PromptUserNamePassword(const PRUnichar *dialogTitle, const PRUnichar *text,
|
||||
const PRUnichar *userNameLabel, const PRUnichar *passwordLabel,
|
||||
const PRUnichar *checkboxMsg, PRBool *checkboxState,
|
||||
PRUnichar **username, PRUnichar **password,
|
||||
PRBool *retval) = 0;
|
||||
PRUnichar **username, PRUnichar **password,
|
||||
const PRUnichar *checkboxMsg, PRBool *checkboxState,
|
||||
PRBool *retval) = 0;
|
||||
|
||||
};
|
||||
|
||||
@ -105,9 +106,9 @@ struct IBrowserFrameGlue {
|
||||
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode); \
|
||||
virtual void Alert(const PRUnichar *dialogTitle, const PRUnichar *text); \
|
||||
virtual void Confirm(const PRUnichar *dialogTitle, const PRUnichar *text, PRBool *_retval); \
|
||||
virtual void Prompt(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *defaultEditText, PRUnichar **result, PRBool *retval); \
|
||||
virtual void PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *checkboxMsg, PRBool *checkboxState, PRUnichar **result, PRBool *retval); \
|
||||
virtual void PromptUserNamePassword(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *userNameLabel, const PRUnichar *passwordLabel, const PRUnichar *checkboxMsg, PRBool *checkboxState, PRUnichar **username, PRUnichar **password, PRBool *retval);
|
||||
virtual void Prompt(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **promptText, const PRUnichar *checkboxMsg, PRBool *checkboxState, PRBool *retval); \
|
||||
virtual void PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **password, const PRUnichar *checkboxMsg, PRBool *checkboxState, PRBool *retval); \
|
||||
virtual void PromptUserNamePassword(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **username, PRUnichar **password, const PRUnichar *checkboxMsg, PRBool *checkboxState, PRBool *retval);
|
||||
|
||||
typedef IBrowserFrameGlue *PBROWSERFRAMEGLUE;
|
||||
|
||||
|
||||
@ -257,15 +257,17 @@ BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_PROMPT_DIALOG DIALOG DISCARDABLE 0, 0, 249, 82
|
||||
IDD_PROMPT_DIALOG DIALOG DISCARDABLE 0, 0, 249, 92
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Prompt Dialog"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,130,61,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,189,61,50,14
|
||||
DEFPUSHBUTTON "OK",IDOK,130,69,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,189,69,50,14
|
||||
LTEXT "Please enter something....",IDC_PROMPT_TEXT,10,7,229,29
|
||||
EDITTEXT IDC_PROMPT_ANSWER,10,39,229,14,ES_AUTOHSCROLL
|
||||
EDITTEXT IDC_PROMPT_ANSWER,7,39,232,13,ES_AUTOHSCROLL
|
||||
CONTROL "Save Answer",IDC_CHECK_SAVE_PASSWORD,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,7,57,229,10
|
||||
END
|
||||
|
||||
IDD_PROMPT_PASSWORD_DIALOG DIALOG DISCARDABLE 0, 0, 248, 93
|
||||
@ -278,7 +280,7 @@ BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,129,75,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,188,75,50,14
|
||||
EDITTEXT IDC_PASSWORD,5,37,233,12,ES_PASSWORD | ES_AUTOHSCROLL
|
||||
CONTROL "Check1",IDC_CHECK_SAVE_PASSWORD,"Button",
|
||||
CONTROL "Save Password",IDC_CHECK_SAVE_PASSWORD,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,7,57,229,10
|
||||
END
|
||||
|
||||
@ -293,8 +295,8 @@ BEGIN
|
||||
EDITTEXT IDC_USERNAME,49,39,153,12,ES_AUTOHSCROLL
|
||||
LTEXT "Password:",IDC_PASSWORD_LABEL,6,58,36,8
|
||||
EDITTEXT IDC_PASSWORD,49,56,153,12,ES_PASSWORD | ES_AUTOHSCROLL
|
||||
CONTROL "Check1",IDC_CHECK_SAVE_PASSWORD,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,6,78,201,10
|
||||
CONTROL "Save User Name and Password",IDC_CHECK_SAVE_PASSWORD,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,78,201,10
|
||||
DEFPUSHBUTTON "OK",IDOK,40,101,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,95,101,50,14
|
||||
END
|
||||
|
||||
@ -68,7 +68,6 @@
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIWalletService.h"
|
||||
#include "nsEmbedAPI.h"
|
||||
#include "nsISHistory.h"
|
||||
#include "nsISHEntry.h"
|
||||
|
||||
@ -592,17 +592,17 @@ NS_IMETHODIMP WebBrowserChrome::ConfirmCheck(const PRUnichar* dialogTitle, const
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP WebBrowserChrome::Prompt(const PRUnichar* dialogTitle, const PRUnichar *text, const PRUnichar* passwordRealm, PRUint32 savePassword, const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval)
|
||||
NS_IMETHODIMP WebBrowserChrome::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **answer, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP WebBrowserChrome::PromptUsernameAndPassword(const PRUnichar* dialogTitle, const PRUnichar *text, const PRUnichar* passwordRealm, PRUint32 savePassword, PRUnichar **user, PRUnichar **pwd, PRBool *_retval)
|
||||
|
||||
NS_IMETHODIMP WebBrowserChrome::PromptUsernameAndPassword(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **username, PRUnichar **password, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP WebBrowserChrome::PromptPassword(const PRUnichar* dialogTitle, const PRUnichar *text, const PRUnichar* passwordRealm, PRUint32 savePassword, PRUnichar **pwd, PRBool *_retval)
|
||||
|
||||
NS_IMETHODIMP WebBrowserChrome::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **password, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@ -423,8 +423,7 @@ char * PromptUserCallback(void *arg, char *prompt, void* clientContext, int isPa
|
||||
|
||||
if (proxyPrompt) {
|
||||
rv = proxyPrompt->PromptPassword(nsnull, NS_ConvertASCIItoUCS2(prompt).GetUnicode(),
|
||||
NS_LITERAL_STRING(" ").get(), // hostname
|
||||
nsIPrompt::SAVE_PASSWORD_NEVER, &password, &value);
|
||||
&password, nsnull, nsnull, &value);
|
||||
|
||||
}
|
||||
if (NS_SUCCEEDED(rv) && value) {
|
||||
|
||||
@ -589,13 +589,13 @@ function myPrompt(message, oldValue, title) {
|
||||
// if bug 41390 gets fixed, use the following line and delete rest of routine
|
||||
// prompt(message, oldValue, title); /* use this if bug 41390 gets fixed */
|
||||
|
||||
var newValue = { };
|
||||
var newValue = { value:oldValue };
|
||||
if (!title) {
|
||||
title = " ";
|
||||
}
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
|
||||
promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
|
||||
promptService.prompt(window, title, message, "", 0, oldValue, newValue)
|
||||
promptService.prompt(window, title, message, newValue, null, { value:0 })
|
||||
return newValue.value;
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIPrompt.idl"
|
||||
#include "nsIAuthPrompt.idl"
|
||||
#include "domstubs.idl"
|
||||
#include "nsIEnumerator.idl"
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
%}
|
||||
|
||||
interface nsIPresShell;
|
||||
interface nsIPrompt;
|
||||
|
||||
native nsAutoString(nsAutoString);
|
||||
[ref] native nsAutoStringRef(nsAutoString);
|
||||
@ -77,7 +78,7 @@ interface nsIWalletService : nsISupports {
|
||||
};
|
||||
|
||||
[scriptable, uuid(6228d644-17fe-11d4-8cee-0060b0fc14a3)]
|
||||
interface nsISingleSignOnPrompt : nsIPrompt
|
||||
interface nsISingleSignOnPrompt : nsIAuthPrompt
|
||||
{
|
||||
void setPromptDialogs(in nsIPrompt dialogs);
|
||||
};
|
||||
|
||||
@ -467,7 +467,7 @@ nsWalletlibService::WALLET_Decrypt (const char *crypt, PRUnichar **text) {
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS4(nsSingleSignOnPrompt,
|
||||
nsISingleSignOnPrompt,
|
||||
nsIPrompt,
|
||||
nsIAuthPrompt,
|
||||
nsIObserver,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
@ -486,33 +486,6 @@ nsSingleSignOnPrompt::Init()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSingleSignOnPrompt::Alert(const PRUnichar *dialogTitle, const PRUnichar *text)
|
||||
{
|
||||
return mPrompt->Alert(dialogTitle, text);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSingleSignOnPrompt::AlertCheck(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
const PRUnichar *checkMsg,
|
||||
PRBool *checkValue)
|
||||
{
|
||||
return mPrompt->AlertCheck(dialogTitle, text, checkMsg, checkValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSingleSignOnPrompt::Confirm(const PRUnichar *dialogTitle, const PRUnichar *text, PRBool *_retval)
|
||||
{
|
||||
return mPrompt->Confirm(dialogTitle, text, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSingleSignOnPrompt::ConfirmCheck(const PRUnichar *dialogTitle, const PRUnichar *text,
|
||||
const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
|
||||
{
|
||||
return mPrompt->ConfirmCheck(dialogTitle, text, checkMsg, checkValue, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSingleSignOnPrompt::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text,
|
||||
@ -551,29 +524,6 @@ nsSingleSignOnPrompt::PromptPassword(const PRUnichar *dialogTitle, const PRUnich
|
||||
realm.get(), mPrompt, _retval, savePassword);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSingleSignOnPrompt::Select(const PRUnichar *dialogTitle, const PRUnichar *text, PRUint32 count,
|
||||
const PRUnichar **selectList, PRInt32 *outSelection, PRBool *_retval)
|
||||
{
|
||||
return mPrompt->Select(dialogTitle, text, count, selectList, outSelection, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSingleSignOnPrompt::UniversalDialog(const PRUnichar *titleMessage, const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text, const PRUnichar *checkboxMsg, const PRUnichar *button0Text,
|
||||
const PRUnichar *button1Text, const PRUnichar *button2Text,
|
||||
const PRUnichar *button3Text, const PRUnichar *editfield1Msg,
|
||||
const PRUnichar *editfield2Msg, PRUnichar **editfield1Value,
|
||||
PRUnichar **editfield2Value, const PRUnichar *iconURL,
|
||||
PRBool *checkboxState, PRInt32 numberButtons, PRInt32 numberEditfields,
|
||||
PRInt32 editField1Password, PRInt32 *buttonPressed)
|
||||
{
|
||||
return mPrompt->UniversalDialog(titleMessage, dialogTitle, text, checkboxMsg, button0Text, button1Text,
|
||||
button2Text, button3Text, editfield1Msg, editfield2Msg, editfield1Value,
|
||||
editfield2Value, iconURL, checkboxState, numberButtons, numberEditfields,
|
||||
editField1Password, buttonPressed);
|
||||
}
|
||||
|
||||
// nsISingleSignOnPrompt methods:
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ class nsSingleSignOnPrompt : public nsISingleSignOnPrompt,
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROMPT
|
||||
NS_DECL_NSIAUTHPROMPT
|
||||
NS_DECL_NSISINGLESIGNONPROMPT
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
|
||||
@ -393,50 +393,40 @@ si_CheckGetPassword
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
PRInt32 buttonPressed = 1; /* in case user exits dialog by clickin X */
|
||||
PRUnichar * prompt_string = (PRUnichar*)dialogTitle;
|
||||
if (dialogTitle == nsnull || nsCRT::strlen(dialogTitle) == 0)
|
||||
prompt_string = Wallet_Localize("PromptForPassword");
|
||||
PRUnichar * check_string;
|
||||
|
||||
// According to nsIPrompt spec, the checkbox is shown or not
|
||||
// depending on whether or not checkValue == nsnull, not checkMsg.
|
||||
PRBool * check_value = checkValue;
|
||||
if (savePassword != SINGSIGN_SAVE_PASSWORD_PERMANENTLY) {
|
||||
check_string = nsnull;
|
||||
check_value = nsnull;
|
||||
} else if (SI_GetBoolPref(pref_Crypto, PR_FALSE)) {
|
||||
check_string = Wallet_Localize("SaveThisPasswordEncrypted");
|
||||
} else {
|
||||
check_string = Wallet_Localize("SaveThisPasswordObscured");
|
||||
}
|
||||
|
||||
res = dialog->UniversalDialog(
|
||||
NULL, /* title message */
|
||||
prompt_string, /* title text in top line of window */
|
||||
szMessage, /* this is the main message */
|
||||
check_string, /* This is the checkbox message */
|
||||
NULL, /* first button text, becomes OK by default */
|
||||
NULL, /* second button text, becomes CANCEL by default */
|
||||
NULL, /* third button text */
|
||||
NULL, /* fourth button text */
|
||||
NULL, /* first edit field label */
|
||||
NULL, /* second edit field label */
|
||||
password, /* first edit field initial and final value */
|
||||
NULL, /* second edit field initial and final value */
|
||||
NULL, /* icon: question mark by default */
|
||||
checkValue, /* initial and final value of checkbox */
|
||||
2, /* number of buttons */
|
||||
1, /* number of edit fields */
|
||||
1, /* is first edit field a password field */
|
||||
&buttonPressed);
|
||||
PRBool confirmed = PR_FALSE;
|
||||
res = dialog->PromptPassword(prompt_string,
|
||||
szMessage,
|
||||
password,
|
||||
check_string,
|
||||
check_value,
|
||||
&confirmed);
|
||||
|
||||
if (dialogTitle == nsnull)
|
||||
Recycle(prompt_string);
|
||||
if (check_string)
|
||||
Recycle(check_string);
|
||||
else
|
||||
*checkValue = PR_FALSE;
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
return res;
|
||||
}
|
||||
if (buttonPressed == 0) {
|
||||
if (confirmed) {
|
||||
return NS_OK;
|
||||
} else {
|
||||
return NS_ERROR_FAILURE; /* user pressed cancel */
|
||||
@ -454,50 +444,40 @@ si_CheckGetData
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
PRInt32 buttonPressed = 1; /* in case user exits dialog by clickin X */
|
||||
PRUnichar * prompt_string = (PRUnichar*)dialogTitle;
|
||||
if (dialogTitle == nsnull || nsCRT::strlen(dialogTitle) == 0)
|
||||
prompt_string = Wallet_Localize("PromptForData");
|
||||
PRUnichar * check_string;
|
||||
|
||||
// According to nsIPrompt spec, the checkbox is shown or not
|
||||
// depending on whether or not checkValue == nsnull, not checkMsg.
|
||||
PRBool * check_value = checkValue;
|
||||
if (savePassword != SINGSIGN_SAVE_PASSWORD_PERMANENTLY) {
|
||||
check_string = nsnull;
|
||||
check_value = nsnull;
|
||||
} else if (SI_GetBoolPref(pref_Crypto, PR_FALSE)) {
|
||||
check_string = Wallet_Localize("SaveThisValueEncrypted");
|
||||
} else {
|
||||
check_string = Wallet_Localize("SaveThisValueObscured");
|
||||
}
|
||||
|
||||
res = dialog->UniversalDialog(
|
||||
NULL, /* title message */
|
||||
prompt_string, /* title text in top line of window */
|
||||
szMessage, /* this is the main message */
|
||||
check_string, /* This is the checkbox message */
|
||||
NULL, /* first button text, becomes OK by default */
|
||||
NULL, /* second button text, becomes CANCEL by default */
|
||||
NULL, /* third button text */
|
||||
NULL, /* fourth button text */
|
||||
NULL, /* first edit field label */
|
||||
NULL, /* second edit field label */
|
||||
data, /* first edit field initial and final value */
|
||||
NULL, /* second edit field initial and final value */
|
||||
NULL, /* icon: question mark by default */
|
||||
checkValue, /* initial and final value of checkbox */
|
||||
2, /* number of buttons */
|
||||
1, /* number of edit fields */
|
||||
0, /* is first edit field a password field */
|
||||
&buttonPressed);
|
||||
PRBool confirmed = PR_FALSE;
|
||||
res = dialog->Prompt(prompt_string,
|
||||
szMessage,
|
||||
data,
|
||||
check_string,
|
||||
check_value,
|
||||
&confirmed);
|
||||
|
||||
if (dialogTitle == nsnull || nsCRT::strlen(dialogTitle) == 0)
|
||||
Recycle(prompt_string);
|
||||
if (check_string)
|
||||
Recycle(check_string);
|
||||
else
|
||||
*checkValue = PR_FALSE;
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
return res;
|
||||
}
|
||||
if (buttonPressed == 0) {
|
||||
if (confirmed) {
|
||||
return NS_OK;
|
||||
} else {
|
||||
return NS_ERROR_FAILURE; /* user pressed cancel */
|
||||
@ -515,54 +495,40 @@ si_CheckGetUsernamePassword
|
||||
PRBool* checkValue)
|
||||
{
|
||||
nsresult res;
|
||||
PRInt32 buttonPressed = 1; /* in case user exits dialog by clickin X */
|
||||
PRUnichar * check_string;
|
||||
PRUnichar * prompt_string = (PRUnichar*)dialogTitle;
|
||||
if (dialogTitle == nsnull || nsCRT::strlen(dialogTitle) == 0)
|
||||
prompt_string = Wallet_Localize("PromptForPassword");
|
||||
PRUnichar * user_string = Wallet_Localize("UserName");
|
||||
PRUnichar * password_string = Wallet_Localize("Password");
|
||||
PRUnichar * check_string;
|
||||
|
||||
// According to nsIPrompt spec, the checkbox is shown or not
|
||||
// depending on whether or not checkValue == nsnull, not checkMsg.
|
||||
PRBool * check_value = checkValue;
|
||||
if (savePassword != SINGSIGN_SAVE_PASSWORD_PERMANENTLY) {
|
||||
check_string = nsnull;
|
||||
check_value = nsnull;
|
||||
} else if (SI_GetBoolPref(pref_Crypto, PR_FALSE)) {
|
||||
check_string = Wallet_Localize("SaveTheseValuesEncrypted");
|
||||
} else {
|
||||
check_string = Wallet_Localize("SaveTheseValuesObscured");
|
||||
}
|
||||
|
||||
res = dialog->UniversalDialog(
|
||||
NULL, /* title message */
|
||||
prompt_string, /* title text in top line of window */
|
||||
szMessage, /* this is the main message */
|
||||
check_string, /* This is the checkbox message */
|
||||
NULL, /* first button text, becomes OK by default */
|
||||
NULL, /* second button text, becomes CANCEL by default */
|
||||
NULL, /* third button text */
|
||||
NULL, /* fourth button text */
|
||||
user_string, /* first edit field label */
|
||||
password_string, /* second edit field label */
|
||||
username, /* first edit field initial and final value */
|
||||
password, /* second edit field initial and final value */
|
||||
NULL, /* icon: question mark by default */
|
||||
checkValue, /* initial and final value of checkbox */
|
||||
2, /* number of buttons */
|
||||
2, /* number of edit fields */
|
||||
0, /* is first edit field a password field */
|
||||
&buttonPressed);
|
||||
PRBool confirmed = PR_FALSE;
|
||||
res = dialog->PromptUsernameAndPassword(dialogTitle,
|
||||
szMessage,
|
||||
username, password,
|
||||
check_string,
|
||||
check_value,
|
||||
&confirmed);
|
||||
|
||||
if (dialogTitle == nsnull)
|
||||
if (dialogTitle == nsnull || nsCRT::strlen(dialogTitle) == 0)
|
||||
Recycle(prompt_string);
|
||||
Recycle(user_string);
|
||||
Recycle(password_string);
|
||||
if (check_string)
|
||||
Recycle(check_string);
|
||||
else
|
||||
*checkValue = PR_FALSE;
|
||||
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
return res;
|
||||
}
|
||||
if (buttonPressed == 0) {
|
||||
if (confirmed) {
|
||||
return NS_OK;
|
||||
} else {
|
||||
return NS_ERROR_FAILURE; /* user pressed cancel */
|
||||
@ -2324,27 +2290,23 @@ si_DoDialogIfPrefIsOff(
|
||||
case promptUsernameAndPassword:
|
||||
res = dialog->PromptUsernameAndPassword(prompt_string,
|
||||
text,
|
||||
realm.GetUnicode(),
|
||||
savePassword,
|
||||
user,
|
||||
pwd,
|
||||
nsnull, nsnull,
|
||||
pressedOK);
|
||||
break;
|
||||
case promptPassword:
|
||||
res = dialog->PromptPassword(prompt_string,
|
||||
text,
|
||||
realm.GetUnicode(),
|
||||
savePassword,
|
||||
pwd,
|
||||
nsnull, nsnull,
|
||||
pressedOK);
|
||||
break;
|
||||
case prompt:
|
||||
res = dialog->Prompt(prompt_string,
|
||||
text,
|
||||
realm.GetUnicode(),
|
||||
savePassword,
|
||||
defaultText,
|
||||
resultText,
|
||||
nsnull, nsnull,
|
||||
pressedOK);
|
||||
#ifdef DEBUG
|
||||
break;
|
||||
|
||||
@ -29,6 +29,8 @@ interface nsIDocShell;
|
||||
interface nsIDOMWindowInternal;
|
||||
interface nsIMsgHeaderSink;
|
||||
interface nsIPrompt;
|
||||
interface nsIAuthPrompt;
|
||||
|
||||
/*
|
||||
* This interface can be used to set data specific to a window.
|
||||
*/
|
||||
@ -45,6 +47,7 @@ interface nsIMsgWindow : nsISupports {
|
||||
void displayHTMLInMessagePane(in wstring title, in wstring body);
|
||||
|
||||
readonly attribute nsIPrompt promptDialog;
|
||||
readonly attribute nsIAuthPrompt authPromptDialog;
|
||||
attribute wstring mailCharacterSet;
|
||||
|
||||
void SetDOMWindow(in nsIDOMWindowInternal window);
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsICharsetConverterManager2.h"
|
||||
#include "nsIChannel.h"
|
||||
@ -487,6 +488,26 @@ NS_IMETHODIMP nsMsgWindow::GetPromptDialog(nsIPrompt **aPrompt)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgWindow::GetAuthPromptDialog(nsIAuthPrompt **aPrompt)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_ENSURE_ARG_POINTER(aPrompt);
|
||||
nsCOMPtr<nsIDocShell> rootShell(do_QueryReferent(mRootDocShellWeak));
|
||||
if (rootShell)
|
||||
{
|
||||
nsCOMPtr<nsIAuthPrompt> dialog;
|
||||
dialog = do_GetInterface(rootShell, &rv);
|
||||
if (dialog)
|
||||
{
|
||||
*aPrompt = dialog;
|
||||
NS_ADDREF(*aPrompt);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgWindow::DisplayHTMLInMessagePane(const PRUnichar *title, const PRUnichar *body)
|
||||
{
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIWebShellWindow.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIWalletService.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIStringBundle.h"
|
||||
@ -687,7 +687,7 @@ nsMsgIncomingServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, const
|
||||
NS_ENSURE_ARG_POINTER(okayValue);
|
||||
|
||||
if (m_password.IsEmpty()) {
|
||||
nsCOMPtr<nsIPrompt> dialog;
|
||||
nsCOMPtr<nsIAuthPrompt> dialog;
|
||||
// aMsgWindow is required if we need to prompt
|
||||
if (aMsgWindow)
|
||||
{
|
||||
@ -705,7 +705,7 @@ nsMsgIncomingServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, const
|
||||
{
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (wwatch)
|
||||
wwatch->GetNewPrompter(0, getter_AddRefs(dialog));
|
||||
wwatch->GetNewAuthPrompter(0, getter_AddRefs(dialog));
|
||||
if (!dialog) return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (NS_SUCCEEDED(rv) && dialog)
|
||||
@ -715,7 +715,7 @@ nsMsgIncomingServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, const
|
||||
rv = GetServerURI(getter_Copies(serverUri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = dialog->PromptPassword(aPromptTitle, aPromptMessage,
|
||||
NS_ConvertASCIItoUCS2(serverUri).get(), nsIPrompt::SAVE_PASSWORD_PERMANENTLY,
|
||||
NS_ConvertASCIItoUCS2(serverUri).get(), nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
|
||||
getter_Copies(uniPassword), okayValue);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
@ -77,10 +77,9 @@ function AddDomain(obj)
|
||||
window,
|
||||
obj.DlgTitle,
|
||||
obj.DlgMsg,
|
||||
"",
|
||||
0,
|
||||
result,
|
||||
null,
|
||||
result
|
||||
{value:0}
|
||||
))
|
||||
DomainName = result.value.replace(/ /g,"");
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIPrompt;
|
||||
interface nsIAuthPrompt;
|
||||
|
||||
[scriptable, uuid(c165b634-1dd1-11b2-a849-82dd67b7519e)]
|
||||
interface nsISmtpServer : nsISupports {
|
||||
@ -39,8 +39,8 @@ interface nsISmtpServer : nsISupports {
|
||||
|
||||
readonly attribute string serverURI;
|
||||
string getPasswordWithUI(in wstring promptString, in wstring promptTitle,
|
||||
in nsIPrompt netPrompt);
|
||||
in nsIAuthPrompt netPrompt);
|
||||
void getUsernamePasswordWithUI(in wstring promptString, in wstring promptTitle,
|
||||
in nsIPrompt netPrompt, out string userid, out string password);
|
||||
in nsIAuthPrompt netPrompt, out string userid, out string password);
|
||||
void forgetPassword();
|
||||
};
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
|
||||
interface nsIMsgIdentity;
|
||||
interface nsIPrompt;
|
||||
interface nsIAuthPrompt;
|
||||
interface nsISmtpServer;
|
||||
interface nsIInterfaceRequestor;
|
||||
|
||||
@ -66,6 +67,7 @@ interface nsISmtpUrl : nsISupports {
|
||||
// smtp://sspitzer@tintin/...
|
||||
attribute nsIMsgIdentity senderIdentity;
|
||||
attribute nsIPrompt prompt;
|
||||
attribute nsIAuthPrompt authPrompt;
|
||||
attribute nsIInterfaceRequestor notificationCallbacks;
|
||||
attribute nsISmtpServer smtpServer;
|
||||
};
|
||||
|
||||
@ -1043,14 +1043,14 @@ function GenericSendMessage( msgType )
|
||||
{
|
||||
if (promptService)
|
||||
{
|
||||
var result = {value:0};
|
||||
var result = {value:gComposeMsgsBundle.getString("defaultSubject")};
|
||||
if (promptService.prompt(
|
||||
window,
|
||||
gComposeMsgsBundle.getString("subjectDlogTitle"),
|
||||
gComposeMsgsBundle.getString("subjectDlogMessage"),
|
||||
"", 0,
|
||||
gComposeMsgsBundle.getString("defaultSubject"),
|
||||
result
|
||||
result,
|
||||
null,
|
||||
{value:0}
|
||||
))
|
||||
{
|
||||
msgCompFields.subject = result.value;
|
||||
@ -1521,9 +1521,9 @@ function AttachPage()
|
||||
window,
|
||||
gComposeMsgsBundle.getString("attachPageDlogTitle"),
|
||||
gComposeMsgsBundle.getString("attachPageDlogMessage"),
|
||||
"", 0,
|
||||
result,
|
||||
null,
|
||||
result))
|
||||
{value:0}))
|
||||
{
|
||||
AddAttachment(result.value, null);
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsMsgCompCID.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsIMsgIdentity.h"
|
||||
@ -1601,8 +1602,8 @@ nsSmtpProtocol::GetPassword(char **aPassword)
|
||||
nsCRT::free(*aPassword);
|
||||
*aPassword = 0;
|
||||
|
||||
nsCOMPtr<nsIPrompt> netPrompt;
|
||||
rv = smtpUrl->GetPrompt(getter_AddRefs(netPrompt));
|
||||
nsCOMPtr<nsIAuthPrompt> netPrompt;
|
||||
rv = smtpUrl->GetAuthPrompt(getter_AddRefs(netPrompt));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString username;
|
||||
@ -1680,8 +1681,8 @@ nsSmtpProtocol::GetUsernamePassword(char **aUsername, char **aPassword)
|
||||
nsCRT::free(*aPassword);
|
||||
*aPassword = 0;
|
||||
|
||||
nsCOMPtr<nsIPrompt> netPrompt;
|
||||
rv = smtpUrl->GetPrompt(getter_AddRefs(netPrompt));
|
||||
nsCOMPtr<nsIAuthPrompt> netPrompt;
|
||||
rv = smtpUrl->GetAuthPrompt(getter_AddRefs(netPrompt));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString hostname;
|
||||
|
||||
@ -209,7 +209,7 @@ nsSmtpServer::SetPassword(const char * aPassword)
|
||||
NS_IMETHODIMP
|
||||
nsSmtpServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, const
|
||||
PRUnichar *aPromptTitle,
|
||||
nsIPrompt* aDialog,
|
||||
nsIAuthPrompt* aDialog,
|
||||
char **aPassword)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
@ -228,7 +228,7 @@ nsSmtpServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, const
|
||||
rv = GetServerURI(getter_Copies(serverUri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = aDialog->PromptPassword(aPromptTitle, aPromptMessage,
|
||||
NS_ConvertASCIItoUCS2(serverUri).get(), nsIPrompt::SAVE_PASSWORD_PERMANENTLY,
|
||||
NS_ConvertASCIItoUCS2(serverUri).get(), nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
|
||||
getter_Copies(uniPassword), &okayValue);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
@ -253,7 +253,7 @@ nsSmtpServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, const
|
||||
NS_IMETHODIMP
|
||||
nsSmtpServer::GetUsernamePasswordWithUI(const PRUnichar * aPromptMessage, const
|
||||
PRUnichar *aPromptTitle,
|
||||
nsIPrompt* aDialog,
|
||||
nsIAuthPrompt* aDialog,
|
||||
char **aUsername,
|
||||
char **aPassword)
|
||||
{
|
||||
@ -275,7 +275,7 @@ nsSmtpServer::GetUsernamePasswordWithUI(const PRUnichar * aPromptMessage, const
|
||||
rv = GetServerURI(getter_Copies(serverUri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = aDialog->PromptUsernameAndPassword(aPromptTitle, aPromptMessage,
|
||||
NS_ConvertASCIItoUCS2(serverUri).get(), nsIPrompt::SAVE_PASSWORD_PERMANENTLY,
|
||||
NS_ConvertASCIItoUCS2(serverUri).get(), nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
|
||||
getter_Copies(uniUsername), getter_Copies(uniPassword), &okayValue);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
@ -187,15 +187,21 @@ nsresult NS_MsgBuildSmtpUrl(nsIFileSpec * aFilePath,
|
||||
smtpUrl->SetPostMessageFile(aFilePath);
|
||||
smtpUrl->SetSenderIdentity(aSenderIdentity);
|
||||
smtpUrl->SetNotificationCallbacks(aNotificationCallbacks);
|
||||
|
||||
nsCOMPtr<nsIPrompt> smtpPrompt(do_GetInterface(aNotificationCallbacks));
|
||||
if (!smtpPrompt)
|
||||
nsCOMPtr<nsIAuthPrompt> smtpAuthPrompt(do_GetInterface(aNotificationCallbacks));
|
||||
if (!smtpPrompt || !smtpAuthPrompt)
|
||||
{
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (wwatch)
|
||||
wwatch->GetNewPrompter(0, getter_AddRefs(smtpPrompt));
|
||||
if (wwatch) {
|
||||
if (!smtpPrompt)
|
||||
wwatch->GetNewPrompter(0, getter_AddRefs(smtpPrompt));
|
||||
if (!smtpAuthPrompt)
|
||||
wwatch->GetNewAuthPrompter(0, getter_AddRefs(smtpAuthPrompt));
|
||||
}
|
||||
}
|
||||
|
||||
smtpUrl->SetPrompt(smtpPrompt);
|
||||
smtpUrl->SetPrompt(smtpPrompt);
|
||||
smtpUrl->SetAuthPrompt(smtpAuthPrompt);
|
||||
url->RegisterListener(aUrlListener);
|
||||
}
|
||||
rv = smtpUrl->QueryInterface(NS_GET_IID(nsIURI), (void **) aUrl);
|
||||
|
||||
@ -534,6 +534,24 @@ nsSmtpUrl::GetPrompt(nsIPrompt **aNetPrompt)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSmtpUrl::SetAuthPrompt(nsIAuthPrompt *aNetAuthPrompt)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNetAuthPrompt);
|
||||
m_netAuthPrompt = aNetAuthPrompt;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSmtpUrl::GetAuthPrompt(nsIAuthPrompt **aNetAuthPrompt)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNetAuthPrompt);
|
||||
if (!m_netAuthPrompt) return NS_ERROR_NULL_POINTER;
|
||||
*aNetAuthPrompt = m_netAuthPrompt;
|
||||
NS_ADDREF(*aNetAuthPrompt);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSmtpUrl::SetNotificationCallbacks(nsIInterfaceRequestor* aCallbacks)
|
||||
{
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
#include "nsIMsgIdentity.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsISmtpServer.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
||||
@ -101,6 +102,7 @@ protected:
|
||||
nsCOMPtr<nsIFileSpec> m_fileName;
|
||||
nsCOMPtr<nsIMsgIdentity> m_senderIdentity;
|
||||
nsCOMPtr<nsIPrompt> m_netPrompt;
|
||||
nsCOMPtr<nsIAuthPrompt> m_netAuthPrompt;
|
||||
nsCOMPtr<nsIInterfaceRequestor> m_callbacks;
|
||||
nsCOMPtr<nsISmtpServer> m_smtpServer;
|
||||
|
||||
|
||||
@ -1444,7 +1444,7 @@ nsMsgNewsFolder::GetGroupPasswordWithUI(const PRUnichar * aPromptMessage, const
|
||||
if (!mGroupPassword) {
|
||||
// prompt the user for the password
|
||||
|
||||
nsCOMPtr<nsIPrompt> dialog;
|
||||
nsCOMPtr<nsIAuthPrompt> dialog;
|
||||
#ifdef DEBUG_seth
|
||||
NS_ASSERTION(aMsgWindow,"no msg window");
|
||||
#endif
|
||||
@ -1463,7 +1463,7 @@ nsMsgNewsFolder::GetGroupPasswordWithUI(const PRUnichar * aPromptMessage, const
|
||||
else {
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (wwatch)
|
||||
wwatch->GetNewPrompter(0, getter_AddRefs(dialog));
|
||||
wwatch->GetNewAuthPrompter(0, getter_AddRefs(dialog));
|
||||
|
||||
if (!dialog) return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -1480,7 +1480,7 @@ nsMsgNewsFolder::GetGroupPasswordWithUI(const PRUnichar * aPromptMessage, const
|
||||
|
||||
nsAutoString realm;
|
||||
CopyASCIItoUCS2(nsLiteralCString(NS_STATIC_CAST(const char*, signonURL)), realm);
|
||||
rv = dialog->PromptPassword(aPromptTitle, aPromptMessage, realm.GetUnicode(), nsIPrompt::SAVE_PASSWORD_PERMANENTLY,
|
||||
rv = dialog->PromptPassword(aPromptTitle, aPromptMessage, realm.GetUnicode(), nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
|
||||
getter_Copies(uniGroupPassword), &okayValue);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
@ -1515,7 +1515,7 @@ nsMsgNewsFolder::GetGroupUsernameWithUI(const PRUnichar * aPromptMessage, const
|
||||
if (!mGroupUsername) {
|
||||
// prompt the user for the username
|
||||
|
||||
nsCOMPtr<nsIPrompt> dialog;
|
||||
nsCOMPtr<nsIAuthPrompt> dialog;
|
||||
#ifdef DEBUG_seth
|
||||
NS_ASSERTION(aMsgWindow,"no msg window");
|
||||
#endif
|
||||
@ -1532,7 +1532,7 @@ nsMsgNewsFolder::GetGroupUsernameWithUI(const PRUnichar * aPromptMessage, const
|
||||
else {
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (wwatch)
|
||||
wwatch->GetNewPrompter(0, getter_AddRefs(dialog));
|
||||
wwatch->GetNewAuthPrompter(0, getter_AddRefs(dialog));
|
||||
|
||||
if (!dialog) return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -1550,7 +1550,7 @@ nsMsgNewsFolder::GetGroupUsernameWithUI(const PRUnichar * aPromptMessage, const
|
||||
nsAutoString realm;
|
||||
CopyASCIItoUCS2(nsLiteralCString(NS_STATIC_CAST(const char*, signonURL)), realm);
|
||||
rv = dialog->Prompt(aPromptTitle, aPromptMessage, realm.GetUnicode(),
|
||||
nsIPrompt::SAVE_PASSWORD_PERMANENTLY, nsnull,
|
||||
nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY, nsnull,
|
||||
getter_Copies(uniGroupUsername), &okayValue);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#
|
||||
|
||||
nsIAuthenticator.idl
|
||||
nsIAuthPrompt.idl
|
||||
nsIChannel.idl
|
||||
nsIFileChannel.idl
|
||||
nsIDownloader.idl
|
||||
|
||||
@ -30,6 +30,7 @@ MODULE = necko
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIAuthenticator.idl \
|
||||
nsIAuthPrompt.idl \
|
||||
nsIChannel.idl \
|
||||
nsIFileChannel.idl \
|
||||
nsIDownloader.idl \
|
||||
|
||||
@ -32,6 +32,7 @@ EXPORTS = \
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\nsIAuthenticator.idl \
|
||||
.\nsIAuthPrompt.idl \
|
||||
.\nsIChannel.idl \
|
||||
.\nsIFileChannel.idl \
|
||||
.\nsIFileStreams.idl \
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIPrompt.idl"
|
||||
#include "nsIAuthPrompt.idl"
|
||||
#include "nsIURL.idl"
|
||||
|
||||
[scriptable,uuid(adf74d2a-1dd1-11b2-b129-f3154be37959)]
|
||||
@ -47,7 +47,7 @@ interface nsIAuthenticator : nsISupports
|
||||
*/
|
||||
string authenticate(in nsIURI uri, in string protocol, in string challenge,
|
||||
in wstring username, in wstring password,
|
||||
in nsIPrompt prompter);
|
||||
in nsIAuthPrompt prompter);
|
||||
|
||||
/**
|
||||
* No interaction with the user required. This indicates that the
|
||||
|
||||
@ -61,44 +61,66 @@ interface nsIPrompt : nsISupports
|
||||
out boolean checkValue);
|
||||
|
||||
/**
|
||||
* Values for the savePassword parameter to prompt, promptPassword and
|
||||
* promptUsernameAndPassword.
|
||||
*/
|
||||
const PRUint32 SAVE_PASSWORD_NEVER = 0;
|
||||
const PRUint32 SAVE_PASSWORD_FOR_SESSION = 1;
|
||||
const PRUint32 SAVE_PASSWORD_PERMANENTLY = 2;
|
||||
* Puts up a dialog with an edit field and an optional checkbox.
|
||||
*
|
||||
* @param dialogTitle
|
||||
* @param text
|
||||
* @param value in: Pre-fills the dialog field if non-null
|
||||
* out: If result is true, a newly allocated
|
||||
* string. If result is false, in string is not
|
||||
* touched.
|
||||
* @param checkMsg if null, will use default title - "Remember Value"
|
||||
* @param checkValue if null, check box will not be shown
|
||||
* @return true for OK, false for Cancel
|
||||
*/
|
||||
boolean prompt(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
inout wstring value,
|
||||
in wstring checkMsg,
|
||||
inout boolean checkValue);
|
||||
|
||||
/**
|
||||
* Puts up a text input dialog with OK and Cancel buttons.
|
||||
* Puts up a dialog with a password field and an optional checkbox.
|
||||
*
|
||||
* @param dialogTitle
|
||||
* @param text
|
||||
* @param password in: Pre-fills the dialog field if non-null
|
||||
* out: If result is true, a newly allocated
|
||||
* string. If result is false, in string is not
|
||||
* touched.
|
||||
* @param checkMsg if null, will use default title - "Remember Password"
|
||||
* @param checkValue if null, check box will not be shown
|
||||
* @return true for OK, false for Cancel
|
||||
*/
|
||||
boolean prompt(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
in wstring passwordRealm,
|
||||
in PRUint32 savePassword,
|
||||
in wstring defaultText,
|
||||
out wstring result);
|
||||
|
||||
*/
|
||||
boolean promptPassword(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
inout wstring password,
|
||||
in wstring checkMsg,
|
||||
inout boolean checkValue);
|
||||
|
||||
/**
|
||||
* Puts up a username/password dialog with OK and Cancel buttons.
|
||||
* Puts up a dialog with an edit field, a password field, and an optional checkbox.
|
||||
*
|
||||
* @param dialogTitle
|
||||
* @param text
|
||||
* @param username in: Pre-fills the dialog field if non-null
|
||||
* out: If result is true, a newly allocated
|
||||
* string. If result is false, in string is not
|
||||
* touched.
|
||||
* @param password in: Pre-fills the dialog field if non-null
|
||||
* out: If result is true, a newly allocated
|
||||
* string. If result is false, in string is not
|
||||
* touched.
|
||||
* @param checkMsg if null, will use default title - "Remember Name and Password"
|
||||
* @param checkValue if null, check box will not be shown
|
||||
* @return true for OK, false for Cancel
|
||||
*/
|
||||
boolean promptUsernameAndPassword(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
in wstring passwordRealm,
|
||||
in PRUint32 savePassword,
|
||||
out wstring user,
|
||||
out wstring pwd);
|
||||
|
||||
/**
|
||||
* Puts up a password dialog with OK and Cancel buttons.
|
||||
* @return true for OK, false for Cancel
|
||||
*/
|
||||
boolean promptPassword(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
in wstring passwordRealm,
|
||||
in PRUint32 savePassword,
|
||||
out wstring pwd);
|
||||
*/
|
||||
boolean promptUsernameAndPassword(in wstring dialogTitle,
|
||||
in wstring text,
|
||||
inout wstring username,
|
||||
inout wstring password,
|
||||
in wstring checkMsg,
|
||||
inout boolean checkValue);
|
||||
|
||||
/**
|
||||
* Puts up a dialog box which has a list box of strings
|
||||
|
||||
Binary file not shown.
@ -273,7 +273,7 @@ nsFTPChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt)
|
||||
if (!mFTPState) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(mFTPState);
|
||||
}
|
||||
rv = mFTPState->Init(this, mPrompter);
|
||||
rv = mFTPState->Init(this, mPrompter, mAuthPrompter);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mFTPState->Connect();
|
||||
@ -405,8 +405,11 @@ nsFTPChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallb
|
||||
|
||||
(void)mCallbacks->GetInterface(NS_GET_IID(nsIPrompt),
|
||||
getter_AddRefs(mPrompter));
|
||||
|
||||
NS_ASSERTION ( mPrompter, "Channel doesn't have a prompt!!!" );
|
||||
|
||||
(void)mCallbacks->GetInterface(NS_GET_IID(nsIAuthPrompt),
|
||||
getter_AddRefs(mAuthPrompter));
|
||||
NS_ASSERTION ( mAuthPrompter, "Channel doesn't have an auth prompt!!!" );
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsAutoLock.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIFTPChannel.h"
|
||||
#include "nsIProxy.h"
|
||||
|
||||
@ -90,6 +91,7 @@ protected:
|
||||
nsCOMPtr<nsIURI> mURL;
|
||||
nsCOMPtr<nsIProgressEventSink> mEventSink;
|
||||
nsCOMPtr<nsIPrompt> mPrompter;
|
||||
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
|
||||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
|
||||
PRBool mConnected;
|
||||
|
||||
@ -1061,7 +1061,7 @@ nsFtpState::S_user() {
|
||||
usernameStr.Append("anonymous");
|
||||
} else {
|
||||
if (!mUsername.Length()) {
|
||||
if (!mPrompter) return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mAuthPrompter) return NS_ERROR_NOT_INITIALIZED;
|
||||
PRUnichar *user = nsnull, *passwd = nsnull;
|
||||
PRBool retval;
|
||||
nsXPIDLCString host;
|
||||
@ -1072,10 +1072,10 @@ nsFtpState::S_user() {
|
||||
|
||||
nsAutoString realm; // XXX i18n
|
||||
CopyASCIItoUCS2(nsLiteralCString(NS_STATIC_CAST(const char*, host)), realm);
|
||||
rv = mPrompter->PromptUsernameAndPassword(nsnull,
|
||||
message.GetUnicode(),
|
||||
realm.GetUnicode(), nsIPrompt::SAVE_PASSWORD_PERMANENTLY,
|
||||
&user, &passwd, &retval);
|
||||
rv = mAuthPrompter->PromptUsernameAndPassword(nsnull,
|
||||
message.GetUnicode(),
|
||||
realm.GetUnicode(), nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
|
||||
&user, &passwd, &retval);
|
||||
|
||||
// if the user canceled or didn't supply a username we want to fail
|
||||
if (!retval || (user && !*user) )
|
||||
@ -1139,7 +1139,7 @@ nsFtpState::S_pass() {
|
||||
}
|
||||
} else {
|
||||
if (!mPassword.Length() || mRetryPass) {
|
||||
if (!mPrompter) return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mAuthPrompter) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
PRUnichar *passwd = nsnull;
|
||||
PRBool retval;
|
||||
@ -1156,11 +1156,11 @@ nsFtpState::S_pass() {
|
||||
nsXPIDLCString prePath;
|
||||
rv = mURL->GetPrePath(getter_Copies(prePath));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = mPrompter->PromptPassword(title.GetUnicode(),
|
||||
message.GetUnicode(),
|
||||
NS_ConvertASCIItoUCS2(prePath).GetUnicode(),
|
||||
nsIPrompt::SAVE_PASSWORD_PERMANENTLY,
|
||||
&passwd, &retval);
|
||||
rv = mAuthPrompter->PromptPassword(title.GetUnicode(),
|
||||
message.GetUnicode(),
|
||||
NS_ConvertASCIItoUCS2(prePath).GetUnicode(),
|
||||
nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
|
||||
&passwd, &retval);
|
||||
|
||||
// we want to fail if the user canceled or didn't enter a password.
|
||||
if (!retval || (passwd && !*passwd) )
|
||||
@ -1929,11 +1929,13 @@ nsFtpState::SetLoadFlags(nsLoadFlags aLoadFlags)
|
||||
|
||||
nsresult
|
||||
nsFtpState::Init(nsIFTPChannel* aChannel,
|
||||
nsIPrompt* aPrompter) {
|
||||
nsIPrompt* aPrompter,
|
||||
nsIAuthPrompt* aAuthPrompter) {
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
mKeepRunning = PR_TRUE;
|
||||
mPrompter = aPrompter;
|
||||
mAuthPrompter = aAuthPrompter;
|
||||
|
||||
// parameter validation
|
||||
NS_ASSERTION(aChannel, "FTP: needs a channel");
|
||||
@ -2177,6 +2179,7 @@ nsFtpState::StopProcessing() {
|
||||
mWriteStream = 0;
|
||||
|
||||
mPrompter = 0;
|
||||
mAuthPrompter = 0;
|
||||
mChannel = 0;
|
||||
|
||||
#ifdef DOUGT_NEW_CACHE
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
#include "nsAutoLock.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsITransport.h"
|
||||
|
||||
#include "nsFtpControlConnection.h"
|
||||
@ -105,7 +106,7 @@ public:
|
||||
nsFtpState();
|
||||
virtual ~nsFtpState();
|
||||
|
||||
nsresult Init(nsIFTPChannel *aChannel, nsIPrompt *aPrompter);
|
||||
nsresult Init(nsIFTPChannel *aChannel, nsIPrompt *aPrompter, nsIAuthPrompt *aAuthPrompter);
|
||||
|
||||
// use this to provide a stream to be written to the server.
|
||||
nsresult SetWriteStream(nsIInputStream* aInStream, PRUint32 aWriteCount);
|
||||
@ -210,6 +211,7 @@ private:
|
||||
PRBool mGenerateHTMLContent;
|
||||
PRPackedBool mIPv6Checked;
|
||||
nsCOMPtr<nsIPrompt> mPrompter;
|
||||
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
|
||||
char *mIPv6ServerAddress; // Server IPv6 address; null if server not IPv6
|
||||
|
||||
// ***** control read gvars
|
||||
|
||||
@ -30,7 +30,7 @@ interface nsISimpleEnumerator;
|
||||
interface nsIAtom;
|
||||
interface nsIInputStream;
|
||||
interface nsIURI;
|
||||
interface nsIPrompt;
|
||||
interface nsIAuthPrompt;
|
||||
|
||||
[scriptable, uuid(35c00430-1938-11d3-933a-000064657374)]
|
||||
interface nsIHTTPChannel : nsIChannel
|
||||
@ -107,7 +107,7 @@ interface nsIHTTPChannel : nsIChannel
|
||||
readonly attribute PRBool usingProxy;
|
||||
readonly attribute PRBool usingTransparentProxy;
|
||||
|
||||
readonly attribute nsIPrompt prompter;
|
||||
readonly attribute nsIAuthPrompt authPrompter;
|
||||
|
||||
/*
|
||||
This string if set is used for forming the final request. So if you
|
||||
|
||||
@ -44,7 +44,7 @@ nsBasicAuth::~nsBasicAuth()
|
||||
nsresult
|
||||
nsBasicAuth::Authenticate(nsIURI *aURI, const char *aProtocol,
|
||||
const char *aChallenge, const PRUnichar *aUser,
|
||||
const PRUnichar *aPass, nsIPrompt *aPrompt,
|
||||
const PRUnichar *aPass, nsIAuthPrompt *aPrompt,
|
||||
char **aResult)
|
||||
{
|
||||
// we only know how to deal with Basic auth for http.
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIProxy.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
@ -185,7 +185,7 @@ nsHTTPChannel::~nsHTTPChannel()
|
||||
|
||||
mHandler = 0;
|
||||
mEventSink = 0;
|
||||
mPrompter = 0;
|
||||
mAuthPrompter = 0;
|
||||
mResponseContext = 0;
|
||||
mLoadGroup = 0;
|
||||
|
||||
@ -541,7 +541,7 @@ nsHTTPChannel::SetNotificationCallbacks(nsIInterfaceRequestor *aCallbacks)
|
||||
// Verify that the event sink is http
|
||||
if (mCallbacks) {
|
||||
mRealEventSink = do_GetInterface(mCallbacks);
|
||||
mRealPrompter = do_GetInterface(mCallbacks);
|
||||
mRealAuthPrompter = do_GetInterface(mCallbacks);
|
||||
mRealProgressEventSink = do_GetInterface(mCallbacks);
|
||||
|
||||
rv = BuildNotificationProxies();
|
||||
@ -573,13 +573,13 @@ nsHTTPChannel::BuildNotificationProxies()
|
||||
getter_AddRefs(mEventSink));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
if (mRealPrompter) {
|
||||
|
||||
if (mRealAuthPrompter) {
|
||||
rv = proxyManager->GetProxyForObject(eventQ,
|
||||
NS_GET_IID(nsIPrompt),
|
||||
mRealPrompter,
|
||||
NS_GET_IID(nsIAuthPrompt),
|
||||
mRealAuthPrompter,
|
||||
PROXY_SYNC | PROXY_ALWAYS,
|
||||
getter_AddRefs(mPrompter));
|
||||
getter_AddRefs(mAuthPrompter));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
@ -2699,8 +2699,8 @@ nsHTTPChannel::Authenticate(const char *aChallenge, PRBool aProxyAuth)
|
||||
// Skip prompting if we already have an authentication string.
|
||||
if (!authString || !*authString) {
|
||||
// Delay this check until we absolutely would need the prompter
|
||||
if (!mPrompter) {
|
||||
NS_WARNING("Failed to prompt for username/password: nsHTTPChannel::mPrompter == NULL");
|
||||
if (!mAuthPrompter) {
|
||||
NS_WARNING("Failed to prompt for username/password: nsHTTPChannel::mAuthPrompter == NULL");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -2719,11 +2719,11 @@ nsHTTPChannel::Authenticate(const char *aChallenge, PRBool aProxyAuth)
|
||||
nsAutoString prePath; // XXX i18n
|
||||
CopyASCIItoUCS2(nsLiteralCString(
|
||||
NS_STATIC_CAST(const char*, urlCString)), prePath);
|
||||
rv = mPrompter->PromptUsernameAndPassword(
|
||||
rv = mAuthPrompter->PromptUsernameAndPassword(
|
||||
nsnull,
|
||||
message.GetUnicode(),
|
||||
prePath.GetUnicode(),
|
||||
nsIPrompt::SAVE_PASSWORD_PERMANENTLY,
|
||||
nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
|
||||
getter_Copies(userBuf),
|
||||
getter_Copies(passwdBuf),
|
||||
&retval);
|
||||
@ -2741,7 +2741,7 @@ nsHTTPChannel::Authenticate(const char *aChallenge, PRBool aProxyAuth)
|
||||
|
||||
if (NS_FAILED(rv) ||
|
||||
NS_FAILED(rv = auth->Authenticate(mURI, "http", authLine.get(),
|
||||
userBuf, passwdBuf, mPrompter,
|
||||
userBuf, passwdBuf, mAuthPrompter,
|
||||
getter_Copies(authString))))
|
||||
return rv;
|
||||
}
|
||||
@ -3273,10 +3273,10 @@ nsHTTPChannel::GetUsingTransparentProxy(PRBool *aUsingProxy)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTTPChannel::GetPrompter(nsIPrompt **aPrompter)
|
||||
nsHTTPChannel::GetAuthPrompter(nsIAuthPrompt **aPrompter)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPrompter);
|
||||
*aPrompter = mPrompter;
|
||||
*aPrompter = mAuthPrompter;
|
||||
NS_IF_ADDREF(*aPrompter);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
#include "nsHTTPResponseListener.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIProxy.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIHTTPEventSink.h"
|
||||
|
||||
#ifdef MOZ_NEW_CACHE
|
||||
@ -182,8 +182,8 @@ protected:
|
||||
// Various event sinks
|
||||
nsCOMPtr<nsIHTTPEventSink> mEventSink;
|
||||
nsCOMPtr<nsIHTTPEventSink> mRealEventSink;
|
||||
nsCOMPtr<nsIPrompt> mPrompter;
|
||||
nsCOMPtr<nsIPrompt> mRealPrompter;
|
||||
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
|
||||
nsCOMPtr<nsIAuthPrompt> mRealAuthPrompter;
|
||||
nsCOMPtr<nsIProgressEventSink> mProgressEventSink;
|
||||
nsCOMPtr<nsIProgressEventSink> mRealProgressEventSink;
|
||||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
|
||||
@ -69,14 +69,14 @@ function RenameProfile()
|
||||
}
|
||||
else {
|
||||
var oldName = selected.getAttribute("rowName");
|
||||
var result = { };
|
||||
var newName = {value:oldName};
|
||||
var dialogTitle = gProfileManagerBundle.getString("renameprofiletitle");
|
||||
var msg = gProfileManagerBundle.getString("renameProfilePrompt");
|
||||
msg = msg.replace(/%oldProfileName%/gi, oldName);
|
||||
while (1) {
|
||||
var rv = promptService.prompt(window, dialogTitle, msg, "", 0, oldName, result);
|
||||
var rv = promptService.prompt(window, dialogTitle, msg, newName, null, {value:0});
|
||||
if (rv) {
|
||||
var newName = result.value;
|
||||
var newName = newName.value;
|
||||
if (!newName) return false;
|
||||
var invalidChars = ["/", "\\", "*", ":"];
|
||||
for( var i = 0; i < invalidChars.length; i++ )
|
||||
|
||||
@ -2271,12 +2271,11 @@ nsBrowserWindow::ConfirmCheck(const PRUnichar *dialogTitle,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserWindow::Prompt(const PRUnichar *dialogTitle,
|
||||
nsBrowserWindow::Prompt(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
const PRUnichar *passwordRealm,
|
||||
PRUint32 savePassword,
|
||||
const PRUnichar *defaultText,
|
||||
PRUnichar **result,
|
||||
PRUnichar **answer,
|
||||
const PRUnichar *checkMsg,
|
||||
PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
nsCAutoString str; str.AssignWithConversion(text);
|
||||
@ -2284,58 +2283,31 @@ nsBrowserWindow::Prompt(const PRUnichar *dialogTitle,
|
||||
char buf[256];
|
||||
|
||||
msg = str.get();
|
||||
if (nsnull != msg) {
|
||||
if (nsnull != msg && nsnull != answer) {
|
||||
printf("Browser Window: %s\n", msg);
|
||||
|
||||
printf("%cPrompt: ", '\007');
|
||||
scanf("%s", buf);
|
||||
nsAutoString response; response.AssignWithConversion(buf);
|
||||
*result = response.ToNewUnicode();
|
||||
if (*answer) {
|
||||
nsMemory::Free(*answer);
|
||||
*answer = nsnull;
|
||||
}
|
||||
*answer = response.ToNewUnicode();
|
||||
*_retval = (*answer && nsCRT::strlen(*answer) > 0);
|
||||
}
|
||||
else
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
*_retval = (nsCRT::strlen(buf) > 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserWindow::PromptUsernameAndPassword(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
const PRUnichar *passwordRealm,
|
||||
PRUint32 savePassword,
|
||||
PRUnichar **user,
|
||||
PRUnichar **pwd,
|
||||
PRBool *_retval)
|
||||
{
|
||||
nsCAutoString str; str.AssignWithConversion(text);
|
||||
const char* msg = nsnull;
|
||||
char buf[256];
|
||||
|
||||
msg = str.get();
|
||||
if (nsnull != msg) {
|
||||
nsAutoString response;
|
||||
printf("Browser Window: %s\n", msg);
|
||||
|
||||
printf("%cUser: ", '\007');
|
||||
scanf("%s", buf);
|
||||
response.AssignWithConversion(buf);
|
||||
*user = response.ToNewUnicode();
|
||||
|
||||
printf("%cPassword: ", '\007');
|
||||
scanf("%s", buf);
|
||||
response.AssignWithConversion(buf);
|
||||
*pwd = response.ToNewUnicode();
|
||||
}
|
||||
|
||||
*_retval = (nsCRT::strlen(*user) > 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserWindow::PromptPassword(const PRUnichar *dialogTitle,
|
||||
nsBrowserWindow::PromptPassword(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
const PRUnichar *passwordRealm,
|
||||
PRUint32 savePassword,
|
||||
PRUnichar **pwd,
|
||||
PRUnichar **password,
|
||||
const PRUnichar *checkMsg,
|
||||
PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
nsCAutoString str; str.AssignWithConversion(text);
|
||||
@ -2343,15 +2315,66 @@ nsBrowserWindow::PromptPassword(const PRUnichar *dialogTitle,
|
||||
char buf[256];
|
||||
|
||||
msg = str.get();
|
||||
if (nsnull != msg) {
|
||||
if (nsnull != msg && nsnull != password) {
|
||||
printf("Browser Window: %s\n", msg);
|
||||
printf("%cPassword: ", '\007');
|
||||
scanf("%s", buf);
|
||||
nsAutoString response; response.AssignWithConversion(buf);
|
||||
*pwd = response.ToNewUnicode();
|
||||
if (*password) {
|
||||
nsMemory::Free(*password);
|
||||
*password = nsnull;
|
||||
}
|
||||
*password = response.ToNewUnicode();
|
||||
*_retval = (*password && nsCRT::strlen(*password) > 0);
|
||||
}
|
||||
else
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
*_retval = (nsCRT::strlen(*pwd) > 0);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -605,20 +605,20 @@ NS_IMETHODIMP nsWebBrowserChrome::ConfirmCheck(const PRUnichar *dialogTitle, con
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* boolean prompt (in wstring dialogTitle, in wstring text, in wstring passwordRealm, in PRUint32 savePassword, in wstring defaultText, out wstring result); */
|
||||
NS_IMETHODIMP nsWebBrowserChrome::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *passwordRealm, PRUint32 savePassword, const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval)
|
||||
/* 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, in wstring passwordRealm, in PRUint32 savePassword, out wstring user, out wstring pwd); */
|
||||
NS_IMETHODIMP nsWebBrowserChrome::PromptUsernameAndPassword(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *passwordRealm, PRUint32 savePassword, PRUnichar **user, PRUnichar **pwd, PRBool *_retval)
|
||||
/* 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, in wstring passwordRealm, in PRUint32 savePassword, out wstring pwd); */
|
||||
NS_IMETHODIMP nsWebBrowserChrome::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *passwordRealm, PRUint32 savePassword, PRUnichar **pwd, PRBool *_retval)
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@ -30,7 +30,6 @@ class nsIWebShell;
|
||||
class nsIWidget;
|
||||
class nsString;
|
||||
class nsIDOMWindowInternal;
|
||||
class nsIPrompt;
|
||||
|
||||
// Interface ID for nsIWebShellWindow
|
||||
#define NS_IWEBSHELL_WINDOW_IID \
|
||||
@ -62,8 +61,6 @@ public:
|
||||
* @return always NS_OK
|
||||
*/
|
||||
NS_IMETHOD ShouldLoadDefaultPage(PRBool *aYes) = 0;
|
||||
|
||||
NS_IMETHOD GetPrompter(nsIPrompt* *result) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
|
||||
// Interfaces needed to include
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
|
||||
// CIDs
|
||||
@ -76,7 +77,8 @@ NS_IMETHODIMP nsChromeTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
|
||||
|
||||
if(aIID.Equals(NS_GET_IID(nsIPrompt)))
|
||||
return mXULWindow->GetInterface(aIID, aSink);
|
||||
|
||||
if(aIID.Equals(NS_GET_IID(nsIAuthPrompt)))
|
||||
return mXULWindow->GetInterface(aIID, aSink);
|
||||
if(aIID.Equals(NS_GET_IID(nsIWebBrowserChrome)))
|
||||
return mXULWindow->GetInterface(aIID, aSink);
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsIXULBrowserWindow.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
@ -85,7 +86,8 @@ NS_IMETHODIMP nsContentTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
|
||||
|
||||
if(aIID.Equals(NS_GET_IID(nsIPrompt)))
|
||||
return mXULWindow->GetInterface(aIID, aSink);
|
||||
|
||||
if(aIID.Equals(NS_GET_IID(nsIAuthPrompt)))
|
||||
return mXULWindow->GetInterface(aIID, aSink);
|
||||
if (aIID.Equals(NS_GET_IID(nsIDocShellTreeItem))) {
|
||||
nsCOMPtr<nsIDocShell> shell;
|
||||
mXULWindow->GetDocShell(getter_AddRefs(shell));
|
||||
|
||||
@ -1735,34 +1735,3 @@ NS_IMETHODIMP nsWebShellWindow::Destroy()
|
||||
return nsXULWindow::Destroy();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShellWindow::GetPrompter(nsIPrompt* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
if (mPrompter == nsnull) {
|
||||
|
||||
// get our corresponding DOMWindow
|
||||
nsCOMPtr<nsIWebShell> webshell;
|
||||
GetWebShell(*getter_AddRefs(webshell));
|
||||
nsCOMPtr<nsIDOMWindowInternal> domiwindow;
|
||||
rv = ConvertWebShellToDOMWindow(webshell, getter_AddRefs(domiwindow));
|
||||
nsCOMPtr<nsIDOMWindow> domWindow(do_QueryInterface(domiwindow));
|
||||
if (!domWindow) {
|
||||
NS_ERROR("Unable to retrieve the DOM window from the new web shell.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrompt> prompt;
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
NS_ASSERTION(wwatch, "failed to get window watcher service");
|
||||
if (wwatch)
|
||||
wwatch->GetNewPrompter(domWindow, getter_AddRefs(prompt));
|
||||
|
||||
mPrompter = prompt;
|
||||
}
|
||||
*result = mPrompter;
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -87,7 +87,6 @@ public:
|
||||
NS_IMETHOD GetWidget(nsIWidget *& aWidget);
|
||||
NS_IMETHOD GetDOMWindow(nsIDOMWindowInternal** aDOMWindow);
|
||||
NS_IMETHOD ConvertWebShellToDOMWindow(nsIWebShell* aShell, nsIDOMWindowInternal** aDOMWindow);
|
||||
NS_IMETHOD GetPrompter(nsIPrompt* *result);
|
||||
// nsWebShellWindow methods...
|
||||
nsresult Initialize(nsIXULWindow * aParent, nsIAppShell* aShell, nsIURI* aUrl,
|
||||
PRBool aCreatedVisible, PRBool aLoadDefaultPage,
|
||||
|
||||
@ -54,6 +54,7 @@
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
|
||||
#include "nsStyleConsts.h"
|
||||
|
||||
@ -122,11 +123,14 @@ NS_IMETHODIMP nsXULWindow::GetInterface(const nsIID& aIID, void** aSink)
|
||||
NS_ENSURE_ARG_POINTER(aSink);
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIPrompt))) {
|
||||
// XXX until nsIWebShellWindow goes away:
|
||||
nsCOMPtr<nsIWebShellWindow> webShellWin =
|
||||
do_QueryInterface(NS_STATIC_CAST(nsIXULWindow*, this), &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return webShellWin->GetPrompter((nsIPrompt**)aSink);
|
||||
rv = EnsurePrompter();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return mPrompter->QueryInterface(aIID, aSink);
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIAuthPrompt))) {
|
||||
rv = EnsureAuthPrompter();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return mAuthPrompter->QueryInterface(aIID, aSink);
|
||||
}
|
||||
if(aIID.Equals(NS_GET_IID(nsIWebBrowserChrome)) &&
|
||||
NS_SUCCEEDED(EnsureContentTreeOwner()) &&
|
||||
@ -661,6 +665,36 @@ NS_IMETHODIMP nsXULWindow::EnsurePrimaryContentTreeOwner()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::EnsurePrompter()
|
||||
{
|
||||
if (mPrompter)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> ourWindow;
|
||||
nsresult rv = GetWindowDOMWindow(getter_AddRefs(ourWindow));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (wwatch)
|
||||
wwatch->GetNewPrompter(ourWindow, getter_AddRefs(mPrompter));
|
||||
}
|
||||
return mPrompter ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::EnsureAuthPrompter()
|
||||
{
|
||||
if (mAuthPrompter)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> ourWindow;
|
||||
nsresult rv = GetWindowDOMWindow(getter_AddRefs(ourWindow));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (wwatch)
|
||||
wwatch->GetNewAuthPrompter(ourWindow, getter_AddRefs(mAuthPrompter));
|
||||
}
|
||||
return mAuthPrompter ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void nsXULWindow::OnChromeLoaded()
|
||||
{
|
||||
mChromeLoaded = PR_TRUE;
|
||||
|
||||
@ -42,6 +42,8 @@
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
|
||||
// nsXULWindow
|
||||
|
||||
@ -66,6 +68,8 @@ protected:
|
||||
NS_IMETHOD EnsureChromeTreeOwner();
|
||||
NS_IMETHOD EnsureContentTreeOwner();
|
||||
NS_IMETHOD EnsurePrimaryContentTreeOwner();
|
||||
NS_IMETHOD EnsurePrompter();
|
||||
NS_IMETHOD EnsureAuthPrompter();
|
||||
|
||||
void OnChromeLoaded();
|
||||
void StaggerPosition(PRInt32 &aRequestedX, PRInt32 &aRequestedY,
|
||||
@ -103,6 +107,8 @@ protected:
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
nsCOMPtr<nsIDOMWindowInternal> mDOMWindow;
|
||||
nsCOMPtr<nsIWeakReference> mParentWindow;
|
||||
nsCOMPtr<nsIPrompt> mPrompter;
|
||||
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
|
||||
nsVoidArray mContentShells;
|
||||
PRBool mContinueModalLoop;
|
||||
nsresult mModalStatus;
|
||||
|
||||
@ -447,7 +447,7 @@ function NewCategory()
|
||||
var promptStr = bundle.GetStringFromName("NewCategoryPrompt");
|
||||
var newTitle = bundle.GetStringFromName("NewCategoryTitle");
|
||||
var result = {value:0};
|
||||
var name = promptService.prompt(window, newTitle, promptStr, "", 0, "",result);
|
||||
var name = promptService.prompt(window, newTitle, promptStr, result, null, {value:0});
|
||||
if ((!result.value) || result.value == "") return(false);
|
||||
|
||||
var newName = RDF.GetLiteral(result.value);
|
||||
@ -498,8 +498,8 @@ function RenameCategory()
|
||||
var currentName = categoryList.selectedItem.getAttribute("label");
|
||||
var promptStr = bundle.GetStringFromName("RenameCategoryPrompt");
|
||||
var renameTitle = bundle.GetStringFromName("RenameCategoryTitle");
|
||||
var result = {value:0};
|
||||
var name = promptService.prompt(window,renameTitle,promptStr,"",0,currentName,result);
|
||||
var result = {value:currentName};
|
||||
var name = promptService.prompt(window,renameTitle,promptStr,result,null,{value:0});
|
||||
if ((!result.value) || (result.value == "") || result.value == currentName) return(false);
|
||||
|
||||
var currentCatID = categoryList.selectedItem.getAttribute("id");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user