This commit is contained in:
blakeross%telocity.com 2002-09-28 22:55:58 +00:00
Родитель b0fccd9a59
Коммит 7ec55f34af
19 изменённых файлов: 575 добавлений и 433 удалений

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

@ -601,10 +601,7 @@ pref("update_notifications.enabled", true);
pref("update_notifications.provider.0.frequency", 7); // number of days
pref("update_notifications.provider.0.datasource", "chrome://communicator-region/locale/region.properties");
// 0 opens the download manager
// 1 opens a progress dialog
// 2 and other values, no download manager, no progress dialog.
pref("browser.downloadmanager.behavior", 0);
pref("browser.downloads.useProgressDialogs", true);
// if true, allow plug-ins to override internal imglib decoder mime types in full-page mode
pref("plugin.override_internal_types", false);

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

@ -59,6 +59,7 @@ var gIgnoreFocus = false;
var gIgnoreClick = false;
var gToolbarMode = "icons";
var gIconSize = "";
var gMustLoadSidebar = false;
var gPrefService = null;
@ -319,6 +320,24 @@ function Startup()
}
}
if (window.opener) {
var openerSidebarBox = window.opener.document.getElementById("sidebar-box");
if (!openerSidebarBox.hidden) {
gMustLoadSidebar = true;
var sidebarBox = document.getElementById("sidebar-box");
sidebarBox.hidden = false;
var sidebarSplitter = document.getElementById("sidebar-splitter");
sidebarSplitter.hidden = false;
var sidebarTitle = document.getElementById("sidebar-title");
sidebarTitle.setAttribute("value", window.opener.document.getElementById("sidebar-title").getAttribute("value"));
sidebarBox.setAttribute("width", openerSidebarBox.boxObject.width);
var sidebarButton = openerSidebarBox.getAttribute("button");
document.getElementById(sidebarButton).checked = true;
sidebarBox.setAttribute("button", sidebarButton);
}
}
// called when we go into full screen, even if it is
// initiated by a web page script
addEventListener("fullscreen", onFullScreen, false);
@ -339,6 +358,11 @@ function Startup()
function delayedStartup(aElt)
{
if (gMustLoadSidebar) {
var sidebar = document.getElementById("sidebar");
sidebar.setAttribute("src", window.opener.document.getElementById("sidebar").getAttribute("src"));
}
// Perform default browser checking (after window opens).
checkForDefaultBrowser();
@ -2434,7 +2458,7 @@ function toDownloadManager()
dlmgrWindow.focus();
}
else {
window.openDialog("chrome://browser/content/downloadmanager/downloadmanager.xul", "Downloads", "chrome");
window.openDialog("chrome://browser/content/downloads/downloadmanager.xul", "Downloads", "chrome,extrachrome,resizable,scrollbars,toolbar,dialog=no");
}
}
@ -3140,27 +3164,33 @@ nsBrowserContentListener.prototype =
parentContentListener: null
}
function openSidebar(aElt) {
function toggleSidebar(aElt) {
var sidebarBox = document.getElementById("sidebar-box");
var sidebar = document.getElementById("sidebar");
var sidebarTitle = document.getElementById("sidebar-title");
var sidebarSplitter = document.getElementById("sidebar-splitter");
if (aElt.checked) {
aElt.checked = false;
sidebar.hidden = true;
sidebarBox.hidden = true;
sidebarSplitter.hidden = true;
return;
}
aElt.checked = true;
if (sidebar.hidden) {
// Can't use .hidden = false here, since that will remove the attr.
// and we need it to exist so we can persist its value.
sidebar.setAttribute("hidden", "false");
sidebarSplitter.setAttribute("hidden", "false");
if (sidebarBox.hidden) {
sidebarBox.hidden = false;
sidebarSplitter.hidden = false;
}
var url = aElt.getAttribute("sidebarurl");
var title = aElt.getAttribute("sidebartitle");
if (!title)
title = aElt.getAttribute("label");
sidebar.setAttribute("src", url);
sidebarBox.setAttribute("button", aElt.id);
sidebarTitle.setAttribute("value", title);
}
function goPreferences(containerID, paneURL, itemID)

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

@ -778,9 +778,27 @@ Contributor(s):
tooltiptext="&throbber.tooltip;"/>
</toolbaritem>
<toolbaritem id="personal-bookmarks" title="&bookmarksItem.title;" flex="1">
<bookmarks-toolbar id="bookmarks-toolbar" flex="1"/>
</toolbaritem>
<toolbaritem id="personal-bookmarks" title="&bookmarksItem.title;" flex="1">
<bookmarks-toolbar id="bookmarks-toolbar" flex="1"/>
</toolbaritem>
<toolbarbutton id="downloads-button" class="toolbarbutton-1" autoCheck="false"
label="&downloadsButton.label;" type="radio" group="sidebar"
sidebarurl="chrome://browser/content/downloads/downloadPanel.xul"
oncommand="toggleSidebar(this);"
tooltiptext="&downloadsButton.tooltip;"/>
<toolbarbutton id="history-button" class="toolbarbutton-1" autoCheck="false"
label="&historyButton.label;" type="radio" group="sidebar"
sidebarurl="chrome://browser/content/history/history-panel.xul"
oncommand="toggleSidebar(this);"
tooltiptext="&historyButton.tooltip;"/>
<toolbarbutton id="bookmarks-button" class="toolbarbutton-1" autoCheck="false"
label="&bookmarksButton.label;" type="radio" group="sidebar"
sidebarurl="chrome://browser/content/bookmarks/bookmarksPanel.xul"
oncommand="toggleSidebar(this);"
tooltiptext="&bookmarksButton.tooltip;"/>
</toolbarpalette>
<toolbar id="nav-bar" class="toolbar-primary chromeclass-toolbar"
@ -809,17 +827,27 @@ Contributor(s):
toolbarname="&personalbarCmd.label;" accesskey="&personalbarCmd.accesskey;"/>
</toolbox>
<hbox flex="1">
<vbox id="sidebar-box" hidden="true">
<hbox id="sidebar-header" align="center" pack="start">
<label id="sidebar-title"/>
</hbox>
<browser id="sidebar" flex="1"
style="min-width: 150px; width: 200px; max-width: 400px;"/>
</vbox>
<!-- we only need to handle |ondragdrop| because everything else is
taken care of by the builtin behavior inside the tabbrowser -->
<tabbrowser id="content"
flex="1" contenttooltip="aHTMLTooltip"
contentcontextmenu="contentAreaContextMenu"
autocompletepopup="PopupAutoComplete"
onnewtab="BrowserOpenTab();"
ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);"
onclick="return contentAreaClick(event);"/>
<splitter id="sidebar-splitter" hidden="true"/>
<!-- we only need to handle |ondragdrop| because everything else is
taken care of by the builtin behavior inside the tabbrowser -->
<tabbrowser id="content"
flex="1" contenttooltip="aHTMLTooltip"
contentcontextmenu="contentAreaContextMenu"
onnewtab="BrowserOpenTab();"
autocompletepopup="PopupAutoComplete"
ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);"
onclick="return contentAreaClick(event);"/>
</hbox>
<statusbar class="chromeclass-status" id="status-bar"
ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);">
<statusbarpanel id="security-button" class="statusbarpanel-iconic"

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

