зеркало из https://github.com/mozilla/pjs.git
Bug 548189 - Remove embedding/components/ui/, r=bsmedberg
--HG-- extra : rebase_source : b5ce791f2f0ac155e8974f9400d2c8d49956e19f
This commit is contained in:
Родитель
8d68927ebf
Коммит
5078a84726
|
@ -45,7 +45,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
# You'd think we could skip building ui if XUL is disabled,
|
||||
# but we need to export interface headers from those directories.
|
||||
|
||||
DIRS = windowwatcher appstartup find webbrowserpersist commandhandler ui
|
||||
DIRS = windowwatcher appstartup find webbrowserpersist commandhandler
|
||||
|
||||
ifdef MOZ_XUL
|
||||
ifdef NS_PRINTING
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
#
|
||||
# ***** 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, Inc.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# 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 *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = helperAppDlg progressDlg
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -1,52 +0,0 @@
|
|||
#
|
||||
# ***** 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, Inc.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# 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 *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
MODULE=helperAppDlg
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
EXTRA_COMPONENTS = \
|
||||
nsHelperAppDlg.js \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -1,894 +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 the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Bill Law <law@netscape.com>
|
||||
* Scott MacGregor <mscott@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 ***** */
|
||||
|
||||
/* This file implements the nsIHelperAppLauncherDialog interface.
|
||||
*
|
||||
* The implementation consists of a JavaScript "class" named nsHelperAppDialog,
|
||||
* comprised of:
|
||||
* - a JS constructor function
|
||||
* - a prototype providing all the interface methods and implementation stuff
|
||||
*
|
||||
* In addition, this file implements an nsIModule object that registers the
|
||||
* nsHelperAppDialog component.
|
||||
*/
|
||||
|
||||
const nsIHelperAppLauncherDialog = Components.interfaces.nsIHelperAppLauncherDialog;
|
||||
const REASON_CANTHANDLE = nsIHelperAppLauncherDialog.REASON_CANTHANDLE;
|
||||
const REASON_SERVERREQUEST = nsIHelperAppLauncherDialog.REASON_SERVERREQUEST;
|
||||
const REASON_TYPESNIFFED = nsIHelperAppLauncherDialog.REASON_TYPESNIFFED;
|
||||
|
||||
|
||||
/* ctor
|
||||
*/
|
||||
function nsHelperAppDialog() {
|
||||
// Initialize data properties.
|
||||
this.mLauncher = null;
|
||||
this.mContext = null;
|
||||
this.mSourcePath = null;
|
||||
this.chosenApp = null;
|
||||
this.givenDefaultApp = false;
|
||||
this.strings = new Array;
|
||||
this.elements = new Array;
|
||||
this.updateSelf = true;
|
||||
this.mTitle = "";
|
||||
this.mIsMac = false;
|
||||
}
|
||||
|
||||
nsHelperAppDialog.prototype = {
|
||||
// Turn this on to get debugging messages.
|
||||
debug: false,
|
||||
|
||||
nsIMIMEInfo : Components.interfaces.nsIMIMEInfo,
|
||||
|
||||
// Dump text (if debug is on).
|
||||
dump: function( text ) {
|
||||
if ( this.debug ) {
|
||||
dump( text );
|
||||
}
|
||||
},
|
||||
|
||||
// This "class" supports nsIHelperAppLauncherDialog, and nsISupports.
|
||||
QueryInterface: function (iid) {
|
||||
if (iid.equals(Components.interfaces.nsIHelperAppLauncherDialog) ||
|
||||
iid.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
},
|
||||
|
||||
// ---------- nsIHelperAppLauncherDialog methods ----------
|
||||
|
||||
// show: Open XUL dialog using window watcher. Since the dialog is not
|
||||
// modal, it needs to be a top level window and the way to open
|
||||
// one of those is via that route).
|
||||
show: function(aLauncher, aContext, aReason) {
|
||||
this.mLauncher = aLauncher;
|
||||
this.mContext = aContext;
|
||||
this.mReason = aReason;
|
||||
// Display the dialog using the Window Watcher interface.
|
||||
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
||||
.getService( Components.interfaces.nsIWindowWatcher );
|
||||
this.mDialog = ww.openWindow( null, // no parent
|
||||
"chrome://global/content/nsHelperAppDlg.xul",
|
||||
null,
|
||||
"chrome,titlebar,dialog=yes",
|
||||
null );
|
||||
// Hook this object to the dialog.
|
||||
this.mDialog.dialog = this;
|
||||
// Watch for error notifications.
|
||||
this.mIsMac = (this.mDialog.navigator.platform.indexOf( "Mac" ) != -1);
|
||||
this.progressListener.helperAppDlg = this;
|
||||
this.mLauncher.setWebProgressListener( this.progressListener );
|
||||
},
|
||||
|
||||
// promptForSaveToFile: Display file picker dialog and return selected file.
|
||||
promptForSaveToFile: function(aLauncher, aContext, aDefaultFile, aSuggestedFileExtension, aForcePrompt) {
|
||||
var result = "";
|
||||
|
||||
const prefSvcContractID = "@mozilla.org/preferences-service;1";
|
||||
const prefSvcIID = Components.interfaces.nsIPrefService;
|
||||
var branch = Components.classes[prefSvcContractID].getService(prefSvcIID)
|
||||
.getBranch("browser.download.");
|
||||
var dir = null;
|
||||
|
||||
const nsILocalFile = Components.interfaces.nsILocalFile;
|
||||
const kDownloadDirPref = "dir";
|
||||
|
||||
// Try and pull in download directory pref
|
||||
try {
|
||||
dir = branch.getComplexValue(kDownloadDirPref, nsILocalFile);
|
||||
} catch (e) { }
|
||||
|
||||
var bundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
|
||||
.getService(Components.interfaces.nsIStringBundleService)
|
||||
.createBundle("chrome://global/locale/nsHelperAppDlg.properties");
|
||||
|
||||
var autoDownload = branch.getBoolPref("autoDownload");
|
||||
// If the autoDownload pref is set then just download to default download directory
|
||||
if (!aForcePrompt && autoDownload && dir && dir.exists()) {
|
||||
if (aDefaultFile == "")
|
||||
aDefaultFile = bundle.GetStringFromName("noDefaultFile") + (aSuggestedFileExtension || "");
|
||||
dir.append(aDefaultFile);
|
||||
return uniqueFile(dir);
|
||||
}
|
||||
|
||||
// Use file picker to show dialog.
|
||||
var nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
var picker = Components.classes[ "@mozilla.org/filepicker;1" ]
|
||||
.createInstance( nsIFilePicker );
|
||||
|
||||
var windowTitle = bundle.GetStringFromName( "saveDialogTitle" );
|
||||
|
||||
var parent = aContext
|
||||
.QueryInterface( Components.interfaces.nsIInterfaceRequestor )
|
||||
.getInterface( Components.interfaces.nsIDOMWindowInternal );
|
||||
picker.init( parent, windowTitle, nsIFilePicker.modeSave );
|
||||
picker.defaultString = aDefaultFile;
|
||||
if (aSuggestedFileExtension) {
|
||||
// aSuggestedFileExtension includes the period, so strip it
|
||||
picker.defaultExtension = aSuggestedFileExtension.substring(1);
|
||||
} else {
|
||||
try {
|
||||
picker.defaultExtension = this.mLauncher.MIMEInfo.primaryExtension;
|
||||
} catch (ex) {
|
||||
}
|
||||
}
|
||||
|
||||
var wildCardExtension = "*";
|
||||
if ( aSuggestedFileExtension ) {
|
||||
wildCardExtension += aSuggestedFileExtension;
|
||||
picker.appendFilter( wildCardExtension, wildCardExtension );
|
||||
}
|
||||
|
||||
picker.appendFilters( nsIFilePicker.filterAll );
|
||||
|
||||
try {
|
||||
if (dir.exists())
|
||||
picker.displayDirectory = dir;
|
||||
} catch (e) { }
|
||||
|
||||
if (picker.show() == nsIFilePicker.returnCancel || !picker.file) {
|
||||
// Null result means user cancelled.
|
||||
return null;
|
||||
}
|
||||
|
||||
// If not using specified location save the user's choice of directory
|
||||
if (branch.getBoolPref("lastLocation") || autoDownload) {
|
||||
var directory = picker.file.parent.QueryInterface(nsILocalFile);
|
||||
branch.setComplexValue(kDownloadDirPref, nsILocalFile, directory);
|
||||
}
|
||||
|
||||
return picker.file;
|
||||
},
|
||||
|
||||
// ---------- implementation methods ----------
|
||||
|
||||
// Web progress listener so we can detect errors while mLauncher is
|
||||
// streaming the data to a temporary file.
|
||||
progressListener: {
|
||||
// Implementation properties.
|
||||
helperAppDlg: null,
|
||||
|
||||
// nsIWebProgressListener methods.
|
||||
// Look for error notifications and display alert to user.
|
||||
onStatusChange: function( aWebProgress, aRequest, aStatus, aMessage ) {
|
||||
if ( aStatus != Components.results.NS_OK ) {
|
||||
// Get prompt service.
|
||||
var prompter = Components.classes[ "@mozilla.org/embedcomp/prompt-service;1" ]
|
||||
.getService( Components.interfaces.nsIPromptService );
|
||||
// Display error alert (using text supplied by back-end).
|
||||
prompter.alert( this.dialog, this.helperAppDlg.mTitle, aMessage );
|
||||
|
||||
// Close the dialog.
|
||||
this.helperAppDlg.onCancel();
|
||||
if ( this.helperAppDlg.mDialog ) {
|
||||
this.helperAppDlg.mDialog.close();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Ignore onProgressChange, onProgressChange64, onStateChange, onLocationChange, onSecurityChange, and onRefreshAttempted notifications.
|
||||
onProgressChange: function( aWebProgress,
|
||||
aRequest,
|
||||
aCurSelfProgress,
|
||||
aMaxSelfProgress,
|
||||
aCurTotalProgress,
|
||||
aMaxTotalProgress ) {
|
||||
},
|
||||
|
||||
onProgressChange64: function( aWebProgress,
|
||||
aRequest,
|
||||
aCurSelfProgress,
|
||||
aMaxSelfProgress,
|
||||
aCurTotalProgress,
|
||||
aMaxTotalProgress ) {
|
||||
},
|
||||
|
||||
onStateChange: function( aWebProgress, aRequest, aStateFlags, aStatus ) {
|
||||
},
|
||||
|
||||
onLocationChange: function( aWebProgress, aRequest, aLocation ) {
|
||||
},
|
||||
|
||||
onSecurityChange: function( aWebProgress, aRequest, state ) {
|
||||
},
|
||||
|
||||
onRefreshAttempted: function( aWebProgress, aURI, aDelay, aSameURI ) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
// initDialog: Fill various dialog fields with initial content.
|
||||
initDialog : function() {
|
||||
// Put product brand short name in prompt.
|
||||
var prompt = this.dialogElement( "prompt" );
|
||||
var modified = this.replaceInsert( prompt.firstChild.nodeValue, 1, this.getString( "brandShortName" ) );
|
||||
prompt.firstChild.nodeValue = modified;
|
||||
|
||||
// Put file name in window title.
|
||||
var suggestedFileName = this.mLauncher.suggestedFileName;
|
||||
|
||||
// Some URIs do not implement nsIURL, so we can't just QI.
|
||||
var url = this.mLauncher.source.clone();
|
||||
try {
|
||||
url.userPass = "";
|
||||
} catch (ex) {}
|
||||
var fname = "";
|
||||
this.mSourcePath = url.prePath;
|
||||
try {
|
||||
url = url.QueryInterface( Components.interfaces.nsIURL );
|
||||
// A url, use file name from it.
|
||||
fname = url.fileName;
|
||||
this.mSourcePath += url.directory;
|
||||
} catch (ex) {
|
||||
// A generic uri, use path.
|
||||
fname = url.path;
|
||||
this.mSourcePath += url.path;
|
||||
}
|
||||
|
||||
if (suggestedFileName)
|
||||
fname = suggestedFileName;
|
||||
|
||||
this.mTitle = this.replaceInsert( this.mDialog.document.title, 1, fname);
|
||||
this.mDialog.document.title = this.mTitle;
|
||||
|
||||
// Put content type, filename and location into intro.
|
||||
this.initIntro(url, fname);
|
||||
|
||||
var iconString = "moz-icon://" + fname + "?size=32&contentType=" + this.mLauncher.MIMEInfo.MIMEType;
|
||||
|
||||
this.dialogElement("contentTypeImage").setAttribute("src", iconString);
|
||||
|
||||
this.initAppAndSaveToDiskValues();
|
||||
|
||||
// Initialize "always ask me" box. This should always be disabled
|
||||
// and set to true for the ambiguous type application/octet-stream.
|
||||
// Same if this dialog was forced due to a server request or type
|
||||
// sniffing
|
||||
var alwaysHandleCheckbox = this.dialogElement( "alwaysHandle" );
|
||||
if (this.mReason != REASON_CANTHANDLE ||
|
||||
this.mLauncher.MIMEInfo.MIMEType == "application/octet-stream"){
|
||||
alwaysHandleCheckbox.checked = false;
|
||||
alwaysHandleCheckbox.disabled = true;
|
||||
}
|
||||
else {
|
||||
alwaysHandleCheckbox.checked = !this.mLauncher.MIMEInfo.alwaysAskBeforeHandling;
|
||||
}
|
||||
|
||||
// Position it.
|
||||
if ( this.mDialog.opener ) {
|
||||
this.mDialog.moveToAlertPosition();
|
||||
} else {
|
||||
this.mDialog.sizeToContent();
|
||||
this.mDialog.centerWindowOnScreen();
|
||||
}
|
||||
|
||||
// Set initial focus
|
||||
this.dialogElement( "mode" ).focus();
|
||||
|
||||
this.mDialog.document.documentElement.getButton("accept").disabled = true;
|
||||
const nsITimer = Components.interfaces.nsITimer;
|
||||
this._timer = Components.classes["@mozilla.org/timer;1"]
|
||||
.createInstance(nsITimer);
|
||||
this._timer.initWithCallback(this, 250, nsITimer.TYPE_ONE_SHOT);
|
||||
},
|
||||
|
||||
// initIntro:
|
||||
initIntro: function(url, filename) {
|
||||
var intro = this.dialogElement( "intro" );
|
||||
var desc = this.mLauncher.MIMEInfo.description;
|
||||
|
||||
var text;
|
||||
if ( this.mReason == REASON_CANTHANDLE )
|
||||
text = "intro.";
|
||||
else if (this.mReason == REASON_SERVERREQUEST )
|
||||
text = "intro.attachment.";
|
||||
else if (this.mReason == REASON_TYPESNIFFED )
|
||||
text = "intro.sniffed.";
|
||||
|
||||
var modified;
|
||||
if (desc)
|
||||
modified = this.replaceInsert( this.getString( text + "label" ), 1, desc );
|
||||
else
|
||||
modified = this.getString( text + "noDesc.label" );
|
||||
|
||||
modified = this.replaceInsert( modified, 2, this.mLauncher.MIMEInfo.MIMEType );
|
||||
modified = this.replaceInsert( modified, 3, filename);
|
||||
modified = this.replaceInsert( modified, 4, this.getString( "brandShortName" ));
|
||||
|
||||
// if mSourcePath is a local file, then let's use the pretty path name instead of an ugly
|
||||
// url...
|
||||
var pathString = url.prePath;
|
||||
try
|
||||
{
|
||||
var fileURL = url.QueryInterface(Components.interfaces.nsIFileURL);
|
||||
if (fileURL)
|
||||
{
|
||||
var fileObject = fileURL.file;
|
||||
if (fileObject)
|
||||
{
|
||||
var parentObject = fileObject.parent;
|
||||
if (parentObject)
|
||||
{
|
||||
pathString = parentObject.path;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(ex) {}
|
||||
|
||||
|
||||
intro.firstChild.nodeValue = "";
|
||||
intro.firstChild.nodeValue = modified;
|
||||
|
||||
// Set the location text, which is separate from the intro text so it can be cropped
|
||||
var location = this.dialogElement( "location" );
|
||||
location.value = pathString;
|
||||
location.setAttribute( "tooltiptext", this.mSourcePath );
|
||||
},
|
||||
|
||||
_timer: null,
|
||||
notify: function (aTimer) {
|
||||
try { // The user may have already canceled the dialog.
|
||||
if (!this._blurred)
|
||||
this.mDialog.document.documentElement.getButton('accept').disabled = false;
|
||||
} catch (ex) {}
|
||||
this._timer = null;
|
||||
},
|
||||
|
||||
_blurred: false,
|
||||
onBlur: function(aEvent) {
|
||||
if (aEvent.target != this.mDialog.document)
|
||||
return;
|
||||
|
||||
this._blurred = true;
|
||||
this.mDialog.document.documentElement.getButton("accept").disabled = true;
|
||||
},
|
||||
|
||||
onFocus: function(aEvent) {
|
||||
if (aEvent.target != this.mDialog.document)
|
||||
return;
|
||||
|
||||
this._blurred = false;
|
||||
if (!this._timer) {
|
||||
// Don't enable the button if the initial timer is running
|
||||
var script = "document.documentElement.getButton('accept').disabled = false";
|
||||
this.mDialog.setTimeout(script, 250);
|
||||
}
|
||||
},
|
||||
|
||||
// Returns true iff opening the default application makes sense.
|
||||
openWithDefaultOK: function() {
|
||||
var result;
|
||||
|
||||
// The checking is different on Windows...
|
||||
if ( this.mDialog.navigator.platform.indexOf( "Win" ) != -1 ) {
|
||||
// Windows presents some special cases.
|
||||
// We need to prevent use of "system default" when the file is
|
||||
// executable (so the user doesn't launch nasty programs downloaded
|
||||
// from the web), and, enable use of "system default" if it isn't
|
||||
// executable (because we will prompt the user for the default app
|
||||
// in that case).
|
||||
|
||||
// Need to get temporary file and check for executable-ness.
|
||||
var tmpFile = this.mLauncher.targetFile;
|
||||
|
||||
// Default is Ok if the file isn't executable (and vice-versa).
|
||||
result = !tmpFile.isExecutable();
|
||||
} else {
|
||||
// On other platforms, default is Ok if there is a default app.
|
||||
// Note that nsIMIMEInfo providers need to ensure that this holds true
|
||||
// on each platform.
|
||||
result = this.mLauncher.MIMEInfo.hasDefaultHandler;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
// Set "default" application description field.
|
||||
initDefaultApp: function() {
|
||||
// Use description, if we can get one.
|
||||
var desc = this.mLauncher.MIMEInfo.defaultDescription;
|
||||
if ( desc ) {
|
||||
this.dialogElement( "useSystemDefault" ).label = this.replaceInsert( this.getString( "defaultApp" ), 1, desc );
|
||||
}
|
||||
},
|
||||
|
||||
// getPath:
|
||||
getPath: function(file) {
|
||||
if (this.mIsMac) {
|
||||
return file.leafName || file.path;
|
||||
}
|
||||
|
||||
return file.path;
|
||||
},
|
||||
|
||||
// initAppAndSaveToDiskValues:
|
||||
initAppAndSaveToDiskValues: function() {
|
||||
// Fill in helper app info, if there is any.
|
||||
try {
|
||||
this.chosenApp =
|
||||
this.mLauncher.MIMEInfo.preferredApplicationHandler
|
||||
.QueryInterface(Components.interfaces.nsILocalHandlerApp);
|
||||
} catch (e) {
|
||||
this.chosenApp = null;
|
||||
}
|
||||
// Initialize "default application" field.
|
||||
this.initDefaultApp();
|
||||
|
||||
// Fill application name textbox.
|
||||
if (this.chosenApp && this.chosenApp.executable &&
|
||||
this.chosenApp.executable.path) {
|
||||
this.dialogElement( "appPath" ).value =
|
||||
this.getPath(this.chosenApp.executable);
|
||||
}
|
||||
|
||||
var useDefault = this.dialogElement( "useSystemDefault" );
|
||||
if (this.mLauncher.MIMEInfo.preferredAction == this.nsIMIMEInfo.useSystemDefault &&
|
||||
this.mReason != REASON_SERVERREQUEST) {
|
||||
// Open (using system default).
|
||||
useDefault.radioGroup.selectedItem = useDefault;
|
||||
} else if (this.mLauncher.MIMEInfo.preferredAction == this.nsIMIMEInfo.useHelperApp &&
|
||||
this.mReason != REASON_SERVERREQUEST) {
|
||||
// Open with given helper app.
|
||||
var openUsing = this.dialogElement( "openUsing" );
|
||||
openUsing.radioGroup.selectedItem = openUsing;
|
||||
} else {
|
||||
// Save to disk.
|
||||
var saveToDisk = this.dialogElement( "saveToDisk" );
|
||||
saveToDisk.radioGroup.selectedItem = saveToDisk;
|
||||
}
|
||||
// If we don't have a "default app" then disable that choice.
|
||||
if ( !this.openWithDefaultOK() ) {
|
||||
// Disable that choice.
|
||||
useDefault.hidden = true;
|
||||
// If that's the default, then switch to "save to disk."
|
||||
if ( useDefault.selected ) {
|
||||
useDefault.radioGroup.selectedItem = this.dialogElement( "saveToDisk" );
|
||||
}
|
||||
}
|
||||
|
||||
// Enable/Disable choose application button and textfield
|
||||
this.toggleChoice();
|
||||
},
|
||||
|
||||
// Enable pick app button if the user chooses that option.
|
||||
toggleChoice : function () {
|
||||
// See what option is selected.
|
||||
var openUsing = this.dialogElement( "openUsing" ).selected;
|
||||
this.dialogElement( "chooseApp" ).disabled = !openUsing;
|
||||
// appPath is always disabled on Mac
|
||||
this.dialogElement( "appPath" ).disabled = !openUsing || this.mIsMac;
|
||||
this.updateOKButton();
|
||||
},
|
||||
|
||||
// Returns the user-selected application
|
||||
helperAppChoice: function() {
|
||||
var result = this.chosenApp;
|
||||
if (!this.mIsMac) {
|
||||
var typed = this.dialogElement( "appPath" ).value;
|
||||
// First, see if one was chosen via the Choose... button.
|
||||
if ( result ) {
|
||||
// Verify that the user didn't type in something different later.
|
||||
if ( typed != result.executable.path ) {
|
||||
// Use what was typed in.
|
||||
try {
|
||||
result.executable.QueryInterface( Components.interfaces.nsILocalFile ).initWithPath( typed );
|
||||
} catch( e ) {
|
||||
// Invalid path was typed.
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// The user didn't use the Choose... button, try using what they typed in.
|
||||
var localFile = Components.classes[ "@mozilla.org/file/local;1" ]
|
||||
.createInstance( Components.interfaces.nsILocalFile );
|
||||
try {
|
||||
localFile.initWithPath( typed );
|
||||
result = Components.classes[
|
||||
"@mozilla.org/uriloader/local-handler-app;1"].
|
||||
createInstance(Components.interfaces.nsILocalHandlerApp);
|
||||
result.executable = localFile;
|
||||
|
||||
} catch( e ) {
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
// Remember what was chosen.
|
||||
this.chosenApp = result;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
updateOKButton: function() {
|
||||
var ok = false;
|
||||
if ( this.dialogElement( "saveToDisk" ).selected )
|
||||
{
|
||||
// This is always OK.
|
||||
ok = true;
|
||||
}
|
||||
else if ( this.dialogElement( "useSystemDefault" ).selected )
|
||||
{
|
||||
// No app need be specified in this case.
|
||||
ok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// only enable the OK button if we have a default app to use or if
|
||||
// the user chose an app....
|
||||
ok = this.chosenApp || /\S/.test( this.dialogElement( "appPath" ).value );
|
||||
}
|
||||
|
||||
// Enable Ok button if ok to press.
|
||||
this.mDialog.document.documentElement.getButton( "accept" ).disabled = !ok;
|
||||
},
|
||||
|
||||
// Returns true iff the user-specified helper app has been modified.
|
||||
appChanged: function() {
|
||||
return this.helperAppChoice() != this.mLauncher.MIMEInfo.preferredApplicationHandler;
|
||||
},
|
||||
|
||||
updateMIMEInfo: function() {
|
||||
var needUpdate = false;
|
||||
// If current selection differs from what's in the mime info object,
|
||||
// then we need to update.
|
||||
// However, we don't want to change the action all nsIMIMEInfo objects to
|
||||
// saveToDisk if mReason is REASON_SERVERREQUEST.
|
||||
if ( this.dialogElement( "saveToDisk" ).selected &&
|
||||
this.mReason != REASON_SERVERREQUEST ) {
|
||||
needUpdate = this.mLauncher.MIMEInfo.preferredAction != this.nsIMIMEInfo.saveToDisk;
|
||||
if ( needUpdate )
|
||||
this.mLauncher.MIMEInfo.preferredAction = this.nsIMIMEInfo.saveToDisk;
|
||||
} else if ( this.dialogElement( "useSystemDefault" ).selected ) {
|
||||
needUpdate = this.mLauncher.MIMEInfo.preferredAction != this.nsIMIMEInfo.useSystemDefault;
|
||||
if ( needUpdate )
|
||||
this.mLauncher.MIMEInfo.preferredAction = this.nsIMIMEInfo.useSystemDefault;
|
||||
} else if ( this.dialogElement( "openUsing" ).selected ) {
|
||||
// For "open with", we need to check both preferred action and whether the user chose
|
||||
// a new app.
|
||||
needUpdate = this.mLauncher.MIMEInfo.preferredAction != this.nsIMIMEInfo.useHelperApp || this.appChanged();
|
||||
if ( needUpdate ) {
|
||||
this.mLauncher.MIMEInfo.preferredAction = this.nsIMIMEInfo.useHelperApp;
|
||||
// App may have changed - Update application
|
||||
var app = this.helperAppChoice();
|
||||
this.mLauncher.MIMEInfo.preferredApplicationHandler = app;
|
||||
}
|
||||
}
|
||||
// Only care about the state of "always ask" if this dialog wasn't forced
|
||||
if ( this.mReason == REASON_CANTHANDLE )
|
||||
{
|
||||
// We will also need to update if the "always ask" flag has changed.
|
||||
needUpdate = needUpdate || this.mLauncher.MIMEInfo.alwaysAskBeforeHandling == this.dialogElement( "alwaysHandle" ).checked;
|
||||
|
||||
// One last special case: If the input "always ask" flag was false, then we always
|
||||
// update. In that case we are displaying the helper app dialog for the first
|
||||
// time for this mime type and we need to store the user's action in the mimeTypes.rdf
|
||||
// data source (whether that action has changed or not; if it didn't change, then we need
|
||||
// to store the "always ask" flag so the helper app dialog will or won't display
|
||||
// next time, per the user's selection).
|
||||
needUpdate = needUpdate || !this.mLauncher.MIMEInfo.alwaysAskBeforeHandling;
|
||||
|
||||
// Make sure mime info has updated setting for the "always ask" flag.
|
||||
this.mLauncher.MIMEInfo.alwaysAskBeforeHandling = !this.dialogElement( "alwaysHandle" ).checked;
|
||||
}
|
||||
|
||||
return needUpdate;
|
||||
},
|
||||
|
||||
// See if the user changed things, and if so, update the
|
||||
// mimeTypes.rdf entry for this mime type.
|
||||
updateHelperAppPref: function() {
|
||||
// We update by passing this mime info into the "Edit Type" helper app
|
||||
// pref dialog. It will update the data source and close the dialog
|
||||
// automatically.
|
||||
this.mDialog.openDialog( "chrome://communicator/content/pref/pref-applications-edit.xul",
|
||||
"_blank",
|
||||
"chrome,modal=yes,resizable=no",
|
||||
this );
|
||||
},
|
||||
|
||||
// onOK:
|
||||
onOK: function() {
|
||||
// Verify typed app path, if necessary.
|
||||
if ( this.dialogElement( "openUsing" ).selected ) {
|
||||
var helperApp = this.helperAppChoice();
|
||||
if ( !helperApp || !helperApp.executable ||
|
||||
!helperApp.executable.exists() ) {
|
||||
// Show alert and try again.
|
||||
var msg = this.replaceInsert( this.getString( "badApp" ), 1, this.dialogElement( "appPath" ).value );
|
||||
var svc = Components.classes[ "@mozilla.org/embedcomp/prompt-service;1" ]
|
||||
.getService( Components.interfaces.nsIPromptService );
|
||||
svc.alert( this.mDialog, this.getString( "badApp.title" ), msg );
|
||||
// Disable the OK button.
|
||||
this.mDialog.document.documentElement.getButton( "accept" ).disabled = true;
|
||||
// Select and focus the input field if input field is not disabled
|
||||
var path = this.dialogElement( "appPath" );
|
||||
if ( !path.disabled ) {
|
||||
path.select();
|
||||
path.focus();
|
||||
}
|
||||
// Clear chosen application.
|
||||
this.chosenApp = null;
|
||||
// Leave dialog up.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove our web progress listener (a progress dialog will be
|
||||
// taking over).
|
||||
this.mLauncher.setWebProgressListener( null );
|
||||
|
||||
// saveToDisk and launchWithApplication can return errors in
|
||||
// certain circumstances (e.g. The user clicks cancel in the
|
||||
// "Save to Disk" dialog. In those cases, we don't want to
|
||||
// update the helper application preferences in the RDF file.
|
||||
try {
|
||||
var needUpdate = this.updateMIMEInfo();
|
||||
if ( this.dialogElement( "saveToDisk" ).selected )
|
||||
this.mLauncher.saveToDisk( null, false );
|
||||
else
|
||||
this.mLauncher.launchWithApplication( null, false );
|
||||
|
||||
// Update user pref for this mime type (if necessary). We do not
|
||||
// store anything in the mime type preferences for the ambiguous
|
||||
// type application/octet-stream.
|
||||
if ( needUpdate &&
|
||||
this.mLauncher.MIMEInfo.MIMEType != "application/octet-stream" )
|
||||
{
|
||||
this.updateHelperAppPref();
|
||||
}
|
||||
|
||||
} catch(e) { }
|
||||
|
||||
// Unhook dialog from this object.
|
||||
this.mDialog.dialog = null;
|
||||
|
||||
// Close up dialog by returning true.
|
||||
return true;
|
||||
},
|
||||
|
||||
// onCancel:
|
||||
onCancel: function() {
|
||||
// Remove our web progress listener.
|
||||
this.mLauncher.setWebProgressListener( null );
|
||||
|
||||
// Cancel app launcher.
|
||||
try {
|
||||
const NS_BINDING_ABORTED = 0x804b0002;
|
||||
this.mLauncher.cancel(NS_BINDING_ABORTED);
|
||||
} catch( exception ) {
|
||||
}
|
||||
|
||||
// Unhook dialog from this object.
|
||||
this.mDialog.dialog = null;
|
||||
|
||||
// Close up dialog by returning true.
|
||||
return true;
|
||||
},
|
||||
|
||||
// dialogElement: Try cache; obtain from document if not there.
|
||||
dialogElement: function( id ) {
|
||||
// Check if we've already fetched it.
|
||||
if ( !( id in this.elements ) ) {
|
||||
// No, then get it from dialog.
|
||||
this.elements[ id ] = this.mDialog.document.getElementById( id );
|
||||
}
|
||||
return this.elements[ id ];
|
||||
},
|
||||
|
||||
// chooseApp: Open file picker and prompt user for application.
|
||||
chooseApp: function() {
|
||||
var nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance( nsIFilePicker );
|
||||
fp.init( this.mDialog,
|
||||
this.getString( "chooseAppFilePickerTitle" ),
|
||||
nsIFilePicker.modeOpen );
|
||||
|
||||
// XXX - We want to say nsIFilePicker.filterExecutable or something
|
||||
fp.appendFilters( nsIFilePicker.filterAll );
|
||||
|
||||
if ( fp.show() == nsIFilePicker.returnOK && fp.file ) {
|
||||
// Remember the file they chose to run.
|
||||
|
||||
var localHandler = Components.classes[
|
||||
"@mozilla.org/uriloader/local-handler-app;1"].
|
||||
createInstance(Components.interfaces.nsILocalHandlerApp);
|
||||
localHandler.executable = fp.file;
|
||||
this.chosenApp = localHandler;
|
||||
// Update dialog.
|
||||
this.dialogElement( "appPath" ).value =
|
||||
this.getPath(this.chosenApp.executable);
|
||||
}
|
||||
},
|
||||
|
||||
// dumpInfo:
|
||||
doDebug: function() {
|
||||
const nsIProgressDialog = Components.interfaces.nsIProgressDialog;
|
||||
// Open new progress dialog.
|
||||
var progress = Components.classes[ "@mozilla.org/progressdialog;1" ]
|
||||
.createInstance( nsIProgressDialog );
|
||||
// Show it.
|
||||
progress.open( this.mDialog );
|
||||
},
|
||||
|
||||
// dumpObj:
|
||||
dumpObj: function( spec ) {
|
||||
var val = "<undefined>";
|
||||
try {
|
||||
val = eval( "this."+spec ).toString();
|
||||
} catch( exception ) {
|
||||
}
|
||||
this.dump( spec + "=" + val + "\n" );
|
||||
},
|
||||
|
||||
// dumpObjectProperties
|
||||
dumpObjectProperties: function( desc, obj ) {
|
||||
for( prop in obj ) {
|
||||
this.dump( desc + "." + prop + "=" );
|
||||
var val = "<undefined>";
|
||||
try {
|
||||
val = obj[ prop ];
|
||||
} catch ( exception ) {
|
||||
}
|
||||
this.dump( val + "\n" );
|
||||
}
|
||||
},
|
||||
|
||||
// getString: Fetch data string from dialog content (and cache it).
|
||||
getString: function( id ) {
|
||||
// Check if we've fetched this string already.
|
||||
if ( !( id in this.strings ) ) {
|
||||
// Try to get it.
|
||||
var elem = this.mDialog.document.getElementById( id );
|
||||
if ( elem
|
||||
&&
|
||||
elem.firstChild
|
||||
&&
|
||||
elem.firstChild.nodeValue ) {
|
||||
this.strings[ id ] = elem.firstChild.nodeValue;
|
||||
} else {
|
||||
// If unable to fetch string, use an empty string.
|
||||
this.strings[ id ] = "";
|
||||
}
|
||||
}
|
||||
return this.strings[ id ];
|
||||
},
|
||||
|
||||
// replaceInsert: Replace given insert with replacement text and return the result.
|
||||
replaceInsert: function( text, insertNo, replacementText ) {
|
||||
var result = text;
|
||||
var regExp = new RegExp("#"+insertNo);
|
||||
result = result.replace( regExp, replacementText );
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// This Component's module implementation. All the code below is used to get this
|
||||
// component registered and accessible via XPCOM.
|
||||
var module = {
|
||||
firstTime: true,
|
||||
|
||||
// registerSelf: Register this component.
|
||||
registerSelf: function (compMgr, fileSpec, location, type) {
|
||||
if (this.firstTime) {
|
||||
this.firstTime = false;
|
||||
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
|
||||
}
|
||||
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
||||
|
||||
compMgr.registerFactoryLocation( this.cid,
|
||||
"Mozilla Helper App Launcher Dialog",
|
||||
this.contractId,
|
||||
fileSpec,
|
||||
location,
|
||||
type );
|
||||
},
|
||||
|
||||
// getClassObject: Return this component's factory object.
|
||||
getClassObject: function (compMgr, cid, iid) {
|
||||
if (!cid.equals(this.cid)) {
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
if (!iid.equals(Components.interfaces.nsIFactory)) {
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return this.factory;
|
||||
},
|
||||
|
||||
/* CID for this class */
|
||||
cid: Components.ID("{F68578EB-6EC2-4169-AE19-8C6243F0ABE1}"),
|
||||
|
||||
/* Contract ID for this class */
|
||||
contractId: "@mozilla.org/helperapplauncherdialog;1",
|
||||
|
||||
/* factory object */
|
||||
factory: {
|
||||
// createInstance: Return a new nsProgressDialog object.
|
||||
createInstance: function (outer, iid) {
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
return (new nsHelperAppDialog()).QueryInterface(iid);
|
||||
}
|
||||
},
|
||||
|
||||
// canUnload: n/a (returns true)
|
||||
canUnload: function(compMgr) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// NSGetModule: Return the nsIModule object.
|
||||
function NSGetModule(compMgr, fileSpec) {
|
||||
return module;
|
||||
}
|
||||
|
||||
// Since we're automatically downloading, we don't get the file picker's
|
||||
// logic to check for existing files, so we need to do that here.
|
||||
//
|
||||
// Note - this code is identical to that in contentAreaUtils.js.
|
||||
// If you are updating this code, update that code too! We can't share code
|
||||
// here since this is called in a js component.
|
||||
function uniqueFile(aLocalFile) {
|
||||
while (aLocalFile.exists()) {
|
||||
parts = /(-\d+)?(\.[^.]+)?$/.test(aLocalFile.leafName);
|
||||
aLocalFile.leafName = RegExp.leftContext + (RegExp.$1 - 1) + RegExp.$2;
|
||||
}
|
||||
return aLocalFile;
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- ***** 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 Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Netscape Communications Corporation.
|
||||
Portions created by the Initial Developer are Copyright (C) 1998-1999
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Bill Law <law@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 ***** -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
|
||||
<!DOCTYPE dialog [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
|
||||
%brandDTD;
|
||||
<!ENTITY % nsHelperAppDlgDTD SYSTEM "chrome://global/locale/nsHelperAppDlg.dtd" >
|
||||
%nsHelperAppDlgDTD;
|
||||
]>
|
||||
|
||||
<dialog id="nsHelperAppDlg"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&caption.label;"
|
||||
onload="dialog.initDialog()"
|
||||
onblur="dialog.onBlur(event);"
|
||||
onfocus="dialog.onFocus(event);"
|
||||
onunload="if (dialog) dialog.onCancel()"
|
||||
style="width: 40em;"
|
||||
ondialogaccept="return dialog.onOK()"
|
||||
ondialogcancel="return dialog.onCancel()">
|
||||
|
||||
<vbox>
|
||||
<hbox>
|
||||
<vbox flex="1">
|
||||
<description id="intro">&intro.label;</description>
|
||||
<description id="location" dir="ltr" crop="start" value=""/>
|
||||
<separator orient="horizontal" class="thin"/>
|
||||
<description id="prompt">&prompt.label;</description>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<image id="contentTypeImage"/>
|
||||
</vbox>
|
||||
</hbox>
|
||||
|
||||
<separator orient="horizontal" class="thin"/>
|
||||
|
||||
<radiogroup id="mode" oncommand="dialog.toggleChoice()" align="stretch">
|
||||
<hbox>
|
||||
<radio id="useSystemDefault"
|
||||
label="&useSystemDefault.noDesc.label;"
|
||||
accesskey="&useSystemDefault.accesskey;"/>
|
||||
</hbox>
|
||||
<hbox align="center">
|
||||
<radio id="openUsing"
|
||||
label="&openUsing.label;"
|
||||
accesskey="&openUsing.accesskey;"/>
|
||||
<textbox id="appPath"
|
||||
flex="1"
|
||||
oninput="dialog.updateOKButton()"
|
||||
onfocus="this.select()"/>
|
||||
<button id="chooseApp"
|
||||
label="&chooseApp.label;"
|
||||
accesskey="&chooseApp.accesskey;"
|
||||
oncommand="dialog.chooseApp()"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<radio id="saveToDisk"
|
||||
label="&saveToDisk.label;"
|
||||
accesskey="&saveToDisk.accesskey;"/>
|
||||
</hbox>
|
||||
</radiogroup>
|
||||
|
||||
<separator orient="horizontal" class="thin"/>
|
||||
|
||||
<checkbox id="alwaysHandle" label="&alwaysHandle.label;" accesskey="&alwaysHandle.accesskey;"/>
|
||||
|
||||
<separator class="groove"/>
|
||||
</vbox>
|
||||
|
||||
<!-- Localizable strings (from .dtd) -->
|
||||
<strings style="display:none;">
|
||||
<string id="brandShortName"> &brandShortName; </string>
|
||||
<string id="intro.label"> &intro.label; </string>
|
||||
<string id="intro.noDesc.label"> &intro.noDesc.label; </string>
|
||||
<string id="intro.attachment.label"> &intro.attachment.label; </string>
|
||||
<string id="intro.attachment.noDesc.label">&intro.attachment.noDesc.label;</string>
|
||||
<string id="intro.sniffed.label"> &intro.sniffed.label; </string>
|
||||
<string id="intro.sniffed.noDesc.label"> &intro.sniffed.noDesc.label; </string>
|
||||
<string id="defaultApp"> &useSystemDefault.label; </string>
|
||||
<string id="badApp"> &badApp; </string>
|
||||
<string id="badApp.title"> &badApp.title; </string>
|
||||
<string id="chooseAppFilePickerTitle"> &chooseAppFilePickerTitle; </string>
|
||||
</strings>
|
||||
</dialog>
|
|
@ -1,3 +0,0 @@
|
|||
toolkit.jar:
|
||||
content/global/nsHelperAppDlg.xul (helperAppDlg/nsHelperAppDlg.xul)
|
||||
content/global/nsProgressDialog.xul (progressDlg/nsProgressDialog.xul)
|
|
@ -1,51 +0,0 @@
|
|||
#
|
||||
# ***** 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, Inc.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# 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 *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = progressDlg
|
||||
XPIDL_MODULE = progressDlg
|
||||
|
||||
EXTRA_COMPONENTS = nsProgressDialog.js
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -1,944 +0,0 @@
|
|||
/* vim:set ts=4 sts=4 sw=4 et cin: */
|
||||
/* ***** 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 Progress Dialog.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Bill Law <law@netscape.com>
|
||||
* Aaron Kaluszka <ask@swva.net>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
/* This file implements the nsIProgressDialog interface. See nsIProgressDialog.idl
|
||||
*
|
||||
* The implementation consists of a JavaScript "class" named nsProgressDialog,
|
||||
* comprised of:
|
||||
* - a JS constructor function
|
||||
* - a prototype providing all the interface methods and implementation stuff
|
||||
*
|
||||
* In addition, this file implements an nsIModule object that registers the
|
||||
* nsProgressDialog component.
|
||||
*/
|
||||
|
||||
/* ctor
|
||||
*/
|
||||
function nsProgressDialog() {
|
||||
// Initialize data properties.
|
||||
this.mParent = null;
|
||||
this.mOperation = null;
|
||||
this.mStartTime = ( new Date() ).getTime();
|
||||
this.observer = null;
|
||||
this.mLastUpdate = Number.MIN_VALUE; // To ensure first onProgress causes update.
|
||||
this.mInterval = 750; // Default to .75 seconds.
|
||||
this.mElapsed = 0;
|
||||
this.mLoaded = false;
|
||||
this.fields = new Array;
|
||||
this.strings = new Array;
|
||||
this.mSource = null;
|
||||
this.mTarget = null;
|
||||
this.mTargetFile = null;
|
||||
this.mMIMEInfo = null;
|
||||
this.mDialog = null;
|
||||
this.mDisplayName = null;
|
||||
this.mPaused = false;
|
||||
this.mRequest = null;
|
||||
this.mCompleted = false;
|
||||
this.mMode = "normal";
|
||||
this.mPercent = -1;
|
||||
this.mRate = 0;
|
||||
this.mBundle = null;
|
||||
this.mCancelDownloadOnClose = true;
|
||||
}
|
||||
|
||||
const nsIProgressDialog = Components.interfaces.nsIProgressDialog;
|
||||
const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher;
|
||||
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
||||
const nsITextToSubURI = Components.interfaces.nsITextToSubURI;
|
||||
const nsIChannel = Components.interfaces.nsIChannel;
|
||||
const nsIFileURL = Components.interfaces.nsIFileURL;
|
||||
const nsIURL = Components.interfaces.nsIURL;
|
||||
const nsILocalFile = Components.interfaces.nsILocalFile;
|
||||
|
||||
nsProgressDialog.prototype = {
|
||||
// Turn this on to get debugging messages.
|
||||
debug: false,
|
||||
|
||||
// Chrome-related constants.
|
||||
dialogChrome: "chrome://global/content/nsProgressDialog.xul",
|
||||
dialogFeatures: "chrome,titlebar,minimizable=yes,dialog=no",
|
||||
|
||||
// getters/setters
|
||||
get saving() { return this.MIMEInfo == null ||
|
||||
this.MIMEInfo.preferredAction == Components.interfaces.nsIMIMEInfo.saveToDisk; },
|
||||
get parent() { return this.mParent; },
|
||||
set parent(newval) { return this.mParent = newval; },
|
||||
get operation() { return this.mOperation; },
|
||||
set operation(newval) { return this.mOperation = newval; },
|
||||
get observer() { return this.mObserver; },
|
||||
set observer(newval) { return this.mObserver = newval; },
|
||||
get startTime() { return this.mStartTime; },
|
||||
set startTime(newval) { return this.mStartTime = newval/1000; }, // PR_Now() is in microseconds, so we convert.
|
||||
get lastUpdate() { return this.mLastUpdate; },
|
||||
set lastUpdate(newval) { return this.mLastUpdate = newval; },
|
||||
get interval() { return this.mInterval; },
|
||||
set interval(newval) { return this.mInterval = newval; },
|
||||
get elapsed() { return this.mElapsed; },
|
||||
set elapsed(newval) { return this.mElapsed = newval; },
|
||||
get loaded() { return this.mLoaded; },
|
||||
set loaded(newval) { return this.mLoaded = newval; },
|
||||
get source() { return this.mSource; },
|
||||
set source(newval) { return this.mSource = newval; },
|
||||
get target() { return this.mTarget; },
|
||||
get targetFile() { return this.mTargetFile; },
|
||||
get MIMEInfo() { return this.mMIMEInfo; },
|
||||
set MIMEInfo(newval) { return this.mMIMEInfo = newval; },
|
||||
get dialog() { return this.mDialog; },
|
||||
set dialog(newval) { return this.mDialog = newval; },
|
||||
get displayName() { return this.mDisplayName; },
|
||||
set displayName(newval) { return this.mDisplayName = newval; },
|
||||
get paused() { return this.mPaused; },
|
||||
get completed() { return this.mCompleted; },
|
||||
get mode() { return this.mMode; },
|
||||
get percent() { return this.mPercent; },
|
||||
get rate() { return this.mRate; },
|
||||
get kRate() { return this.mRate / 1024; },
|
||||
get cancelDownloadOnClose() { return this.mCancelDownloadOnClose; },
|
||||
set cancelDownloadOnClose(newval) { return this.mCancelDownloadOnClose = newval; },
|
||||
|
||||
set target(newval) {
|
||||
// If newval references a file on the local filesystem, then grab a
|
||||
// reference to its corresponding nsIFile.
|
||||
if (newval instanceof nsIFileURL && newval.file instanceof nsILocalFile) {
|
||||
this.mTargetFile = newval.file.QueryInterface(nsILocalFile);
|
||||
} else {
|
||||
this.mTargetFile = null;
|
||||
}
|
||||
|
||||
return this.mTarget = newval;
|
||||
},
|
||||
|
||||
// These setters use functions that update the dialog.
|
||||
set paused(newval) { return this.setPaused(newval); },
|
||||
set completed(newval) { return this.setCompleted(newval); },
|
||||
set mode(newval) { return this.setMode(newval); },
|
||||
set percent(newval) { return this.setPercent(newval); },
|
||||
set rate(newval) { return this.setRate(newval); },
|
||||
|
||||
// ---------- nsIProgressDialog methods ----------
|
||||
|
||||
// open: Store aParentWindow and open the dialog.
|
||||
open: function( aParentWindow ) {
|
||||
// Save parent and "persist" operation.
|
||||
this.parent = aParentWindow;
|
||||
|
||||
// Open dialog using the WindowWatcher service.
|
||||
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
||||
.getService( nsIWindowWatcher );
|
||||
this.dialog = ww.openWindow( this.parent,
|
||||
this.dialogChrome,
|
||||
null,
|
||||
this.dialogFeatures,
|
||||
this );
|
||||
},
|
||||
|
||||
init: function( aSource, aTarget, aDisplayName, aMIMEInfo, aStartTime,
|
||||
aTempFile, aOperation ) {
|
||||
this.source = aSource;
|
||||
this.target = aTarget;
|
||||
this.displayName = aDisplayName;
|
||||
this.MIMEInfo = aMIMEInfo;
|
||||
if ( aStartTime ) {
|
||||
this.startTime = aStartTime;
|
||||
}
|
||||
this.operation = aOperation;
|
||||
},
|
||||
|
||||
// ----- nsIDownloadProgressListener/nsIWebProgressListener methods -----
|
||||
// Take advantage of javascript's function overloading feature to combine
|
||||
// similiar nsIDownloadProgressListener and nsIWebProgressListener methods
|
||||
// in one. For nsIWebProgressListener calls, the aDownload paramater will
|
||||
// always be undefined.
|
||||
|
||||
// Look for STATE_STOP and update dialog to indicate completion when it happens.
|
||||
onStateChange: function( aWebProgress, aRequest, aStateFlags, aStatus, aDownload ) {
|
||||
if ( aStateFlags & nsIWebProgressListener.STATE_STOP ) {
|
||||
// if we are downloading, then just wait for the first STATE_STOP
|
||||
if ( this.targetFile != null ) {
|
||||
// we are done transferring...
|
||||
this.completed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise, wait for STATE_STOP with aRequest corresponding to
|
||||
// our target. XXX redirects might screw up this logic.
|
||||
try {
|
||||
var chan = aRequest.QueryInterface(nsIChannel);
|
||||
if (chan.URI.equals(this.target)) {
|
||||
// we are done transferring...
|
||||
this.completed = true;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Handle progress notifications.
|
||||
onProgressChange: function( aWebProgress,
|
||||
aRequest,
|
||||
aCurSelfProgress,
|
||||
aMaxSelfProgress,
|
||||
aCurTotalProgress,
|
||||
aMaxTotalProgress,
|
||||
aDownload ) {
|
||||
return this.onProgressChange64(aWebProgress, aRequest, aCurSelfProgress,
|
||||
aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress, aDownload);
|
||||
},
|
||||
|
||||
onProgressChange64: function( aWebProgress,
|
||||
aRequest,
|
||||
aCurSelfProgress,
|
||||
aMaxSelfProgress,
|
||||
aCurTotalProgress,
|
||||
aMaxTotalProgress,
|
||||
aDownload ) {
|
||||
// Get current time.
|
||||
var now = ( new Date() ).getTime();
|
||||
|
||||
// If interval hasn't elapsed, ignore it.
|
||||
if ( now - this.lastUpdate < this.interval ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update this time.
|
||||
this.lastUpdate = now;
|
||||
|
||||
// Update elapsed time.
|
||||
this.elapsed = now - this.startTime;
|
||||
|
||||
// Calculate percentage.
|
||||
if ( aMaxTotalProgress > 0) {
|
||||
this.percent = Math.floor( ( aCurTotalProgress * 100.0 ) / aMaxTotalProgress );
|
||||
} else {
|
||||
this.percent = -1;
|
||||
}
|
||||
|
||||
// If dialog not loaded, then don't bother trying to update display.
|
||||
if ( !this.loaded ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update dialog's display of elapsed time.
|
||||
this.setValue( "timeElapsed", this.formatSeconds( this.elapsed / 1000 ) );
|
||||
|
||||
// Now that we've set the progress and the time, update # bytes downloaded...
|
||||
// Update status (nn KB of mm KB at xx.x KB/sec)
|
||||
var status = this.getString( "progressMsg" );
|
||||
|
||||
// Insert 1 is the number of kilobytes downloaded so far.
|
||||
status = this.replaceInsert( status, 1, parseInt( aCurTotalProgress/1024 + .5 ) );
|
||||
|
||||
// Insert 2 is the total number of kilobytes to be downloaded (if known).
|
||||
if ( aMaxTotalProgress != "-1" ) {
|
||||
status = this.replaceInsert( status, 2, parseInt( aMaxTotalProgress/1024 + .5 ) );
|
||||
} else {
|
||||
status = this.replaceInsert( status, 2, "??" );
|
||||
}
|
||||
|
||||
// Insert 3 is the download rate.
|
||||
if ( this.elapsed ) {
|
||||
// Use the download speed where available, otherwise calculate
|
||||
// rate using current progress and elapsed time.
|
||||
if ( aDownload ) {
|
||||
this.rate = aDownload.speed;
|
||||
} else {
|
||||
this.rate = ( aCurTotalProgress * 1000 ) / this.elapsed;
|
||||
}
|
||||
status = this.replaceInsert( status, 3, this.kRate.toFixed(1) );
|
||||
} else {
|
||||
// Rate not established, yet.
|
||||
status = this.replaceInsert( status, 3, "??.?" );
|
||||
}
|
||||
|
||||
// All 3 inserts are taken care of, now update status msg.
|
||||
this.setValue( "status", status );
|
||||
|
||||
// Update time remaining.
|
||||
if ( this.rate && ( aMaxTotalProgress > 0 ) ) {
|
||||
// Calculate how much time to download remaining at this rate.
|
||||
var rem = Math.round( ( aMaxTotalProgress - aCurTotalProgress ) / this.rate );
|
||||
this.setValue( "timeLeft", this.formatSeconds( rem ) );
|
||||
} else {
|
||||
// We don't know how much time remains.
|
||||
this.setValue( "timeLeft", this.getString( "unknownTime" ) );
|
||||
}
|
||||
},
|
||||
|
||||
// Look for error notifications and display alert to user.
|
||||
onStatusChange: function( aWebProgress, aRequest, aStatus, aMessage, aDownload ) {
|
||||
// Check for error condition (only if dialog is still open).
|
||||
if ( aStatus != Components.results.NS_OK ) {
|
||||
if ( this.loaded ) {
|
||||
// Get prompt service.
|
||||
var prompter = Components.classes[ "@mozilla.org/embedcomp/prompt-service;1" ]
|
||||
.getService( Components.interfaces.nsIPromptService );
|
||||
// Display error alert (using text supplied by back-end).
|
||||
var title = this.getProperty( this.saving ? "savingAlertTitle" : "openingAlertTitle",
|
||||
[ this.fileName() ],
|
||||
1 );
|
||||
prompter.alert( this.dialog, title, aMessage );
|
||||
|
||||
// Close the dialog.
|
||||
if ( !this.completed ) {
|
||||
this.onCancel();
|
||||
}
|
||||
} else {
|
||||
// Error occurred prior to onload even firing.
|
||||
// We can't handle this error until we're done loading, so
|
||||
// defer the handling of this call.
|
||||
this.dialog.setTimeout( function(obj,wp,req,stat,msg){obj.onStatusChange(wp,req,stat,msg)},
|
||||
100, this, aWebProgress, aRequest, aStatus, aMessage );
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Ignore onLocationChange and onSecurityChange notifications.
|
||||
onLocationChange: function( aWebProgress, aRequest, aLocation, aDownload ) {
|
||||
},
|
||||
|
||||
onSecurityChange: function( aWebProgress, aRequest, aState, aDownload ) {
|
||||
},
|
||||
|
||||
// ---------- nsIObserver methods ----------
|
||||
observe: function( anObject, aTopic, aData ) {
|
||||
// Something of interest occured on the dialog.
|
||||
// Dispatch to corresponding implementation method.
|
||||
switch ( aTopic ) {
|
||||
case "onload":
|
||||
this.onLoad();
|
||||
break;
|
||||
case "oncancel":
|
||||
this.onCancel();
|
||||
break;
|
||||
case "onpause":
|
||||
this.onPause();
|
||||
break;
|
||||
case "onlaunch":
|
||||
this.onLaunch();
|
||||
break;
|
||||
case "onreveal":
|
||||
this.onReveal();
|
||||
break;
|
||||
case "onunload":
|
||||
this.onUnload();
|
||||
break;
|
||||
case "oncompleted":
|
||||
// This event comes in when setCompleted needs to be deferred because
|
||||
// the dialog isn't loaded yet.
|
||||
this.completed = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
// ---------- nsISupports methods ----------
|
||||
|
||||
// This "class" supports nsIProgressDialog, nsIWebProgressListener (by virtue
|
||||
// of interface inheritance), nsIObserver, and nsISupports.
|
||||
QueryInterface: function (iid) {
|
||||
if (iid.equals(Components.interfaces.nsIProgressDialog) ||
|
||||
iid.equals(Components.interfaces.nsIDownload) ||
|
||||
iid.equals(Components.interfaces.nsITransfer) ||
|
||||
iid.equals(Components.interfaces.nsIWebProgressListener) ||
|
||||
iid.equals(Components.interfaces.nsIWebProgressListener2) ||
|
||||
iid.equals(Components.interfaces.nsIDownloadProgressListener) ||
|
||||
iid.equals(Components.interfaces.nsIObserver) ||
|
||||
iid.equals(Components.interfaces.nsIInterfaceRequestor) ||
|
||||
iid.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
},
|
||||
|
||||
// ---------- nsIInterfaceRequestor methods ----------
|
||||
|
||||
getInterface: function(iid) {
|
||||
if (iid.equals(Components.interfaces.nsIPrompt) ||
|
||||
iid.equals(Components.interfaces.nsIAuthPrompt)) {
|
||||
// use the window watcher service to get a nsIPrompt/nsIAuthPrompt impl
|
||||
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
||||
.getService(Components.interfaces.nsIWindowWatcher);
|
||||
var prompt;
|
||||
if (iid.equals(Components.interfaces.nsIPrompt))
|
||||
prompt = ww.getNewPrompter(this.parent);
|
||||
else
|
||||
prompt = ww.getNewAuthPrompter(this.parent);
|
||||
return prompt;
|
||||
}
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
},
|
||||
|
||||
// ---------- implementation methods ----------
|
||||
|
||||
// Initialize the dialog.
|
||||
onLoad: function() {
|
||||
// Note that onLoad has finished.
|
||||
this.loaded = true;
|
||||
|
||||
// Fill dialog.
|
||||
this.loadDialog();
|
||||
|
||||
// Position dialog.
|
||||
if ( this.dialog.opener ) {
|
||||
this.dialog.moveToAlertPosition();
|
||||
} else {
|
||||
this.dialog.centerWindowOnScreen();
|
||||
}
|
||||
|
||||
// Set initial focus on "keep open" box. If that box is hidden, or, if
|
||||
// the download is already complete, then focus is on the cancel/close
|
||||
// button. The download may be complete if it was really short and the
|
||||
// dialog took longer to open than to download the data.
|
||||
if ( !this.completed && !this.saving ) {
|
||||
this.dialogElement( "keep" ).focus();
|
||||
} else {
|
||||
this.dialogElement( "cancel" ).focus();
|
||||
}
|
||||
},
|
||||
|
||||
// load dialog with initial contents
|
||||
loadDialog: function() {
|
||||
// Check whether we're saving versus opening with a helper app.
|
||||
if ( !this.saving ) {
|
||||
// Put proper label on source field.
|
||||
this.setValue( "sourceLabel", this.getString( "openingSource" ) );
|
||||
|
||||
// Target is the "preferred" application. Hide if empty.
|
||||
if ( this.MIMEInfo &&
|
||||
this.MIMEInfo.preferredApplicationHandler &&
|
||||
this.MIMEInfo.preferredApplicationHandler.executable ) {
|
||||
var appName =
|
||||
this.MIMEInfo.preferredApplicationHandler.executable.leafName;
|
||||
if ( appName == null || appName.length == 0 ) {
|
||||
this.hide( "targetRow" );
|
||||
} else {
|
||||
// Use the "with:" label.
|
||||
this.setValue( "targetLabel", this.getString( "openingTarget" ) );
|
||||
// Name of application.
|
||||
this.setValue( "target", appName );
|
||||
}
|
||||
} else {
|
||||
this.hide( "targetRow" );
|
||||
}
|
||||
} else {
|
||||
// If target is not a local file, then hide extra dialog controls.
|
||||
if (this.targetFile != null) {
|
||||
this.setValue( "target", this.targetFile.path );
|
||||
} else {
|
||||
this.setValue( "target", this.target.spec );
|
||||
this.hide( "pauseResume" );
|
||||
this.hide( "launch" );
|
||||
this.hide( "reveal" );
|
||||
}
|
||||
}
|
||||
|
||||
// Set source field.
|
||||
this.setValue( "source", this.source.spec );
|
||||
|
||||
var now = ( new Date() ).getTime();
|
||||
|
||||
// Initialize the elapsed time.
|
||||
if ( !this.elapsed ) {
|
||||
this.elapsed = now - this.startTime;
|
||||
}
|
||||
|
||||
// Update elapsed time display.
|
||||
this.setValue( "timeElapsed", this.formatSeconds( this.elapsed / 1000 ) );
|
||||
this.setValue( "timeLeft", this.getString( "unknownTime" ) );
|
||||
|
||||
// Initialize the "keep open" box. Hide this if we're opening a helper app
|
||||
// or if we are uploading.
|
||||
if ( !this.saving || !this.targetFile ) {
|
||||
// Hide this in this case.
|
||||
this.hide( "keep" );
|
||||
} else {
|
||||
// Initialize using last-set value from prefs.
|
||||
var prefs = Components.classes[ "@mozilla.org/preferences-service;1" ]
|
||||
.getService( Components.interfaces.nsIPrefBranch );
|
||||
if ( prefs ) {
|
||||
this.dialogElement( "keep" ).checked = prefs.getBoolPref( "browser.download.progressDnldDialog.keepAlive" );
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize title.
|
||||
this.setTitle();
|
||||
},
|
||||
|
||||
// Cancel button stops the download (if not completed),
|
||||
// and closes the dialog.
|
||||
onCancel: function() {
|
||||
// Cancel the download, if not completed.
|
||||
if ( !this.completed ) {
|
||||
if ( this.operation ) {
|
||||
const NS_BINDING_ABORTED = 0x804b0002;
|
||||
this.operation.cancel(NS_BINDING_ABORTED);
|
||||
// XXX We're supposed to clean up files/directories.
|
||||
}
|
||||
if ( this.observer ) {
|
||||
this.observer.observe( this, "oncancel", "" );
|
||||
}
|
||||
this.paused = false;
|
||||
}
|
||||
// Test whether the dialog is already closed.
|
||||
// This will be the case if we've come through onUnload.
|
||||
if ( this.dialog ) {
|
||||
// Close the dialog.
|
||||
this.dialog.close();
|
||||
}
|
||||
},
|
||||
|
||||
// onunload event means the dialog has closed.
|
||||
// We go through our onCancel logic to stop the download if still in progress.
|
||||
onUnload: function() {
|
||||
// Remember "keep dialog open" setting, if visible.
|
||||
if ( this.saving ) {
|
||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService( Components.interfaces.nsIPrefBranch );
|
||||
if ( prefs ) {
|
||||
prefs.setBoolPref( "browser.download.progressDnldDialog.keepAlive", this.dialogElement( "keep" ).checked );
|
||||
}
|
||||
}
|
||||
this.dialog = null; // The dialog is history.
|
||||
if ( this.mCancelDownloadOnClose ) {
|
||||
this.onCancel();
|
||||
}
|
||||
},
|
||||
|
||||
// onpause event means the user pressed the pause/resume button
|
||||
// Toggle the pause/resume state (see the function setPause(), below).i
|
||||
onPause: function() {
|
||||
this.paused = !this.paused;
|
||||
},
|
||||
|
||||
// onlaunch event means the user pressed the launch button
|
||||
// Invoke the launch method of the target file.
|
||||
onLaunch: function() {
|
||||
try {
|
||||
const kDontAskAgainPref = "browser.download.progressDnlgDialog.dontAskForLaunch";
|
||||
try {
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
var dontAskAgain = pref.getBoolPref(kDontAskAgainPref);
|
||||
} catch (e) {
|
||||
// we need to ask if we're unsure
|
||||
dontAskAgain = false;
|
||||
}
|
||||
if ( !dontAskAgain && this.targetFile.isExecutable() ) {
|
||||
try {
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService( Components.interfaces.nsIPromptService );
|
||||
} catch (ex) {
|
||||
// getService doesn't return null, it throws
|
||||
return;
|
||||
}
|
||||
var title = this.getProperty( "openingAlertTitle",
|
||||
[ this.fileName() ],
|
||||
1 );
|
||||
var msg = this.getProperty( "securityAlertMsg",
|
||||
[ this.fileName() ],
|
||||
1 );
|
||||
var dontaskmsg = this.getProperty( "dontAskAgain",
|
||||
[ ], 0 );
|
||||
var checkbox = {value:0};
|
||||
var okToProceed = promptService.confirmCheck(this.dialog, title, msg, dontaskmsg, checkbox);
|
||||
try {
|
||||
if (checkbox.value != dontAskAgain)
|
||||
pref.setBoolPref(kDontAskAgainPref, checkbox.value);
|
||||
} catch (ex) {}
|
||||
|
||||
if ( !okToProceed )
|
||||
return;
|
||||
}
|
||||
this.targetFile.launch();
|
||||
this.dialog.close();
|
||||
} catch ( exception ) {
|
||||
// XXX Need code here to tell user the launch failed!
|
||||
dump( "nsProgressDialog::onLaunch failed: " + exception + "\n" );
|
||||
}
|
||||
},
|
||||
|
||||
// onreveal event means the user pressed the "reveal location" button
|
||||
// Invoke the reveal method of the target file.
|
||||
onReveal: function() {
|
||||
try {
|
||||
this.targetFile.reveal();
|
||||
this.dialog.close();
|
||||
} catch ( exception ) {
|
||||
}
|
||||
},
|
||||
|
||||
// Get filename from the target.
|
||||
fileName: function() {
|
||||
if ( this.targetFile != null )
|
||||
return this.targetFile.leafName;
|
||||
try {
|
||||
var escapedFileName = this.target.QueryInterface(nsIURL).fileName;
|
||||
var textToSubURI = Components.classes["@mozilla.org/intl/texttosuburi;1"]
|
||||
.getService(nsITextToSubURI);
|
||||
return textToSubURI.unEscapeURIForUI(this.target.originCharset, escapedFileName);
|
||||
} catch (e) {}
|
||||
return "";
|
||||
},
|
||||
|
||||
// Set the dialog title.
|
||||
setTitle: function() {
|
||||
// Start with saving/opening template.
|
||||
// If percentage is not known (-1), use alternate template
|
||||
var title = this.saving
|
||||
? ( this.percent != -1 ? this.getString( "savingTitle" ) : this.getString( "unknownSavingTitle" ) )
|
||||
: ( this.percent != -1 ? this.getString( "openingTitle" ) : this.getString( "unknownOpeningTitle" ) );
|
||||
|
||||
|
||||
// Use file name as insert 1.
|
||||
title = this.replaceInsert( title, 1, this.fileName() );
|
||||
|
||||
// Use percentage as insert 2 (if known).
|
||||
if ( this.percent != -1 ) {
|
||||
title = this.replaceInsert( title, 2, this.percent );
|
||||
}
|
||||
|
||||
// Set dialog's title property.
|
||||
if ( this.dialog ) {
|
||||
this.dialog.document.title = title;
|
||||
}
|
||||
},
|
||||
|
||||
// Update the dialog to indicate specified percent complete.
|
||||
setPercent: function( percent ) {
|
||||
// Maximum percentage is 100.
|
||||
if ( percent > 100 ) {
|
||||
percent = 100;
|
||||
}
|
||||
// Test if percentage is changing.
|
||||
if ( this.percent != percent ) {
|
||||
this.mPercent = percent;
|
||||
|
||||
// If dialog not opened yet, bail early.
|
||||
if ( !this.loaded ) {
|
||||
return this.mPercent;
|
||||
}
|
||||
|
||||
if ( percent == -1 ) {
|
||||
// Progress meter needs to be in "undetermined" mode.
|
||||
this.mode = "undetermined";
|
||||
|
||||
// Update progress meter percentage text.
|
||||
this.setValue( "progressText", "" );
|
||||
} else {
|
||||
// Progress meter needs to be in normal mode.
|
||||
this.mode = "normal";
|
||||
|
||||
// Set progress meter thermometer.
|
||||
this.setValue( "progress", percent );
|
||||
|
||||
// Update progress meter percentage text.
|
||||
this.setValue( "progressText", this.replaceInsert( this.getString( "percentMsg" ), 1, percent ) );
|
||||
}
|
||||
|
||||
// Update title.
|
||||
this.setTitle();
|
||||
}
|
||||
return this.mPercent;
|
||||
},
|
||||
|
||||
// Update download rate and dialog display.
|
||||
setRate: function( rate ) {
|
||||
this.mRate = rate;
|
||||
return this.mRate;
|
||||
},
|
||||
|
||||
// Handle download completion.
|
||||
setCompleted: function() {
|
||||
// If dialog hasn't loaded yet, defer this.
|
||||
if ( !this.loaded ) {
|
||||
this.dialog.setTimeout( function(obj){obj.setCompleted()}, 100, this );
|
||||
return false;
|
||||
}
|
||||
if ( !this.mCompleted ) {
|
||||
this.mCompleted = true;
|
||||
|
||||
// If the "keep dialog open" box is checked, then update dialog.
|
||||
if ( this.dialog && this.dialogElement( "keep" ).checked ) {
|
||||
// Indicate completion in status area.
|
||||
var string = this.getString( "completeMsg" );
|
||||
string = this.replaceInsert( string,
|
||||
1,
|
||||
this.formatSeconds( this.elapsed/1000 ) );
|
||||
string = this.replaceInsert( string,
|
||||
2,
|
||||
this.targetFile.fileSize >> 10 );
|
||||
|
||||
this.setValue( "status", string);
|
||||
// Put progress meter at 100%.
|
||||
this.percent = 100;
|
||||
|
||||
// Set time remaining to 00:00.
|
||||
this.setValue( "timeLeft", this.formatSeconds( 0 ) );
|
||||
|
||||
// Change Cancel button to Close, and give it focus.
|
||||
var cancelButton = this.dialogElement( "cancel" );
|
||||
cancelButton.label = this.getString( "close" );
|
||||
cancelButton.focus();
|
||||
|
||||
// Activate reveal/launch buttons if we enable them.
|
||||
var enableButtons = true;
|
||||
try {
|
||||
var prefs = Components.classes[ "@mozilla.org/preferences-service;1" ]
|
||||
.getService( Components.interfaces.nsIPrefBranch );
|
||||
enableButtons = prefs.getBoolPref( "browser.download.progressDnldDialog.enable_launch_reveal_buttons" );
|
||||
} catch ( e ) {
|
||||
}
|
||||
|
||||
if ( enableButtons ) {
|
||||
this.enable( "reveal" );
|
||||
try {
|
||||
if ( this.targetFile != null ) {
|
||||
this.enable( "launch" );
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
|
||||
// Disable the Pause/Resume buttons.
|
||||
this.dialogElement( "pauseResume" ).disabled = true;
|
||||
|
||||
// Fix up dialog layout (which gets messed up sometimes).
|
||||
this.dialog.sizeToContent();
|
||||
|
||||
// GetAttention to show the user that we're done
|
||||
this.dialog.getAttention();
|
||||
} else if ( this.dialog ) {
|
||||
this.dialog.close();
|
||||
}
|
||||
}
|
||||
return this.mCompleted;
|
||||
},
|
||||
|
||||
// Set progress meter to given mode ("normal" or "undetermined").
|
||||
setMode: function( newMode ) {
|
||||
if ( this.mode != newMode ) {
|
||||
// Need to update progress meter.
|
||||
this.dialogElement( "progress" ).setAttribute( "mode", newMode );
|
||||
}
|
||||
return this.mMode = newMode;
|
||||
},
|
||||
|
||||
// Set pause/resume state.
|
||||
setPaused: function( pausing ) {
|
||||
// If state changing, then update stuff.
|
||||
if ( this.paused != pausing ) {
|
||||
var string = pausing ? "resume" : "pause";
|
||||
this.dialogElement( "pauseResume" ).label = this.getString(string);
|
||||
|
||||
// If we have an observer, tell it to suspend/resume
|
||||
if ( this.observer ) {
|
||||
this.observer.observe( this, pausing ? "onpause" : "onresume" , "" );
|
||||
}
|
||||
}
|
||||
return this.mPaused = pausing;
|
||||
},
|
||||
|
||||
// Format number of seconds in hh:mm:ss form.
|
||||
formatSeconds: function( secs ) {
|
||||
// Round the number of seconds to remove fractions.
|
||||
secs = parseInt( secs + .5 );
|
||||
var hours = parseInt( secs/3600 );
|
||||
secs -= hours*3600;
|
||||
var mins = parseInt( secs/60 );
|
||||
secs -= mins*60;
|
||||
var result;
|
||||
if ( hours )
|
||||
result = this.getString( "longTimeFormat" );
|
||||
else
|
||||
result = this.getString( "shortTimeFormat" );
|
||||
|
||||
if ( hours < 10 )
|
||||
hours = "0" + hours;
|
||||
if ( mins < 10 )
|
||||
mins = "0" + mins;
|
||||
if ( secs < 10 )
|
||||
secs = "0" + secs;
|
||||
|
||||
// Insert hours, minutes, and seconds into result string.
|
||||
result = this.replaceInsert( result, 1, hours );
|
||||
result = this.replaceInsert( result, 2, mins );
|
||||
result = this.replaceInsert( result, 3, secs );
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
// Get dialog element using argument as id.
|
||||
dialogElement: function( id ) {
|
||||
// Check if we've already fetched it.
|
||||
if ( !( id in this.fields ) ) {
|
||||
// No, then get it from dialog.
|
||||
try {
|
||||
this.fields[ id ] = this.dialog.document.getElementById( id );
|
||||
} catch(e) {
|
||||
this.fields[ id ] = {
|
||||
value: "",
|
||||
setAttribute: function(id,val) {},
|
||||
removeAttribute: function(id) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.fields[ id ];
|
||||
},
|
||||
|
||||
// Set dialog element value for given dialog element.
|
||||
setValue: function( id, val ) {
|
||||
this.dialogElement( id ).value = val;
|
||||
},
|
||||
|
||||
// Enable dialog element.
|
||||
enable: function( field ) {
|
||||
this.dialogElement( field ).removeAttribute( "disabled" );
|
||||
},
|
||||
|
||||
// Get localizable string from properties file.
|
||||
getProperty: function( propertyId, strings, len ) {
|
||||
if ( !this.mBundle ) {
|
||||
this.mBundle = Components.classes[ "@mozilla.org/intl/stringbundle;1" ]
|
||||
.getService( Components.interfaces.nsIStringBundleService )
|
||||
.createBundle( "chrome://global/locale/nsProgressDialog.properties");
|
||||
}
|
||||
return len ? this.mBundle.formatStringFromName( propertyId, strings, len )
|
||||
: this.mBundle.getStringFromName( propertyId );
|
||||
},
|
||||
|
||||
// Get localizable string (from dialog <data> elements).
|
||||
getString: function ( stringId ) {
|
||||
// Check if we've fetched this string already.
|
||||
if ( !( this.strings && stringId in this.strings ) ) {
|
||||
// Presume the string is empty if we can't get it.
|
||||
this.strings[ stringId ] = "";
|
||||
// Try to get it.
|
||||
try {
|
||||
this.strings[ stringId ] = this.dialog.document.getElementById( "string."+stringId ).childNodes[0].nodeValue;
|
||||
} catch (e) {}
|
||||
}
|
||||
return this.strings[ stringId ];
|
||||
},
|
||||
|
||||
// Replaces insert ("#n") with input text.
|
||||
replaceInsert: function( text, index, value ) {
|
||||
var result = text;
|
||||
var regExp = new RegExp( "#"+index );
|
||||
result = result.replace( regExp, value );
|
||||
return result;
|
||||
},
|
||||
|
||||
// Hide a given dialog field.
|
||||
hide: function( field ) {
|
||||
this.dialogElement( field ).hidden = true;
|
||||
|
||||
// Also hide any related separator element...
|
||||
var sep = this.dialogElement( field+"Separator" );
|
||||
if (sep)
|
||||
sep.hidden = true;
|
||||
},
|
||||
|
||||
// Return input in hex, prepended with "0x" and leading zeros (to 8 digits).
|
||||
hex: function( x ) {
|
||||
return "0x" + ("0000000" + Number(x).toString(16)).slice(-8);
|
||||
},
|
||||
|
||||
// Dump text (if debug is on).
|
||||
dump: function( text ) {
|
||||
if ( this.debug ) {
|
||||
dump( text );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This Component's module implementation. All the code below is used to get this
|
||||
// component registered and accessible via XPCOM.
|
||||
var module = {
|
||||
// registerSelf: Register this component.
|
||||
registerSelf: function (compMgr, fileSpec, location, type) {
|
||||
var compReg = compMgr.QueryInterface( Components.interfaces.nsIComponentRegistrar );
|
||||
compReg.registerFactoryLocation( this.cid,
|
||||
"Mozilla Download Progress Dialog",
|
||||
this.contractId,
|
||||
fileSpec,
|
||||
location,
|
||||
type );
|
||||
},
|
||||
|
||||
// getClassObject: Return this component's factory object.
|
||||
getClassObject: function (compMgr, cid, iid) {
|
||||
if (!cid.equals(this.cid))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
||||
if (!iid.equals(Components.interfaces.nsIFactory))
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
return this.factory;
|
||||
},
|
||||
|
||||
/* CID for this class */
|
||||
cid: Components.ID("{F5D248FD-024C-4f30-B208-F3003B85BC92}"),
|
||||
|
||||
/* Contract ID for this class */
|
||||
contractId: "@mozilla.org/progressdialog;1",
|
||||
|
||||
/* factory object */
|
||||
factory: {
|
||||
// createInstance: Return a new nsProgressDialog object.
|
||||
createInstance: function (outer, iid) {
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
return (new nsProgressDialog()).QueryInterface(iid);
|
||||
}
|
||||
},
|
||||
|
||||
// canUnload: n/a (returns true)
|
||||
canUnload: function(compMgr) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// NSGetModule: Return the nsIModule object.
|
||||
function NSGetModule(compMgr, fileSpec) {
|
||||
return module;
|
||||
}
|
|
@ -1,169 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- -*- Mode: HTML -*- -->
|
||||
|
||||
<!-- ***** 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 Progress Dialog.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corp.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2002
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Scott MacGregor <mscott@netscape.com>
|
||||
- Bill Law <law@netscape.com>
|
||||
- Aaron Kaluszka <ask@swva.net>
|
||||
-
|
||||
- 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 LGPL or the GPL. 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 ***** -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://global/locale/nsProgressDialog.dtd">
|
||||
|
||||
<!-- This dialog can only be opened by creating an instance of the
|
||||
component "@mozilla.org/progressdialog;1". You cannot open it
|
||||
via window.open (or window.openDialog, or any variants thereof).
|
||||
|
||||
That code will pass an nsIObserver interface via window.arguments[0].
|
||||
All "commands" in this dialog simply send notifications via that
|
||||
interface.
|
||||
|
||||
See the implementation of that component in
|
||||
http://lxr.mozilla.org/seamonkey/source/embedding/components/ui/progressDlg/nsProgressDialog.js
|
||||
for details.
|
||||
-->
|
||||
|
||||
<window xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
class="dialog"
|
||||
title="&defaultTitle;"
|
||||
onload="notifyObserver('onload')"
|
||||
onunload="notifyObserver('onunload')"
|
||||
style="width: 32em;">
|
||||
|
||||
<!-- This is the only JS code in this file. It simply routes the "command"
|
||||
to the dialog's observer (the implementation in nsProgressDialog.js).
|
||||
-->
|
||||
<script type="application/x-javascript"><![CDATA[
|
||||
function notifyObserver( cmd ) {
|
||||
// Remember observer at onload time.
|
||||
if ( cmd == 'onload' ) {
|
||||
window.observer = window.arguments[0].QueryInterface( Components.interfaces.nsIObserver );
|
||||
}
|
||||
window.observer.observe( null, cmd, '' );
|
||||
}
|
||||
]]></script>
|
||||
|
||||
<!-- This is non-visible content that simply adds translatable string
|
||||
into the document so that it is accessible to JS code.
|
||||
-->
|
||||
|
||||
<data id="string.close">&close;</data>
|
||||
<data id="string.progressMsg">&progressMsg;</data>
|
||||
<data id="string.completeMsg">&completeMsg;</data>
|
||||
<data id="string.percentMsg">&percentMsg;</data>
|
||||
<data id="string.shortTimeFormat">&shortTimeFormat;</data>
|
||||
<data id="string.longTimeFormat">&longTimeFormat;</data>
|
||||
<data id="string.unknownTime">&unknownTime;</data>
|
||||
<data id="string.pausedMsg">&pausedMsg;</data>
|
||||
<data id="string.savingTitle">&savingTitle;</data>
|
||||
<data id="string.openingTitle">&openingTitle;</data>
|
||||
<data id="string.openingSource">&openingSource;</data>
|
||||
<data id="string.openingTarget">&openingTarget;</data>
|
||||
<data id="string.unknownSavingTitle">&unknownSavingTitle;</data>
|
||||
<data id="string.unknownOpeningTitle">&unknownOpeningTitle;</data>
|
||||
<data id="string.pause">&pause;</data>
|
||||
<data id="string.resume">&resume;</data>
|
||||
|
||||
<grid flex="1">
|
||||
<columns>
|
||||
<column/>
|
||||
<column flex="1"/>
|
||||
</columns>
|
||||
|
||||
<rows>
|
||||
<row>
|
||||
<hbox align="center" pack="end">
|
||||
<label id="sourceLabel" value="&savingSource;"/>
|
||||
</hbox>
|
||||
<textbox id="source" class="scrollfield" readonly="true" flex="1"/>
|
||||
</row>
|
||||
<separator class="thin"/>
|
||||
<row id="targetRow">
|
||||
<hbox align="center" pack="end">
|
||||
<label id="targetLabel" value="&savingTarget;"/>
|
||||
</hbox>
|
||||
<textbox id="target" class="scrollfield" readonly="true" flex="1"/>
|
||||
</row>
|
||||
<separator id="targetRowSeparator" class="thin"/>
|
||||
<row>
|
||||
<hbox align="center" pack="end">
|
||||
<label value="&status;"/>
|
||||
</hbox>
|
||||
<label id="status" value=" " flex="1"/>
|
||||
</row>
|
||||
<separator class="thin"/>
|
||||
<row>
|
||||
<hbox align="center" pack="end">
|
||||
<label value="&timeLeft;"/>
|
||||
</hbox>
|
||||
<label id="timeLeft" value=" "/>
|
||||
</row>
|
||||
<separator class="thin"/>
|
||||
<row>
|
||||
<hbox align="center" pack="end">
|
||||
<label value="&timeElapsed;"/>
|
||||
</hbox>
|
||||
<label id="timeElapsed" value=" "/>
|
||||
</row>
|
||||
<separator class="thin"/>
|
||||
<row>
|
||||
<hbox align="center" pack="end">
|
||||
<label value="&progress;"/>
|
||||
</hbox>
|
||||
<progressmeter id="progress" mode="normal" value="0"/>
|
||||
<hbox align="center" pack="end">
|
||||
<label id="progressText" value=" " style="width: 4em;"/>
|
||||
</hbox>
|
||||
</row>
|
||||
<separator/>
|
||||
</rows>
|
||||
</grid>
|
||||
<hbox align="center">
|
||||
<checkbox id="keep" label="&keep;"/>
|
||||
</hbox>
|
||||
<separator id="keepSeparator"/>
|
||||
<hbox>
|
||||
<button id="cancel" label="&cancel;" oncommand="notifyObserver( 'oncancel' )"/>
|
||||
<button id="pauseResume" label="&pause;" oncommand="window.notifyObserver( 'onpause' )"/>
|
||||
<spacer flex="1"/>
|
||||
<button id="launch" label="&launch;" disabled="true" oncommand="window.notifyObserver( 'onlaunch' )"/>
|
||||
<button id="reveal" label="&reveal;" disabled="true" oncommand="window.notifyObserver( 'onreveal' )"/>
|
||||
</hbox>
|
||||
</window>
|
|
@ -1,42 +0,0 @@
|
|||
<!ENTITY caption.label "Opening #1">
|
||||
|
||||
<!-- Localization note: The default intro text has 3 "inserts":
|
||||
#1 - replaced with the descriptive text that describes the mime type
|
||||
(e.g., "MSWord Document")
|
||||
#2 - replaced with the mime type (e.g., "application/ms-word")
|
||||
#3 - replaced with the filename (e.g., "manual.doc")
|
||||
#4 - will be replaced by the brand name (e.g., "Mozilla")
|
||||
If there is no descriptive text, then the alternative text is used which
|
||||
has only insert #2.
|
||||
-->
|
||||
<!ENTITY intro.label "The file "#3" is of type #2 (#1), and #4 does not know how to handle this file type. This file is located at:">
|
||||
<!ENTITY intro.noDesc.label "The file "#3" is of type #2, and #4 does not know how to handle this file type. This file is located at:">
|
||||
|
||||
<!ENTITY intro.attachment.label "The site has suggested that "#3" be handled as an attachment. It is of type #2 (#1) and located at:">
|
||||
<!ENTITY intro.attachment.noDesc.label "The site has suggested that "#3" be handled as an attachment. It is of type #2 and located at:">
|
||||
|
||||
<!ENTITY intro.sniffed.label "#4 has detected that the file "#3" is likely to be of type #2 (#1). The file is located at:">
|
||||
<!ENTITY intro.sniffed.noDesc.label "#4 has detected that the file "#3" is likely to be of type #2. The file is located at:">
|
||||
|
||||
<!ENTITY prompt.label "What should #1 do with this file?">
|
||||
|
||||
<!ENTITY alwaysHandle.label "Always perform this action when handling files of this type">
|
||||
<!ENTITY alwaysHandle.accesskey "A">
|
||||
|
||||
<!ENTITY saveToDisk.label "Save it to disk">
|
||||
<!ENTITY saveToDisk.accesskey "S">
|
||||
|
||||
<!ENTITY useSystemDefault.label "Open it with the default application (#1)">
|
||||
<!ENTITY useSystemDefault.noDesc.label "Open it with the default application">
|
||||
<!ENTITY useSystemDefault.accesskey "O">
|
||||
|
||||
<!ENTITY openUsing.label "Open it with">
|
||||
<!ENTITY openUsing.accesskey "w">
|
||||
|
||||
<!ENTITY chooseApp.label "Choose…">
|
||||
<!ENTITY chooseApp.accesskey "C">
|
||||
|
||||
<!ENTITY chooseAppFilePickerTitle "Choose Helper Application">
|
||||
|
||||
<!ENTITY badApp "The application you specified ("#1") could not be found. Check the file name or select another application.">
|
||||
<!ENTITY badApp.title "Application not found">
|
|
@ -1,2 +0,0 @@
|
|||
saveDialogTitle=Enter name of file to save to…
|
||||
noDefaultFile=unnamed
|
|
@ -1,136 +0,0 @@
|
|||
<!-- ***** 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 Progress Dialog.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Netscape Communications Corp.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2002
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Bill Law <law@netscape.com>
|
||||
- Aaron Kaluszka <ask@swva.net>
|
||||
-
|
||||
- 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 LGPL or the GPL. 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 ***** -->
|
||||
|
||||
<!-- These strings are used on the download progress dialog.
|
||||
See: http://lxr.mozilla.org/seamonkey/source/embedding/components/ui/progressDlg/nsProgressDialog.xul
|
||||
-->
|
||||
|
||||
<!-- This is used prior to initializing with a proper title -->
|
||||
<!ENTITY defaultTitle "Saving">
|
||||
|
||||
<!-- These are used when saving -->
|
||||
<!ENTITY savingTitle "#2% of #1 Saved">
|
||||
<!ENTITY savingSource "Saving From:">
|
||||
<!ENTITY savingTarget "To:">
|
||||
|
||||
<!-- These are used when opening (with an application) -->
|
||||
<!ENTITY openingTitle "#2% of #1 Completed">
|
||||
<!ENTITY openingSource "Opening From:">
|
||||
<!ENTITY openingTarget "With:">
|
||||
|
||||
<!-- This is used when the download percentage is unknown -->
|
||||
<!ENTITY unknownSavingTitle "Saving #1">
|
||||
<!ENTITY unknownOpeningTitle "Opening #1">
|
||||
|
||||
<!-- Labels on other fields -->
|
||||
<!ENTITY status "Status:">
|
||||
<!ENTITY timeElapsed "Time Elapsed:">
|
||||
<!ENTITY timeLeft "Time Left:">
|
||||
<!ENTITY progress "Progress:">
|
||||
|
||||
<!-- Label for the "keep dialog" checkbox -->
|
||||
<!ENTITY keep "Keep this window open after the download is complete.">
|
||||
|
||||
<!-- Button labels -->
|
||||
<!ENTITY cancel "Cancel">
|
||||
<!ENTITY pause "Pause">
|
||||
<!ENTITY resume "Resume">
|
||||
<!ENTITY close "Close">
|
||||
<!ENTITY reveal "Show File Location">
|
||||
<!ENTITY launch "Launch File">
|
||||
|
||||
<!-- Status/progress messages -->
|
||||
|
||||
<!-- LOCALIZATION NOTE (pausedMsg):
|
||||
This string is used to indicate that the download is paused -->
|
||||
<!ENTITY pausedMsg "Download Paused">
|
||||
|
||||
<!-- LOCALIZATION NOTE (progressMsg):
|
||||
|
||||
This string is used to generate the status message used during
|
||||
file download.
|
||||
|
||||
#1 will be replaced by the number of bytes downloaded thus far
|
||||
#2 will be replaced by the total number of bytes to be downloaded
|
||||
#3 will be replaced by the download rate (in KB per second) -->
|
||||
<!ENTITY progressMsg "#1KB of #2KB (at #3KB/sec)">
|
||||
|
||||
<!-- LOCALIZATION NOTE (unknownTime):
|
||||
|
||||
This string is used when the time remaining is unknown. -->
|
||||
<!ENTITY unknownTime "Unknown">
|
||||
|
||||
<!-- LOCALIZATION NOTE (longTimeFormat):
|
||||
|
||||
This string is used to format elapsed/remaining times when the
|
||||
time exceeds 1 hour in length.
|
||||
|
||||
#1 will be replaced by the number of hours
|
||||
#2 will be replaced by the number of minutes
|
||||
#3 will be replaced by the number of seconds -->
|
||||
<!ENTITY longTimeFormat "#1:#2:#3">
|
||||
|
||||
<!-- LOCALIZATION NOTE (shortTimeFormat):
|
||||
|
||||
This string is used to format elapsed/remaining times when the
|
||||
time is less than 1 hour in length. Note that you can leave
|
||||
"#1" out of this string to omit the leading "00:" if you so choose.
|
||||
|
||||
#1 will be replaced by the number of hours
|
||||
#2 will be replaced by the number of minutes
|
||||
#3 will be replaced by the number of seconds -->
|
||||
<!ENTITY shortTimeFormat "#2:#3">
|
||||
|
||||
<!-- LOCALIZATION NOTE (completeMsg):
|
||||
|
||||
This string is displayed when the download is complete. The insert
|
||||
"#1" is replaced by the elapsed time, formatted according to the
|
||||
xxxTimeFormat strings defined above). You can omit "#1" if you don't
|
||||
want the elapsed time in the message.
|
||||
|
||||
#1 will be replaced by the elapsed time
|
||||
#2 will be replaced by the size of the file in Kilobytes -->
|
||||
<!ENTITY completeMsg "Finished, #2 KB downloaded (elapsed time was #1)">
|
||||
|
||||
<!-- LOCALIZATION NOTE (percentMsg):
|
||||
|
||||
This string is used to format the text to the right of the progress
|
||||
meter.
|
||||
|
||||
#1 will be replaced by the percentage of the file that has been saved -->
|
||||
<!ENTITY percentMsg "#1%">
|
|
@ -1,41 +0,0 @@
|
|||
# ***** 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 Progress Dialog.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corp.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2002
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Bill Law <law@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 *****
|
||||
|
||||
savingAlertTitle=Saving %S
|
||||
openingAlertTitle=Opening %S
|
||||
securityAlertMsg=Warning! Executable files may contain viruses or other malicious code that could harm your computer. Use caution when opening this file. Are you sure you want to launch %S?
|
||||
dontAskAgain=Don't ask me again.
|
|
@ -56,10 +56,6 @@
|
|||
+ locale/@AB_CD@/global/viewSource.properties (%chrome/global/viewSource.properties)
|
||||
+ locale/@AB_CD@/global/wizard.dtd (%chrome/global/wizard.dtd)
|
||||
+ locale/@AB_CD@/global/wizard.properties (%chrome/global/wizard.properties)
|
||||
locale/@AB_CD@/global/nsHelperAppDlg.dtd (%chrome/global/nsHelperAppDlg.dtd)
|
||||
locale/@AB_CD@/global/nsHelperAppDlg.properties (%chrome/global/nsHelperAppDlg.properties)
|
||||
locale/@AB_CD@/global/nsProgressDialog.dtd (%chrome/global/nsProgressDialog.dtd)
|
||||
locale/@AB_CD@/global/nsProgressDialog.properties (%chrome/global/nsProgressDialog.properties)
|
||||
locale/@AB_CD@/global/xpinstall/xpinstall.properties (%chrome/global/xpinstall/xpinstall.properties)
|
||||
locale/@AB_CD@/global/crashes.dtd (%crashreporter/crashes.dtd)
|
||||
locale/@AB_CD@/global/crashes.properties (%crashreporter/crashes.properties)
|
||||
|
|
|
@ -1147,16 +1147,6 @@ nsUnknownContentTypeDialog.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
// dumpInfo:
|
||||
doDebug: function() {
|
||||
const nsIProgressDialog = Components.interfaces.nsIProgressDialog;
|
||||
// Open new progress dialog.
|
||||
var progress = Components.classes[ "@mozilla.org/progressdialog;1" ]
|
||||
.createInstance( nsIProgressDialog );
|
||||
// Show it.
|
||||
progress.open( this.mDialog );
|
||||
},
|
||||
|
||||
// dumpObj:
|
||||
dumpObj: function( spec ) {
|
||||
var val = "<undefined>";
|
||||
|
|
Загрузка…
Ссылка в новой задаче