Bug 241082 exthandler should require just nsITransfer, not nsIDownload

patch by Zbigniew Braniecki <gandalf@firefox.pl> r=biesi sr=darin
This commit is contained in:
cbiesinger%web.de 2005-01-04 13:40:51 +00:00
Родитель c6668610ec
Коммит e279a2a949
17 изменённых файлов: 246 добавлений и 228 удалений

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

@ -266,7 +266,7 @@ function foundHeaderInfo(aSniffer, aData, aSkipPrompt)
persist.persistFlags &= ~nsIWBP.PERSIST_FLAGS_NO_CONVERSION;
// Create download and initiate it (below)
var dl = Components.classes["@mozilla.org/download;1"].createInstance(Components.interfaces.nsIDownload);
var tr = Components.classes["@mozilla.org/download;1"].createInstance(Components.interfaces.nsITransfer);
if (isDocument && saveAsType != kSaveAsType_URL) {
// Saving a Document, not a URI:
@ -295,11 +295,11 @@ function foundHeaderInfo(aSniffer, aData, aSkipPrompt)
}
const kWrapColumn = 80;
dl.init(aSniffer.uri, persistArgs.target, null, null, null, persist);
tr.init(aSniffer.uri, persistArgs.target, null, null, null, persist);
persist.saveDocument(persistArgs.source, persistArgs.target, filesFolder,
persistArgs.contentType, encodingFlags, kWrapColumn);
} else {
dl.init(source, persistArgs.target, null, null, null, persist);
tr.init(source, persistArgs.target, null, null, null, persist);
var referrer = aData.referrer || getReferrer(document)
persist.saveURI(source, null, referrer, persistArgs.postData, null, persistArgs.target);
}

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

@ -163,12 +163,6 @@ nsDownloadListener::GetDisplayName(PRUnichar * *aDisplayName)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDownloadListener::SetDisplayName(const PRUnichar * aDisplayName)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute long long startTime; */
NS_IMETHODIMP
nsDownloadListener::GetStartTime(PRInt64 *aStartTime)

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

@ -141,12 +141,6 @@ nsDownloadListener::GetDisplayName(PRUnichar * *aDisplayName)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDownloadListener::SetDisplayName(const PRUnichar * aDisplayName)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute long long startTime; */
NS_IMETHODIMP
nsDownloadListener::GetStartTime(PRInt64 *aStartTime)

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