@ -235,4 +235,13 @@
<!ENTITY textZoomReduceCmd.commandkey "-">
<!ENTITY openLocationCmd.label "Open Location">
<!ENTITY openLocationCmd.accesskey "L">
<!ENTITY openLocationCmd.accesskey "L">
<!ENTITY downloadsButton.label "Downloads">
<!ENTITY downloadsButton.tooltip "Displays the progress of ongoing downloads">
<!ENTITY bookmarksButton.label "Bookmarks">
<!ENTITY bookmarksButton.tooltip "Displays your bookmarks">
<!ENTITY historyButton.label "History">
<!ENTITY historyButton.tooltip "Displays pages you've viewed recently">

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

@ -545,6 +545,22 @@ toolbar[iconsize="small"] #print-button[disabled="true"] {
-moz-image-region: rect(0px 53px 27px 27px) !important;
}
#sidebar-header {
height: 23px;
background-color: -moz-Dialog;
border-bottom: 1px solid ThreeDShadow;
border-top: 1px solid ThreeDHighlight;
}
#sidebar {
border-bottom: 1px solid ThreeDShadow;
background-color: white;
}
#sidebar-title {
padding-left: 4px;
}
#go-button[disabled="true"] {
-moz-image-region: rect(0px 80px 27px 54px) !important;
}

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

@ -0,0 +1,116 @@
<!DOCTYPE window [
<!ENTITY % downloadDTD SYSTEM "chrome://browser/locale/downloads/downloadmanager.dtd" >
%downloadDTD;
]>
<bindings id="downloadBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<binding id="download">
<resources>
<stylesheet src="chrome://browser/skin/downloadmanager/downloadmanager.css"/>
</resources>
<content>
<xul:deck anonid="title-deck">
<xul:hbox>
<xul:image style="max-width: 16px; max-height: 16px;" xbl:inherits="src=image"/>
<xul:label xbl:inherits="value=target"/>
</xul:hbox>
<xul:hbox>
<xul:image style="max-width: 16px; max-height: 16px;" xbl:inherits="src=image"/>
<xul:label xbl:inherits="value=target" class="link" onclick="this.parentNode.parentNode.parentNode.launch();"/>
</xul:hbox>
</xul:deck>
<xul:deck flex="1" anonid="deck" class="indented">
<xul:vbox flex="1">
<xul:hbox flex="1">
<xul:progressmeter mode="normal" value="0" flex="1"
xbl:inherits="value=progress,mode=progressmode"/>
<xul:label xbl:inherits="value=progress"/>
</xul:hbox>
<xul:hbox align="start">
<xul:label value="&cancel.label;" class="link" onclick="this.parentNode.parentNode.parentNode.parentNode.cancel();"/>
</xul:hbox>
</xul:vbox>
<xul:vbox align="start">
<xul:label value="&done.label;" class="bold"/>
</xul:vbox>
<xul:label value="&cancelled.label;" class="bold"/>
<xul:label value="&failed.label;" class="bold"/>
</xul:deck>
</content>
<implementation>
<method name="onEnd">
<parameter name="aType"/>
<body>
<![CDATA[
var deck = document.getAnonymousElementByAttribute(this, "anonid", "deck");
var index;
switch(aType) {
case "dl-failed":
index = 3;
break;
case "dl-cancel":
index = 2;
break;
case "dl-done":
default:
index = 1;
var titleDeck = document.getAnonymousElementByAttribute(this, "anonid", "title-deck");
titleDeck.selectedIndex = 1;
}
deck.selectedIndex = index;
]]>
</body>
</method>
<method name="cancel">
<body>
<![CDATA[
const dlmgrContractID = "@mozilla.org/download-manager;1";
const dlmgrIID = Components.interfaces.nsIDownloadManager;
var dlmgr = Components.classes[dlmgrContractID].getService(dlmgrIID);
dlmgr.cancelDownload(this.id);
]]>
</body>
</method>
<property name="localFile">
<getter>
<![CDATA[
var lfContractID = "@mozilla.org/file/local;1";
var lfIID = Components.interfaces.nsILocalFile;
var lf = Components.classes[lfContractID].createInstance(lfIID);
lf.initWithPath(this.getAttribute("file"));
return lf;
]]>
</getter>
</property>
<method name="launch">
<body>
<![CDATA[
try {
this.localFile.launch();
}
catch(ex) {
}
]]>
</body>
</method>
<method name="show">
<body>
<![CDATA[
try {
this.localFile.reveal();
}
catch(ex) {
}
]]>
</body>
</method>
</implementation>
</binding>
</bindings>

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

@ -0,0 +1,70 @@
const kObserverServiceProgID = "@mozilla.org/observer-service;1";
var gDownloadView, gDownloadManager;
const dlObserver = {
observe: function(subject, topic, state) {
var subject = subject.QueryInterface(Components.interfaces.nsIDownload);
var elt = document.getElementById(subject.target.path);
switch (topic) {
case "dl-progress":
elt.setAttribute("progress", subject.percentComplete);
break;
default:
elt.onEnd(topic);
break;
}
}
};
function Startup() {
gDownloadView = document.getElementById("downloadView");
const dlmgrContractID = "@mozilla.org/download-manager;1";
const dlmgrIID = Components.interfaces.nsIDownloadManager;
gDownloadManager = Components.classes[dlmgrContractID].getService(dlmgrIID);
var ds = gDownloadManager.datasource;
gDownloadView.database.AddDataSource(ds);
gDownloadView.builder.rebuild();
var observerService = Components.classes[kObserverServiceProgID]
.getService(Components.interfaces.nsIObserverService);
observerService.addObserver(dlObserver, "dl-progress", false);
observerService.addObserver(dlObserver, "dl-done", false);
observerService.addObserver(dlObserver, "dl-cancel", false);
observerService.addObserver(dlObserver, "dl-failed", false);
}
function Shutdown() {
var observerService = Components.classes[kObserverServiceProgID]
.getService(Components.interfaces.nsIObserverService);
observerService.removeObserver(dlObserver, "dl-progress");
observerService.removeObserver(dlObserver, "dl-done");
observerService.removeObserver(dlObserver, "dl-cancel");
observerService.removeObserver(dlObserver, "dl-failed");
}
var downloadDNDObserver =
{
onDragOver: function (aEvent, aFlavour, aDragSession)
{
aDragSession.canDrop = true;
},
onDrop: function(aEvent, aXferData, aDragSession)
{
var split = aXferData.data.split("\n");
var url = split[0];
var name = split[1];
saveURL(url, name, null, true);
},
_flavourSet: null,
getSupportedFlavours: function ()
{
if (!this._flavourSet) {
this._flavourSet = new FlavourSet();
this._flavourSet.appendFlavour("text/x-moz-url");
this._flavourSet.appendFlavour("text/unicode");
}
return this._flavourSet;
}
}

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

@ -0,0 +1,27 @@
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/downloads/downloadmanager.css"?>
<?xml-stylesheet href="chrome://browser/skin/downloads/downloadmanager.css"?>
<page xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:nc="http://home.netscape.com/NC-rdf#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="Startup();" onunload="Shutdown();">
<script type="application/x-javascript" src="chrome://browser/content/downloads/downloadPanel.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaUtils.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>
<vbox id="downloadView" flex="1" style="overflow: auto;"
datasources="rdf:null" ref="NC:DownloadsRoot"
ondragdrop="nsDragAndDrop.drop(event, downloadDNDObserver);">
<template>
<rule nc:DownloadState="0" parseType="Integer">
<download uri="rdf:*"
image="moz-icon:rdf:http://home.netscape.com/NC-rdf#File"
target="rdf:http://home.netscape.com/NC-rdf#Name"
file="rdf:http://home.netscape.com/NC-rdf#File"/>
</rule>
</template>
</vbox>
</page>

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

