mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 383224 - Remove XPInstall bits from the Download Manager. r=enndeakin, r=mano
This commit is contained in:
parent
853359a4e9
commit
69b766193c
@ -45,8 +45,8 @@ include $(DEPTH)/config/autoconf.mk
|
|||||||
MODULE = downloads
|
MODULE = downloads
|
||||||
|
|
||||||
XPIDLSRCS = nsIDownloadManager.idl \
|
XPIDLSRCS = nsIDownloadManager.idl \
|
||||||
nsIXPInstallManagerUI.idl \
|
|
||||||
nsIDownloadProgressListener.idl \
|
nsIDownloadProgressListener.idl \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
include $(topsrcdir)/config/rules.mk
|
include $(topsrcdir)/config/rules.mk
|
||||||
|
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
/* -*- 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):
|
|
||||||
* Ben Goodger <ben@netscape.com>
|
|
||||||
*
|
|
||||||
* 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 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 ***** */
|
|
||||||
|
|
||||||
// Keeps track of ongoing downloads, in the form of nsIDownload's.
|
|
||||||
|
|
||||||
#include "nsISupports.idl"
|
|
||||||
|
|
||||||
interface nsIXPIProgressDialog;
|
|
||||||
interface nsIDownload;
|
|
||||||
|
|
||||||
[scriptable, uuid(087f52a4-8fd8-40ab-ae52-c3e161810141)]
|
|
||||||
interface nsIXPInstallManagerUI : nsISupports {
|
|
||||||
// Install States
|
|
||||||
const short INSTALL_DOWNLOADING = 5;
|
|
||||||
const short INSTALL_INSTALLING = 6;
|
|
||||||
const short INSTALL_FINISHED = 7;
|
|
||||||
|
|
||||||
const short DOWNLOAD_TYPE_INSTALL = 1;
|
|
||||||
|
|
||||||
readonly attribute nsIXPIProgressDialog xpiProgress;
|
|
||||||
|
|
||||||
readonly attribute boolean hasActiveXPIOperations;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
@ -94,7 +94,7 @@ static PRInt32 gRefCnt = 0;
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// nsDownloadManager
|
// nsDownloadManager
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS3(nsDownloadManager, nsIDownloadManager, nsIXPInstallManagerUI, nsIObserver)
|
NS_IMPL_ISUPPORTS2(nsDownloadManager, nsIDownloadManager, nsIObserver)
|
||||||
|
|
||||||
nsDownloadManager::~nsDownloadManager()
|
nsDownloadManager::~nsDownloadManager()
|
||||||
{
|
{
|
||||||
@ -527,29 +527,6 @@ nsDownloadManager::GetDownloadFromDB(PRUint32 aID, nsDownload **retVal)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsDownloadManager::AddToCurrentDownloads(nsDownload *aDl)
|
|
||||||
{
|
|
||||||
// If this is an install operation, ensure we have a progress listener for the
|
|
||||||
// install and track this download separately.
|
|
||||||
if (aDl->mDownloadType == nsIXPInstallManagerUI::DOWNLOAD_TYPE_INSTALL) {
|
|
||||||
if (!mXPIProgress) {
|
|
||||||
mXPIProgress = new nsXPIProgressListener(this);
|
|
||||||
if (!mXPIProgress)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIXPIProgressDialog *dialog = mXPIProgress.get();
|
|
||||||
nsXPIProgressListener *listener = NS_STATIC_CAST(nsXPIProgressListener*,
|
|
||||||
dialog);
|
|
||||||
listener->AddDownload(aDl);
|
|
||||||
}
|
|
||||||
|
|
||||||
mCurrentDownloads.AppendObject(aDl);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//// nsIDownloadManager
|
//// nsIDownloadManager
|
||||||
|
|
||||||
@ -768,18 +745,16 @@ nsDownloadManager::CleanUp()
|
|||||||
{
|
{
|
||||||
DownloadState states[] = { nsIDownloadManager::DOWNLOAD_FINISHED,
|
DownloadState states[] = { nsIDownloadManager::DOWNLOAD_FINISHED,
|
||||||
nsIDownloadManager::DOWNLOAD_FAILED,
|
nsIDownloadManager::DOWNLOAD_FAILED,
|
||||||
nsIDownloadManager::DOWNLOAD_CANCELED,
|
nsIDownloadManager::DOWNLOAD_CANCELED };
|
||||||
nsIXPInstallManagerUI::INSTALL_FINISHED };
|
|
||||||
|
|
||||||
nsCOMPtr<mozIStorageStatement> stmt;
|
nsCOMPtr<mozIStorageStatement> stmt;
|
||||||
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
"DELETE FROM moz_downloads "
|
"DELETE FROM moz_downloads "
|
||||||
"WHERE state = ?1 "
|
"WHERE state = ?1 "
|
||||||
"OR state = ?2 "
|
"OR state = ?2 "
|
||||||
"OR state = ?3 "
|
"OR state = ?3"), getter_AddRefs(stmt));
|
||||||
"OR state = ?4"), getter_AddRefs(stmt));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
for (PRUint32 i = 0; i < 4; ++i) {
|
for (PRUint32 i = 0; i < 3; ++i) {
|
||||||
rv = stmt->BindInt32Parameter(i, states[i]);
|
rv = stmt->BindInt32Parameter(i, states[i]);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
@ -794,8 +769,7 @@ nsDownloadManager::GetCanCleanUp(PRBool *aResult)
|
|||||||
|
|
||||||
DownloadState states[] = { nsIDownloadManager::DOWNLOAD_FINISHED,
|
DownloadState states[] = { nsIDownloadManager::DOWNLOAD_FINISHED,
|
||||||
nsIDownloadManager::DOWNLOAD_FAILED,
|
nsIDownloadManager::DOWNLOAD_FAILED,
|
||||||
nsIDownloadManager::DOWNLOAD_CANCELED,
|
nsIDownloadManager::DOWNLOAD_CANCELED };
|
||||||
nsIXPInstallManagerUI::INSTALL_FINISHED };
|
|
||||||
|
|
||||||
nsCOMPtr<mozIStorageStatement> stmt;
|
nsCOMPtr<mozIStorageStatement> stmt;
|
||||||
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
@ -803,10 +777,9 @@ nsDownloadManager::GetCanCleanUp(PRBool *aResult)
|
|||||||
"FROM moz_downloads "
|
"FROM moz_downloads "
|
||||||
"WHERE state = ?1 "
|
"WHERE state = ?1 "
|
||||||
"OR state = ?2 "
|
"OR state = ?2 "
|
||||||
"OR state = ?3 "
|
"OR state = ?3"), getter_AddRefs(stmt));
|
||||||
"OR state = ?4"), getter_AddRefs(stmt));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
for (PRUint32 i = 0; i < 4; ++i) {
|
for (PRUint32 i = 0; i < 3; ++i) {
|
||||||
rv = stmt->BindInt32Parameter(i, states[i]);
|
rv = stmt->BindInt32Parameter(i, states[i]);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
@ -1055,15 +1028,9 @@ nsDownloadManager::Observe(nsISupports *aSubject,
|
|||||||
} else if (strcmp(aTopic, "quit-application") == 0) {
|
} else if (strcmp(aTopic, "quit-application") == 0) {
|
||||||
gStoppingDownloads = PR_TRUE;
|
gStoppingDownloads = PR_TRUE;
|
||||||
|
|
||||||
if (currDownloadCount) {
|
if (currDownloadCount)
|
||||||
CancelAllDownloads();
|
CancelAllDownloads();
|
||||||
|
|
||||||
// Download Manager is shutting down! Tell the XPInstallManager to stop
|
|
||||||
// transferring any files that may have been being downloaded.
|
|
||||||
mObserverService->NotifyObservers(mXPIProgress, "xpinstall-progress",
|
|
||||||
NS_LITERAL_STRING("cancel").get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now that active downloads have been canceled, remove all downloads if
|
// Now that active downloads have been canceled, remove all downloads if
|
||||||
// the user's retention policy specifies it.
|
// the user's retention policy specifies it.
|
||||||
if (GetRetentionBehavior() == 1)
|
if (GetRetentionBehavior() == 1)
|
||||||
@ -1095,19 +1062,6 @@ nsDownloadManager::Observe(nsISupports *aSubject,
|
|||||||
NS_LITERAL_STRING("offlineCancelDownloadsAlertMsgMultiple").get(),
|
NS_LITERAL_STRING("offlineCancelDownloadsAlertMsgMultiple").get(),
|
||||||
NS_LITERAL_STRING("offlineCancelDownloadsAlertMsg").get(),
|
NS_LITERAL_STRING("offlineCancelDownloadsAlertMsg").get(),
|
||||||
NS_LITERAL_STRING("dontGoOfflineButton").get());
|
NS_LITERAL_STRING("dontGoOfflineButton").get());
|
||||||
PRBool data;
|
|
||||||
cancelDownloads->GetData(&data);
|
|
||||||
if (!data) {
|
|
||||||
gStoppingDownloads = PR_TRUE;
|
|
||||||
|
|
||||||
// Network is going down! Tell the XPInstallManager to stop
|
|
||||||
// transferring any files that may have been being downloaded.
|
|
||||||
mObserverService->NotifyObservers(mXPIProgress, "xpinstall-progress",
|
|
||||||
NS_LITERAL_STRING("cancel").get());
|
|
||||||
|
|
||||||
CancelAllDownloads();
|
|
||||||
gStoppingDownloads = PR_FALSE;
|
|
||||||
}
|
|
||||||
} else if (strcmp(aTopic, "alertclickcallback") == 0) {
|
} else if (strcmp(aTopic, "alertclickcallback") == 0) {
|
||||||
// Attempt to locate a browser window to parent the download manager to
|
// Attempt to locate a browser window to parent the download manager to
|
||||||
nsCOMPtr<nsIWindowMediator> wm = do_GetService(NS_WINDOWMEDIATOR_CONTRACTID);
|
nsCOMPtr<nsIWindowMediator> wm = do_GetService(NS_WINDOWMEDIATOR_CONTRACTID);
|
||||||
@ -1171,154 +1125,6 @@ nsDownloadManager::ConfirmCancelDownloads(PRInt32 aCount,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// nsIXPInstallManagerUI
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsDownloadManager::GetXpiProgress(nsIXPIProgressDialog** aProgress)
|
|
||||||
{
|
|
||||||
*aProgress = mXPIProgress;
|
|
||||||
NS_IF_ADDREF(*aProgress);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsDownloadManager::GetHasActiveXPIOperations(PRBool* aHasOps)
|
|
||||||
{
|
|
||||||
nsIXPIProgressDialog* dialog = mXPIProgress.get();
|
|
||||||
nsXPIProgressListener* listener = NS_STATIC_CAST(nsXPIProgressListener*, dialog);
|
|
||||||
*aHasOps = !mXPIProgress ? PR_FALSE : listener->HasActiveXPIOperations();
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// nsXPIProgressListener
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS1(nsXPIProgressListener, nsIXPIProgressDialog)
|
|
||||||
|
|
||||||
nsXPIProgressListener::nsXPIProgressListener(nsDownloadManager* aDownloadManager)
|
|
||||||
{
|
|
||||||
NS_NewISupportsArray(getter_AddRefs(mDownloads));
|
|
||||||
|
|
||||||
mDownloadManager = aDownloadManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsXPIProgressListener::~nsXPIProgressListener()
|
|
||||||
{
|
|
||||||
// Release any remaining references to objects held by the downloads array
|
|
||||||
mDownloads->Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nsXPIProgressListener::AddDownload(nsIDownload* aDownload)
|
|
||||||
{
|
|
||||||
PRUint32 cnt;
|
|
||||||
mDownloads->Count(&cnt);
|
|
||||||
PRBool foundMatch = PR_FALSE;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uri1, uri2;
|
|
||||||
for (PRUint32 i = 0; i < cnt; ++i) {
|
|
||||||
nsCOMPtr<nsIDownload> download(do_QueryElementAt(mDownloads, i));
|
|
||||||
download->GetSource(getter_AddRefs(uri1));
|
|
||||||
aDownload->GetSource(getter_AddRefs(uri2));
|
|
||||||
|
|
||||||
uri1->Equals(uri2, &foundMatch);
|
|
||||||
if (foundMatch)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!foundMatch)
|
|
||||||
mDownloads->AppendElement(aDownload);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nsXPIProgressListener::RemoveDownloadAtIndex(PRUint32 aIndex)
|
|
||||||
{
|
|
||||||
mDownloads->RemoveElementAt(aIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
nsXPIProgressListener::HasActiveXPIOperations()
|
|
||||||
{
|
|
||||||
PRUint32 count;
|
|
||||||
mDownloads->Count(&count);
|
|
||||||
return count != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// nsIXPIProgressDialog
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsXPIProgressListener::OnStateChange(PRUint32 aIndex, PRInt16 aState, PRInt32 aValue)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIWebProgressListener> wpl(do_QueryElementAt(mDownloads, aIndex));
|
|
||||||
nsIWebProgressListener* temp = wpl.get();
|
|
||||||
nsDownload* dl = NS_STATIC_CAST(nsDownload*, temp);
|
|
||||||
// Sometimes we get XPInstall progress notifications after everything is done, and there's
|
|
||||||
// no more active downloads... this null check is to prevent a crash in this case.
|
|
||||||
if (!dl)
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIObserverService> os;
|
|
||||||
|
|
||||||
DownloadState newState = aState;
|
|
||||||
switch (aState) {
|
|
||||||
case nsIXPIProgressDialog::DOWNLOAD_START:
|
|
||||||
wpl->OnStateChange(nsnull, nsnull, nsIWebProgressListener::STATE_START, 0);
|
|
||||||
|
|
||||||
newState = nsIXPInstallManagerUI::INSTALL_DOWNLOADING;
|
|
||||||
|
|
||||||
os = do_GetService("@mozilla.org/observer-service;1");
|
|
||||||
if (os)
|
|
||||||
os->NotifyObservers(dl, "dl-start", nsnull);
|
|
||||||
break;
|
|
||||||
case nsIXPIProgressDialog::DOWNLOAD_DONE:
|
|
||||||
break;
|
|
||||||
case nsIXPIProgressDialog::INSTALL_START:
|
|
||||||
newState = nsIXPInstallManagerUI::INSTALL_INSTALLING;
|
|
||||||
break;
|
|
||||||
case nsIXPIProgressDialog::INSTALL_DONE:
|
|
||||||
wpl->OnStateChange(nsnull, nsnull, nsIWebProgressListener::STATE_STOP, 0);
|
|
||||||
|
|
||||||
newState = nsIXPInstallManagerUI::INSTALL_FINISHED;
|
|
||||||
|
|
||||||
// Now, remove it from our internal bookkeeping list.
|
|
||||||
RemoveDownloadAtIndex(aIndex);
|
|
||||||
break;
|
|
||||||
case nsIXPIProgressDialog::DIALOG_CLOSE:
|
|
||||||
// Close now, if we're allowed to.
|
|
||||||
os = do_GetService("@mozilla.org/observer-service;1");
|
|
||||||
if (os)
|
|
||||||
os->NotifyObservers(nsnull, "xpinstall-dialog-close", nsnull);
|
|
||||||
|
|
||||||
if (!gStoppingDownloads) {
|
|
||||||
nsCOMPtr<nsIStringBundleService> sbs(do_GetService("@mozilla.org/intl/stringbundle;1"));
|
|
||||||
nsCOMPtr<nsIStringBundle> brandBundle, xpinstallBundle;
|
|
||||||
sbs->CreateBundle("chrome://branding/locale/brand.properties", getter_AddRefs(brandBundle));
|
|
||||||
sbs->CreateBundle("chrome://mozapps/locale/xpinstall/xpinstallConfirm.properties", getter_AddRefs(xpinstallBundle));
|
|
||||||
|
|
||||||
nsXPIDLString brandShortName, message, title;
|
|
||||||
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), getter_Copies(brandShortName));
|
|
||||||
const PRUnichar* strings[1] = { brandShortName.get() };
|
|
||||||
xpinstallBundle->FormatStringFromName(NS_LITERAL_STRING("installComplete").get(), strings, 1, getter_Copies(message));
|
|
||||||
xpinstallBundle->GetStringFromName(NS_LITERAL_STRING("installCompleteTitle").get(), getter_Copies(title));
|
|
||||||
|
|
||||||
nsCOMPtr<nsIPromptService> ps(do_GetService(NS_PROMPTSERVICE_CONTRACTID));
|
|
||||||
ps->Alert(nsnull, title, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dl->SetState(newState);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsXPIProgressListener::OnProgress(PRUint32 aIndex, PRUint64 aValue, PRUint64 aMaxValue)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIWebProgressListener2> wpl(do_QueryElementAt(mDownloads, aIndex));
|
|
||||||
if (wpl)
|
|
||||||
return wpl->OnProgressChange64(nsnull, nsnull, 0, 0, aValue, aMaxValue);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// nsDownload
|
// nsDownload
|
||||||
|
|
||||||
|
@ -42,14 +42,12 @@
|
|||||||
#define downloadmanager___h___
|
#define downloadmanager___h___
|
||||||
|
|
||||||
#include "nsIDownloadManager.h"
|
#include "nsIDownloadManager.h"
|
||||||
#include "nsIXPInstallManagerUI.h"
|
|
||||||
#include "nsIDownloadProgressListener.h"
|
#include "nsIDownloadProgressListener.h"
|
||||||
#include "nsIDownload.h"
|
#include "nsIDownload.h"
|
||||||
#include "nsIDOMDocument.h"
|
#include "nsIDOMDocument.h"
|
||||||
#include "nsIDOMEventListener.h"
|
#include "nsIDOMEventListener.h"
|
||||||
#include "nsIWebProgressListener.h"
|
#include "nsIWebProgressListener.h"
|
||||||
#include "nsIWebProgressListener2.h"
|
#include "nsIWebProgressListener2.h"
|
||||||
#include "nsIXPIProgressDialog.h"
|
|
||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
#include "nsIWebBrowserPersist.h"
|
#include "nsIWebBrowserPersist.h"
|
||||||
#include "nsILocalFile.h"
|
#include "nsILocalFile.h"
|
||||||
@ -75,13 +73,11 @@ class nsXPIProgressListener;
|
|||||||
class nsDownload;
|
class nsDownload;
|
||||||
|
|
||||||
class nsDownloadManager : public nsIDownloadManager,
|
class nsDownloadManager : public nsIDownloadManager,
|
||||||
public nsIXPInstallManagerUI,
|
|
||||||
public nsIObserver
|
public nsIObserver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIDOWNLOADMANAGER
|
NS_DECL_NSIDOWNLOADMANAGER
|
||||||
NS_DECL_NSIXPINSTALLMANAGERUI
|
|
||||||
NS_DECL_NSIOBSERVER
|
NS_DECL_NSIOBSERVER
|
||||||
|
|
||||||
nsresult Init();
|
nsresult Init();
|
||||||
@ -97,7 +93,15 @@ protected:
|
|||||||
nsresult CreateTable();
|
nsresult CreateTable();
|
||||||
nsresult ImportDownloadHistory();
|
nsresult ImportDownloadHistory();
|
||||||
nsresult GetDownloadFromDB(PRUint32 aID, nsDownload **retVal);
|
nsresult GetDownloadFromDB(PRUint32 aID, nsDownload **retVal);
|
||||||
nsresult AddToCurrentDownloads(nsDownload *aDl);
|
|
||||||
|
inline nsresult AddToCurrentDownloads(nsDownload *aDl)
|
||||||
|
{
|
||||||
|
if (!mCurrentDownloads.AppendObject(aDl))
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a download with the specified information to the DB.
|
* Adds a download with the specified information to the DB.
|
||||||
@ -158,28 +162,23 @@ protected:
|
|||||||
static PRBool IsInFinalStage(DownloadState aState)
|
static PRBool IsInFinalStage(DownloadState aState)
|
||||||
{
|
{
|
||||||
return aState == nsIDownloadManager::DOWNLOAD_NOTSTARTED ||
|
return aState == nsIDownloadManager::DOWNLOAD_NOTSTARTED ||
|
||||||
aState == nsIDownloadManager::DOWNLOAD_DOWNLOADING ||
|
aState == nsIDownloadManager::DOWNLOAD_DOWNLOADING;
|
||||||
aState == nsIXPInstallManagerUI::INSTALL_INSTALLING;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRBool IsInProgress(DownloadState aState)
|
static PRBool IsInProgress(DownloadState aState)
|
||||||
{
|
{
|
||||||
return aState == nsIDownloadManager::DOWNLOAD_NOTSTARTED ||
|
return aState == nsIDownloadManager::DOWNLOAD_NOTSTARTED ||
|
||||||
aState == nsIDownloadManager::DOWNLOAD_DOWNLOADING ||
|
aState == nsIDownloadManager::DOWNLOAD_DOWNLOADING ||
|
||||||
aState == nsIDownloadManager::DOWNLOAD_PAUSED ||
|
aState == nsIDownloadManager::DOWNLOAD_PAUSED;
|
||||||
aState == nsIXPInstallManagerUI::INSTALL_DOWNLOADING ||
|
|
||||||
aState == nsIXPInstallManagerUI::INSTALL_INSTALLING;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRBool CompletedSuccessfully(DownloadState aState)
|
static PRBool CompletedSuccessfully(DownloadState aState)
|
||||||
{
|
{
|
||||||
return aState == nsIDownloadManager::DOWNLOAD_FINISHED ||
|
return aState == nsIDownloadManager::DOWNLOAD_FINISHED;
|
||||||
aState == nsIXPInstallManagerUI::INSTALL_FINISHED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsCOMArray<nsIDownloadProgressListener> mListeners;
|
nsCOMArray<nsIDownloadProgressListener> mListeners;
|
||||||
nsCOMPtr<nsIXPIProgressDialog> mXPIProgress;
|
|
||||||
nsCOMPtr<nsIStringBundle> mBundle;
|
nsCOMPtr<nsIStringBundle> mBundle;
|
||||||
nsCOMPtr<nsITimer> mDMOpenTimer;
|
nsCOMPtr<nsITimer> mDMOpenTimer;
|
||||||
nsCOMPtr<mozIStorageConnection> mDBConn;
|
nsCOMPtr<mozIStorageConnection> mDBConn;
|
||||||
@ -189,28 +188,6 @@ private:
|
|||||||
friend class nsDownload;
|
friend class nsDownload;
|
||||||
};
|
};
|
||||||
|
|
||||||
class nsXPIProgressListener : public nsIXPIProgressDialog
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NS_DECL_NSIXPIPROGRESSDIALOG
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
|
|
||||||
nsXPIProgressListener() { }
|
|
||||||
nsXPIProgressListener(nsDownloadManager* aManager);
|
|
||||||
virtual ~nsXPIProgressListener();
|
|
||||||
|
|
||||||
void AddDownload(nsIDownload* aDownload);
|
|
||||||
|
|
||||||
PRBool HasActiveXPIOperations();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void RemoveDownloadAtIndex(PRUint32 aIndex);
|
|
||||||
|
|
||||||
private:
|
|
||||||
nsDownloadManager* mDownloadManager;
|
|
||||||
nsCOMPtr<nsISupportsArray> mDownloads;
|
|
||||||
};
|
|
||||||
|
|
||||||
class nsDownload : public nsIDownload
|
class nsDownload : public nsIDownload
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -403,60 +403,6 @@
|
|||||||
</content>
|
</content>
|
||||||
</binding>
|
</binding>
|
||||||
|
|
||||||
<binding id="install-downloading" extends="chrome://mozapps/content/downloads/download.xml#download-downloading">
|
|
||||||
<content>
|
|
||||||
<xul:hbox flex="1" class="downloadContentBox" xbl:inherits="animated,animated-temp">
|
|
||||||
<xul:vbox pack="start">
|
|
||||||
<xul:image class="downloadTypeIcon" validate="always" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
|
|
||||||
</xul:vbox>
|
|
||||||
<xul:vbox flex="1">
|
|
||||||
<xul:hbox flex="1">
|
|
||||||
<xul:vbox flex="1">
|
|
||||||
<xul:label xbl:inherits="value=target" crop="center"/>
|
|
||||||
<xul:progressmeter mode="normal" value="0" flex="1"
|
|
||||||
xbl:inherits="value=progress,mode=progressmode"/>
|
|
||||||
</xul:vbox>
|
|
||||||
</xul:hbox>
|
|
||||||
<xul:hbox align="center">
|
|
||||||
<xul:label xbl:inherits="value=status" flex="1" crop="right"/>
|
|
||||||
</xul:hbox>
|
|
||||||
</xul:vbox>
|
|
||||||
</xul:hbox>
|
|
||||||
</content>
|
|
||||||
</binding>
|
|
||||||
|
|
||||||
<binding id="install-installing" extends="chrome://mozapps/content/downloads/download.xml#download-base">
|
|
||||||
<content>
|
|
||||||
<xul:hbox flex="1">
|
|
||||||
<xul:vbox pack="start">
|
|
||||||
<xul:image class="downloadTypeIcon" validate="always" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
|
|
||||||
</xul:vbox>
|
|
||||||
<xul:vbox pack="start" flex="1">
|
|
||||||
<xul:label xbl:inherits="value=target" crop="center"/>
|
|
||||||
<xul:label value="&installing.label;"/>
|
|
||||||
</xul:vbox>
|
|
||||||
</xul:hbox>
|
|
||||||
</content>
|
|
||||||
</binding>
|
|
||||||
|
|
||||||
<binding id="install-done" extends="chrome://mozapps/content/downloads/download.xml#download-base">
|
|
||||||
<content>
|
|
||||||
<xul:hbox flex="1">
|
|
||||||
<xul:vbox pack="start">
|
|
||||||
<xul:image class="downloadTypeIcon" validate="always" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
|
|
||||||
</xul:vbox>
|
|
||||||
<xul:vbox pack="start" flex="1">
|
|
||||||
<xul:label xbl:inherits="value=target" crop="center"/>
|
|
||||||
<xul:label value="&done.label;"/>
|
|
||||||
</xul:vbox>
|
|
||||||
<xul:vbox pack="start">
|
|
||||||
<xul:label value="&cmd.remove.label;" class="text-link"
|
|
||||||
onclick="this.parentNode.parentNode.parentNode.fireEvent('remove');"/>
|
|
||||||
</xul:vbox>
|
|
||||||
</xul:hbox>
|
|
||||||
</content>
|
|
||||||
</binding>
|
|
||||||
|
|
||||||
<binding id="download-view">
|
<binding id="download-view">
|
||||||
<implementation>
|
<implementation>
|
||||||
<field name="_selected">null</field>
|
<field name="_selected">null</field>
|
||||||
|
@ -23,18 +23,6 @@ download[state="4"] {
|
|||||||
-moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-paused');
|
-moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-paused');
|
||||||
}
|
}
|
||||||
|
|
||||||
download[state="5"] {
|
|
||||||
-moz-binding: url('chrome://mozapps/content/downloads/download.xml#install-downloading');
|
|
||||||
}
|
|
||||||
|
|
||||||
download[state="6"] {
|
|
||||||
-moz-binding: url('chrome://mozapps/content/downloads/download.xml#install-installing');
|
|
||||||
}
|
|
||||||
|
|
||||||
download[state="7"] {
|
|
||||||
-moz-binding: url('chrome://mozapps/content/downloads/download.xml#install-done');
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only focus links in the selected item*/
|
/* Only focus links in the selected item*/
|
||||||
download:not([selected="true"]) .text-link {
|
download:not([selected="true"]) .text-link {
|
||||||
-moz-user-focus: none;
|
-moz-user-focus: none;
|
||||||
|
@ -46,7 +46,6 @@
|
|||||||
const kObserverServiceProgID = "@mozilla.org/observer-service;1";
|
const kObserverServiceProgID = "@mozilla.org/observer-service;1";
|
||||||
const kDlmgrContractID = "@mozilla.org/download-manager;1";
|
const kDlmgrContractID = "@mozilla.org/download-manager;1";
|
||||||
const nsIDownloadManager = Components.interfaces.nsIDownloadManager;
|
const nsIDownloadManager = Components.interfaces.nsIDownloadManager;
|
||||||
const nsIXPInstallManagerUI = Components.interfaces.nsIXPInstallManagerUI;
|
|
||||||
const PREF_BDM_CLOSEWHENDONE = "browser.download.manager.closeWhenDone";
|
const PREF_BDM_CLOSEWHENDONE = "browser.download.manager.closeWhenDone";
|
||||||
const PREF_BDM_ALERTONEXEOPEN = "browser.download.manager.alertOnEXEOpen";
|
const PREF_BDM_ALERTONEXEOPEN = "browser.download.manager.alertOnEXEOpen";
|
||||||
const PREF_BDM_RETENTION = "browser.download.manager.retention";
|
const PREF_BDM_RETENTION = "browser.download.manager.retention";
|
||||||
@ -63,14 +62,6 @@ var gDownloadsView = null;
|
|||||||
var gUserInterfered = false;
|
var gUserInterfered = false;
|
||||||
var gActiveDownloads = [];
|
var gActiveDownloads = [];
|
||||||
|
|
||||||
// This variable exists because for XPInstalls, we don't want to close the
|
|
||||||
// download manager until the XPInstallManager sends the DIALOG_CLOSE status
|
|
||||||
// message. Setting this variable to false when the downloads window is
|
|
||||||
// opened by the xpinstall manager prevents the window from being closed after
|
|
||||||
// each download completes (because xpinstall downloads are done sequentially,
|
|
||||||
// not concurrently)
|
|
||||||
var gCanAutoClose = true;
|
|
||||||
|
|
||||||
// If the user has interacted with the window in a significant way, we should
|
// If the user has interacted with the window in a significant way, we should
|
||||||
// not auto-close the window. Tough UI decisions about what is "significant."
|
// not auto-close the window. Tough UI decisions about what is "significant."
|
||||||
var gUserInteracted = false;
|
var gUserInteracted = false;
|
||||||
@ -168,7 +159,7 @@ function autoRemoveAndClose(aDownload)
|
|||||||
var autoClose = pref.getBoolPref(PREF_BDM_CLOSEWHENDONE);
|
var autoClose = pref.getBoolPref(PREF_BDM_CLOSEWHENDONE);
|
||||||
if (autoClose && (!window.opener ||
|
if (autoClose && (!window.opener ||
|
||||||
window.opener.location.href == window.location.href) &&
|
window.opener.location.href == window.location.href) &&
|
||||||
gCanAutoClose && !gUserInteracted) {
|
!gUserInteracted) {
|
||||||
gCloseDownloadManager();
|
gCloseDownloadManager();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -223,21 +214,6 @@ var gDownloadObserver = {
|
|||||||
// switch view to it
|
// switch view to it
|
||||||
gDownloadsView.selectedIndex = 0;
|
gDownloadsView.selectedIndex = 0;
|
||||||
break;
|
break;
|
||||||
case "xpinstall-download-started":
|
|
||||||
var windowArgs = aSubject.QueryInterface(Components.interfaces.nsISupportsArray);
|
|
||||||
var params = windowArgs.QueryElementAt(0, Components.interfaces.nsISupportsInterfacePointer);
|
|
||||||
params = params.data.QueryInterface(Components.interfaces.nsIDialogParamBlock);
|
|
||||||
var installObserver = windowArgs.QueryElementAt(1, Components.interfaces.nsISupportsInterfacePointer);
|
|
||||||
installObserver = installObserver.data.QueryInterface(Components.interfaces.nsIObserver);
|
|
||||||
XPInstallDownloadManager.addDownloads(params, installObserver);
|
|
||||||
break;
|
|
||||||
case "xpinstall-dialog-close":
|
|
||||||
if ("gDownloadManager" in window) {
|
|
||||||
var mgr = gDownloadManager.QueryInterface(Components.interfaces.nsIXPInstallManagerUI);
|
|
||||||
gCanAutoClose = mgr.hasActiveXPIOperations;
|
|
||||||
autoRemoveAndClose();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -550,20 +526,6 @@ function Startup()
|
|||||||
observerService.addObserver(gDownloadObserver, "dl-cancel", false);
|
observerService.addObserver(gDownloadObserver, "dl-cancel", false);
|
||||||
observerService.addObserver(gDownloadObserver, "dl-failed", false);
|
observerService.addObserver(gDownloadObserver, "dl-failed", false);
|
||||||
observerService.addObserver(gDownloadObserver, "dl-start", false);
|
observerService.addObserver(gDownloadObserver, "dl-start", false);
|
||||||
observerService.addObserver(gDownloadObserver, "xpinstall-download-started", false);
|
|
||||||
observerService.addObserver(gDownloadObserver, "xpinstall-dialog-close", false);
|
|
||||||
|
|
||||||
// Now look and see if we're being opened by XPInstall
|
|
||||||
if ("arguments" in window) {
|
|
||||||
try {
|
|
||||||
var params = window.arguments[0].QueryInterface(Components.interfaces.nsIDialogParamBlock);
|
|
||||||
var installObserver = window.arguments[1].QueryInterface(Components.interfaces.nsIObserver);
|
|
||||||
XPInstallDownloadManager.addDownloads(params, installObserver);
|
|
||||||
var mgr = gDownloadManager.QueryInterface(Components.interfaces.nsIXPInstallManagerUI);
|
|
||||||
gCanAutoClose = mgr.hasActiveXPIOperations;
|
|
||||||
}
|
|
||||||
catch (e) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is for the "Clean Up" button, which requires there to be
|
// This is for the "Clean Up" button, which requires there to be
|
||||||
// non-active downloads before it can be enabled.
|
// non-active downloads before it can be enabled.
|
||||||
@ -588,68 +550,6 @@ function Shutdown()
|
|||||||
observerService.removeObserver(gDownloadObserver, "dl-cancel");
|
observerService.removeObserver(gDownloadObserver, "dl-cancel");
|
||||||
observerService.removeObserver(gDownloadObserver, "dl-failed");
|
observerService.removeObserver(gDownloadObserver, "dl-failed");
|
||||||
observerService.removeObserver(gDownloadObserver, "dl-start");
|
observerService.removeObserver(gDownloadObserver, "dl-start");
|
||||||
observerService.removeObserver(gDownloadObserver, "xpinstall-download-started");
|
|
||||||
observerService.removeObserver(gDownloadObserver, "xpinstall-dialog-close");
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// XPInstall
|
|
||||||
|
|
||||||
var XPInstallDownloadManager = {
|
|
||||||
addDownloads: function (aParams, aObserver)
|
|
||||||
{
|
|
||||||
var numXPInstallItems = aParams.GetInt(1);
|
|
||||||
|
|
||||||
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
|
|
||||||
var tempDir = fileLocator.get("TmpD", Components.interfaces.nsIFile);
|
|
||||||
|
|
||||||
var mimeService = Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"].getService(Components.interfaces.nsIMIMEService);
|
|
||||||
|
|
||||||
var IOService = Components.classes["@mozilla.org/network/io-service;1"]
|
|
||||||
.getService(Components.interfaces.nsIIOService);
|
|
||||||
|
|
||||||
var xpinstallManager = gDownloadManager.QueryInterface(Components.interfaces.nsIXPInstallManagerUI);
|
|
||||||
|
|
||||||
var xpiString = "";
|
|
||||||
|
|
||||||
for (var i = 0; i < numXPInstallItems;) {
|
|
||||||
// Pretty Name
|
|
||||||
var displayName = aParams.GetString(i++);
|
|
||||||
|
|
||||||
// URI
|
|
||||||
var uri = IOService.newURI(aParams.GetString(i++), null, null);
|
|
||||||
|
|
||||||
var iconURL = aParams.GetString(i++);
|
|
||||||
|
|
||||||
// Local File Target
|
|
||||||
var url = uri.QueryInterface(Components.interfaces.nsIURL);
|
|
||||||
var localTarget = tempDir.clone();
|
|
||||||
localTarget.append(url.fileName);
|
|
||||||
|
|
||||||
xpiString += localTarget.path + ",";
|
|
||||||
|
|
||||||
// MIME Info
|
|
||||||
var mimeInfo = null;
|
|
||||||
try {
|
|
||||||
mimeInfo = mimeService.getFromTypeAndExtension(null, url.fileExtension);
|
|
||||||
}
|
|
||||||
catch (e) { }
|
|
||||||
|
|
||||||
if (!iconURL)
|
|
||||||
iconURL = "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png";
|
|
||||||
|
|
||||||
var targetUrl = makeFileURI(localTarget);
|
|
||||||
var download = gDownloadManager.addDownload(Components.interfaces.nsIXPInstallManagerUI.DOWNLOAD_TYPE_INSTALL,
|
|
||||||
uri, targetUrl, displayName, iconURL, mimeInfo, 0, null);
|
|
||||||
|
|
||||||
// Advance the enumerator
|
|
||||||
var certName = aParams.GetString(i++);
|
|
||||||
}
|
|
||||||
|
|
||||||
var observerService = Components.classes[kObserverServiceProgID]
|
|
||||||
.getService(Components.interfaces.nsIObserverService);
|
|
||||||
observerService.notifyObservers(xpinstallManager.xpiProgress, "xpinstall-progress", "open");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -745,9 +645,7 @@ var gDownloadViewController = {
|
|||||||
|
|
||||||
if (state != nsIDownloadManager.DOWNLOAD_NOTSTARTED &&
|
if (state != nsIDownloadManager.DOWNLOAD_NOTSTARTED &&
|
||||||
state != nsIDownloadManager.DOWNLOAD_DOWNLOADING &&
|
state != nsIDownloadManager.DOWNLOAD_DOWNLOADING &&
|
||||||
state != nsIDownloadManager.DOWNLOAD_PAUSED &&
|
state != nsIDownloadManager.DOWNLOAD_PAUSED)
|
||||||
state != nsIXPInstallManagerUI.INSTALL_DOWNLOADING &&
|
|
||||||
state != nsIXPInstallManagerUI.INSTALL_INSTALLING)
|
|
||||||
gDownloadsView.removeChild(gDownloadsView.children[i]);
|
gDownloadsView.removeChild(gDownloadsView.children[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user