Do better error checking to prevent crashing trying to show a JS dialog

when loading a tab in the background (bug 152945)
This commit is contained in:
pinkerton%netscape.com 2002-06-21 03:36:44 +00:00
Родитель 17e6372d35
Коммит 3579f6aecc
8 изменённых файлов: 44 добавлений и 28 удалений

Просмотреть файл

@ -541,7 +541,7 @@ NS_IMETHODIMP
nsCocoaBrowserListener::GetSiteWindow(void * *aSiteWindow) nsCocoaBrowserListener::GetSiteWindow(void * *aSiteWindow)
{ {
NS_ENSURE_ARG_POINTER(aSiteWindow); NS_ENSURE_ARG_POINTER(aSiteWindow);
*aSiteWindow = nsnull;
if (!mView) { if (!mView) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -715,7 +715,7 @@ private:
NS_IMPL_ISUPPORTS1(nsHeaderSniffer, nsIWebProgressListener) NS_IMPL_ISUPPORTS1(nsHeaderSniffer, nsIWebProgressListener)
// Implementation of nsIWebProgressListener // Implementation of nsIWebProgressListener
/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aStateFlags, in unsigned long aStatus); */ /* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in unsigned long aStatus); */
NS_IMETHODIMP NS_IMETHODIMP
nsHeaderSniffer::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsHeaderSniffer::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags,
PRUint32 aStatus) PRUint32 aStatus)
@ -1357,7 +1357,6 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
filterList: aFilterList]; filterList: aFilterList];
} }
-(IBAction)cut:(id)aSender -(IBAction)cut:(id)aSender
{ {
nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser)); nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
@ -1378,8 +1377,9 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
-(IBAction)delete:(id)aSender -(IBAction)delete:(id)aSender
{ {
nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser)); // nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
clipboard->SelectNone(); // clipboard->SelectNone();
NSLog(@"delete not implemented\n");
} }
-(IBAction)selectAll:(id)aSender -(IBAction)selectAll:(id)aSender

Просмотреть файл

@ -205,7 +205,9 @@ GetNSWindowForDOMWindow(nsIDOMWindow* window)
} }
NSWindow* nswin; NSWindow* nswin;
siteWindow->GetSiteWindow((void**)&nswin); nsresult rv = siteWindow->GetSiteWindow((void**)&nswin);
if (NS_FAILED(rv))
return nsnull;
return nswin; return nswin;
} }
@ -224,6 +226,8 @@ nsCocoaBrowserService::Alert(nsIDOMWindow *parent,
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)]; NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)]; NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSWindow* window = GetNSWindowForDOMWindow(parent); NSWindow* window = GetNSWindowForDOMWindow(parent);
if (!window)
return NS_ERROR_FAILURE;
[controller alert:window title:titleStr text:textStr]; [controller alert:window title:titleStr text:textStr];
@ -650,7 +654,7 @@ nsCocoaBrowserService::CertExpired(nsITransportSecurityInfo *socketInfo,
// HACK: there is no way to get which window this is for from the API. The // HACK: there is no way to get which window this is for from the API. The
// security team in mozilla just cheats and assumes the frontmost window so // security team in mozilla just cheats and assumes the frontmost window so
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well. // that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
*_retval = (PRBool)[controller certExpired:[NSApp mainWindow]]; *_retval = (PRBool)[controller expiredCert:[NSApp mainWindow]];
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -205,7 +205,9 @@ GetNSWindowForDOMWindow(nsIDOMWindow* window)
} }
NSWindow* nswin; NSWindow* nswin;
siteWindow->GetSiteWindow((void**)&nswin); nsresult rv = siteWindow->GetSiteWindow((void**)&nswin);
if (NS_FAILED(rv))
return nsnull;
return nswin; return nswin;
} }
@ -224,6 +226,8 @@ nsCocoaBrowserService::Alert(nsIDOMWindow *parent,
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)]; NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)]; NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSWindow* window = GetNSWindowForDOMWindow(parent); NSWindow* window = GetNSWindowForDOMWindow(parent);
if (!window)
return NS_ERROR_FAILURE;
[controller alert:window title:titleStr text:textStr]; [controller alert:window title:titleStr text:textStr];
@ -650,7 +654,7 @@ nsCocoaBrowserService::CertExpired(nsITransportSecurityInfo *socketInfo,
// HACK: there is no way to get which window this is for from the API. The // HACK: there is no way to get which window this is for from the API. The
// security team in mozilla just cheats and assumes the frontmost window so // security team in mozilla just cheats and assumes the frontmost window so
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well. // that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
*_retval = (PRBool)[controller certExpired:[NSApp mainWindow]]; *_retval = (PRBool)[controller expiredCert:[NSApp mainWindow]];
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -541,7 +541,7 @@ NS_IMETHODIMP
nsCocoaBrowserListener::GetSiteWindow(void * *aSiteWindow) nsCocoaBrowserListener::GetSiteWindow(void * *aSiteWindow)
{ {
NS_ENSURE_ARG_POINTER(aSiteWindow); NS_ENSURE_ARG_POINTER(aSiteWindow);
*aSiteWindow = nsnull;
if (!mView) { if (!mView) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -715,7 +715,7 @@ private:
NS_IMPL_ISUPPORTS1(nsHeaderSniffer, nsIWebProgressListener) NS_IMPL_ISUPPORTS1(nsHeaderSniffer, nsIWebProgressListener)
// Implementation of nsIWebProgressListener // Implementation of nsIWebProgressListener
/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aStateFlags, in unsigned long aStatus); */ /* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in unsigned long aStatus); */
NS_IMETHODIMP NS_IMETHODIMP
nsHeaderSniffer::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsHeaderSniffer::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags,
PRUint32 aStatus) PRUint32 aStatus)
@ -1357,7 +1357,6 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
filterList: aFilterList]; filterList: aFilterList];
} }
-(IBAction)cut:(id)aSender -(IBAction)cut:(id)aSender
{ {
nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser)); nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
@ -1378,8 +1377,9 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
-(IBAction)delete:(id)aSender -(IBAction)delete:(id)aSender
{ {
nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser)); // nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
clipboard->SelectNone(); // clipboard->SelectNone();
NSLog(@"delete not implemented\n");
} }
-(IBAction)selectAll:(id)aSender -(IBAction)selectAll:(id)aSender