@ -0,0 +1,4 @@
download {
-moz-binding: url('chrome://browser/content/downloads/download-bindings.xml#download');
-moz-box-orient: vertical;
}

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

@ -40,32 +40,19 @@
const NC_NS = "http://home.netscape.com/NC-rdf#";
var gDownloadView = null;
var gDownloadManager = null;
var gDownloadView = null;
var gRDFService = null;
var gNC_File = null;
var gStatusBar = null;
const dlObserver = {
observe: function(subject, topic, state) {
if (topic != "download-starting") return;
selectDownload(subject.QueryInterface(Components.interfaces.nsIDownload));
}
};
function selectDownload(aDownload)
{
var dlElt = document.getElementById(aDownload.target.path);
var dlIndex = gDownloadView.contentView.getIndexOfItem(dlElt);
gDownloadView.treeBoxObject.selection.select(dlIndex);
gDownloadView.treeBoxObject.ensureRowIsVisible(dlIndex);
}
function Startup()
{
if (!window.arguments.length)
return;
try {
var observerService = Components.classes[kObserverServiceProgID]
.getService(Components.interfaces.nsIObserverService);
@ -80,15 +67,14 @@ function Startup()
gNC_File = gRDFService.GetResource(NC_NS + "File");
gDownloadView = document.getElementById("downloadView");
const dlmgrContractID = "@mozilla.org/download-manager;1";
const dlmgrIID = Components.interfaces.nsIDownloadManager;
gDownloadManager = Components.classes[dlmgrContractID].getService(dlmgrIID);
var ds = window.arguments[0];
var ds = gDownloadManager.datasource;
gDownloadView = document.getElementById("downloadView");
gDownloadView.database.AddDataSource(ds);
gDownloadView.builder.rebuild();
gDownloadView.builder.rebuild();
window.setTimeout(onRebuild, 0);
var key;
@ -111,30 +97,10 @@ function Startup()
function onRebuild() {
gDownloadView.controllers.appendController(downloadViewController);
gDownloadView.focus();
// If the window was opened automatically because
// a download started, select the new download
if (window.arguments.length > 1 && window.arguments[1]) {
var dl = window.arguments[1];
selectDownload(dl.QueryInterface(Components.interfaces.nsIDownload));
}
else if (gDownloadView.view.rowCount) {
// Select the first item in the view, if any.
gDownloadView.treeBoxObject.selection.select(0);
}
gDownloadView.treeBoxObject.selection.select(0);
}
function onSelect(aEvent) {
if (!gStatusBar)
gStatusBar = document.getElementById("statusbar-text");
var selectionCount = gDownloadView.treeBoxObject.selection.count;
if (selectionCount == 1)
gStatusBar.label = getSelectedItem().id;
else
gStatusBar.label = "";
window.updateCommands("tree-select");
}
@ -143,8 +109,6 @@ var downloadViewController = {
{
switch (aCommand) {
case "cmd_properties":
case "cmd_pause":
case "cmd_cancel":
case "cmd_remove":
case "cmd_openfile":
case "cmd_showinshell":
@ -155,37 +119,18 @@ var downloadViewController = {
},
isCommandEnabled: function dVC_isCommandEnabled (aCommand)
{
{
var selectionCount = gDownloadView.treeBoxObject.selection.count;
if (!selectionCount) return false;
var selectedItem = getSelectedItem();
var isDownloading = gDownloadManager.getDownload(selectedItem.id);
switch (aCommand) {
case "cmd_openfile":
try {
if (isDownloading || getFileForItem(selectedItem).isExecutable())
return false;
} catch(e) {
// Exception means file doesn't exist; launch is not allowed.
return false;
}
case "cmd_showinshell":
// some apps like kazaa/morpheus let you "preview" in-progress downloads because
// that's possible for movies and music. for now, just disable indiscriminately.
return selectionCount == 1;
case "cmd_properties":
return selectionCount == 1 && isDownloading;
case "cmd_pause":
return false;
case "cmd_cancel":
// XXX check if selection is still in progress
// how to handle multiple selection?
return isDownloading;
case "cmd_showinshell":
return selectionCount == 1;
case "cmd_remove":
// XXX ensure selection isn't still in progress
// and how to handle multiple selection?
return !isDownloading;
return selectionCount;
case "cmd_selectAll":
return gDownloadView.view.rowCount != selectionCount;
default:
@ -199,10 +144,6 @@ var downloadViewController = {
var file, i;
switch (aCommand) {
case "cmd_properties":
selectedItem = getSelectedItem();
gDownloadManager.openProgressDialogFor(selectedItem.id, window);
break;
case "cmd_openfile":
selectedItem = getSelectedItem();
file = getFileForItem(selectedItem);
@ -217,7 +158,8 @@ var downloadViewController = {
file = file.QueryInterface(Components.interfaces.nsIFile);
var parent = file.parent;
if (parent) {
const browserURL = "chrome://navigator/content/navigator.xul";
//XXXBlake use chromeUrlForTask pref here
const browserURL = "chrome://browser/content/navigator.xul";
window.openDialog(browserURL, "_blank", "chrome,all,dialog=no", parent.path);
}
}
@ -225,15 +167,6 @@ var downloadViewController = {
file.reveal();
}
break;
case "cmd_pause":
break;
case "cmd_cancel":
// XXX we should probably prompt the user
selectedItems = getSelectedItems();
for (i = 0; i < selectedItems.length; i++)
gDownloadManager.cancelDownload(selectedItems[i].id);
window.updateCommands("tree-select");
break;
case "cmd_remove":
selectedItems = getSelectedItems();
gDownloadManager.startBatchUpdate();
@ -249,7 +182,7 @@ var downloadViewController = {
gDownloadManager.endBatchUpdate();
observer.endUpdateBatch(ds);
var remote = window.arguments[0].QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
var remote = gDownloadManager.datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
remote.Flush();
gDownloadView.builder.rebuild();
if (minValue >= gDownloadView.treeBoxObject.view.rowCount)
@ -319,14 +252,3 @@ function createLocalFile(aFilePath)
lf.initWithPath(aFilePath);
return lf;
}
function Shutdown()
{
try {
var observerService = Components.classes[kObserverServiceProgID]
.getService(Components.interfaces.nsIObserverService);
observerService.removeObserver(dlObserver, "download-starting");
}
catch (ex) {
}
}

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

@ -25,13 +25,13 @@
Jan Varga <varga@utcru.sk>
-->
<?xml-stylesheet href="chrome://communicator/skin/"?>
<?xml-stylesheet href="chrome://global/skin/"?>
<?xml-stylesheet href="chrome://browser/skin/downloads/downloadmanager.css"?>
<?xul-overlay href="chrome://communicator/content/tasksOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
<!DOCTYPE window [
<!ENTITY % downloadManagerDTD SYSTEM "chrome://communicator/locale/downloadmanager/downloadmanager.dtd">
<!ENTITY % downloadManagerDTD SYSTEM "chrome://browser/locale/downloads/downloadmanager.dtd">
%downloadManagerDTD;
<!ENTITY % downloadProgressDTD SYSTEM "chrome://global/locale/nsProgressDialog.dtd" >
%downloadProgressDTD;
@ -40,19 +40,19 @@
<window id="downloadManager"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:nc="http://home.netscape.com/NC-rdf#"
windowtype="Download:Manager"
width="500" height="300" screenX="10" screenY="10"
persist="width height screenX screenY"
title="&downloadManager.title;"
onload="Startup();"
onunload="Shutdown();">
onload="Startup();">
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/downloadmanager/downloadmanager.js"/>
<script type="application/x-javascript" src="chrome://browser/content/downloads/downloadmanager.js"/>
<stringbundle id="dlMgrBundle"
src="chrome://communicator/locale/downloadmanager/downloadmanager.properties"/>
src="chrome://browser/locale/downloads/downloadmanager.properties"/>
<stringbundle id="dlProgressDlgBundle"
src="chrome://global/locale/nsProgressDialog.properties"/>
@ -66,59 +66,37 @@
<data id="strings.unknownTime">&unknownTime;</data>
<data id="strings.pausedMsg">&pausedMsg;</data>
<commandset id="commands">
<commandset id="commandUpdate_Downloads"
commandupdater="true"
events="focus,tree-select"
oncommandupdate="downloadViewController.onCommandUpdate()"/>
<commandset id="downloadCommands">
<command id="cmd_properties"
oncommand="goDoCommand('cmd_properties');"/>
<command id="cmd_pause"
oncommand="goDoCommand('cmd_pause');"/>
<command id="cmd_cancel"
oncommand="goDoCommand('cmd_cancel');"/>
<command id="cmd_remove"
oncommand="goDoCommand('cmd_remove');"/>
<command id="cmd_openfile"
oncommand="goDoCommand('cmd_openfile');"/>
<command id="cmd_showinshell"
oncommand="goDoCommand('cmd_showinshell');"/>
</commandset>
<!-- File Menu -->
<command id="cmd_newNavigator"/>
<command id="cmd_close" oncommand="close()"/>
<command id="cmd_quit"/>
<commandset id="commandUpdate_Downloads"
commandupdater="true"
events="focus,tree-select"
oncommandupdate="downloadViewController.onCommandUpdate()"/>
<commandset id="downloadCommands">
<command id="cmd_properties"
oncommand="goDoCommand('cmd_properties');"/>
<command id="cmd_remove"
oncommand="goDoCommand('cmd_remove');"/>
<command id="cmd_openfile"
oncommand="goDoCommand('cmd_openfile');"/>
<command id="cmd_showinshell"
oncommand="goDoCommand('cmd_showinshell');"/>
</commandset>
<broadcasterset id="navBroadcasters"/>
<keyset id="tasksKeys">
<!-- File Menu -->
<key id="key_newNavigator"/>
<!-- File Menu -->
<command id="cmd_close" oncommand="close()"/>
<keyset>
<key id="key_close"/>
<key id="key_quit"/>
<!-- These keybindings do not have a command specified in the overlay,
which is good, but we need to specify it ourselves here -->
<key id="key_selectAll" command="cmd_selectAll"/>
<key id="key_remove" keycode="VK_DELETE" command="cmd_remove"/>
<key id="key_properties" key="&cmd.properties.keybinding;"
command="cmd_properties" modifiers="accel"/>
</keyset>
<toolbox id="toolbox">
<toolbar id="download-toolbar" tbalign="stretch" class="chromeclass-toolbar" persist="collapsed" grippytooltiptext="&dm.tooltip;">
<toolbarbutton label="&cmd.properties.label;" accesskey="&cmd.properties.accesskey;"
command="cmd_properties"/>
<toolbarseparator/>
<toolbarbutton label="&cmd.cancel.label;" accesskey="&cmd.cancel.accesskey;"
command="cmd_cancel"/>
<toolbar id="download-toolbar" tbalign="stretch" class="chromeclass-toolbar" persist="collapsed">
<toolbarbutton label="&cmd.remove.label;" accesskey="&cmd.remove.accesskey;"
command="cmd_remove"/>
<toolbarseparator/>
@ -130,73 +108,90 @@
<tree id="downloadView" flex="1" class="plain"
datasources="rdf:null" ref="NC:DownloadsRoot" flags="dont-test-empty"
ondblclick="return goDoCommand('cmd_properties');" enableColumnDrag="true"
onselect="onSelect(event);">
enableColumnDrag="true"
onselect="this.treeBoxObject.view.selectionChanged(); onSelect(event);">
<treecols>
<treecol id="Name" primary="true"
label="&view.header.name.label;"
label="&name.label;"
class="sortDirectionIndicator" width="3*" flex="3"
sort="http://home.netscape.com/NC-rdf#Name"
persist="width sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol id="Progress" type="progressmeter"
label="&view.header.progress.label;"
class="sortDirectionIndicator" width="3*" flex="3"
sort="http://home.netscape.com/NC-rdf#ProgressPercent"
persist="width hidden sortActive sortDirection"
sortActive="true" sortDirection="descending"/>
<splitter class="tree-splitter"/>
<treecol id="ProgressPercent" hidden="true"
label="&view.header.progresstext.label;"
<treecol id="StatusText"
label="&status.label;"
class="sortDirectionIndicator" width="1*" flex="1"
sort="http://home.netscape.com/NC-rdf#ProgressPercent"
sort="http://home.netscape.com/NC-rdf#StatusText"
persist="width hidden sortActive sortDirection"/>
<!--
<splitter class="tree-splitter"/>
<treecol id="TimeRemaining"
label="&view.header.timeremaining.label;"
label="&timeremaining.label;"
class="sortDirectionIndicator" width="1*" flex="1"
sort="http://home.netscape.com/NC-rdf#TimeRemaining"
persist="width hidden sortActive sortDirection"/>
-->
<splitter class="tree-splitter"/>
<treecol id="Transferred"
label="&view.header.transferred.label;"
label="&transferred.label;"
class="sortDirectionIndicator" width="1*" flex="1"
sort="http://home.netscape.com/NC-rdf#Transferred"
persist="width hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol id="TransferRate"
label="&view.header.transferrate.label;"
class="sortDirectionIndicator" width="1*" flex="1"
sort="http://home.netscape.com/NC-rdf#TransferRate"
persist="width hidden sortActive sortDirection"/>
<!--
<splitter class="tree-splitter"/>
<treecol id="TimeElapsed" hidden="true"
label="&view.header.timeelapsed.label;"
label="&timeelapsed.label;"
class="sortDirectionIndicator" width="1*" flex="1"
sort="http://home.netscape.com/NC-rdf#TimeElapsed"
persist="width hidden sortActive sortDirection"/>
-->
<splitter class="tree-splitter"/>
<treecol id="Source" hidden="true"
label="&view.header.source.label;"
<treecol id="Source"
label="&source.label;"
class="sortDirectionIndicator" width="1*" flex="1"
sort="http://home.netscape.com/NC-rdf#URL"
persist="width hidden sortActive sortDirection"/>
</treecols>
<template>
<rule>
<rule nc:DownloadState="1" parseType="Integer">
<treechildren>
<treeitem uri="rdf:*">
<treerow>
<treecell src="moz-icon:rdf:http://home.netscape.com/NC-rdf#File"
label="rdf:http://home.netscape.com/NC-rdf#Name"/>
<treecell mode="rdf:http://home.netscape.com/NC-rdf#ProgressMode"
value="rdf:http://home.netscape.com/NC-rdf#ProgressPercent"
label="rdf:http://home.netscape.com/NC-rdf#StatusText"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#ProgressPercent"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#TimeRemaining"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#StatusText"/>
<!-- <treecell label="rdf:http://home.netscape.com/NC-rdf#TimeRemaining"/> -->
<treecell label="rdf:http://home.netscape.com/NC-rdf#Transferred"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#TransferRate"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#TimeElapsed"/>
<!-- <treecell label="rdf:http://home.netscape.com/NC-rdf#TimeElapsed"/> -->
<treecell label="rdf:http://home.netscape.com/NC-rdf#URL"/>
</treerow>
</treeitem>
</treechildren>
</rule>
<rule nc:DownloadState="2" parseType="Integer">
<treechildren>
<treeitem uri="rdf:*">
<treerow>
<treecell src="moz-icon:rdf:http://home.netscape.com/NC-rdf#File"
label="rdf:http://home.netscape.com/NC-rdf#Name"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#StatusText"/>
<!-- <treecell label="rdf:http://home.netscape.com/NC-rdf#TimeRemaining"/> -->
<treecell label="rdf:http://home.netscape.com/NC-rdf#Transferred"/>
<!-- <treecell label="rdf:http://home.netscape.com/NC-rdf#TimeElapsed"/> -->
<treecell label="rdf:http://home.netscape.com/NC-rdf#URL"/>
</treerow>
</treeitem>
</treechildren>
</rule>
<rule nc:DownloadState="3" parseType="Integer">
<treechildren>
<treeitem uri="rdf:*">
<treerow>
<treecell src="moz-icon:rdf:http://home.netscape.com/NC-rdf#File"
label="rdf:http://home.netscape.com/NC-rdf#Name"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#StatusText"/>
<!-- <treecell label="rdf:http://home.netscape.com/NC-rdf#TimeRemaining"/> -->
<treecell label="rdf:http://home.netscape.com/NC-rdf#Transferred"/>
<!-- <treecell label="rdf:http://home.netscape.com/NC-rdf#TimeElapsed"/> -->
<treecell label="rdf:http://home.netscape.com/NC-rdf#URL"/>
</treerow>
</treeitem>
@ -204,9 +199,4 @@
</rule>
</template>
</tree>
<statusbar id="status-bar" class="chromeclass-status">
<statusbarpanel id="statusbar-text" label="" flex="1"/>
</statusbar>
</window>

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

@ -1,6 +1,13 @@
browser.jar:
content/browser/downloads/downloadmanager.xul (content/downloadmanager.xul)
content/browser/downloads/downloadmanager.js (content/downloadmanager.js)
content/browser/downloads/downloadPanel.js (content/downloadPanel.js)
content/browser/downloads/downloadPanel.xul (content/downloadPanel.xul)
content/browser/downloads/download-bindings.xml (content/download-bindings.xml)
content/browser/downloads/downloadmanager.css (content/downloadmanager.css)
classic.jar:
skin/classic/browser/downloads/downloadmanager.css (skin/downloadmanager.css)
en-US.jar:
locale/en-US/browser/downloads/downloadmanager.dtd (locale/downloadmanager.dtd)

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

@ -1,12 +1,21 @@
<!ENTITY view.header.name.label "Name">
<!ENTITY view.header.progress.label "Progress">
<!ENTITY view.header.status.label "Status">
<!ENTITY view.header.timeremaining.label "Time Remaining">
<!ENTITY view.header.transferred.label "Transferred">
<!ENTITY view.header.transferrate.label "Speed">
<!ENTITY view.header.timeelapsed.label "Time Elapsed">
<!ENTITY view.header.progresstext.label "&#37;">
<!ENTITY view.header.source.label "Source">
<!ENTITY name.label "Name">
<!ENTITY progress.label "Progress">
<!ENTITY status.label "Status">
<!ENTITY timeremaining.label "Time Remaining">
<!ENTITY transferred.label "Transferred">
<!ENTITY transferrate.label "Speed">
<!ENTITY timeelapsed.label "Time Elapsed">
<!ENTITY status.label "Status">
<!--<!ENTITY progresstext.label "&#37;">-->
<!ENTITY source.label "Source">
<!ENTITY done.label "Done">
<!ENTITY cancel.label "Cancel">
<!ENTITY cancelled.label "Cancelled">
<!ENTITY launch.label "Launch">
<!ENTITY divider.label "-">
<!ENTITY show.label "Show">
<!ENTITY failed.label "Failed">
<!ENTITY downloadManager.title "Download Manager">
@ -21,7 +30,6 @@
<!ENTITY cmd.cancel.accesskey "c">
<!ENTITY cmd.openfile.label "Launch File">
<!ENTITY cmd.openfile.accesskey "L">
<!ENTITY dm.tooltip "Toolbar">
<!ENTITY confirmCancel "Are you sure you want to cancel the saving of this file?">
<!ENTITY progressMsgNoRate "#1KB of #2KB">
<!ENTITY rateMsg "#1KB/sec">

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

@ -47,6 +47,7 @@ interface nsILocalFile;
interface nsIDownload;
interface nsIWebBrowserPersist;
interface nsIMIMEInfo;
interface nsIRDFDataSource;
[scriptable, uuid(9be66cc0-1dd1-11b2-8617-e3a3ed26e3b0)]
interface nsIDownloadManager : nsISupports {
@ -121,17 +122,6 @@ interface nsIDownloadManager : nsISupports {
// UI-related methods
/**
* Opens the Download Manager front end.
*
* @param aParent The parent, or opener, of the front end (optional).
* @param aDownload A download to pass to the manager window. Useful
* if, for example, you want the window to select a
* certain download (optional).
*/
void open(in nsIDOMWindow aParent, in nsIDownload aDownload);
/**
* Opens an individual progress dialog displaying progress for the download.
*
@ -143,13 +133,6 @@ interface nsIDownloadManager : nsISupports {
void openProgressDialogFor(in string aPersistentDescriptor, in nsIDOMWindow aParent);
/**
* Called when the download manager front end is closed. Useful for
* third party managers to let us know when they've closed.
*/
void onClose();
/**
* Indicate that a batch update (e.g. mass removal) is about to start.
*/
@ -161,6 +144,8 @@ interface nsIDownloadManager : nsISupports {
*/
void endBatchUpdate();
readonly attribute nsIRDFDataSource datasource;
};

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

@ -0,0 +1,37 @@
.bold {
font-weight: bold;
}
page > #downloadView {
background-color: white;
padding: 10px;
}
download {
padding: 3px;
min-height: 25px;
}
#downloadView > treechildren:-moz-tree-image(Name) {
margin-right: 2px;
}
.indented {
margin-left: 17px;
}
.link {
text-decoration: underline;
color: blue;
cursor: pointer;
-moz-user-focus: normal;
border: 1px solid transparent;
}
.link:hover:active {
color: red;
}
.link:focus {
border: 1px dotted black;
}

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

@ -65,10 +65,12 @@
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
static PRBool gQuitting = PR_FALSE;
#define DOWNLOAD_MANAGER_FE_URL "chrome://communicator/content/downloadmanager/downloadmanager.xul"
#define DOWNLOAD_MANAGER_BUNDLE "chrome://communicator/locale/downloadmanager/downloadmanager.properties"
#define DOWNLOAD_MANAGER_FE_URL "chrome://browser/content/downloadmanager/downloadmanager.xul"
#define DOWNLOAD_MANAGER_BUNDLE "chrome://browser/locale/downloadmanager/downloadmanager.properties"
#define INTERVAL 500
#define DOWNLOAD_ENDED_TIMEOUT 5000
nsIRDFResource* gNC_DownloadsRoot;
nsIRDFResource* gNC_File;
@ -81,11 +83,12 @@ nsIRDFResource* gNC_DownloadState;
nsIRDFResource* gNC_StatusText;
nsIRDFService* gRDFService;
nsIObserverService* gObserverService;
///////////////////////////////////////////////////////////////////////////////
// nsDownloadManager
NS_IMPL_ISUPPORTS3(nsDownloadManager, nsIDownloadManager, nsIDOMEventListener, nsIObserver)
NS_IMPL_ISUPPORTS2(nsDownloadManager, nsIDownloadManager, nsIObserver)
nsDownloadManager::nsDownloadManager() : mBatches(0)
{
@ -111,6 +114,31 @@ nsDownloadManager::~nsDownloadManager()
}
void PR_CALLBACK nsDownloadManager::DownloadCallback(nsITimer *aTimer, void *aClosure)
{
DownloadClosure* closure = (DownloadClosure*)aClosure;
closure->DownloadManager->DownloadEnded(closure->path.get(), nsnull);
delete aClosure;
}
PRInt32 PR_CALLBACK nsDownloadManager::CancelAllDownloads(nsHashKey* aKey, void* aData, void* aClosure)
{
nsCStringKey* key = (nsCStringKey*)aKey;
nsresult rv;
nsCOMPtr<nsIDownloadManager> manager = do_QueryInterface((nsISupports*)aClosure, &rv);
if (NS_FAILED(rv)) return kHashEnumerateRemove;
DownloadState state;
NS_STATIC_CAST(nsDownload*, aData)->GetDownloadState(&state);
if (state == NOTSTARTED || state == DOWNLOADING)
manager->CancelDownload(key->GetString());
else
NS_STATIC_CAST(nsDownloadManager*, aClosure)->DownloadEnded(key->GetString(), nsnull);
return kHashEnumerateRemove;
}
nsresult
nsDownloadManager::Init()
{
@ -118,10 +146,11 @@ nsDownloadManager::Init()
mRDFContainerUtils = do_GetService("@mozilla.org/rdf/container-utils;1", &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIObserverService> obsService = do_GetService("@mozilla.org/observer-service;1", &rv);
rv = nsServiceManager::GetService("@mozilla.org/observer-service;1", NS_GET_IID(nsIObserverService),
(nsISupports**) &gObserverService);
if (NS_FAILED(rv)) return rv;
obsService->AddObserver(this, "quit-application", PR_FALSE);
gObserverService->AddObserver(this, "quit-application", PR_FALSE);
rv = nsServiceManager::GetService(kRDFServiceCID, NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDFService);
@ -144,9 +173,6 @@ nsDownloadManager::Init()
rv = gRDFService->GetDataSourceBlocking(downloadsDB.get(), getter_AddRefs(mDataSource));
if (NS_FAILED(rv)) return rv;
mListener = do_CreateInstance("@mozilla.org/download-manager/listener;1", &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(kStringBundleServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
@ -169,7 +195,9 @@ nsDownloadManager::DownloadEnded(const char* aPath, const PRUnichar* aMessage)
nsCStringKey key(aPath);
if (mCurrDownloads.Exists(&key)) {
AssertProgressInfoFor(aPath);
mCurrDownloads.Remove(&key);
if (!gQuitting)
mCurrDownloads.Remove(&key);
}
return NS_OK;
@ -216,14 +244,6 @@ nsDownloadManager::GetDownloadsContainer(nsIRDFContainer** aResult)
return rv;
}
nsresult
nsDownloadManager::GetInternalListener(nsIDownloadProgressListener** aInternalListener)
{
*aInternalListener = mListener;
NS_IF_ADDREF(*aInternalListener);
return NS_OK;
}
nsresult
nsDownloadManager::GetDataSource(nsIRDFDataSource** aDataSource)
{
@ -422,6 +442,10 @@ nsDownloadManager::AddDownload(nsIURI* aSource,
rv = aTarget->GetNativePath(path);
if (NS_FAILED(rv)) return rv;
nsCStringKey key(path);
if (mCurrDownloads.Exists(&key))
CancelDownload(path.get());
nsCOMPtr<nsIRDFResource> downloadRes;
gRDFService->GetResource(path.get(), getter_AddRefs(downloadRes));
@ -518,10 +542,6 @@ nsDownloadManager::AddDownload(nsIURI* aSource,
aPersist->SetProgressListener(listener);
}
nsCStringKey key(path);
if (mCurrDownloads.Exists(&key))
mCurrDownloads.Remove(&key);
mCurrDownloads.Put(&key, *aDownload);
return rv;
@ -579,9 +599,11 @@ nsDownloadManager::CancelDownload(const char* aPath)
rv = observer->Observe(download, "oncancel", nsnull);
if (NS_FAILED(rv)) return rv;
}
gObserverService->NotifyObservers(download, "dl-cancel", nsnull);
DownloadEnded(aPath, nsnull);
// if there's a progress dialog open for the item,
// we have to notify it that we're cancelling
nsCOMPtr<nsIProgressDialog> dialog;
@ -688,59 +710,13 @@ nsDownloadManager::EndBatchUpdate()
}
NS_IMETHODIMP
nsDownloadManager::Open(nsIDOMWindow* aParent, nsIDownload* aDownload)
nsDownloadManager::GetDatasource(nsIRDFDataSource** aDatasource)
{
// first assert new progress info so the ui is correctly updated
// if this fails, it fails -- continue.
AssertProgressInfo();
//check for an existing manager window and focus it
nsresult rv;
nsCOMPtr<nsIWindowMediator> wm = do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> dlSupports(do_QueryInterface(aDownload));
// if the window's already open, do nothing (focusing it would be annoying)
nsCOMPtr<nsIDOMWindowInternal> recentWindow;
wm->GetMostRecentWindow(NS_LITERAL_STRING("Download:Manager").get(), getter_AddRefs(recentWindow));
if (recentWindow) {
nsCOMPtr<nsIObserverService> obsService = do_GetService("@mozilla.org/observer-service;1", &rv);
if (NS_FAILED(rv)) return rv;
return obsService->NotifyObservers(dlSupports, "download-starting", nsnull);
}
// if we ever have the capability to display the UI of third party dl managers,
// we'll open their UI here instead.
nsCOMPtr<nsIWindowWatcher> ww = do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
// pass the datasource to the window
nsCOMPtr<nsISupportsArray> params(do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID));
nsCOMPtr<nsISupports> dsSupports(do_QueryInterface(mDataSource));
params->AppendElement(dsSupports);
params->AppendElement(dlSupports);
nsCOMPtr<nsIDOMWindow> newWindow;
rv = ww->OpenWindow(aParent,
DOWNLOAD_MANAGER_FE_URL,
"_blank",
"chrome,all,dialog=no,resizable",
params,
getter_AddRefs(newWindow));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(newWindow);
if (!target) return NS_ERROR_FAILURE;
rv = target->AddEventListener(NS_LITERAL_STRING("load"), this, PR_FALSE);
if (NS_FAILED(rv)) return rv;
return target->AddEventListener(NS_LITERAL_STRING("unload"), this, PR_FALSE);
*aDatasource = mDataSource;
NS_IF_ADDREF(*aDatasource);
return NS_OK;
}
NS_IMETHODIMP
nsDownloadManager::OpenProgressDialogFor(const char* aPath, nsIDOMWindow* aParent)
{
@ -772,8 +748,6 @@ nsDownloadManager::OpenProgressDialogFor(const char* aPath, nsIDOMWindow* aParen
nsCOMPtr<nsIProgressDialog> dialog(do_CreateInstance("@mozilla.org/progressdialog;1", &rv));
if (NS_FAILED(rv)) return rv;
dialog->SetCancelDownloadOnClose(PR_FALSE);
nsCOMPtr<nsIDownload> dl = do_QueryInterface(dialog);
// now give the dialog the necessary context
@ -806,36 +780,6 @@ nsDownloadManager::OpenProgressDialogFor(const char* aPath, nsIDOMWindow* aParen
return dialog->Open(aParent);
}
NS_IMETHODIMP
nsDownloadManager::OnClose()
{
mDocument = nsnull;
mListener->SetDocument(nsnull);
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIDOMEventListener
NS_IMETHODIMP
nsDownloadManager::HandleEvent(nsIDOMEvent* aEvent)
{
// the event is either load or unload
nsAutoString eventType;
aEvent->GetType(eventType);
if (eventType.Equals(NS_LITERAL_STRING("unload")))
return OnClose();
nsCOMPtr<nsIDOMEventTarget> target;
nsresult rv = aEvent->GetTarget(getter_AddRefs(target));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMNode> targetNode(do_QueryInterface(target));
mDocument = do_QueryInterface(targetNode);
mListener->SetDocument(mDocument);
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIObserver
@ -861,27 +805,9 @@ nsDownloadManager::Observe(nsISupports* aSubject, const char* aTopic, const PRUn
return CancelDownload(path.get());
}
}
else if (nsCRT::strcmp(aTopic, "quit-application") == 0) {
nsCOMPtr<nsISupports> supports;
nsCOMPtr<nsIRDFResource> res;
const char* uri;
nsCOMPtr<nsIRDFInt> intLiteral;
gRDFService->GetIntLiteral(DOWNLOADING, getter_AddRefs(intLiteral));
nsCOMPtr<nsISimpleEnumerator> downloads;
rv = mDataSource->GetSources(gNC_DownloadState, intLiteral, PR_TRUE, getter_AddRefs(downloads));
if (NS_FAILED(rv)) return rv;
PRBool hasMoreElements;
downloads->HasMoreElements(&hasMoreElements);
while (hasMoreElements) {
downloads->GetNext(getter_AddRefs(supports));
res = do_QueryInterface(supports);
res->GetValueConst(&uri);
CancelDownload(uri);
downloads->HasMoreElements(&hasMoreElements);
}
else if (nsCRT::strcmp(aTopic, "quit-application") == 0 && mCurrDownloads.Count()) {
gQuitting = PR_TRUE;
mCurrDownloads.Enumerate(CancelAllDownloads, this);
}
return NS_OK;
}
@ -903,11 +829,6 @@ nsDownload::nsDownload():mDownloadState(NOTSTARTED),
nsDownload::~nsDownload()
{
nsCAutoString path;
nsresult rv = mTarget->GetNativePath(path);
if (NS_FAILED(rv)) return;
mDownloadManager->AssertProgressInfoFor(path.get());
}
nsresult
@ -1023,7 +944,7 @@ nsDownload::OnProgressChange(nsIWebProgress *aWebProgress,
PRTime delta;
PRTime now = PR_Now();
LL_SUB(delta, now, mLastUpdate);
if (LL_CMP(delta, <, INTERVAL) && aMaxTotalProgress != -1 && aCurTotalProgress < aMaxTotalProgress)
if (LL_CMP(delta, <, INTERVAL) && aMaxTotalProgress != -1 && aCurTotalProgress < aMaxTotalProgress)
return NS_OK;
mLastUpdate = now;
@ -1050,14 +971,7 @@ nsDownload::OnProgressChange(nsIWebProgress *aWebProgress,
aCurTotalProgress, aMaxTotalProgress);
}
if (mDownloadManager->MustUpdateUI()) {
nsCOMPtr<nsIDownloadProgressListener> internalListener;
mDownloadManager->GetInternalListener(getter_AddRefs(internalListener));
if (internalListener) {
internalListener->OnProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress, this);
}
}
gObserverService->NotifyObservers(NS_STATIC_CAST(nsIDownload *, this), "dl-progress", nsnull);
if (mDialogListener) {
mDialogListener->OnProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress,
@ -1071,19 +985,6 @@ NS_IMETHODIMP
nsDownload::OnLocationChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsIURI *aLocation)
{
if (mListener)
mListener->OnLocationChange(aWebProgress, aRequest, aLocation);
if (mDownloadManager->MustUpdateUI()) {
nsCOMPtr<nsIDownloadProgressListener> internalListener;
mDownloadManager->GetInternalListener(getter_AddRefs(internalListener));
if (internalListener)
internalListener->OnLocationChange(aWebProgress, aRequest, aLocation, this);
}
if (mDialogListener)
mDialogListener->OnLocationChange(aWebProgress, aRequest, aLocation);
return NS_OK;
}
@ -1096,20 +997,26 @@ nsDownload::OnStatusChange(nsIWebProgress *aWebProgress,
mDownloadState = FAILED;
nsCAutoString path;
nsresult rv = mTarget->GetNativePath(path);
if (NS_SUCCEEDED(rv))
mDownloadManager->DownloadEnded(path.get(), aMessage);
if (NS_SUCCEEDED(rv)) {
gObserverService->NotifyObservers(NS_STATIC_CAST(nsIDownload *, this), "dl-failed", nsnull);
if (mTimer)
mTimer->Cancel();
if (!mTimer)
mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
if (NS_FAILED(rv)) return rv;
DownloadClosure* closure = new DownloadClosure();
closure->DownloadManager = mDownloadManager;
closure->path = path;
mTimer->InitWithFuncCallback(nsDownloadManager::DownloadCallback, (void*)closure, DOWNLOAD_ENDED_TIMEOUT, nsITimer::TYPE_ONE_SHOT);
}
}
if (mListener)
mListener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
if (mDownloadManager->MustUpdateUI()) {
nsCOMPtr<nsIDownloadProgressListener> internalListener;
mDownloadManager->GetInternalListener(getter_AddRefs(internalListener));
if (internalListener)
internalListener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage, this);
}
if (mDialogListener)
mDialogListener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
else {
@ -1152,13 +1059,6 @@ nsDownload::OnStateChange(nsIWebProgress* aWebProgress,
if (mListener)
mListener->OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus);
if (mDownloadManager->MustUpdateUI()) {
nsCOMPtr<nsIDownloadProgressListener> internalListener;
mDownloadManager->GetInternalListener(getter_AddRefs(internalListener));
if (internalListener)
internalListener->OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus, this);
}
if (mDialogListener)
mDialogListener->OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus);
@ -1171,11 +1071,20 @@ nsDownload::OnStateChange(nsIWebProgress* aWebProgress,
mCurrBytes = mMaxBytes;
mPercentComplete = 100;
gObserverService->NotifyObservers(NS_STATIC_CAST(nsIDownload *, this), "dl-done", nsnull);
nsCAutoString path;
nsresult rv = mTarget->GetNativePath(path);
if (NS_FAILED(rv)) return rv;
mDownloadManager->DownloadEnded(path.get(), nsnull);
if (!mTimer)
mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
if (NS_FAILED(rv)) return rv;
DownloadClosure* closure = new DownloadClosure();
closure->DownloadManager = mDownloadManager;
closure->path = path;
mTimer->InitWithFuncCallback(nsDownloadManager::DownloadCallback, (void*)closure, DOWNLOAD_ENDED_TIMEOUT, nsITimer::TYPE_ONE_SHOT);
}
// break the cycle we created in AddDownload
@ -1190,19 +1099,6 @@ NS_IMETHODIMP
nsDownload::OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, PRUint32 aState)
{
if (mListener)
mListener->OnSecurityChange(aWebProgress, aRequest, aState);
if (mDownloadManager->MustUpdateUI()) {
nsCOMPtr<nsIDownloadProgressListener> internalListener;
mDownloadManager->GetInternalListener(getter_AddRefs(internalListener));
if (internalListener)
internalListener->OnSecurityChange(aWebProgress, aRequest, aState, this);
}
if (mDialogListener)
mDialogListener->OnSecurityChange(aWebProgress, aRequest, aState);
return NS_OK;
}
@ -1291,6 +1187,7 @@ nsDownload::GetPercentComplete(PRInt32* aPercentComplete)
NS_IMETHODIMP
nsDownload::SetListener(nsIWebProgressListener* aListener)
{
printf("SET LISTENER...\n");
mListener = aListener;
return NS_OK;
}

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

@ -47,7 +47,6 @@
#include "nsIRDFRemoteDataSource.h"
#include "nsIRDFService.h"
#include "nsIDOMDocument.h"
#include "nsIDOMEventListener.h"
#include "nsIRDFContainerUtils.h"
#include "nsIWebProgressListener.h"
#include "nsIURI.h"
@ -59,17 +58,16 @@
#include "nsIStringBundle.h"
#include "nsIProgressDialog.h"
#include "nsIMIMEInfo.h"
#include "nsITimer.h"
enum DownloadState { NOTSTARTED = -1, DOWNLOADING, FINISHED, FAILED, CANCELED };
class nsDownloadManager : public nsIDownloadManager,
public nsIDOMEventListener,
public nsIObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOWNLOADMANAGER
NS_DECL_NSIDOMEVENTLISTENER
NS_DECL_NSIOBSERVER
nsresult Init();
@ -77,22 +75,22 @@ public:
nsDownloadManager();
virtual ~nsDownloadManager();
static void PR_CALLBACK DownloadCallback(nsITimer *aTimer, void *aClosure);
static PRInt32 PR_CALLBACK CancelAllDownloads(nsHashKey* aKey, void* aData, void* aClosure);
nsresult DownloadEnded(const char* aPersistentDescriptor, const PRUnichar* aMessage);
protected:
nsresult GetDownloadsContainer(nsIRDFContainer** aResult);
nsresult GetProfileDownloadsFileURL(nsCString& aDownloadsFileURL);
nsresult GetInternalListener(nsIDownloadProgressListener** aInternalListener);
nsresult GetDataSource(nsIRDFDataSource** aDataSource);
nsresult AssertProgressInfo();
nsresult AssertProgressInfoFor(const char* aPersistentDescriptor);
nsresult DownloadStarted(const char* aPersistentDescriptor);
nsresult DownloadEnded(const char* aPersistentDescriptor, const PRUnichar* aMessage);
PRBool MustUpdateUI() { if (mDocument) return PR_TRUE; return PR_FALSE; }
nsresult AssertProgressInfoFor(const char* aPersistentDescriptor);
private:
nsCOMPtr<nsIRDFDataSource> mDataSource;
nsCOMPtr<nsIDOMDocument> mDocument;
nsCOMPtr<nsIRDFContainer> mDownloadsContainer;
nsCOMPtr<nsIDownloadProgressListener> mListener;
nsCOMPtr<nsIRDFContainerUtils> mRDFContainerUtils;
nsCOMPtr<nsIStringBundle> mBundle;
PRInt32 mBatches;
@ -101,6 +99,11 @@ private:
friend class nsDownload;
};
struct DownloadClosure {
nsDownloadManager* DownloadManager;
nsCString path;
};
class nsDownload : public nsIDownload,
public nsIWebProgressListener
{
@ -140,6 +143,7 @@ private:
nsCOMPtr<nsIProgressDialog> mDialog;
nsCOMPtr<nsIObserver> mObserver;
nsCOMPtr<nsIMIMEInfo> mMIMEInfo;
DownloadState mDownloadState;
PRInt32 mPercentComplete;
@ -147,6 +151,7 @@ private:
PRInt32 mMaxBytes;
PRInt64 mStartTime;
PRTime mLastUpdate;
nsCOMPtr<nsITimer> mTimer;
friend class nsDownloadManager;
};

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

@ -45,7 +45,7 @@
#include "nsIPrefService.h"
#include "nsIMIMEInfo.h"
#define DOWNLOAD_MANAGER_BEHAVIOR_PREF "browser.downloadmanager.behavior"
#define USE_PROGRESS_DIALOGS_PREF "browser.downloads.useProgressDialogs"
class nsDownloadProxy : public nsIDownload,
public nsIWebProgressListener
@ -70,15 +70,13 @@ public:
rv = dm->AddDownload(aSource, aTarget, aDisplayName, aMIMEInfo, aStartTime, aPersist, getter_AddRefs(mInner));
if (NS_FAILED(rv)) return rv;
PRInt32 behavior = 0;
nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1", &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
branch->GetIntPref(DOWNLOAD_MANAGER_BEHAVIOR_PREF, &behavior);
if (behavior == 0)
return dm->Open(nsnull, this);
if (behavior == 1) {
PRBool useProgressDialogs = PR_TRUE;
branch->GetBoolPref(USE_PROGRESS_DIALOGS_PREF, &useProgressDialogs);
if (useProgressDialogs) {
nsCAutoString path;
rv = aTarget->GetNativePath(path);
if (NS_FAILED(rv)) return rv;

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

@ -35,17 +35,13 @@ splitter {
cursor: e-resize;
border: 2px solid;
-moz-border-top-colors: ThreeDHighlight ThreeDLightShadow;
-moz-border-right-colors: ThreeDDarkShadow ThreeDShadow;
-moz-border-right-colors: transparent;
-moz-border-bottom-colors: ThreeDShadow ThreeDLightShadow;
-moz-border-left-colors: ThreeDDarkShadow ThreeDHighlight;
min-width: 8px;
-moz-border-left-colors: ThreeDShadow ThreeDHighlight;
min-width: 5px;
background-color: ThreeDFace;
}
splitter[state="dragging"] {
background-image: url("chrome://global/skin/splitter/drag-bg.gif");
}
/* ::::: splitter (horizontal) ::::: */
splitter[orient="vertical"] {