зеркало из https://github.com/mozilla/pjs.git
Bug 75745 - Remove nsIPrompt implementations from embedding chrome. r=valeski, sr=blizzard, a=chofmann
This commit is contained in:
Родитель
7f21f77318
Коммит
e97ca9d0fd
Двоичные данные
embedding/browser/powerplant/PPBrowser.mcp
Двоичные данные
embedding/browser/powerplant/PPBrowser.mcp
Двоичный файл не отображается.
|
@ -50,6 +50,7 @@
|
|||
#include "UMacUnicode.h"
|
||||
#include "CAppFileLocationProvider.h"
|
||||
#include "EmbedEventHandling.h"
|
||||
#include "PromptService.h"
|
||||
|
||||
#include "nsEmbedAPI.h"
|
||||
|
||||
|
@ -72,6 +73,8 @@
|
|||
|
||||
#include <TextServices.h>
|
||||
|
||||
#define NATIVE_PROMPTS
|
||||
|
||||
#if USE_PROFILES
|
||||
#include "CProfileManager.h"
|
||||
#include "nsIProfileChangeStatus.h"
|
||||
|
@ -193,6 +196,7 @@ CBrowserApp::CBrowserApp()
|
|||
|
||||
rv = NS_InitEmbedding(appDir, fileLocProvider);
|
||||
|
||||
OverrideComponents();
|
||||
InitializeWindowCreator();
|
||||
InitializeEmbedEventHandling(this);
|
||||
}
|
||||
|
@ -264,6 +268,35 @@ CBrowserApp::StartUp()
|
|||
ObeyCommand(PP_PowerPlant::cmd_New, nil); // EXAMPLE, create a new window
|
||||
}
|
||||
|
||||
nsresult
|
||||
CBrowserApp::OverrideComponents()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
#ifdef NATIVE_PROMPTS
|
||||
#define NS_PROMPTSERVICE_CID \
|
||||
{0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}}
|
||||
static NS_DEFINE_CID(kPromptServiceCID, NS_PROMPTSERVICE_CID);
|
||||
|
||||
// Here, we're creating a factory using a method compiled into
|
||||
// the application. This is preferable if you do not want to locate
|
||||
// and load an external DLL. That approach is used by MfcEmbed if
|
||||
// that's of interest.
|
||||
|
||||
nsCOMPtr<nsIFactory> promptFactory;
|
||||
rv = NS_NewPromptServiceFactory(getter_AddRefs(promptFactory));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = nsComponentManager::RegisterFactory(kPromptServiceCID,
|
||||
"Prompt Service",
|
||||
"@mozilla.org/embedcomp/prompt-service;1",
|
||||
promptFactory,
|
||||
PR_TRUE); // replace existing
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ MakeMenuBar
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
protected:
|
||||
|
||||
virtual void StartUp(); // override startup functions
|
||||
virtual nsresult OverrideComponents();
|
||||
virtual void MakeMenuBar();
|
||||
|
||||
virtual nsresult InitializePrefs();
|
||||
|
|
|
@ -149,9 +149,20 @@ void CBrowserShell::FinishCreateSelf()
|
|||
Rect portFrame;
|
||||
CalcPortFrameRect(portFrame);
|
||||
nsRect r(portFrame.left, portFrame.top, portFrame.right - portFrame.left, portFrame.bottom - portFrame.top);
|
||||
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIWebBrowserChrome> ourChrome;
|
||||
ourWindow->GetIWebBrowserChrome(getter_AddRefs(ourChrome));
|
||||
ThrowIfNil_(ourChrome);
|
||||
|
||||
mWebBrowser->SetContainerWindow(ourChrome);
|
||||
mWebBrowserAsBaseWin->InitWindow(aWidget->GetNativeData(NS_NATIVE_WIDGET), nsnull, r.x, r.y, r.width, r.height);
|
||||
mWebBrowserAsBaseWin->Create();
|
||||
|
||||
nsWeakPtr weakling(dont_AddRef(NS_GetWeakReference(ourChrome)));
|
||||
rv = mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Call to AddWebBrowserListener failed");
|
||||
|
||||
// Set the global history
|
||||
nsCOMPtr<nsIDocShell> docShell(do_GetInterface(mWebBrowser));
|
||||
|
@ -159,7 +170,6 @@ void CBrowserShell::FinishCreateSelf()
|
|||
nsCOMPtr<nsIDocShellHistory> dsHistory(do_QueryInterface(docShell));
|
||||
if (dsHistory)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIGlobalHistory, history, NS_GLOBALHISTORY_CONTRACTID, &rv);
|
||||
if (history)
|
||||
dsHistory->SetGlobalHistory(history);
|
||||
|
@ -447,16 +457,7 @@ void CBrowserShell::ListenToMessage(MessageT inMessage,
|
|||
|
||||
NS_IMETHODIMP CBrowserShell::SetTopLevelWindow(nsIWebBrowserChrome * aTopLevelWindow)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
mWebBrowser->SetContainerWindow(aTopLevelWindow);
|
||||
if (aTopLevelWindow) {
|
||||
nsWeakPtr weakling(dont_AddRef(NS_GetWeakReference(aTopLevelWindow)));
|
||||
rv = mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Call to AddWebBrowserListener failed");
|
||||
}
|
||||
|
||||
return rv;
|
||||
return mWebBrowser->SetContainerWindow(aTopLevelWindow);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -294,6 +294,10 @@ void CBrowserWindow::FinishCreate()
|
|||
if (NS_FAILED(rv))
|
||||
Throw_(NS_ERROR_GET_CODE(rv));
|
||||
|
||||
mBrowserShell = dynamic_cast<CBrowserShell*>(FindPaneByID(paneID_WebShellView));
|
||||
ThrowIfNULL_(mBrowserShell); // Curtains if we don't have this
|
||||
mBrowserChrome->BrowserShell() = mBrowserShell;
|
||||
|
||||
Inherited::FinishCreate();
|
||||
}
|
||||
|
||||
|
@ -304,15 +308,8 @@ void CBrowserWindow::FinishCreate()
|
|||
|
||||
void CBrowserWindow::FinishCreateSelf()
|
||||
{
|
||||
mBrowserShell = dynamic_cast<CBrowserShell*>(FindPaneByID(paneID_WebShellView));
|
||||
ThrowIfNULL_(mBrowserShell); // Curtains if we don't have this
|
||||
SetLatentSub(mBrowserShell);
|
||||
|
||||
// Tell our CBrowserShell about the chrome
|
||||
mBrowserShell->SetTopLevelWindow(mBrowserChrome);
|
||||
// Tell our chrome about the CBrowserShell
|
||||
mBrowserChrome->BrowserShell() = mBrowserShell;
|
||||
|
||||
// Find our subviews - When we have a way of creating this
|
||||
// window with various chrome flags, we may or may not have
|
||||
// all of these subviews so don't fail if they don't exist
|
||||
|
|
|
@ -74,6 +74,7 @@ private:
|
|||
|
||||
friend class CWebBrowserChrome;
|
||||
friend class CWindowCreator;
|
||||
friend class CBrowserShell;
|
||||
|
||||
public:
|
||||
enum { class_ID = FOUR_CHAR_CODE('BroW') };
|
||||
|
|
|
@ -53,34 +53,6 @@
|
|||
// Constants
|
||||
const PRInt32 kGrowIconSize = 15;
|
||||
|
||||
|
||||
class CWebBrowserPrompter : public nsIPrompt
|
||||
{
|
||||
public:
|
||||
CWebBrowserPrompter(CWebBrowserChrome* aChrome);
|
||||
virtual ~CWebBrowserPrompter();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_FORWARD_NSIPROMPT(mChrome->);
|
||||
|
||||
protected:
|
||||
CWebBrowserChrome *mChrome;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(CWebBrowserPrompter, nsIPrompt);
|
||||
|
||||
CWebBrowserPrompter::CWebBrowserPrompter(CWebBrowserChrome* aChrome) :
|
||||
mChrome(aChrome)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
CWebBrowserPrompter::~CWebBrowserPrompter()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//*** CWebBrowserChrome: Object Management
|
||||
//*****************************************************************************
|
||||
|
@ -109,7 +81,6 @@ NS_INTERFACE_MAP_BEGIN(CWebBrowserChrome)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIPrompt)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITooltipListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
|
@ -482,447 +453,14 @@ NS_IMETHODIMP CWebBrowserChrome::SetTitle(const PRUnichar * aTitle)
|
|||
|
||||
NS_IMETHODIMP CWebBrowserChrome::GetSiteWindow(void * *aSiteWindow)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// CWebBrowserChrome::nsIPrompt
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP CWebBrowserChrome::Alert(const PRUnichar *dialogTitle, const PRUnichar *text)
|
||||
{
|
||||
StDialogHandler theHandler(dlog_Alert, mBrowserWindow);
|
||||
LWindow *theDialog = theHandler.GetDialog();
|
||||
nsCAutoString cStr;
|
||||
Str255 pStr;
|
||||
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(dialogTitle), pStr);
|
||||
theDialog->SetDescriptor(pStr);
|
||||
|
||||
LStaticText *msgText = dynamic_cast<LStaticText*>(theDialog->FindPaneByID('Msg '));
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(text), cStr);
|
||||
cStr.ReplaceChar('\n', '\r');
|
||||
msgText->SetText(const_cast<char *>(cStr.get()), cStr.Length());
|
||||
|
||||
theDialog->Show();
|
||||
theDialog->Select();
|
||||
|
||||
while (true) // This is our modal dialog event loop
|
||||
{
|
||||
MessageT hitMessage = theHandler.DoDialog();
|
||||
|
||||
if (hitMessage == msg_OK)
|
||||
break;
|
||||
}
|
||||
NS_ENSURE_ARG(aSiteWindow);
|
||||
NS_ENSURE_STATE(mBrowserWindow);
|
||||
|
||||
*aSiteWindow = mBrowserWindow->GetMacPort();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWebBrowserChrome::AlertCheck(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
const PRUnichar *checkMsg,
|
||||
PRBool *checkValue)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(checkValue);
|
||||
|
||||
StDialogHandler theHandler(dlog_ConfirmCheck, mBrowserWindow);
|
||||
LWindow *theDialog = theHandler.GetDialog();
|
||||
nsCAutoString cStr;
|
||||
Str255 pStr;
|
||||
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(dialogTitle), pStr);
|
||||
theDialog->SetDescriptor(pStr);
|
||||
|
||||
LStaticText *msgText = dynamic_cast<LStaticText*>(theDialog->FindPaneByID('Msg '));
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(text), cStr);
|
||||
cStr.ReplaceChar('\n', '\r');
|
||||
msgText->SetText(const_cast<char *>(cStr.get()), cStr.Length());
|
||||
|
||||
LCheckBox *checkBox = dynamic_cast<LCheckBox*>(theDialog->FindPaneByID('Chck'));
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(checkMsg), pStr);
|
||||
checkBox->SetDescriptor(pStr);
|
||||
checkBox->SetValue(*checkValue ? 1 : 0);
|
||||
|
||||
theDialog->Show();
|
||||
theDialog->Select();
|
||||
|
||||
while (true) // This is our modal dialog event loop
|
||||
{
|
||||
MessageT hitMessage = theHandler.DoDialog();
|
||||
|
||||
if (hitMessage == msg_OK)
|
||||
{
|
||||
*checkValue = checkBox->GetValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWebBrowserChrome::Confirm(const PRUnichar *dialogTitle, const PRUnichar *text, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
StDialogHandler theHandler(dlog_Confirm, mBrowserWindow);
|
||||
LWindow *theDialog = theHandler.GetDialog();
|
||||
nsCAutoString cStr;
|
||||
Str255 pStr;
|
||||
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(dialogTitle), pStr);
|
||||
theDialog->SetDescriptor(pStr);
|
||||
|
||||
LStaticText *msgText = dynamic_cast<LStaticText*>(theDialog->FindPaneByID('Msg '));
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(text), cStr);
|
||||
cStr.ReplaceChar('\n', '\r');
|
||||
msgText->SetText(const_cast<char *>(cStr.get()), cStr.Length());
|
||||
|
||||
theDialog->Show();
|
||||
theDialog->Select();
|
||||
|
||||
while (true) // This is our modal dialog event loop
|
||||
{
|
||||
MessageT hitMessage = theHandler.DoDialog();
|
||||
|
||||
if (hitMessage == msg_OK)
|
||||
{
|
||||
*_retval = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
else if (hitMessage == msg_Cancel)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWebBrowserChrome::ConfirmCheck(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(checkValue);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
StDialogHandler theHandler(dlog_ConfirmCheck, mBrowserWindow);
|
||||
LWindow *theDialog = theHandler.GetDialog();
|
||||
nsCAutoString cStr;
|
||||
Str255 pStr;
|
||||
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(dialogTitle), pStr);
|
||||
theDialog->SetDescriptor(pStr);
|
||||
|
||||
LStaticText *msgText = dynamic_cast<LStaticText*>(theDialog->FindPaneByID('Msg '));
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(text), cStr);
|
||||
cStr.ReplaceChar('\n', '\r');
|
||||
msgText->SetText(const_cast<char *>(cStr.get()), cStr.Length());
|
||||
|
||||
LCheckBox *checkBox = dynamic_cast<LCheckBox*>(theDialog->FindPaneByID('Chck'));
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsLiteralString(checkMsg), pStr);
|
||||
checkBox->SetDescriptor(pStr);
|
||||
checkBox->SetValue(*checkValue ? 1 : 0);
|
||||
|
||||
theDialog->Show();
|
||||
theDialog->Select();
|
||||
|
||||
while (true) // This is our modal dialog event loop
|
||||
{
|
||||
MessageT hitMessage = theHandler.DoDialog();
|
||||
|
||||
if (hitMessage == msg_OK)
|
||||
{
|
||||
*_retval = PR_TRUE;
|
||||
*checkValue = checkBox->GetValue();
|
||||
break;
|
||||
}
|
||||
else if (hitMessage == msg_Cancel)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWebBrowserChrome::ConfirmEx(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
PRUint32 button0And1Flags,
|
||||
const PRUnichar *button2Title,
|
||||
const PRUnichar *checkMsg,
|
||||
PRBool *checkValue,
|
||||
PRInt32 *buttonPressed)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWebBrowserChrome::Prompt(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
PRUnichar **answer,
|
||||
const PRUnichar *checkMsg,
|
||||
PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
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;
|
||||
|
||||
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);
|
||||
cStr.ReplaceChar('\n', '\r');
|
||||
msgText->SetText(const_cast<char *>(cStr.get()), cStr.Length());
|
||||
|
||||
LEditText *responseText = dynamic_cast<LEditText*>(theDialog->FindPaneByID('Rslt'));
|
||||
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();
|
||||
|
||||
while (true) // This is our modal dialog event loop
|
||||
{
|
||||
MessageT hitMessage = theHandler.DoDialog();
|
||||
|
||||
if (hitMessage == msg_OK)
|
||||
{
|
||||
nsAutoString ucStr;
|
||||
|
||||
*_retval = PR_TRUE;
|
||||
if (answer && *answer) {
|
||||
nsMemory::Free(*answer);
|
||||
*answer = nsnull;
|
||||
}
|
||||
responseText->GetDescriptor(pStr);
|
||||
CPlatformUCSConversion::GetInstance()->PlatformToUCS(pStr, ucStr);
|
||||
*answer = ucStr.ToNewUnicode();
|
||||
if (*answer == nsnull)
|
||||
resultErr = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (checkValue)
|
||||
*checkValue = checkbox->GetValue();
|
||||
|
||||
break;
|
||||
}
|
||||
else if (hitMessage == msg_Cancel)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return resultErr;
|
||||
}
|
||||
|
||||
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(_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;
|
||||
|
||||
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);
|
||||
cStr.ReplaceChar('\n', '\r');
|
||||
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();
|
||||
theDialog->Select();
|
||||
|
||||
while (true) // This is our modal dialog event loop
|
||||
{
|
||||
MessageT hitMessage = theHandler.DoDialog();
|
||||
|
||||
if (hitMessage == msg_OK)
|
||||
{
|
||||
nsAutoString ucStr;
|
||||
|
||||
if (username && *username) {
|
||||
nsMemory::Free(*username);
|
||||
*username = nsnull;
|
||||
}
|
||||
userText->GetDescriptor(pStr);
|
||||
CPlatformUCSConversion::GetInstance()->PlatformToUCS(pStr, ucStr);
|
||||
*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);
|
||||
*password = ucStr.ToNewUnicode();
|
||||
if (*password == nsnull)
|
||||
resultErr = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (checkValue)
|
||||
*checkValue = checkbox->GetValue();
|
||||
|
||||
*_retval = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
else if (hitMessage == msg_Cancel)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return resultErr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWebBrowserChrome::PromptPassword(const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
PRUnichar **password,
|
||||
const PRUnichar *checkMsg,
|
||||
PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
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;
|
||||
|
||||
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);
|
||||
cStr.ReplaceChar('\n', '\r');
|
||||
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();
|
||||
theDialog->Select();
|
||||
|
||||
while (true) // This is our modal dialog event loop
|
||||
{
|
||||
MessageT hitMessage = theHandler.DoDialog();
|
||||
|
||||
if (hitMessage == msg_OK)
|
||||
{
|
||||
nsAutoString ucStr;
|
||||
|
||||
if (password && *password) {
|
||||
nsMemory::Free(*password);
|
||||
*password = nsnull;
|
||||
}
|
||||
pwdText->GetDescriptor(pStr);
|
||||
CPlatformUCSConversion::GetInstance()->PlatformToUCS(pStr, ucStr);
|
||||
*password = ucStr.ToNewUnicode();
|
||||
if (*password == nsnull)
|
||||
resultErr = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (checkValue)
|
||||
*checkValue = checkbox->GetValue();
|
||||
|
||||
*_retval = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
else if (hitMessage == msg_Cancel)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return resultErr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWebBrowserChrome::Select(const PRUnichar *inDialogTitle, const PRUnichar *inMsg, PRUint32 inCount, const PRUnichar **inList, PRInt32 *outSelection, PRBool *_retval)
|
||||
{
|
||||
//XXX First Check In
|
||||
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// CWebBrowserChrome::nsIContextMenuListener
|
||||
//*****************************************************************************
|
||||
|
|
|
@ -46,7 +46,6 @@ class CBrowserShell;
|
|||
class CWebBrowserChrome : public nsIWebBrowserChrome,
|
||||
public nsIWebProgressListener,
|
||||
public nsIEmbeddingSiteWindow,
|
||||
public nsIPrompt,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIContextMenuListener,
|
||||
public nsITooltipListener,
|
||||
|
@ -59,7 +58,6 @@ public:
|
|||
NS_DECL_NSIWEBBROWSERCHROME
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
NS_DECL_NSIEMBEDDINGSITEWINDOW
|
||||
NS_DECL_NSIPROMPT
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
NS_DECL_NSICONTEXTMENULISTENER
|
||||
NS_DECL_NSITOOLTIPLISTENER
|
||||
|
|
Загрузка…
Ссылка в новой задаче