Просмотреть файл

@ -541,7 +541,7 @@ NS_IMETHODIMP
nsCocoaBrowserListener::GetSiteWindow(void * *aSiteWindow) nsCocoaBrowserListener::GetSiteWindow(void * *aSiteWindow)
{ {
NS_ENSURE_ARG_POINTER(aSiteWindow); NS_ENSURE_ARG_POINTER(aSiteWindow);
*aSiteWindow = nsnull;
if (!mView) { if (!mView) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -715,7 +715,7 @@ private:
NS_IMPL_ISUPPORTS1(nsHeaderSniffer, nsIWebProgressListener) NS_IMPL_ISUPPORTS1(nsHeaderSniffer, nsIWebProgressListener)
// Implementation of nsIWebProgressListener // Implementation of nsIWebProgressListener
/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aStateFlags, in unsigned long aStatus); */ /* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in unsigned long aStatus); */
NS_IMETHODIMP NS_IMETHODIMP
nsHeaderSniffer::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsHeaderSniffer::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags,
PRUint32 aStatus) PRUint32 aStatus)
@ -1357,7 +1357,6 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
filterList: aFilterList]; filterList: aFilterList];
} }
-(IBAction)cut:(id)aSender -(IBAction)cut:(id)aSender
{ {
nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser)); nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
@ -1378,8 +1377,9 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
-(IBAction)delete:(id)aSender -(IBAction)delete:(id)aSender
{ {
nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser)); // nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
clipboard->SelectNone(); // clipboard->SelectNone();
NSLog(@"delete not implemented\n");
} }
-(IBAction)selectAll:(id)aSender -(IBAction)selectAll:(id)aSender

Просмотреть файл

