mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-26 02:17:34 +09:00
Issue #65 - Remove AppConstants from toolkit/mozapps/downloads
This commit is contained in:
parent
905663865e
commit
f1210b0d9a
5 changed files with 141 additions and 138 deletions
|
|
@ -16,7 +16,6 @@ const Cu = Components.utils;
|
||||||
const Cr = Components.results;
|
const Cr = Components.results;
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "Services",
|
XPCOMUtils.defineLazyModuleGetter(this, "Services",
|
||||||
"resource://gre/modules/Services.jsm");
|
"resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
|
|
@ -177,33 +176,33 @@ var DownloadTaskbarProgressUpdater =
|
||||||
*/
|
*/
|
||||||
_setActiveWindow: function DTPU_setActiveWindow(aWindow, aIsDownloadWindow)
|
_setActiveWindow: function DTPU_setActiveWindow(aWindow, aIsDownloadWindow)
|
||||||
{
|
{
|
||||||
if (AppConstants.platform == "win") {
|
#ifdef XP_WIN
|
||||||
// Clear out the taskbar for the old active window. (If there was no active
|
// Clear out the taskbar for the old active window. (If there was no active
|
||||||
// window, this is a no-op.)
|
// window, this is a no-op.)
|
||||||
this._clearTaskbar();
|
this._clearTaskbar();
|
||||||
|
|
||||||
this._activeWindowIsDownloadWindow = aIsDownloadWindow;
|
this._activeWindowIsDownloadWindow = aIsDownloadWindow;
|
||||||
if (aWindow) {
|
if (aWindow) {
|
||||||
// Get the taskbar progress for this window
|
// Get the taskbar progress for this window
|
||||||
let docShell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).
|
let docShell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||||
getInterface(Ci.nsIWebNavigation).
|
getInterface(Ci.nsIWebNavigation).
|
||||||
QueryInterface(Ci.nsIDocShellTreeItem).treeOwner.
|
QueryInterface(Ci.nsIDocShellTreeItem).treeOwner.
|
||||||
QueryInterface(Ci.nsIInterfaceRequestor).
|
QueryInterface(Ci.nsIInterfaceRequestor).
|
||||||
getInterface(Ci.nsIXULWindow).docShell;
|
getInterface(Ci.nsIXULWindow).docShell;
|
||||||
let taskbarProgress = this._taskbar.getTaskbarProgress(docShell);
|
let taskbarProgress = this._taskbar.getTaskbarProgress(docShell);
|
||||||
this._activeTaskbarProgress = taskbarProgress;
|
this._activeTaskbarProgress = taskbarProgress;
|
||||||
|
|
||||||
this._updateTaskbar();
|
this._updateTaskbar();
|
||||||
// _onActiveWindowUnload is idempotent, so we don't need to check whether
|
// _onActiveWindowUnload is idempotent, so we don't need to check whether
|
||||||
// we've already set this before or not.
|
// we've already set this before or not.
|
||||||
aWindow.addEventListener("unload", function () {
|
aWindow.addEventListener("unload", function () {
|
||||||
DownloadTaskbarProgressUpdater._onActiveWindowUnload(taskbarProgress);
|
DownloadTaskbarProgressUpdater._onActiveWindowUnload(taskbarProgress);
|
||||||
}, false);
|
}, false);
|
||||||
}
|
|
||||||
else {
|
|
||||||
this._activeTaskbarProgress = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
this._activeTaskbarProgress = null;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
},
|
},
|
||||||
|
|
||||||
// / Current state displayed on the active window's taskbar item
|
// / Current state displayed on the active window's taskbar item
|
||||||
|
|
@ -213,14 +212,15 @@ var DownloadTaskbarProgressUpdater =
|
||||||
|
|
||||||
_shouldSetState: function DTPU_shouldSetState()
|
_shouldSetState: function DTPU_shouldSetState()
|
||||||
{
|
{
|
||||||
if (AppConstants.platform == "win") {
|
#ifdef XP_WIN
|
||||||
// If the active window is not the download manager window, set the state
|
// If the active window is not the download manager window, set the state
|
||||||
// only if it is normal or indeterminate.
|
// only if it is normal or indeterminate.
|
||||||
return this._activeWindowIsDownloadWindow ||
|
return this._activeWindowIsDownloadWindow ||
|
||||||
(this._taskbarState == Ci.nsITaskbarProgress.STATE_NORMAL ||
|
(this._taskbarState == Ci.nsITaskbarProgress.STATE_NORMAL ||
|
||||||
this._taskbarState == Ci.nsITaskbarProgress.STATE_INDETERMINATE);
|
this._taskbarState == Ci.nsITaskbarProgress.STATE_INDETERMINATE);
|
||||||
}
|
#else
|
||||||
return true;
|
return true;
|
||||||
|
#endif
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ var Cu = Components.utils;
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
Cu.import("resource://gre/modules/DownloadUtils.jsm");
|
Cu.import("resource://gre/modules/DownloadUtils.jsm");
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
|
||||||
|
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||||
"resource://gre/modules/PluralForm.jsm");
|
"resource://gre/modules/PluralForm.jsm");
|
||||||
|
|
@ -253,18 +252,18 @@ function openDownload(aDownload)
|
||||||
dontAsk = !pref.getBoolPref(PREF_BDM_CONFIRMOPENEXE);
|
dontAsk = !pref.getBoolPref(PREF_BDM_CONFIRMOPENEXE);
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
|
|
||||||
if (AppConstants.platform == "win") {
|
#ifdef XP_WIN
|
||||||
// On Vista and above, we rely on native security prompting for
|
// On Vista and above, we rely on native security prompting for
|
||||||
// downloaded content unless it's disabled.
|
// downloaded content unless it's disabled.
|
||||||
try {
|
try {
|
||||||
var sysInfo = Cc["@mozilla.org/system-info;1"].
|
var sysInfo = Cc["@mozilla.org/system-info;1"].
|
||||||
getService(Ci.nsIPropertyBag2);
|
getService(Ci.nsIPropertyBag2);
|
||||||
if (parseFloat(sysInfo.getProperty("version")) >= 6 &&
|
if (parseFloat(sysInfo.getProperty("version")) >= 6 &&
|
||||||
pref.getBoolPref(PREF_BDM_SCANWHENDONE)) {
|
pref.getBoolPref(PREF_BDM_SCANWHENDONE)) {
|
||||||
dontAsk = true;
|
dontAsk = true;
|
||||||
}
|
}
|
||||||
} catch (ex) { }
|
} catch (ex) { }
|
||||||
}
|
#endif
|
||||||
|
|
||||||
if (!dontAsk) {
|
if (!dontAsk) {
|
||||||
var strings = document.getElementById("downloadStrings");
|
var strings = document.getElementById("downloadStrings");
|
||||||
|
|
@ -478,10 +477,11 @@ var gDownloadObserver = {
|
||||||
removeFromView(dl);
|
removeFromView(dl);
|
||||||
break;
|
break;
|
||||||
case "browser-lastwindow-close-granted":
|
case "browser-lastwindow-close-granted":
|
||||||
if (AppConstants.platform != "macosx" &&
|
#ifndef XP_MACOSX
|
||||||
gDownloadManager.activeDownloadCount == 0) {
|
if (gDownloadManager.activeDownloadCount == 0) {
|
||||||
setTimeout(gCloseDownloadManager, 0);
|
setTimeout(gCloseDownloadManager, 0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ toolkit.jar:
|
||||||
% content mozapps %content/mozapps/
|
% content mozapps %content/mozapps/
|
||||||
* content/mozapps/downloads/unknownContentType.xul (content/unknownContentType.xul)
|
* content/mozapps/downloads/unknownContentType.xul (content/unknownContentType.xul)
|
||||||
* content/mozapps/downloads/downloads.xul (content/downloads.xul)
|
* content/mozapps/downloads/downloads.xul (content/downloads.xul)
|
||||||
content/mozapps/downloads/downloads.js (content/downloads.js)
|
* content/mozapps/downloads/downloads.js (content/downloads.js)
|
||||||
content/mozapps/downloads/DownloadProgressListener.js (content/DownloadProgressListener.js)
|
content/mozapps/downloads/DownloadProgressListener.js (content/DownloadProgressListener.js)
|
||||||
content/mozapps/downloads/downloads.css (content/downloads.css)
|
content/mozapps/downloads/downloads.css (content/downloads.css)
|
||||||
content/mozapps/downloads/download.xml (content/download.xml)
|
content/mozapps/downloads/download.xml (content/download.xml)
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,9 @@ EXTRA_PP_COMPONENTS += [
|
||||||
EXTRA_JS_MODULES += [
|
EXTRA_JS_MODULES += [
|
||||||
'DownloadLastDir.jsm',
|
'DownloadLastDir.jsm',
|
||||||
'DownloadPaths.jsm',
|
'DownloadPaths.jsm',
|
||||||
'DownloadTaskbarProgress.jsm',
|
|
||||||
'DownloadUtils.jsm',
|
'DownloadUtils.jsm',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
EXTRA_PP_JS_MODULES += ['DownloadTaskbarProgress.jsm']
|
||||||
|
|
||||||
JAR_MANIFESTS += ['jar.mn']
|
JAR_MANIFESTS += ['jar.mn']
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
const {utils: Cu, interfaces: Ci, classes: Cc, results: Cr} = Components;
|
const {utils: Cu, interfaces: Ci, classes: Cc, results: Cr} = Components;
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "EnableDelayHelper",
|
XPCOMUtils.defineLazyModuleGetter(this, "EnableDelayHelper",
|
||||||
"resource://gre/modules/SharedPromptUtils.jsm");
|
"resource://gre/modules/SharedPromptUtils.jsm");
|
||||||
|
|
@ -408,22 +407,22 @@ nsUnknownContentTypeDialog.prototype = {
|
||||||
// is now caught properly in the caller of validateLeafName.
|
// is now caught properly in the caller of validateLeafName.
|
||||||
var createdFile = DownloadPaths.createNiceUniqueFile(aLocalFolder);
|
var createdFile = DownloadPaths.createNiceUniqueFile(aLocalFolder);
|
||||||
|
|
||||||
if (AppConstants.platform == "win") {
|
#ifdef XP_WIN
|
||||||
let ext;
|
let ext;
|
||||||
try {
|
try {
|
||||||
// We can fail here if there's no primary extension set
|
// We can fail here if there's no primary extension set
|
||||||
ext = "." + this.mLauncher.MIMEInfo.primaryExtension;
|
ext = "." + this.mLauncher.MIMEInfo.primaryExtension;
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
|
|
||||||
// Append a file extension if it's an executable that doesn't have one
|
// Append a file extension if it's an executable that doesn't have one
|
||||||
// but make sure we actually have an extension to add
|
// but make sure we actually have an extension to add
|
||||||
let leaf = createdFile.leafName;
|
let leaf = createdFile.leafName;
|
||||||
if (ext && leaf.slice(-ext.length) != ext && createdFile.isExecutable()) {
|
if (ext && leaf.slice(-ext.length) != ext && createdFile.isExecutable()) {
|
||||||
createdFile.remove(false);
|
createdFile.remove(false);
|
||||||
aLocalFolder.leafName = leaf + ext;
|
aLocalFolder.leafName = leaf + ext;
|
||||||
createdFile = DownloadPaths.createNiceUniqueFile(aLocalFolder);
|
createdFile = DownloadPaths.createNiceUniqueFile(aLocalFolder);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return createdFile;
|
return createdFile;
|
||||||
},
|
},
|
||||||
|
|
@ -639,22 +638,22 @@ nsUnknownContentTypeDialog.prototype = {
|
||||||
|
|
||||||
// Returns true if opening the default application makes sense.
|
// Returns true if opening the default application makes sense.
|
||||||
openWithDefaultOK: function() {
|
openWithDefaultOK: function() {
|
||||||
// The checking is different on Windows...
|
#ifdef XP_WIN
|
||||||
if (AppConstants.platform == "win") {
|
// Windows presents some special cases.
|
||||||
// Windows presents some special cases.
|
// We need to prevent use of "system default" when the file is
|
||||||
// We need to prevent use of "system default" when the file is
|
// executable (so the user doesn't launch nasty programs downloaded
|
||||||
// executable (so the user doesn't launch nasty programs downloaded
|
// from the web), and, enable use of "system default" if it isn't
|
||||||
// from the web), and, enable use of "system default" if it isn't
|
// executable (because we will prompt the user for the default app
|
||||||
// executable (because we will prompt the user for the default app
|
// in that case).
|
||||||
// in that case).
|
|
||||||
|
|
||||||
// Default is Ok if the file isn't executable (and vice-versa).
|
// Default is Ok if the file isn't executable (and vice-versa).
|
||||||
return !this.mLauncher.targetFileIsExecutable;
|
return !this.mLauncher.targetFileIsExecutable;
|
||||||
}
|
#else
|
||||||
// On other platforms, default is Ok if there is a default app.
|
// On other platforms, default is Ok if there is a default app.
|
||||||
// Note that nsIMIMEInfo providers need to ensure that this holds true
|
// Note that nsIMIMEInfo providers need to ensure that this holds true
|
||||||
// on each platform.
|
// on each platform.
|
||||||
return this.mLauncher.MIMEInfo.hasDefaultHandler;
|
return this.mLauncher.MIMEInfo.hasDefaultHandler;
|
||||||
|
#endif
|
||||||
},
|
},
|
||||||
|
|
||||||
// Set "default" application description field.
|
// Set "default" application description field.
|
||||||
|
|
@ -675,10 +674,11 @@ nsUnknownContentTypeDialog.prototype = {
|
||||||
|
|
||||||
// getPath:
|
// getPath:
|
||||||
getPath: function (aFile) {
|
getPath: function (aFile) {
|
||||||
if (AppConstants.platform == "macosx") {
|
#ifdef XP_MACOSX
|
||||||
return aFile.leafName || aFile.path;
|
return aFile.leafName || aFile.path;
|
||||||
}
|
#else
|
||||||
return aFile.path;
|
return aFile.path;
|
||||||
|
#endif
|
||||||
},
|
},
|
||||||
|
|
||||||
// initAppAndSaveToDiskValues:
|
// initAppAndSaveToDiskValues:
|
||||||
|
|
@ -980,19 +980,20 @@ nsUnknownContentTypeDialog.prototype = {
|
||||||
// Retrieve the pretty description from the file
|
// Retrieve the pretty description from the file
|
||||||
getFileDisplayName: function getFileDisplayName(file)
|
getFileDisplayName: function getFileDisplayName(file)
|
||||||
{
|
{
|
||||||
if (AppConstants.platform == "win") {
|
#ifdef XP_WIN
|
||||||
if (file instanceof Components.interfaces.nsILocalFileWin) {
|
if (file instanceof Components.interfaces.nsILocalFileWin) {
|
||||||
try {
|
try {
|
||||||
return file.getVersionInfoField("FileDescription");
|
return file.getVersionInfoField("FileDescription");
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
|
||||||
} else if (AppConstants.platform == "macosx") {
|
|
||||||
if (file instanceof Components.interfaces.nsILocalFileMac) {
|
|
||||||
try {
|
|
||||||
return file.bundleDisplayName;
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#elifdef XP_MACOSX
|
||||||
|
if (file instanceof Components.interfaces.nsILocalFileMac) {
|
||||||
|
try {
|
||||||
|
return file.bundleDisplayName;
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return file.leafName;
|
return file.leafName;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -1006,10 +1007,11 @@ nsUnknownContentTypeDialog.prototype = {
|
||||||
var otherHandler = this.dialogElement("otherHandler");
|
var otherHandler = this.dialogElement("otherHandler");
|
||||||
otherHandler.removeAttribute("hidden");
|
otherHandler.removeAttribute("hidden");
|
||||||
otherHandler.setAttribute("path", this.getPath(this.chosenApp.executable));
|
otherHandler.setAttribute("path", this.getPath(this.chosenApp.executable));
|
||||||
if (AppConstants.platform == "win")
|
#ifdef XP_WIN
|
||||||
otherHandler.label = this.getFileDisplayName(this.chosenApp.executable);
|
otherHandler.label = this.getFileDisplayName(this.chosenApp.executable);
|
||||||
else
|
#else
|
||||||
otherHandler.label = this.chosenApp.name;
|
otherHandler.label = this.chosenApp.name;
|
||||||
|
#endif
|
||||||
this.dialogElement("openHandler").selectedIndex = 1;
|
this.dialogElement("openHandler").selectedIndex = 1;
|
||||||
this.dialogElement("openHandler").setAttribute("lastSelectedItemID", "otherHandler");
|
this.dialogElement("openHandler").setAttribute("lastSelectedItemID", "otherHandler");
|
||||||
|
|
||||||
|
|
@ -1025,50 +1027,49 @@ nsUnknownContentTypeDialog.prototype = {
|
||||||
},
|
},
|
||||||
// chooseApp: Open file picker and prompt user for application.
|
// chooseApp: Open file picker and prompt user for application.
|
||||||
chooseApp: function() {
|
chooseApp: function() {
|
||||||
if (AppConstants.platform == "win") {
|
#ifdef XP_WIN
|
||||||
// Protect against the lack of an extension
|
// Protect against the lack of an extension
|
||||||
var fileExtension = "";
|
var fileExtension = "";
|
||||||
try {
|
try {
|
||||||
fileExtension = this.mLauncher.MIMEInfo.primaryExtension;
|
fileExtension = this.mLauncher.MIMEInfo.primaryExtension;
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to use the pretty description of the type, if one is available.
|
// Try to use the pretty description of the type, if one is available.
|
||||||
var typeString = this.mLauncher.MIMEInfo.description;
|
var typeString = this.mLauncher.MIMEInfo.description;
|
||||||
|
|
||||||
if (!typeString) {
|
if (!typeString) {
|
||||||
// If there is none, use the extension to
|
// If there is none, use the extension to
|
||||||
// identify the file, e.g. "ZIP file"
|
// identify the file, e.g. "ZIP file"
|
||||||
if (fileExtension) {
|
if (fileExtension) {
|
||||||
typeString =
|
typeString =
|
||||||
this.dialogElement("strings").
|
this.dialogElement("strings").
|
||||||
getFormattedString("fileType", [fileExtension.toUpperCase()]);
|
getFormattedString("fileType", [fileExtension.toUpperCase()]);
|
||||||
} else {
|
} else {
|
||||||
// If we can't even do that, just give up and show the MIME type.
|
// If we can't even do that, just give up and show the MIME type.
|
||||||
typeString = this.mLauncher.MIMEInfo.MIMEType;
|
typeString = this.mLauncher.MIMEInfo.MIMEType;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.title =
|
|
||||||
this.dialogElement("strings").getString("chooseAppFilePickerTitle");
|
|
||||||
params.description = typeString;
|
|
||||||
params.filename = this.mLauncher.suggestedFileName;
|
|
||||||
params.mimeInfo = this.mLauncher.MIMEInfo;
|
|
||||||
params.handlerApp = null;
|
|
||||||
|
|
||||||
this.mDialog.openDialog("chrome://global/content/appPicker.xul", null,
|
|
||||||
"chrome,modal,centerscreen,titlebar,dialog=yes",
|
|
||||||
params);
|
|
||||||
|
|
||||||
if (params.handlerApp &&
|
|
||||||
params.handlerApp.executable &&
|
|
||||||
params.handlerApp.executable.isFile()) {
|
|
||||||
// Remember the file they chose to run.
|
|
||||||
this.chosenApp = params.handlerApp;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
var params = {};
|
||||||
|
params.title =
|
||||||
|
this.dialogElement("strings").getString("chooseAppFilePickerTitle");
|
||||||
|
params.description = typeString;
|
||||||
|
params.filename = this.mLauncher.suggestedFileName;
|
||||||
|
params.mimeInfo = this.mLauncher.MIMEInfo;
|
||||||
|
params.handlerApp = null;
|
||||||
|
|
||||||
|
this.mDialog.openDialog("chrome://global/content/appPicker.xul", null,
|
||||||
|
"chrome,modal,centerscreen,titlebar,dialog=yes",
|
||||||
|
params);
|
||||||
|
|
||||||
|
if (params.handlerApp &&
|
||||||
|
params.handlerApp.executable &&
|
||||||
|
params.handlerApp.executable.isFile()) {
|
||||||
|
// Remember the file they chose to run.
|
||||||
|
this.chosenApp = params.handlerApp;
|
||||||
|
}
|
||||||
|
#else
|
||||||
#if MOZ_WIDGET_GTK == 3
|
#if MOZ_WIDGET_GTK == 3
|
||||||
var nsIApplicationChooser = Components.interfaces.nsIApplicationChooser;
|
var nsIApplicationChooser = Components.interfaces.nsIApplicationChooser;
|
||||||
var appChooser = Components.classes["@mozilla.org/applicationchooser;1"]
|
var appChooser = Components.classes["@mozilla.org/applicationchooser;1"]
|
||||||
|
|
@ -1103,6 +1104,7 @@ nsUnknownContentTypeDialog.prototype = {
|
||||||
this.chosenApp = localHandlerApp;
|
this.chosenApp = localHandlerApp;
|
||||||
}
|
}
|
||||||
#endif // MOZ_WIDGET_GTK == 3
|
#endif // MOZ_WIDGET_GTK == 3
|
||||||
|
#endif // XP_WIN
|
||||||
}
|
}
|
||||||
this.finishChooseApp();
|
this.finishChooseApp();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue