diff --git a/mozilla/embedding/browser/photon/src/EmbedDownload.cpp b/mozilla/embedding/browser/photon/src/EmbedDownload.cpp new file mode 100644 index 00000000000..0e7b7a5deef --- /dev/null +++ b/mozilla/embedding/browser/photon/src/EmbedDownload.cpp @@ -0,0 +1,155 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Adrian Mardare + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "EmbedDownload.h" + +EmbedDownload::EmbedDownload( PtMozillaWidget_t *aMoz, int aDownloadTicket, const char * aURL ) +{ + mMozillaWidget = aMoz; + mDownloadTicket = aDownloadTicket; + mURL = strdup( aURL ); + mDone = PR_FALSE; + mLauncher = nsnull; + mPersist = nsnull; + + /* insert d into aMoz->fDownload */ + aMoz->fDownload = ( EmbedDownload ** ) realloc( aMoz->fDownload, ( aMoz->fDownloadCount + 1 ) * sizeof( EmbedDownload * ) ); + if( aMoz->fDownload ) { + aMoz->fDownload[ aMoz->fDownloadCount ] = this; + aMoz->fDownloadCount++; + } +} + +EmbedDownload::~EmbedDownload() +{ + int i; + +///* ATENTIE */ printf( "EmbedDownload destructor this=%p\n", this ); + + /* remove d from the mMoz->fDownload */ + for( i=0; ifDownloadCount; i++ ) { + if( mMozillaWidget->fDownload[i] == this ) break; + } + + if( ifDownloadCount ) { + int j; + + for( j=i; jfDownloadCount-1; j++ ) + mMozillaWidget->fDownload[j] = mMozillaWidget->fDownload[j+1]; + + mMozillaWidget->fDownloadCount--; + if( !mMozillaWidget->fDownloadCount ) { + free( mMozillaWidget->fDownload ); + mMozillaWidget->fDownload = NULL; + } + + if( mDone == PR_FALSE ) ReportDownload( Pt_WEB_DOWNLOAD_CANCEL, 0, 0, "" ); + } + +///* ATENTIE */ printf( "after remove fDownloadCount=%d\n", mMozillaWidget->fDownloadCount ); + + free( mURL ); +} + +EmbedDownload *FindDownload( PtMozillaWidget_t *moz, int download_ticket ) +{ + int i; + for( i=0; ifDownloadCount; i++ ) { + if( moz->fDownload[i]->mDownloadTicket == download_ticket ) return moz->fDownload[i]; + } + return NULL; +} + + +void EmbedDownload::ReportDownload( int type, int current, int total, char *message ) +{ + PtCallbackInfo_t cbinfo; + PtWebDownloadCallback_t cb; + + memset( &cbinfo, 0, sizeof( cbinfo ) ); + cbinfo.reason = Pt_CB_MOZ_DOWNLOAD; + cbinfo.cbdata = &cb; + + cb.download_ticket = mDownloadTicket; + cb.type = type; + cb.url = mURL; + cb.current = current; + cb.total = total; + cb.message = message; + + if( type == Pt_WEB_DOWNLOAD_DONE ) mDone = PR_TRUE; + +///* ATENTIE */ printf( "In EmbedDownload::ReportDownload type=%s\n", +//type==Pt_WEB_DOWNLOAD_CANCEL? "Pt_WEB_DOWNLOAD_CANCEL": +//type==Pt_WEB_DOWNLOAD_DONE? "Pt_WEB_DOWNLOAD_DONE": +//type==Pt_WEB_DOWNLOAD_PROGRESS? "Pt_WEB_DOWNLOAD_PROGRESS":"unknown"); + + PtInvokeCallbackList( mMozillaWidget->web_download_cb, (PtWidget_t *)mMozillaWidget, &cbinfo ); + } + + +/* nsIWebProgressListener interface */ +NS_IMPL_ISUPPORTS1(EmbedDownload, nsIWebProgressListener) + +NS_IMETHODIMP EmbedDownload::OnProgressChange(nsIWebProgress *aProgress, nsIRequest *aRequest, PRInt32 curSelfProgress, PRInt32 maxSelfProgress, PRInt32 curTotalProgress, PRInt32 maxTotalProgress) { + +///* ATENTIE */ printf("this=%p OnProgressChange curSelfProgress=%d maxSelfProgress=%d curTotalProgress=%d maxTotalProgress=%d\n", +//this, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress ); + + ReportDownload( Pt_WEB_DOWNLOAD_PROGRESS, curSelfProgress, maxSelfProgress, "" ); + + return NS_OK; + } + +NS_IMETHODIMP EmbedDownload::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus) { + if( aStateFlags & STATE_STOP ) { + ReportDownload( Pt_WEB_DOWNLOAD_DONE, 0, 0, "" ); + } + return NS_OK; + } + +NS_IMETHODIMP EmbedDownload::OnLocationChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, nsIURI *location) { + return NS_OK; + } +NS_IMETHODIMP EmbedDownload::OnStatusChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, nsresult aStatus, const PRUnichar* aMessage) { + return NS_OK; + } +NS_IMETHODIMP EmbedDownload::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 state) { + return NS_OK; + } diff --git a/mozilla/embedding/browser/photon/src/EmbedDownload.h b/mozilla/embedding/browser/photon/src/EmbedDownload.h new file mode 100644 index 00000000000..c8ffbb1b829 --- /dev/null +++ b/mozilla/embedding/browser/photon/src/EmbedDownload.h @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Adrian Mardare + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef EMBEDDOWNLOAD_EMB +#define EMBEDDOWNLOAD_EMB + +#include "nsIWebProgressListener.h" +#include "nsIWebBrowserPersist.h" +#include "EmbedPrivate.h" +#include "PtMozilla.h" + +/* download related */ +class EmbedDownload : public nsIWebProgressListener +{ + +public: + EmbedDownload( PtMozillaWidget_t *aMoz, int aDownloadTicket, const char * aURL ); + virtual ~EmbedDownload(); + + void ReportDownload( int type, int current, int total, char *message ); + + int mDownloadTicket; + nsIHelperAppLauncher *mLauncher; /* weak reference - either mLauncher or mPersist is set, but not both */ + nsIWebBrowserPersist *mPersist; /* weak reference - either mLauncher or mPersist is set, but not both */ + + NS_DECL_ISUPPORTS + NS_DECL_NSIWEBPROGRESSLISTENER + +private: + PtMozillaWidget_t *mMozillaWidget; + char *mURL; + PRBool mDone; + }; + +EmbedDownload *FindDownload( PtMozillaWidget_t *moz, int download_ticket ); + +#endif diff --git a/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp b/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp index 3fabfca45fa..fb4b086bdcb 100644 --- a/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp +++ b/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp @@ -23,11 +23,11 @@ #include #include #include -#include #include #include #include #include "nsReadableUtils.h" +#include "nsNetUtil.h" #include "nsIWidget.h" // for do_GetInterface @@ -57,7 +57,6 @@ #include #include "nsIWebBrowserPrint.h" #include "nsIClipboardCommands.h" -#include "docshell/nsCDefaultURIFixup.h" // for the focus hacking we need to do #include @@ -216,8 +215,6 @@ EmbedPrivate::Setup() // get a handle on the navigation object mNavigation = do_QueryInterface(webBrowser); - mFixup = do_GetService(NS_URIFIXUP_CONTRACTID); - // Create our session history object and tell the navigation object // to use it. We need to do this before we create the web browser // window. @@ -324,7 +321,6 @@ EmbedPrivate::Destroy(void) // release navigation mNavigation = nsnull; - mFixup = nsnull; //m_PrintSettings = nsnull; @@ -610,37 +606,6 @@ EmbedPrivate::SaveAs(char *fname, char *dirname) return (1); } -int -EmbedPrivate::SaveURI(char *aURI, char *fname) -{ -/* ATENTIE it was */ -#if 0 - if (mWindow && mFixup) - { - nsIURI* uri; - - mFixup->CreateFixupURI(nsDependentCString(aURI), 0, &(uri)); - return (mWindow->SaveURI(uri, fname)); - } -#endif - - if (mWindow && mFixup) - { - nsIURI* uri; - mFixup->CreateFixupURI( NS_LITERAL_CSTRING(aURI), 0, &(uri)); - return (mWindow->SaveURI(uri, fname)); - } - - return (1); -} - -void -EmbedPrivate::CancelSaveURI() -{ - if (mWindow) - mWindow->CancelSaveURI(); -} - nsresult EmbedPrivate::AppendToStream(const char *aData, PRInt32 aLen) { diff --git a/mozilla/embedding/browser/photon/src/EmbedPrivate.h b/mozilla/embedding/browser/photon/src/EmbedPrivate.h index 44cd3d159d2..5a59de16e57 100644 --- a/mozilla/embedding/browser/photon/src/EmbedPrivate.h +++ b/mozilla/embedding/browser/photon/src/EmbedPrivate.h @@ -81,8 +81,6 @@ class EmbedPrivate { void SelectAll (void); void Clear (void); int SaveAs(char *fname,char *dirname); - int SaveURI(char *uri, char *fname); - void CancelSaveURI(); void Print(PpPrintContext_t *pc); PRBool CanGoBack(); PRBool CanGoForward(); @@ -134,7 +132,6 @@ class EmbedPrivate { nsCOMPtr mPrintGuard; nsCOMPtr mNavigation; - nsCOMPtr mFixup; nsCOMPtr mSessionHistory; // our event receiver diff --git a/mozilla/embedding/browser/photon/src/EmbedWindow.cpp b/mozilla/embedding/browser/photon/src/EmbedWindow.cpp index a9cbbd9a40c..18bf96001e1 100644 --- a/mozilla/embedding/browser/photon/src/EmbedWindow.cpp +++ b/mozilla/embedding/browser/photon/src/EmbedWindow.cpp @@ -206,31 +206,6 @@ EmbedWindow::SaveAs(char *fname, char *dirname) return 0; } -int -EmbedWindow::SaveURI(nsIURI *uri, char *fname) -{ - PtMozillaWidget_t *w = (PtMozillaWidget_t *)(mOwner->mOwningWidget); - nsCOMPtr persist(do_QueryInterface(mWebBrowser)); - if (persist) - { - nsCOMPtr file; - NS_NewNativeLocalFile(nsDependentCString(fname), PR_TRUE, getter_AddRefs(file)); - persist->SetProgressListener((nsIWebProgressListener*) w->EmbedRef->mProgress); - persist->SaveURI(uri, nsnull, nsnull, nsnull, nsnull, file); - return (0); - } - return 1; -} - -void -EmbedWindow::CancelSaveURI() -{ - nsCOMPtr persist(do_QueryInterface(mWebBrowser)); - persist->SetProgressListener(nsnull); - persist->CancelSave(); -} - - NS_IMETHODIMP EmbedWindow::GetWebBrowser(nsIWebBrowser **aWebBrowser) { @@ -489,6 +464,7 @@ NS_IMETHODIMP EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText) { +#if 0 nsAutoString tipText ( aTipText ); const char* tipString = ToNewCString(tipText), *font = "TextFont08"; PtArg_t args[10]; @@ -537,6 +513,7 @@ EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, nsMemory::Free( (void*)tipString ); +#endif return NS_OK; } @@ -640,47 +617,49 @@ NS_IMETHODIMP EmbedWindow::OnShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent PtInvokeCallbackList(cb, (PtWidget_t *)moz, &cbinfo); - /* store the url we clicked on */ - nsAutoString rightClickUrl; - - if (aContextFlags & CONTEXT_IMAGE) + if( aContextFlags & CONTEXT_IMAGE ) { + /* store the url we clicked on */ + nsAutoString rightClickUrl; + // Get the IMG SRC nsresult rv = NS_OK; nsCOMPtr imgElement(do_QueryInterface(aNode, &rv)); - if (NS_FAILED(rv)) - return NS_OK; + if(NS_FAILED(rv)) return NS_OK; rv = imgElement->GetSrc(rightClickUrl); - if(NS_FAILED(rv)) - { - if( moz->rightClickUrl ) - free( moz->rightClickUrl ); - moz->rightClickUrl = NULL; - return NS_OK; - } + + if( moz->rightClickUrl_image ) free( moz->rightClickUrl_image ); + + if(NS_FAILED(rv)) moz->rightClickUrl_image = NULL; + else moz->rightClickUrl_image = ToNewCString(rightClickUrl); } - else + + if( aContextFlags & CONTEXT_LINK ) { + /* CONTEXT_IMAGE|CONTEXT_LINK is set for an with an as an ancestor */ + if( aContextFlags & CONTEXT_IMAGE ) { + nsIDOMNode *parent; + aNode->GetParentNode( &parent ); + if( parent ) aNode = parent; + } + + /* store the url we clicked on */ + nsAutoString rightClickUrl; + nsresult rv = NS_OK; nsCOMPtr linkElement(do_QueryInterface(aNode, &rv)); - if(NS_FAILED(rv)) - return NS_OK; + + if(NS_FAILED(rv)) return NS_OK; // Note that this string is in UCS2 format rv = linkElement->GetHref( rightClickUrl ); - if(NS_FAILED(rv)) - { - if( moz->rightClickUrl ) - free( moz->rightClickUrl ); - moz->rightClickUrl = NULL; - return NS_OK; - } - } - if( moz->rightClickUrl ) - free( moz->rightClickUrl ); - moz->rightClickUrl = ToNewCString(rightClickUrl); + if( moz->rightClickUrl_link ) free( moz->rightClickUrl_link ); + + if(NS_FAILED(rv)) moz->rightClickUrl_link = NULL; + else moz->rightClickUrl_link = ToNewCString(rightClickUrl); + } return NS_OK; } diff --git a/mozilla/embedding/browser/photon/src/EmbedWindow.h b/mozilla/embedding/browser/photon/src/EmbedWindow.h index 6d2f42bb7d3..13f4793318c 100644 --- a/mozilla/embedding/browser/photon/src/EmbedWindow.h +++ b/mozilla/embedding/browser/photon/src/EmbedWindow.h @@ -63,8 +63,6 @@ class EmbedWindow : public nsIWebBrowserChrome, nsresult CreateWindow (void); void ReleaseChildren (void); int SaveAs(char *fname,char *dirname); - int SaveURI(nsIURI *uri, char *fname); - void CancelSaveURI(); NS_DECL_ISUPPORTS diff --git a/mozilla/embedding/browser/photon/src/HeaderSniffer.cpp b/mozilla/embedding/browser/photon/src/HeaderSniffer.cpp new file mode 100644 index 00000000000..8b3288fc30f --- /dev/null +++ b/mozilla/embedding/browser/photon/src/HeaderSniffer.cpp @@ -0,0 +1,164 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Adrian Mardare + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsILocalFile.h" +#include "nsIChannel.h" +#include "nsIHttpChannel.h" +#include "nsIURL.h" +#include "necko/nsNetUtil.h" +#include "HeaderSniffer.h" +#include "EmbedDownload.h" + +const char* const kPersistContractID = "@mozilla.org/embedding/browser/nsWebBrowserPersist;1"; + +HeaderSniffer::HeaderSniffer( nsIWebBrowserPersist* aPersist, PtMozillaWidget_t *aMoz, nsIURI* aURL, nsIFile* aFile ) +: mPersist(aPersist) +, mTmpFile(aFile) +, mURL(aURL) +{ + mMozillaWidget = aMoz; +} + +HeaderSniffer::~HeaderSniffer( ) +{ +} + +NS_IMPL_ISUPPORTS1(HeaderSniffer, nsIWebProgressListener) + + +/* nsIWebProgressListener interface */ + +NS_IMETHODIMP HeaderSniffer::OnProgressChange(nsIWebProgress *aProgress, nsIRequest *aRequest, PRInt32 curSelfProgress, PRInt32 maxSelfProgress, PRInt32 curTotalProgress, PRInt32 maxTotalProgress) { + return NS_OK; + } + +NS_IMETHODIMP HeaderSniffer::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus) { + + if( aStateFlags & nsIWebProgressListener::STATE_START ) { + + nsCOMPtr kungFuDeathGrip(mPersist); // be sure to keep it alive while we save + // since it owns us as a listener + nsCOMPtr kungFuSuicideGrip(this); // and keep ourselves alive + + nsresult rv; + nsCOMPtr channel = do_QueryInterface(aRequest, &rv); + if (!channel) return rv; + + nsCAutoString contentType, suggested_filename; + channel->GetContentType(contentType); + + // Get the content-disposition if we're an HTTP channel. + nsCOMPtr httpChannel(do_QueryInterface(channel)); + if (httpChannel) { + nsCAutoString contentDisposition; + nsresult rv = httpChannel->GetResponseHeader(nsCAutoString("content-disposition"), contentDisposition); + if( NS_SUCCEEDED(rv) && !contentDisposition.IsEmpty() ) { + PRInt32 index = contentDisposition.Find("filename="); + if( index >= 0 ) { + // Take the substring following the prefix. + index += 9; + contentDisposition.Right(suggested_filename, contentDisposition.Length() - index); + } + } + } + + /* make the client display a file selection dialog */ + PtCallbackInfo_t cbinfo; + PtWebUnknownWithNameCallback_t cb; + + memset( &cbinfo, 0, sizeof( cbinfo ) ); + cbinfo.reason = Pt_CB_MOZ_UNKNOWN; + cbinfo.cbdata = &cb; + cb.action = Pt_WEB_ACTION_OK; + cb.content_type = (char*)contentType.get(); + nsCAutoString spec; mURL->GetSpec( spec ); + cb.url = (char*)spec.get(); + cb.content_length = strlen( cb.url ); + cb.suggested_filename = (char*)suggested_filename.get(); + PtInvokeCallbackList( mMozillaWidget->web_unknown_cb, (PtWidget_t *)mMozillaWidget, &cbinfo ); + /* this will modal wait for a Pt_ARG_WEB_UNKNOWN_RESP, in mozserver */ + + + /* cancel the initial save - we used it only to sniff the header */ + mPersist->CancelSave(); + + /* remove the tmp file */ + PRBool exists; + mTmpFile->Exists(&exists); + if(exists) + mTmpFile->Remove(PR_FALSE); + + /* we have the result in mMozillaWidget->moz_unknown_ctrl */ + if( mMozillaWidget->moz_unknown_ctrl->response == Pt_WEB_RESPONSE_OK ) { + /* start the actual save */ + + /* the user chosen filename is mMozillaWidget->moz_unknown_ctrl->filename */ + nsCOMPtr file(do_CreateInstance("@mozilla.org/file/local;1")); + NS_ENSURE_TRUE(file, NS_ERROR_FAILURE); + + nsCString s ( mMozillaWidget->moz_unknown_ctrl->filename ); + file->InitWithNativePath( s ); + if( !file ) return NS_ERROR_FAILURE; + + /* add this download to our list */ + nsCAutoString spec; + mURL->GetSpec( spec ); + + nsCOMPtr webPersist(do_CreateInstance(kPersistContractID, &rv)); + EmbedDownload *download = new EmbedDownload( mMozillaWidget, mMozillaWidget->moz_unknown_ctrl->download_ticket, spec.get() ); + if( webPersist ) { + download->mPersist = webPersist; + webPersist->SetProgressListener( download ); + webPersist->SaveURI( mURL, nsnull, nsnull, nsnull, nsnull, file ); + } + } + } + return NS_OK; + } + +NS_IMETHODIMP HeaderSniffer::OnLocationChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, nsIURI *location) { + return NS_OK; + } +NS_IMETHODIMP HeaderSniffer::OnStatusChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, nsresult aStatus, const PRUnichar* aMessage) { + return NS_OK; + } +NS_IMETHODIMP HeaderSniffer::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 state) { + return NS_OK; + } + diff --git a/mozilla/embedding/browser/photon/src/HeaderSniffer.h b/mozilla/embedding/browser/photon/src/HeaderSniffer.h new file mode 100644 index 00000000000..5ae0d540ddd --- /dev/null +++ b/mozilla/embedding/browser/photon/src/HeaderSniffer.h @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Adrian Mardare + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef HEADERSNIFFER_EMB +#define HEADERSNIFFER_EMB + +#include "nsIWebProgressListener.h" +#include "nsIWebBrowserPersist.h" +#include "EmbedPrivate.h" +#include "PtMozilla.h" + +class HeaderSniffer : public nsIWebProgressListener +{ +public: + HeaderSniffer( nsIWebBrowserPersist* aPersist, PtMozillaWidget_t *aMoz, nsIURI* aURL, nsIFile* aFile ); + virtual ~HeaderSniffer(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIWEBPROGRESSLISTENER + +private: + PtMozillaWidget_t *mMozillaWidget; + nsIWebBrowserPersist* mPersist; // Weak. It owns us as a listener. + nsCOMPtr mTmpFile; + nsCOMPtr mURL; +}; + +#endif diff --git a/mozilla/embedding/browser/photon/src/Makefile.in b/mozilla/embedding/browser/photon/src/Makefile.in index 6660fcf00c5..6a44483b19c 100644 --- a/mozilla/embedding/browser/photon/src/Makefile.in +++ b/mozilla/embedding/browser/photon/src/Makefile.in @@ -62,6 +62,8 @@ CPPSRCS = \ PtMozilla.cpp \ EmbedStream.cpp \ PromptService.cpp \ + EmbedDownload.cpp \ + HeaderSniffer.cpp \ nsUnknownContentTypeHandler.cpp # Force applications to be built non-statically diff --git a/mozilla/embedding/browser/photon/src/PtMozilla.cpp b/mozilla/embedding/browser/photon/src/PtMozilla.cpp index c8201cc3766..95e44068fd2 100644 --- a/mozilla/embedding/browser/photon/src/PtMozilla.cpp +++ b/mozilla/embedding/browser/photon/src/PtMozilla.cpp @@ -69,6 +69,8 @@ #include "EmbedPrivate.h" #include "EmbedWindow.h" +#include "EmbedDownload.h" +#include "HeaderSniffer.h" #include "PromptService.h" #include "PtMozilla.h" @@ -127,19 +129,6 @@ MozSetPreference(PtWidget_t *widget, int type, char *pref, void *data) } } -int MozSavePageAs(PtWidget_t *widget, char *fname, int type) -{ - PtMozillaWidget_t *moz = (PtMozillaWidget_t *) widget; - char dirname[1024]; - - if (!fname || !widget) return -1; - - sprintf( dirname, "%s.dir", fname ); - moz->EmbedRef->SaveAs( fname, dirname ); - - return (0); -} - static void MozLoadURL(PtMozillaWidget_t *moz, char *url) { @@ -151,6 +140,43 @@ MozLoadURL(PtMozillaWidget_t *moz, char *url) moz->EmbedRef->LoadCurrentURI(); } +/* watch for an Ph_EV_INFO event in order to detect an Ph_OFFSCREEN_INVALID */ +static int EvInfo( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) +{ + if( cbinfo->event && cbinfo->event->type == Ph_EV_INFO && cbinfo->event->subtype == Ph_OFFSCREEN_INVALID ) { + PtMozillaWidget_t *moz = ( PtMozillaWidget_t * ) widget; + nsIPref *pref = moz->EmbedRef->GetPrefs(); + PRBool displayInternalChange = PR_FALSE; + pref->GetBoolPref("browser.display.internaluse.graphics_changed", &displayInternalChange); + pref->SetBoolPref("browser.display.internaluse.graphics_changed", !displayInternalChange); + } + return Pt_CONTINUE; +} + +const char* const kPersistContractID = "@mozilla.org/embedding/browser/nsWebBrowserPersist;1"; + +void MozSaveTarget( char *url, PtMozillaWidget_t *moz ) +{ + nsresult rv; + nsCOMPtr webPersist(do_CreateInstance(kPersistContractID, &rv)); + if( !webPersist ) return; + + nsCOMPtr uri; + NS_NewURI( getter_AddRefs(uri), url ); + + /* create a temporary file */ + char tmp_path[1024]; + tmpnam( tmp_path ); + nsCOMPtr tmpFile; + NS_NewNativeLocalFile(nsDependentCString( tmp_path ), PR_TRUE, getter_AddRefs(tmpFile)); + + /* create a download object, use to sniff the headers for a location indication */ + HeaderSniffer *sniffer = new HeaderSniffer( webPersist, moz, uri, tmpFile ); + + webPersist->SetProgressListener( sniffer ); + webPersist->SaveURI( uri, nsnull, nsnull, nsnull, nsnull, tmpFile ); +} + // defaults function, called on creation of a widget static void mozilla_defaults( PtWidget_t *widget ) @@ -175,6 +201,8 @@ mozilla_defaults( PtWidget_t *widget ) Pt_BOTTOM_ANCHORED_TOP | Pt_RIGHT_ANCHORED_LEFT | Pt_ANCHORS_INVALID; cntr->flags |= Pt_CHILD_GETTING_FOCUS; + + PtAddEventHandler( widget, Ph_EV_INFO, EvInfo, NULL ); } // widget destroy function @@ -344,6 +372,17 @@ mozilla_modify( PtWidget_t *widget, PtArg_t const *argt, PtResourceRec_t const * finder->FindNext( &didFind ); break; } + + case Pt_MOZ_COMMAND_SAVEAS: { + PtWebClient2Command_t *wdata = ( PtWebClient2Command_t * ) argt->len; + char *dirname = ( char * ) calloc( 1, strlen( wdata->SaveasInfo.filename + 7 ) ); + if( dirname ) { + sprintf( dirname, "%s_files", wdata->SaveasInfo.filename ); + moz->EmbedRef->SaveAs( wdata->SaveasInfo.filename, dirname ); + free( dirname ); + } + break; + } } break; @@ -357,16 +396,19 @@ mozilla_modify( PtWidget_t *widget, PtArg_t const *argt, PtResourceRec_t const * case Pt_ARG_MOZ_UNKNOWN_RESP: { PtWebClient2UnknownData_t *unknown = ( PtWebClient2UnknownData_t * ) argt->value; if( unknown->response == Pt_WEB_RESPONSE_CANCEL ) { - Download_t *d = FindDownload( moz, unknown->download_ticket ); - d->mLauncher->Cancel(); - RemoveDownload( moz, unknown->download_ticket ); + EmbedDownload *d = FindDownload( moz, unknown->download_ticket ); + if( d ) { + if( d->mLauncher ) d->mLauncher->Cancel(); /* this will also call the EmbedDownload destructor */ + else if( d->mPersist ) d->mPersist->CancelSave(); /* this will also call the EmbedDownload destructor */ + else delete d; /* just in case neither d->mLauncher or d->mPersist was set */ + } } } break; case Pt_ARG_MOZ_DOWNLOAD: { - moz->EmbedRef->SaveURI((char*)argt->value, (char*) argt->len); + MozSaveTarget( (char*)argt->value, moz ); } break; @@ -454,11 +496,13 @@ mozilla_get_info( PtWidget_t *widget, PtArg_t const *argt, PtResourceRec_t const mozilla_get_pref( widget, (char*)argt->len, (char*) argt->value ); break; - case Pt_ARG_MOZ_GET_CONTEXT: - if ( moz->rightClickUrl ) - *(char**) argt->value = moz->rightClickUrl; - else - *(char*) argt->value = 0; + case Pt_ARG_MOZ_GET_CONTEXT: { + if( argt->len & Pt_MOZ_CONTEXT_LINK ) + *(char**) argt->value = moz->rightClickUrl_link; + else if( argt->len & Pt_MOZ_CONTEXT_IMAGE ) + *(char**) argt->value = moz->rightClickUrl_image; + else *(char**) argt->value = moz->rightClickUrl_link; + } break; case Pt_ARG_MOZ_ENCODING: @@ -967,7 +1011,7 @@ static int StartupEmbedding() // Initialize XPCOM's module info table NSGetStaticModuleInfo = ph_getModuleInfo; #endif - + rv = NS_InitEmbedding(nsnull, nsnull); if( NS_FAILED( rv ) ) return -1; diff --git a/mozilla/embedding/browser/photon/src/PtMozilla.h b/mozilla/embedding/browser/photon/src/PtMozilla.h index 65d8ffa6e07..f196f84c9b9 100644 --- a/mozilla/embedding/browser/photon/src/PtMozilla.h +++ b/mozilla/embedding/browser/photon/src/PtMozilla.h @@ -46,6 +46,8 @@ extern PtWidgetClassRef_t *PtMozilla; +class EmbedDownload; /* forward declaration */ + /* Resources */ #define Pt_ARG_MOZ_GET_URL Pt_RESOURCE( 104, 0 ) @@ -284,9 +286,6 @@ typedef struct mozilla_print_status_t #define Pt_MOZ_PREF_INT 3 #define Pt_MOZ_PREF_COLOR 4 void MozSetPreference(PtWidget_t *widget, int type, char *pref, void *data); -#define Pt_MOZ_SAVEAS_HTML 1 -#define Pt_MOZ_SAVEAS_TEXT 2 -int MozSavePageAs(PtWidget_t *widget, char *fname, int type); // mozilla commands enum @@ -297,7 +296,7 @@ enum Pt_MOZ_COMMAND_SELECTALL, Pt_MOZ_COMMAND_CLEAR, Pt_MOZ_COMMAND_FIND, - Pt_MOZ_COMMAND_SAVEAS, + Pt_MOZ_COMMAND_SAVEAS }; typedef struct { @@ -328,7 +327,7 @@ typedef struct Pt_mozilla_client_widget char disable_exception_dlg, disable_new_windows, spare[2]; int fDownloadCount; - struct Download_ **fDownload; + EmbedDownload **fDownload; /* text_zoom is the text zooming as set by the client ( 100 = 100% ) */ short int text_zoom; @@ -337,7 +336,8 @@ typedef struct Pt_mozilla_client_widget to remember to set the zooming when the content is loaded */ short int actual_text_zoom; - char *rightClickUrl; /* keep the url the user clicked on, to provide it latter for Pt_ARG_WEB_GET_CONTEXT */ + char *rightClickUrl_image; /* keep the url the user clicked on, to provide it latter for Pt_ARG_WEB_GET_CONTEXT */ + char *rightClickUrl_link; /* keep the url the user clicked on, to provide it latter for Pt_ARG_WEB_GET_CONTEXT */ PtMozillaAuthCtrl_t *moz_auth_ctrl; PtMozillaUnknownCtrl_t *moz_unknown_ctrl; diff --git a/mozilla/embedding/browser/photon/src/nsUnknownContentTypeHandler.cpp b/mozilla/embedding/browser/photon/src/nsUnknownContentTypeHandler.cpp index 13c32a46fe2..fd22814a271 100644 --- a/mozilla/embedding/browser/photon/src/nsUnknownContentTypeHandler.cpp +++ b/mozilla/embedding/browser/photon/src/nsUnknownContentTypeHandler.cpp @@ -50,8 +50,6 @@ #include "EmbedPrivate.h" #include "PtMozilla.h" -#include - nsUnknownContentTypeHandler::nsUnknownContentTypeHandler( ) { NS_INIT_ISUPPORTS(); ///* ATENTIE */ printf( "In nsUnknownContentTypeHandler constructor\n" ); @@ -59,12 +57,7 @@ nsUnknownContentTypeHandler::nsUnknownContentTypeHandler( ) { nsUnknownContentTypeHandler::~nsUnknownContentTypeHandler( ) { -///* ATENTIE */ printf( "In destructor mURL=%s\n", mURL ); - - /* remove this download from our list */ - RemoveDownload( mMozillaWidget, mDownloadTicket ); - - if( mURL ) free( mURL ); +///* ATENTIE */ printf( "In nsUnknownContentTypeHandler destr\n" ); } @@ -83,8 +76,6 @@ NS_IMETHODIMP nsUnknownContentTypeHandler::PromptForSaveToFile( nsIHelperAppLaun NS_ENSURE_ARG_POINTER(_retval); *_retval = nsnull; - aLauncher->SetWebProgressListener( this ); - /* try to get the PtMozillawidget_t* pointer form the aContext - use the fact the the WebBrowserContainer is registering itself as nsIDocumentLoaderObserver ( SetDocLoaderObserver ) */ nsCOMPtr domw( do_GetInterface( aWindowContext ) ); @@ -93,8 +84,6 @@ NS_IMETHODIMP nsUnknownContentTypeHandler::PromptForSaveToFile( nsIHelperAppLaun PtWidget_t *w = GetWebBrowser( parent ); PtMozillaWidget_t *moz = ( PtMozillaWidget_t * ) w; - mMozillaWidget = moz; - /* get the suggested filename */ NS_ConvertUCS2toUTF8 theUnicodeString( aDefaultFile ); const char *filename = theUnicodeString.get( ); @@ -102,12 +91,10 @@ NS_IMETHODIMP nsUnknownContentTypeHandler::PromptForSaveToFile( nsIHelperAppLaun /* get the url */ nsCOMPtr aSourceUrl; aLauncher->GetSource( getter_AddRefs(aSourceUrl) ); - char *url; + const char *url; nsCAutoString specString; aSourceUrl->GetSpec(specString); - url = (char *) specString.get(); - - mURL = strdup( url ); + url = specString.get(); /* get the mime type */ nsCOMPtr mimeInfo; @@ -124,7 +111,7 @@ NS_IMETHODIMP nsUnknownContentTypeHandler::PromptForSaveToFile( nsIHelperAppLaun cbinfo.cbdata = &cb; cb.action = Pt_WEB_ACTION_OK; cb.content_type = mimeType; - cb.url = url; + cb.url = (char *)url; cb.content_length = strlen( cb.url ); cb.suggested_filename = (char*)filename; PtInvokeCallbackList( moz->web_unknown_cb, (PtWidget_t *)moz, &cbinfo ); @@ -133,8 +120,6 @@ NS_IMETHODIMP nsUnknownContentTypeHandler::PromptForSaveToFile( nsIHelperAppLaun /* we have the result in moz->moz_unknown_ctrl */ if( moz->moz_unknown_ctrl->response != Pt_WEB_RESPONSE_OK ) return NS_ERROR_ABORT; - mDownloadTicket = moz->moz_unknown_ctrl->download_ticket; - /* the user chosen filename is moz->moz_unknown_ctrl->filename */ nsCOMPtr file(do_CreateInstance("@mozilla.org/file/local;1")); NS_ENSURE_TRUE(file, NS_ERROR_FAILURE); @@ -147,7 +132,9 @@ NS_IMETHODIMP nsUnknownContentTypeHandler::PromptForSaveToFile( nsIHelperAppLaun NS_ADDREF( *_retval ); /* add this download to our list */ - AddDownload( mMozillaWidget, mDownloadTicket, aLauncher, this ); + EmbedDownload *download = new EmbedDownload( moz, moz->moz_unknown_ctrl->download_ticket, url ); + download->mLauncher = aLauncher; + aLauncher->SetWebProgressListener( download ); return NS_OK; } @@ -180,119 +167,6 @@ PtWidget_t *nsUnknownContentTypeHandler::GetWebBrowser(nsIDOMWindow *aWindow) return val; } - -/* nsIWebProgressListener interface */ - -/* void onProgressChange (in nsIWebProgress aProgress, in nsIRequest aRequest, in long curSelfProgress, in long maxSelfProgress, in long curTotalProgress, in long maxTotalProgress); */ -NS_IMETHODIMP nsUnknownContentTypeHandler::OnProgressChange(nsIWebProgress *aProgress, nsIRequest *aRequest, PRInt32 curSelfProgress, PRInt32 maxSelfProgress, PRInt32 curTotalProgress, PRInt32 maxTotalProgress) { - -///* ATENTIE */ printf("this=%p OnProgressChange curSelfProgress=%d maxSelfProgress=%d curTotalProgress=%d maxTotalProgress=%d\n", -//this, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress ); - - ReportDownload( Pt_WEB_DOWNLOAD_PROGRESS, curSelfProgress, maxSelfProgress, "" ); - - return NS_OK; - } - -NS_IMETHODIMP nsUnknownContentTypeHandler::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus) { - if( aStateFlags & STATE_STOP ) { - ReportDownload( Pt_WEB_DOWNLOAD_DONE, 0, 0, "" ); - } - return NS_OK; - } - -NS_IMETHODIMP nsUnknownContentTypeHandler::OnLocationChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, nsIURI *location) { - return NS_OK; - } -NS_IMETHODIMP nsUnknownContentTypeHandler::OnStatusChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, nsresult aStatus, const PRUnichar* aMessage) { - return NS_OK; - } -NS_IMETHODIMP nsUnknownContentTypeHandler::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 state) { - return NS_OK; - } - -NS_IMETHODIMP nsUnknownContentTypeHandler::ReportDownload( int type, int current, int total, char *message ) -{ - PtCallbackInfo_t cbinfo; - PtWebDownloadCallback_t cb; - - memset( &cbinfo, 0, sizeof( cbinfo ) ); - cbinfo.reason = Pt_CB_MOZ_DOWNLOAD; - cbinfo.cbdata = &cb; - - cb.download_ticket = mDownloadTicket; - cb.type = type; - cb.url = mURL; - cb.current = current; - cb.total = total; - cb.message = message; - - PtInvokeCallbackList( mMozillaWidget->web_download_cb, (PtWidget_t *)mMozillaWidget, &cbinfo ); - return NS_OK; - } - -void AddDownload( PtMozillaWidget_t *moz, int download_ticket, nsIHelperAppLauncher* aLauncher, nsUnknownContentTypeHandler *unknown ) -{ - Download_t *d; - - d = ( Download_t * ) calloc( 1, sizeof( Download_t ) ); - if( !d ) return; - - d->download_ticket = download_ticket; - d->mLauncher = aLauncher; - NS_RELEASE( aLauncher ); - - d->unknown = unknown; - - /* insert d into moz->fDownload */ - moz->fDownload = ( Download_t ** ) realloc( moz->fDownload, ( moz->fDownloadCount + 1 ) * sizeof( Download_t * ) ); - if( !moz->fDownload ) return; - - moz->fDownload[ moz->fDownloadCount ] = d; - moz->fDownloadCount++; -} - -void RemoveDownload( PtMozillaWidget_t *moz, int download_ticket ) -{ - int i; - - /* remove d from the moz->fDownload */ - for( i=0; ifDownloadCount; i++ ) { - if( moz->fDownload[i]->download_ticket == download_ticket ) break; - } - - if( ifDownloadCount ) { - int j; - Download_t *d; - - d = moz->fDownload[i]; - - for( j=i; jfDownloadCount-1; j++ ) - moz->fDownload[j] = moz->fDownload[j+1]; - - moz->fDownloadCount--; - if( !moz->fDownloadCount ) { - free( moz->fDownload ); - moz->fDownload = NULL; - } - - d->unknown->ReportDownload( Pt_WEB_DOWNLOAD_CANCEL, 0, 0, "" ); - - free( d ); - } - -///* ATENTIE */ printf( "after remove fDownloadCount=%d\n", moz->fDownloadCount ); -} - -Download_t *FindDownload( PtMozillaWidget_t *moz, int download_ticket ) -{ - int i; - for( i=0; ifDownloadCount; i++ ) { - if( moz->fDownload[i]->download_ticket == download_ticket ) return moz->fDownload[i]; - } - return NULL; -} - //####################################################################################### #define className nsUnknownContentTypeHandler diff --git a/mozilla/embedding/browser/photon/src/nsUnknownContentTypeHandler.h b/mozilla/embedding/browser/photon/src/nsUnknownContentTypeHandler.h index a978c870b59..d7f673750ee 100644 --- a/mozilla/embedding/browser/photon/src/nsUnknownContentTypeHandler.h +++ b/mozilla/embedding/browser/photon/src/nsUnknownContentTypeHandler.h @@ -1,19 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Adrian Mardare + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + #ifndef NSUNKNOWNCONTENTTYPEHANDLER_EMB #define NSUNKNOWNCONTENTTYPEHANDLER_EMB #include "nsIHelperAppLauncherDialog.h" #include "nsIExternalHelperAppService.h" -#include "nsIWebProgressListener.h" #include "nsIWebBrowserPersist.h" #include "nsWeakReference.h" #include "nsIWindowWatcher.h" #include "nsIEmbeddingSiteWindow.h" +#include "EmbedDownload.h" #include "PtMozilla.h" static NS_DEFINE_CID( kCID, NS_IHELPERAPPLAUNCHERDIALOG_IID ); -class nsUnknownContentTypeHandler : public nsIHelperAppLauncherDialog, nsIWebProgressListener { +class nsUnknownContentTypeHandler : public nsIHelperAppLauncherDialog { public: @@ -27,28 +66,12 @@ public: // This class implements the nsIHelperAppLauncherDialog interface functions. NS_DECL_NSIHELPERAPPLAUNCHERDIALOG - NS_DECL_NSIWEBPROGRESSLISTENER - - NS_IMETHOD ReportDownload( int type, int current, int total, char *message ); private: PtWidget_t* GetWebBrowser(nsIDOMWindow *aWindow); - PtMozillaWidget_t *mMozillaWidget; - char *mURL; - long mDownloadTicket; }; // nsUnknownContentTypeHandler int Init_nsUnknownContentTypeHandler_Factory( ); -/* download related */ -typedef struct Download_ { - int download_ticket; - nsCOMPtr mLauncher; - nsUnknownContentTypeHandler *unknown; - } Download_t; -void AddDownload( PtMozillaWidget_t *moz, int download_ticket, nsIHelperAppLauncher* aLauncher, nsUnknownContentTypeHandler *unknown ); -void RemoveDownload( PtMozillaWidget_t *moz, int download_ticket ); -Download_t *FindDownload( PtMozillaWidget_t *moz, int download_ticket ); - #endif