@ -205,7 +205,9 @@ GetNSWindowForDOMWindow(nsIDOMWindow* window)
} }
NSWindow* nswin; NSWindow* nswin;
siteWindow->GetSiteWindow((void**)&nswin); nsresult rv = siteWindow->GetSiteWindow((void**)&nswin);
if (NS_FAILED(rv))
return nsnull;
return nswin; return nswin;
} }
@ -224,6 +226,8 @@ nsCocoaBrowserService::Alert(nsIDOMWindow *parent,
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)]; NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)]; NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSWindow* window = GetNSWindowForDOMWindow(parent); NSWindow* window = GetNSWindowForDOMWindow(parent);
if (!window)
return NS_ERROR_FAILURE;
[controller alert:window title:titleStr text:textStr]; [controller alert:window title:titleStr text:textStr];
@ -650,7 +654,7 @@ nsCocoaBrowserService::CertExpired(nsITransportSecurityInfo *socketInfo,
// HACK: there is no way to get which window this is for from the API. The // HACK: there is no way to get which window this is for from the API. The
// security team in mozilla just cheats and assumes the frontmost window so // security team in mozilla just cheats and assumes the frontmost window so
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well. // that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
*_retval = (PRBool)[controller certExpired:[NSApp mainWindow]]; *_retval = (PRBool)[controller expiredCert:[NSApp mainWindow]];
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -205,7 +205,9 @@ GetNSWindowForDOMWindow(nsIDOMWindow* window)
} }
NSWindow* nswin; NSWindow* nswin;
siteWindow->GetSiteWindow((void**)&nswin); nsresult rv = siteWindow->GetSiteWindow((void**)&nswin);
if (NS_FAILED(rv))
return nsnull;
return nswin; return nswin;
} }
@ -224,6 +226,8 @@ nsCocoaBrowserService::Alert(nsIDOMWindow *parent,
NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)]; NSString* titleStr = [NSString stringWithCharacters:dialogTitle length:(dialogTitle ? nsCRT::strlen(dialogTitle) : 0)];
NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)]; NSString* textStr = [NSString stringWithCharacters:text length:(text ? nsCRT::strlen(text) : 0)];
NSWindow* window = GetNSWindowForDOMWindow(parent); NSWindow* window = GetNSWindowForDOMWindow(parent);
if (!window)
return NS_ERROR_FAILURE;
[controller alert:window title:titleStr text:textStr]; [controller alert:window title:titleStr text:textStr];
@ -650,7 +654,7 @@ nsCocoaBrowserService::CertExpired(nsITransportSecurityInfo *socketInfo,
// HACK: there is no way to get which window this is for from the API. The // HACK: there is no way to get which window this is for from the API. The
// security team in mozilla just cheats and assumes the frontmost window so // security team in mozilla just cheats and assumes the frontmost window so
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well. // that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
*_retval = (PRBool)[controller certExpired:[NSApp mainWindow]]; *_retval = (PRBool)[controller expiredCert:[NSApp mainWindow]];
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -541,7 +541,7 @@ NS_IMETHODIMP
nsCocoaBrowserListener::GetSiteWindow(void * *aSiteWindow) nsCocoaBrowserListener::GetSiteWindow(void * *aSiteWindow)
{ {
NS_ENSURE_ARG_POINTER(aSiteWindow); NS_ENSURE_ARG_POINTER(aSiteWindow);
*aSiteWindow = nsnull;
if (!mView) { if (!mView) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -715,7 +715,7 @@ private:
NS_IMPL_ISUPPORTS1(nsHeaderSniffer, nsIWebProgressListener) NS_IMPL_ISUPPORTS1(nsHeaderSniffer, nsIWebProgressListener)
// Implementation of nsIWebProgressListener // Implementation of nsIWebProgressListener
/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aStateFlags, in unsigned long aStatus); */ /* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in unsigned long aStatus); */
NS_IMETHODIMP NS_IMETHODIMP
nsHeaderSniffer::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsHeaderSniffer::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags,
PRUint32 aStatus) PRUint32 aStatus)
@ -1357,7 +1357,6 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
filterList: aFilterList]; filterList: aFilterList];
} }
-(IBAction)cut:(id)aSender -(IBAction)cut:(id)aSender
{ {
nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser)); nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
@ -1378,8 +1377,9 @@ nsHeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aReq
-(IBAction)delete:(id)aSender -(IBAction)delete:(id)aSender
{ {
nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser)); // nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(_webBrowser));
clipboard->SelectNone(); // clipboard->SelectNone();
NSLog(@"delete not implemented\n");
} }
-(IBAction)selectAll:(id)aSender -(IBAction)selectAll:(id)aSender