@ -136,11 +136,6 @@ NS_IMETHODIMP CDownload::GetDisplayName(PRUnichar * *aDisplayName)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP CDownload::SetDisplayName(const PRUnichar * aDisplayName)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute long long startTime; */
NS_IMETHODIMP CDownload::GetStartTime(PRInt64 *aStartTime)
{

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

@ -62,8 +62,8 @@ interface nsIDOMWindow;
* not need to hold a reference to it.
*/
[scriptable, uuid(1915c4f1-ee57-4684-b46a-0d9f695403b4)]
interface nsIProgressDialog : nsITransfer {
[scriptable, uuid(80183bd3-b9e8-45a6-a2ee-1449bc0d4253)]
interface nsIProgressDialog : nsIDownload {
/**
* Open the dialog
*

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

@ -140,7 +140,7 @@
#include "nsCExternalHandlerService.h"
#include "nsIExternalProtocolService.h"
#include "nsIMIMEService.h"
#include "nsIDownload.h"
#include "nsITransfer.h"
#include "nsILinkHandler.h"
@ -280,7 +280,7 @@ public:
nsCString m_contentType; // used only when saving attachment
nsCOMPtr<nsIWebProgressListener> mWebProgressListener;
nsCOMPtr<nsITransfer> mTransfer;
PRInt32 mProgress;
PRInt32 mContentLength;
PRBool mCanceled;
@ -1793,8 +1793,8 @@ nsresult nsSaveMsgListener::InitializeDownload(nsIRequest * aRequest, PRInt32 aB
// so make an arbitrary decision based on the content length of the attachment
if (mContentLength != -1 && mContentLength > aBytesDownloaded * 2)
{
nsCOMPtr<nsIDownload> dl = do_CreateInstance("@mozilla.org/download;1", &rv);
if (dl && outputFile)
nsCOMPtr<nsITransfer> tr = do_CreateInstance("@mozilla.org/download;1", &rv);
if (tr && outputFile)
{
PRTime timeDownloadStarted = PR_Now();
@ -1803,11 +1803,11 @@ nsresult nsSaveMsgListener::InitializeDownload(nsIRequest * aRequest, PRInt32 aB
nsCOMPtr<nsIURI> url;
channel->GetURI(getter_AddRefs(url));
rv = dl->Init(url, outputURI, nsnull, mimeinfo, timeDownloadStarted, nsnull);
rv = tr->Init(url, outputURI, nsnull, mimeinfo, timeDownloadStarted, nsnull);
dl->SetObserver(this);
tr->SetObserver(this);
// now store the web progresslistener
mWebProgressListener = do_QueryInterface(dl);
mTransfer = tr;
}
}
@ -1951,11 +1951,11 @@ nsSaveMsgListener::OnStopRequest(nsIRequest* request, nsISupports* aSupport,
}
}
if(mWebProgressListener)
if(mTransfer)
{
mWebProgressListener->OnProgressChange(nsnull, nsnull, mContentLength, mContentLength, mContentLength, mContentLength);
mWebProgressListener->OnStateChange(nsnull, nsnull, nsIWebProgressListener::STATE_STOP, NS_OK);
mWebProgressListener = nsnull; // break any circular dependencies between the progress dialog and use
mTransfer->OnProgressChange(nsnull, nsnull, mContentLength, mContentLength, mContentLength, mContentLength);
mTransfer->OnStateChange(nsnull, nsnull, nsIWebProgressListener::STATE_STOP, NS_OK);
mTransfer = nsnull; // break any circular dependencies between the progress dialog and use
}
Release(); // all done kill ourself
@ -2010,8 +2010,8 @@ nsSaveMsgListener::OnDataAvailable(nsIRequest* request,
}
}
if (NS_SUCCEEDED(rv) && mWebProgressListener) // Send progress notification.
mWebProgressListener->OnProgressChange(nsnull, request, mProgress, mContentLength, mProgress, mContentLength);
if (NS_SUCCEEDED(rv) && mTransfer) // Send progress notification.
mTransfer->OnProgressChange(nsnull, request, mProgress, mContentLength, mProgress, mContentLength);
}
return rv;
}

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

@ -595,7 +595,7 @@ nsDownloadManager::AddDownload(DownloadType aDownloadType,
if (displayName.IsEmpty()) {
targetFile->GetLeafName(displayName);
}
(*aDownload)->SetDisplayName(displayName.get());
internalDownload->SetDisplayName(displayName.get());
nsCOMPtr<nsIRDFLiteral> nameLiteral;
gRDFService->GetLiteral(displayName.get(), getter_AddRefs(nameLiteral));
@ -1903,6 +1903,29 @@ nsDownload::SetTarget(nsIURI* aTarget)
return NS_OK;
}
nsresult
nsDownload::SetDisplayName(const PRUnichar* aDisplayName)
{
mDisplayName = aDisplayName;
nsCOMPtr<nsIRDFDataSource> ds;
mDownloadManager->GetDatasource(getter_AddRefs(ds));
nsCOMPtr<nsIRDFLiteral> nameLiteral;
nsCOMPtr<nsIRDFResource> res;
nsAutoString path;
nsresult rv = GetFilePathFromURI(mTarget, path);
if (NS_FAILED(rv)) return rv;
gRDFService->GetUnicodeResource(path, getter_AddRefs(res));
gRDFService->GetLiteral(aDisplayName, getter_AddRefs(nameLiteral));
ds->Assert(res, gNC_Name, nameLiteral, PR_TRUE);
return NS_OK;
}
nsresult
nsDownload::GetTransferInformation(PRInt32* aCurr, PRInt32* aMax)
{
@ -2152,28 +2175,6 @@ nsDownload::Init(nsIURI* aSource,
return NS_OK;
}
NS_IMETHODIMP
nsDownload::SetDisplayName(const PRUnichar* aDisplayName)
{
mDisplayName = aDisplayName;
nsCOMPtr<nsIRDFDataSource> ds;
mDownloadManager->GetDatasource(getter_AddRefs(ds));
nsCOMPtr<nsIRDFLiteral> nameLiteral;
nsCOMPtr<nsIRDFResource> res;
nsAutoString path;
nsresult rv = GetFilePathFromURI(mTarget, path);
if (NS_FAILED(rv)) return rv;
gRDFService->GetUnicodeResource(path, getter_AddRefs(res));
gRDFService->GetLiteral(aDisplayName, getter_AddRefs(nameLiteral));
ds->Assert(res, gNC_Name, nameLiteral, PR_TRUE);
return NS_OK;
}
NS_IMETHODIMP
nsDownload::GetDisplayName(PRUnichar** aDisplayName)
{

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

@ -194,8 +194,7 @@ private:
nsCOMPtr<nsIRDFDataSource> mInner;
};
class nsDownload : public nsIDownload,
public nsIWebProgressListener
class nsDownload : public nsIDownload
{
public:
NS_DECL_NSIWEBPROGRESSLISTENER
@ -220,6 +219,7 @@ protected:
nsresult GetDialog(nsIProgressDialog** aDialog);
nsresult SetPersist(nsIWebBrowserPersist* aPersist);
nsresult SetTarget(nsIURI* aTarget);
nsresult SetDisplayName(const PRUnichar* aDisplayName);
nsresult SetSource(nsIURI* aSource);
nsresult GetTransferInformation(PRInt32* aCurr, PRInt32* aMax);
nsresult SetMIMEInfo(nsIMIMEInfo* aMIMEInfo);

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

@ -85,6 +85,7 @@ XPIDLSRCS = \
nsIURILoader.idl \
nsCURILoader.idl \
nsIDownload.idl \
nsITransfer.idl \
nsIDocumentLoader.idl \
$(NULL)

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

@ -36,7 +36,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsITransfer.idl"
interface nsIURI;
interface nsILocalFile;
@ -45,88 +45,7 @@ interface nsIWebBrowserPersist;
interface nsIWebProgressListener;
interface nsIMIMEInfo;
[scriptable, uuid(6ce8aba0-b159-411a-b14e-d1ae80b6aa9d)]
interface nsITransfer : nsISupports {
/**
* Initializes the transfer with certain properties. This function must
* be called prior to accessing any properties on this interface.
*
* @param aSource The source URI of the transfer.
*
* @param aTarget The target URI of the transfer.
*
* @param aDisplayName The user-readable description of the transfer.
*
* @param aMIMEInfo The MIME info associated with the target,
* including MIME type and helper app when appropriate.
* This parameter is optional.
*
* @param aPersist The "persist" used for this transfer. If set,
* the manager will set its listener to the transfer item
* and use it for cancellation. If not set, the client
* is expected to set the transfer item as the listener on
* whatever transfer component is being used, and to
* set an observer on the transfer item that listens for
* the "oncancel" topic and cancels the transfer.
*/
void init(in nsIURI aSource,
in nsIURI aTarget,
in wstring aDisplayName,
in nsIMIMEInfo aMIMEInfo,
in long long startTime,
in nsIWebBrowserPersist aPersist);
/**
* The source of the transfer.
*/
readonly attribute nsIURI source;
/**
* The target of the transfer.
*/
readonly attribute nsIURI target;
/**
* Optional. If set, it will be used for cancellation, and the transfer
* will be set as its listener. If not, |observer| should be set to listen
* and respond accordingly to topics like oncancel, and the client promises
* to set the transfer item as the listener for whatever transfer component
* is being used.
*/
readonly attribute nsIWebBrowserPersist persist;
/**
* The user-readable description of the transfer.
*/
attribute wstring displayName;
/**
* The time a transfer was started.
*/
readonly attribute long long startTime;
/**
* Optional. If set, it will contain the target's relevant MIME information.
* This includes it's MIME Type, helper app, and whether that helper should be
* executed.
*/
readonly attribute nsIMIMEInfo MIMEInfo;
/**
* Optional; transferring information is passed to this listener and used to
* update client UI.
*/
attribute nsIWebProgressListener listener;
/**
* If set, receives notifications of events like cancel ("oncancel").
* Must be set if no persist object is specified (see above).
*/
attribute nsIObserver observer;
};
[scriptable, uuid(0332d825-f3dd-4f15-abaa-e2958d396a52)]
[scriptable, uuid(4584178b-ebbd-4d5e-91d3-aa676c2291d2)]
interface nsIDownload : nsITransfer {
/**
@ -150,31 +69,45 @@ interface nsIDownload : nsITransfer {
* Unknown size is represented by 0.
*/
readonly attribute PRUint64 size;
/**
* The source of the transfer.
*/
readonly attribute nsIURI source;
/**
* The target of the transfer.
*/
readonly attribute nsIURI target;
/**
* Optional. If set, it will be used for cancellation, and the transfer
* will be set as its listener. If not, |observer| should be set to listen
* and respond accordingly to topics like oncancel, and the client promises
* to set the transfer item as the listener for whatever transfer component
* is being used.
*/
readonly attribute nsIWebBrowserPersist persist;
/**
* The user-readable description of the transfer.
*/
readonly attribute wstring displayName;
/**
* The time a transfer was started.
*/
readonly attribute long long startTime;
/**
* Optional. If set, it will contain the target's relevant MIME information.
* This includes it's MIME Type, helper app, and whether that helper should be
* executed.
*/
readonly attribute nsIMIMEInfo MIMEInfo;
};
%{C++
/**
* A component with this contract ID will be created each time a download is
* started, and Init will be called on it and an observer will be set.
*
* Notifications of the download progress will happen via
* nsIWebProgressListener.
*
* If nsIObserver is implemented, the component may get a notification with
* topic "temp-file" and an nsILocalFile instance as subject, which indicates
* the location of a temporary file; i.e. a file in which the received data will
* be stored, but which is not equal to the target file.
*
* INTERFACES THAT NEED TO BE IMPLEMENTED:
* nsITransfer
* nsIDownload
* nsIWebProgressListener
*
* INTERFACES THAT MAY BE IMPLEMENTED:
* nsIObserver
*/
#define NS_DOWNLOAD_CONTRACTID "@mozilla.org/download;1"
// {E3FA9D0A-1DD1-11B2-BDEF-8C720B597445}
#define NS_DOWNLOAD_CID \
{ 0xe3fa9d0a, 0x1dd1, 0x11b2, { 0xbd, 0xef, 0x8c, 0x72, 0x0b, 0x59, 0x74, 0x45 } }

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

@ -0,0 +1,112 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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):
* Blake Ross <blaker@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 MPL, 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 MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIWebProgressListener.idl"
interface nsIURI;
interface nsIObserver;
interface nsIWebBrowserPersist;
interface nsIMIMEInfo;
[scriptable, uuid(e57c27f8-2a4e-4d80-bf80-1ffd634c734e)]
interface nsITransfer : nsIWebProgressListener {
/**
* Initializes the transfer with certain properties. This function must
* be called prior to accessing any properties on this interface.
*
* @param aSource The source URI of the transfer.
*
* @param aTarget The target URI of the transfer.
*
* @param aDisplayName The user-readable description of the transfer.
*
* @param aMIMEInfo The MIME info associated with the target,
* including MIME type and helper app when appropriate.
* This parameter is optional.
*
* @param aPersist The "persist" used for this transfer. If set,
* the manager will set its listener to the transfer item
* and use it for cancellation. If not set, the client
* is expected to set the transfer item as the listener on
* whatever transfer component is being used, and to
* set an observer on the transfer item that listens for
* the "oncancel" topic and cancels the transfer.
*/
void init(in nsIURI aSource,
in nsIURI aTarget,
in wstring aDisplayName,
in nsIMIMEInfo aMIMEInfo,
in long long startTime,
in nsIWebBrowserPersist aPersist);
/**
* Optional; transferring information is passed to this listener and used to
* update client UI.
*/
attribute nsIWebProgressListener listener;
/**
* If set, receives notifications of events like cancel ("oncancel").
* Must be set if no persist object is specified (see above).
*/
attribute nsIObserver observer;
};
%{C++
/**
* A component with this contract ID will be created each time a download is
* started, and nsITransfer::Init will be called on it and an observer will be set.
*
* Notifications of the download progress will happen via
* nsIWebProgressListener.
*
* If nsIObserver is implemented, the component may get a notification with
* topic "temp-file" and an nsILocalFile instance as subject, which indicates
* the location of a temporary file; i.e. a file in which the received data will
* be stored, but which is not equal to the target file.
*
* INTERFACES THAT MUST BE IMPLEMENTED:
* nsITransfer
* nsIWebProgressListener
*
* INTERFACES THAT MAY BE IMPLEMENTED:
* nsIObserver
*/
#define NS_DOWNLOAD_CONTRACTID "@mozilla.org/download;1"
%}

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

@ -56,7 +56,7 @@
#include "nsIMIMEService.h"
#include "nsILoadGroup.h"
#include "nsIWebProgressListener.h"
#include "nsIDownload.h"
#include "nsITransfer.h"
#include "nsReadableUtils.h"
#include "nsIRequest.h"
#include "nsDirectoryServiceDefs.h"
@ -1980,13 +1980,13 @@ NS_IMETHODIMP nsExternalAppHandler::OnStopRequest(nsIRequest *request, nsISuppor
ExecuteDesiredAction();
// At this point, the channel should still own us. So releasing the reference
// to us in the nsIDownload should be ok.
// This nsIDownload object holds a reference to us (we are its observer), so
// to us in the nsITransfer should be ok.
// This nsITransfer object holds a reference to us (we are its observer), so
// we need to release the reference to break a reference cycle (and therefore
// to prevent leaking)
nsCOMPtr<nsIDownload> dl(do_QueryInterface(mWebProgressListener));
if (dl)
dl->SetObserver(nsnull);
nsCOMPtr<nsITransfer> tr(do_QueryInterface(mWebProgressListener));
if (tr)
tr->SetObserver(nsnull);
mWebProgressListener = nsnull;
return NS_OK;
@ -2090,7 +2090,7 @@ NS_IMETHODIMP nsExternalAppHandler::GetSuggestedFileName(nsAString& aSuggestedFi
return NS_OK;
}
nsresult nsExternalAppHandler::InitializeDownload(nsIDownload* aDownload)
nsresult nsExternalAppHandler::InitializeDownload(nsITransfer* aTransfer)
{
nsresult rv;
@ -2098,14 +2098,14 @@ nsresult nsExternalAppHandler::InitializeDownload(nsIDownload* aDownload)
rv = NS_NewFileURI(getter_AddRefs(target), mFinalFileDestination);
if (NS_FAILED(rv)) return rv;
rv = aDownload->Init(mSourceUrl, target, nsnull,
rv = aTransfer->Init(mSourceUrl, target, nsnull,
mMimeInfo, mTimeDownloadStarted, nsnull);
if (NS_FAILED(rv)) return rv;
rv = aDownload->SetObserver(this);
rv = aTransfer->SetObserver(this);
// Tell the listener about the location of the target file
nsCOMPtr<nsIObserver> obs(do_QueryInterface(aDownload));
nsCOMPtr<nsIObserver> obs(do_QueryInterface(aTransfer));
if (obs)
obs->Observe(mTempFile, "temp-file", nsnull);
@ -2120,25 +2120,21 @@ nsresult nsExternalAppHandler::CreateProgressListener()
// need to break the reference cycle.
mDialog = nsnull;
nsresult rv;
nsCOMPtr<nsIWebProgressListener> listener;
nsCOMPtr<nsIDownload> dl = do_CreateInstance("@mozilla.org/download;1", &rv);
if (NS_SUCCEEDED(rv)) {
InitializeDownload(dl);
listener = do_QueryInterface(dl);
}
nsCOMPtr<nsITransfer> tr = do_CreateInstance("@mozilla.org/download;1", &rv);
if (NS_SUCCEEDED(rv))
InitializeDownload(tr);
// note we might not have a listener here if the QI() failed, or if
// there is no nsIDownload object, but we still call
// there is no nsITransfer object, but we still call
// SetWebProgressListener() to make sure our progress state is sane
// NOTE: This will set up a reference cycle (this nsIDownload has us set up as
// NOTE: This will set up a reference cycle (this nsITransfer has us set up as
// its observer). This cycle will be broken in Cancel, CloseProgressWindow or
// OnStopRequest.
SetWebProgressListener(listener);
SetWebProgressListener(tr);
if (listener)
listener->OnStateChange(nsnull, mRequest, nsIWebProgressListener::STATE_START, NS_OK);
if (tr)
tr->OnStateChange(nsnull, mRequest, nsIWebProgressListener::STATE_START, NS_OK);
return rv;
}
@ -2456,9 +2452,9 @@ NS_IMETHODIMP nsExternalAppHandler::Cancel()
// Release the listener, to break the reference cycle with it (we are the
// observer of the listener).
nsCOMPtr<nsIDownload> dl(do_QueryInterface(mWebProgressListener));
if (dl)
dl->SetObserver(nsnull);
nsCOMPtr<nsITransfer> tr(do_QueryInterface(mWebProgressListener));
if (tr)
tr->SetObserver(nsnull);
mWebProgressListener = nsnull;
return NS_OK;

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

@ -76,7 +76,7 @@
class nsExternalAppHandler;
class nsIMIMEInfo;
class nsIRDFService;
class nsIDownload;
class nsITransfer;
/**
* The helper app service. Responsible for handling content that Mozilla
@ -450,9 +450,9 @@ protected:
PRBool GetNeverAskFlagFromPref(const char * prefName, const char * aContentType);
/**
* Initialize an nsIDownload object for use as a progress object
* Initialize an nsITransfer object for use as a progress object
*/
nsresult InitializeDownload(nsIDownload*);
nsresult InitializeDownload(nsITransfer*);
/**
* Helper routine to ensure mSuggestedFileName is "correct";

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

@ -339,7 +339,7 @@ function internalSave(aURL, aDocument, aDefaultFileName, aShouldBypassCache,
persist.persistFlags |= nsIWBP.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
// Create download and initiate it (below)
var dl = Components.classes["@mozilla.org/download;1"].createInstance(Components.interfaces.nsIDownload);
var tr = Components.classes["@mozilla.org/download;1"].createInstance(Components.interfaces.nsITransfer);
if (useSaveDocument) {
// Saving a Document, not a URI:
@ -367,12 +367,12 @@ function internalSave(aURL, aDocument, aDefaultFileName, aShouldBypassCache,
}
const kWrapColumn = 80;
dl.init((aChosenData ? aChosenData.uri : fileInfo.uri),
tr.init((aChosenData ? aChosenData.uri : fileInfo.uri),
persistArgs.target, null, null, null, persist);
persist.saveDocument(persistArgs.source, persistArgs.target, filesFolder,
persistArgs.contentType, encodingFlags, kWrapColumn);
} else {
dl.init((aChosenData ? aChosenData.uri : source),
tr.init((aChosenData ? aChosenData.uri : source),
persistArgs.target, null, null, null, persist);
var referer = aReferrer || getReferrer(document);
persist.saveURI((aChosenData ? aChosenData.uri : source),

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

@ -953,6 +953,28 @@ nsDownload::Suspend()
return mRequest->Suspend();
}
nsresult
nsDownload::SetDisplayName(const PRUnichar* aDisplayName)
{
mDisplayName = aDisplayName;
nsCOMPtr<nsIRDFDataSource> ds;
mDownloadManager->GetDataSource(getter_AddRefs(ds));
nsCOMPtr<nsIRDFLiteral> nameLiteral;
nsCOMPtr<nsIRDFResource> res;
nsCAutoString path;
nsresult rv = GetFilePathUTF8(mTarget, path);
if (NS_FAILED(rv)) return rv;
gRDFService->GetResource(path, getter_AddRefs(res));
gRDFService->GetLiteral(aDisplayName, getter_AddRefs(nameLiteral));
ds->Assert(res, gNC_Name, nameLiteral, PR_TRUE);
return NS_OK;
}
nsresult
nsDownload::Resume()
{
@ -1291,28 +1313,6 @@ nsDownload::Init(nsIURI* aSource,
return NS_OK;
}
NS_IMETHODIMP
nsDownload::SetDisplayName(const PRUnichar* aDisplayName)
{
mDisplayName = aDisplayName;
nsCOMPtr<nsIRDFDataSource> ds;
mDownloadManager->GetDataSource(getter_AddRefs(ds));
nsCOMPtr<nsIRDFLiteral> nameLiteral;
nsCOMPtr<nsIRDFResource> res;
nsCAutoString path;
nsresult rv = GetFilePathUTF8(mTarget, path);
if (NS_FAILED(rv)) return rv;
gRDFService->GetResource(path, getter_AddRefs(res));
gRDFService->GetLiteral(aDisplayName, getter_AddRefs(nameLiteral));
ds->Assert(res, gNC_Name, nameLiteral, PR_TRUE);
return NS_OK;
}
NS_IMETHODIMP
nsDownload::GetDisplayName(PRUnichar** aDisplayName)
{

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

@ -105,7 +105,6 @@ private:
};
class nsDownload : public nsIDownload,
public nsIWebProgressListener,
public nsIObserver
{
public:
@ -119,6 +118,7 @@ public:
~nsDownload();
nsresult Suspend();
nsresult SetDisplayName(const PRUnichar* aDisplayName);
nsresult Resume();
void DisplayDownloadFinishedAlert();

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

@ -47,8 +47,7 @@
#define DOWNLOAD_MANAGER_BEHAVIOR_PREF "browser.downloadmanager.behavior"
class nsDownloadProxy : public nsIDownload,
public nsIWebProgressListener
class nsDownloadProxy : public nsIDownload
{
public:
@ -94,13 +93,6 @@ public:
return mInner->GetDisplayName(aDisplayName);
}
NS_IMETHODIMP SetDisplayName(const PRUnichar* aDisplayName)
{
if (!mInner)
return NS_ERROR_NOT_INITIALIZED;
return mInner->SetDisplayName(aDisplayName);
}
NS_IMETHODIMP GetMIMEInfo(nsIMIMEInfo** aMIMEInfo)
{
if (!mInner)