зеркало из https://github.com/mozilla/pjs.git
Bug 569542: fix appPicker.js's getFileDisplayName function, and make all copies of this method identical, r=Neil
--HG-- extra : rebase_source : 23f0da39af75427aaeb02ba32a1a88af3f339230
This commit is contained in:
Родитель
50ed10a73b
Коммит
ef236f55fd
|
@ -685,25 +685,17 @@ FeedWriter.prototype = {
|
||||||
if (file instanceof Ci.nsILocalFileWin) {
|
if (file instanceof Ci.nsILocalFileWin) {
|
||||||
try {
|
try {
|
||||||
return file.getVersionInfoField("FileDescription");
|
return file.getVersionInfoField("FileDescription");
|
||||||
}
|
} catch (e) {}
|
||||||
catch (e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
var lfm = file.QueryInterface(Ci.nsILocalFileMac);
|
if (file instanceof Ci.nsILocalFileMac) {
|
||||||
try {
|
try {
|
||||||
return lfm.bundleDisplayName;
|
return file.bundleDisplayName;
|
||||||
}
|
} catch (e) {}
|
||||||
catch (e) {
|
|
||||||
// fall through to the file name
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
var ios =
|
return file.leafName;
|
||||||
Cc["@mozilla.org/network/io-service;1"].
|
|
||||||
getService(Ci.nsIIOService);
|
|
||||||
var url = ios.newFileURI(file).QueryInterface(Ci.nsIURL);
|
|
||||||
return url.fileName;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -130,45 +130,28 @@ const APP_ICON_ATTR_NAME = "appHandlerIcon";
|
||||||
//****************************************************************************//
|
//****************************************************************************//
|
||||||
// Utilities
|
// Utilities
|
||||||
|
|
||||||
function getDisplayNameForFile(aFile) {
|
function getFileDisplayName(file) {
|
||||||
/*
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
*/
|
if (file instanceof Ci.nsILocalFileWin) {
|
||||||
if (aFile instanceof Ci.nsILocalFileWin) {
|
|
||||||
try {
|
try {
|
||||||
return aFile.getVersionInfoField("FileDescription");
|
return file.getVersionInfoField("FileDescription");
|
||||||
}
|
} catch (e) {}
|
||||||
catch(ex) {
|
|
||||||
// fall through to the file name
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
*/
|
if (file instanceof Ci.nsILocalFileMac) {
|
||||||
if (aFile instanceof Ci.nsILocalFileMac) {
|
|
||||||
try {
|
try {
|
||||||
return aFile.bundleDisplayName;
|
return file.bundleDisplayName;
|
||||||
}
|
} catch (e) {}
|
||||||
catch(ex) {
|
|
||||||
// fall through to the file name
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
#endif
|
#endif
|
||||||
*/
|
return file.leafName;
|
||||||
|
|
||||||
return Cc["@mozilla.org/network/io-service;1"].
|
|
||||||
getService(Ci.nsIIOService).
|
|
||||||
newFileURI(aFile).
|
|
||||||
QueryInterface(Ci.nsIURL).
|
|
||||||
fileName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLocalHandlerApp(aFile) {
|
function getLocalHandlerApp(aFile) {
|
||||||
var localHandlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
|
var localHandlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
|
||||||
createInstance(Ci.nsILocalHandlerApp);
|
createInstance(Ci.nsILocalHandlerApp);
|
||||||
localHandlerApp.name = getDisplayNameForFile(aFile);
|
localHandlerApp.name = getFileDisplayName(aFile);
|
||||||
localHandlerApp.executable = aFile;
|
localHandlerApp.executable = aFile;
|
||||||
|
|
||||||
return localHandlerApp;
|
return localHandlerApp;
|
||||||
|
@ -673,7 +656,7 @@ FeedHandlerInfo.prototype = {
|
||||||
if (defaultFeedReader) {
|
if (defaultFeedReader) {
|
||||||
let handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
|
let handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
|
||||||
createInstance(Ci.nsIHandlerApp);
|
createInstance(Ci.nsIHandlerApp);
|
||||||
handlerApp.name = getDisplayNameForFile(defaultFeedReader);
|
handlerApp.name = getFileDisplayName(defaultFeedReader);
|
||||||
handlerApp.QueryInterface(Ci.nsILocalHandlerApp);
|
handlerApp.QueryInterface(Ci.nsILocalHandlerApp);
|
||||||
handlerApp.executable = defaultFeedReader;
|
handlerApp.executable = defaultFeedReader;
|
||||||
|
|
||||||
|
@ -1268,7 +1251,7 @@ var gApplicationsPane = {
|
||||||
var preferredApp = aHandlerInfo.preferredApplicationHandler;
|
var preferredApp = aHandlerInfo.preferredApplicationHandler;
|
||||||
var name;
|
var name;
|
||||||
if (preferredApp instanceof Ci.nsILocalHandlerApp)
|
if (preferredApp instanceof Ci.nsILocalHandlerApp)
|
||||||
name = getDisplayNameForFile(preferredApp.executable);
|
name = getFileDisplayName(preferredApp.executable);
|
||||||
else
|
else
|
||||||
name = preferredApp.name;
|
name = preferredApp.name;
|
||||||
return this._prefsBundle.getFormattedString("useApp", [name]);
|
return this._prefsBundle.getFormattedString("useApp", [name]);
|
||||||
|
@ -1451,7 +1434,7 @@ var gApplicationsPane = {
|
||||||
menuItem.setAttribute("action", Ci.nsIHandlerInfo.useHelperApp);
|
menuItem.setAttribute("action", Ci.nsIHandlerInfo.useHelperApp);
|
||||||
let label;
|
let label;
|
||||||
if (possibleApp instanceof Ci.nsILocalHandlerApp)
|
if (possibleApp instanceof Ci.nsILocalHandlerApp)
|
||||||
label = getDisplayNameForFile(possibleApp.executable);
|
label = getFileDisplayName(possibleApp.executable);
|
||||||
else
|
else
|
||||||
label = possibleApp.name;
|
label = possibleApp.name;
|
||||||
label = this._prefsBundle.getFormattedString("useApp", [label]);
|
label = this._prefsBundle.getFormattedString("useApp", [label]);
|
||||||
|
@ -1739,7 +1722,7 @@ var gApplicationsPane = {
|
||||||
this._isValidHandlerExecutable(fp.file)) {
|
this._isValidHandlerExecutable(fp.file)) {
|
||||||
handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
|
handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
|
||||||
createInstance(Ci.nsILocalHandlerApp);
|
createInstance(Ci.nsILocalHandlerApp);
|
||||||
handlerApp.name = getDisplayNameForFile(fp.file);
|
handlerApp.name = getFileDisplayName(fp.file);
|
||||||
handlerApp.executable = fp.file;
|
handlerApp.executable = fp.file;
|
||||||
|
|
||||||
// Add the app to the type's list of possible handlers.
|
// Add the app to the type's list of possible handlers.
|
||||||
|
|
|
@ -148,22 +148,18 @@ AppPicker.prototype =
|
||||||
*/
|
*/
|
||||||
getFileDisplayName: function getFileDisplayName(file) {
|
getFileDisplayName: function getFileDisplayName(file) {
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
const nsILocalFileWin = Components.interfaces.nsILocalFileWin;
|
if (file instanceof Components.interfaces.nsILocalFileWin) {
|
||||||
if (file instanceof nsILocalFileWin) {
|
|
||||||
try {
|
try {
|
||||||
return file.getVersionInfoField("FileDescription");
|
return file.getVersionInfoField("FileDescription");
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
const nsILocalFileMac = Components.interfaces.nsILocalFileMac;
|
if (file instanceof Components.interfaces.nsILocalFileMac) {
|
||||||
if (file instanceof nsILocalFileMac) {
|
try {
|
||||||
try {
|
return file.bundleDisplayName;
|
||||||
return lfm.bundleDisplayName;
|
} catch (e) {}
|
||||||
} catch (e) {
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return file.leafName;
|
return file.leafName;
|
||||||
},
|
},
|
||||||
|
|
|
@ -970,8 +970,14 @@ nsUnknownContentTypeDialog.prototype = {
|
||||||
if (file instanceof Components.interfaces.nsILocalFileWin) {
|
if (file instanceof Components.interfaces.nsILocalFileWin) {
|
||||||
try {
|
try {
|
||||||
return file.getVersionInfoField("FileDescription");
|
return file.getVersionInfoField("FileDescription");
|
||||||
} catch (ex) {
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef XP_MACOSX
|
||||||
|
if (file instanceof Components.interfaces.nsILocalFileMac) {
|
||||||
|
try {
|
||||||
|
return file.bundleDisplayName;
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return file.leafName;
|
return file.leafName;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче