mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
8c296bbcd4
This patch was generated by a script. Here's the source of the script for future reference: function convert() { echo "Converting $1 to $2..." find . ! -wholename "*nsprpub*" \ ! -wholename "*security/nss*" \ ! -wholename "*/.hg*" \ ! -wholename "obj-ff-dbg*" \ ! -name nsXPCOMCID.h \ ! -name prtypes.h \ -type f \ \( -iname "*.cpp" \ -o -iname "*.h" \ -o -iname "*.c" \ -o -iname "*.cc" \ -o -iname "*.idl" \ -o -iname "*.ipdl" \ -o -iname "*.ipdlh" \ -o -iname "*.mm" \) | \ xargs -n 1 sed -i -e "s/\b$1\b/$2/g" } convert PRInt8 int8_t convert PRUint8 uint8_t convert PRInt16 int16_t convert PRUint16 uint16_t convert PRInt32 int32_t convert PRUint32 uint32_t convert PRInt64 int64_t convert PRUint64 uint64_t convert PRIntn int convert PRUintn unsigned convert PRSize size_t convert PROffset32 int32_t convert PROffset64 int64_t convert PRPtrdiff ptrdiff_t convert PRFloat64 double
155 lines
5.5 KiB
C++
155 lines
5.5 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef downloadproxy___h___
|
|
#define downloadproxy___h___
|
|
|
|
#include "nsIDownloadManager.h"
|
|
#include "nsIPrefBranch.h"
|
|
#include "nsIPrefService.h"
|
|
#include "nsIMIMEInfo.h"
|
|
#include "nsIFileURL.h"
|
|
#include "nsIDownloadManagerUI.h"
|
|
|
|
#define PREF_BDM_SHOWWHENSTARTING "browser.download.manager.showWhenStarting"
|
|
#define PREF_BDM_FOCUSWHENSTARTING "browser.download.manager.focusWhenStarting"
|
|
|
|
class nsDownloadProxy : public nsITransfer
|
|
{
|
|
public:
|
|
|
|
nsDownloadProxy() { }
|
|
virtual ~nsDownloadProxy() { }
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_IMETHODIMP Init(nsIURI* aSource,
|
|
nsIURI* aTarget,
|
|
const nsAString& aDisplayName,
|
|
nsIMIMEInfo *aMIMEInfo,
|
|
PRTime aStartTime,
|
|
nsIFile* aTempFile,
|
|
nsICancelable* aCancelable) {
|
|
nsresult rv;
|
|
nsCOMPtr<nsIDownloadManager> dm = do_GetService("@mozilla.org/download-manager;1", &rv);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = dm->AddDownload(nsIDownloadManager::DOWNLOAD_TYPE_DOWNLOAD, aSource,
|
|
aTarget, aDisplayName, aMIMEInfo, aStartTime,
|
|
aTempFile, aCancelable, getter_AddRefs(mInner));
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1", &rv);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
|
|
|
|
bool showDM = true;
|
|
if (branch)
|
|
branch->GetBoolPref(PREF_BDM_SHOWWHENSTARTING, &showDM);
|
|
|
|
if (showDM) {
|
|
uint32_t id;
|
|
mInner->GetId(&id);
|
|
|
|
nsCOMPtr<nsIDownloadManagerUI> dmui =
|
|
do_GetService("@mozilla.org/download-manager-ui;1", &rv);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
bool visible;
|
|
rv = dmui->GetVisible(&visible);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
bool focusWhenStarting = true;
|
|
if (branch)
|
|
(void)branch->GetBoolPref(PREF_BDM_FOCUSWHENSTARTING, &focusWhenStarting);
|
|
|
|
if (visible && !focusWhenStarting)
|
|
return NS_OK;
|
|
|
|
return dmui->Show(nullptr, id, nsIDownloadManagerUI::REASON_NEW_DOWNLOAD);
|
|
}
|
|
return rv;
|
|
}
|
|
|
|
NS_IMETHODIMP OnStateChange(nsIWebProgress* aWebProgress,
|
|
nsIRequest* aRequest, uint32_t aStateFlags,
|
|
nsresult aStatus)
|
|
{
|
|
NS_ENSURE_TRUE(mInner, NS_ERROR_NOT_INITIALIZED);
|
|
return mInner->OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus);
|
|
}
|
|
|
|
NS_IMETHODIMP OnStatusChange(nsIWebProgress *aWebProgress,
|
|
nsIRequest *aRequest, nsresult aStatus,
|
|
const PRUnichar *aMessage)
|
|
{
|
|
NS_ENSURE_TRUE(mInner, NS_ERROR_NOT_INITIALIZED);
|
|
return mInner->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
|
|
}
|
|
|
|
NS_IMETHODIMP OnLocationChange(nsIWebProgress *aWebProgress,
|
|
nsIRequest *aRequest, nsIURI *aLocation,
|
|
uint32_t aFlags)
|
|
{
|
|
NS_ENSURE_TRUE(mInner, NS_ERROR_NOT_INITIALIZED);
|
|
return mInner->OnLocationChange(aWebProgress, aRequest, aLocation, aFlags);
|
|
}
|
|
|
|
NS_IMETHODIMP OnProgressChange(nsIWebProgress *aWebProgress,
|
|
nsIRequest *aRequest,
|
|
int32_t aCurSelfProgress,
|
|
int32_t aMaxSelfProgress,
|
|
int32_t aCurTotalProgress,
|
|
int32_t aMaxTotalProgress)
|
|
{
|
|
NS_ENSURE_TRUE(mInner, NS_ERROR_NOT_INITIALIZED);
|
|
return mInner->OnProgressChange(aWebProgress, aRequest,
|
|
aCurSelfProgress,
|
|
aMaxSelfProgress,
|
|
aCurTotalProgress,
|
|
aMaxTotalProgress);
|
|
}
|
|
|
|
NS_IMETHODIMP OnProgressChange64(nsIWebProgress *aWebProgress,
|
|
nsIRequest *aRequest,
|
|
int64_t aCurSelfProgress,
|
|
int64_t aMaxSelfProgress,
|
|
int64_t aCurTotalProgress,
|
|
int64_t aMaxTotalProgress)
|
|
{
|
|
NS_ENSURE_TRUE(mInner, NS_ERROR_NOT_INITIALIZED);
|
|
return mInner->OnProgressChange64(aWebProgress, aRequest,
|
|
aCurSelfProgress,
|
|
aMaxSelfProgress,
|
|
aCurTotalProgress,
|
|
aMaxTotalProgress);
|
|
}
|
|
|
|
NS_IMETHODIMP OnRefreshAttempted(nsIWebProgress *aWebProgress,
|
|
nsIURI *aUri,
|
|
int32_t aDelay,
|
|
bool aSameUri,
|
|
bool *allowRefresh)
|
|
{
|
|
*allowRefresh = true;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP OnSecurityChange(nsIWebProgress *aWebProgress,
|
|
nsIRequest *aRequest, uint32_t aState)
|
|
{
|
|
NS_ENSURE_TRUE(mInner, NS_ERROR_NOT_INITIALIZED);
|
|
return mInner->OnSecurityChange(aWebProgress, aRequest, aState);
|
|
}
|
|
|
|
private:
|
|
nsCOMPtr<nsIDownload> mInner;
|
|
};
|
|
|
|
NS_IMPL_ISUPPORTS3(nsDownloadProxy, nsITransfer,
|
|
nsIWebProgressListener, nsIWebProgressListener2)
|
|
|
|
#endif
|