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