Added in some code to expose the path to the os default application. Tested via tests on Windows. Mac and Linux will use the nsMIMEInfoImpl which will supply the functionality for them and be tested with the auto-tests.
Differential Revision: https://phabricator.services.mozilla.com/D204306
Some code to exercise this in the browser console:
```
{
const printNames = async (appList) => {
let buffer = "Start:\n";
for (let index = 0; index < appList4.length; index++) {
let app = appList4.queryElementAt(index, Ci.nsILocalHandlerApp);
buffer += app.executable.leafName;
buffer += "\n";
}
buffer += "\n";
for (let index = 0; index < appList4.length; index++) {
let app = appList4.queryElementAt(index, Ci.nsILocalHandlerApp);
let prettyName = await app.prettyNameAsync();
buffer += prettyName;
buffer += "\n";
}
buffer += "\n";
for (let index = 0; index < appList4.length; index++) {
let app = appList4.queryElementAt(index, Ci.nsILocalHandlerApp);
buffer += app.executable.displayName;
buffer += "\n";
}
buffer += "\n";
for (let index = 0; index < appList4.length; index++) {
let app = appList4.queryElementAt(index, Ci.nsILocalHandlerApp);
if (AppConstants.platform == "win") {
let file = app.executable;
if (file instanceof Ci.nsILocalFileWin) {
try {
buffer += file.getVersionInfoField("FileDescription");
} catch (e) {
}
}
}
buffer += "\n";
}
buffer += "\nEnd\n";
console.log(buffer);
};
const lazy4 = {};
XPCOMUtils.defineLazyServiceGetters(lazy4, {
gMIMEService: ["@mozilla.org/mime;1", "nsIMIMEService"],
});
let mimeInfo4 = lazy4.gMIMEService.getFromTypeAndExtension("text/html", "html");
if (mimeInfo4.hasDefaultHandler) {
console.log(`HasDefaultHandler = true`);
console.log(`Description = ${mimeInfo4.defaultDescription}`);
} else {
console.log(`HasDefaultHandler = false`);
}
let appList4 = mimeInfo4.possibleLocalHandlers || [];
console.log("appList4 = ");
console.log(JSON.stringify(appList4));
printNames(appList4);
}
```
That produces output that can be seen in a pretty form here:
https://docs.google.com/spreadsheets/d/1OvtrZgMlPMJO4Wgu6wwAYvm89orj9HdS_tsDxYn7yrA/edit#gid=0
This does not fix-up things so that all calls to getName() on the LocalHandlerApp are switched to prettyNameAsync. That work is tracked here: https://bugzilla.mozilla.org/show_bug.cgi?id=1884267
Differential Revision: https://phabricator.services.mozilla.com/D203876
Some code to exercise this in the browser console:
```
{
const printNames = async (appList) => {
let buffer = "Start:\n";
for (let index = 0; index < appList4.length; index++) {
let app = appList4.queryElementAt(index, Ci.nsILocalHandlerApp);
buffer += app.executable.leafName;
buffer += "\n";
}
buffer += "\n";
for (let index = 0; index < appList4.length; index++) {
let app = appList4.queryElementAt(index, Ci.nsILocalHandlerApp);
let prettyName = await app.prettyNameAsync();
buffer += prettyName;
buffer += "\n";
}
buffer += "\n";
for (let index = 0; index < appList4.length; index++) {
let app = appList4.queryElementAt(index, Ci.nsILocalHandlerApp);
buffer += app.executable.displayName;
buffer += "\n";
}
buffer += "\n";
for (let index = 0; index < appList4.length; index++) {
let app = appList4.queryElementAt(index, Ci.nsILocalHandlerApp);
if (AppConstants.platform == "win") {
let file = app.executable;
if (file instanceof Ci.nsILocalFileWin) {
try {
buffer += file.getVersionInfoField("FileDescription");
} catch (e) {
}
}
}
buffer += "\n";
}
buffer += "\nEnd\n";
console.log(buffer);
};
const lazy4 = {};
XPCOMUtils.defineLazyServiceGetters(lazy4, {
gMIMEService: ["@mozilla.org/mime;1", "nsIMIMEService"],
});
let mimeInfo4 = lazy4.gMIMEService.getFromTypeAndExtension("text/html", "html");
if (mimeInfo4.hasDefaultHandler) {
console.log(`HasDefaultHandler = true`);
console.log(`Description = ${mimeInfo4.defaultDescription}`);
} else {
console.log(`HasDefaultHandler = false`);
}
let appList4 = mimeInfo4.possibleLocalHandlers || [];
console.log("appList4 = ");
console.log(JSON.stringify(appList4));
printNames(appList4);
}
```
That produces output that can be seen in a pretty form here:
https://docs.google.com/spreadsheets/d/1OvtrZgMlPMJO4Wgu6wwAYvm89orj9HdS_tsDxYn7yrA/edit#gid=0
This does not fix-up things so that all calls to getName() on the LocalHandlerApp are switched to prettyNameAsync. That work is tracked here: https://bugzilla.mozilla.org/show_bug.cgi?id=1884267
Differential Revision: https://phabricator.services.mozilla.com/D203876
Added in some code to expose the path to the os default application. Tested via tests on Windows. Mac and Linux will use the nsMIMEInfoImpl which will supply the functionality for them and be tested with the auto-tests.
Differential Revision: https://phabricator.services.mozilla.com/D204306
Some code to exercise this in the browser console:
```
{
const printNames = async (appList) => {
let buffer = "Start:\n";
for (let index = 0; index < appList4.length; index++) {
let app = appList4.queryElementAt(index, Ci.nsILocalHandlerApp);
buffer += app.executable.leafName;
buffer += "\n";
}
buffer += "\n";
for (let index = 0; index < appList4.length; index++) {
let app = appList4.queryElementAt(index, Ci.nsILocalHandlerApp);
let prettyName = await app.prettyNameAsync();
buffer += prettyName;
buffer += "\n";
}
buffer += "\n";
for (let index = 0; index < appList4.length; index++) {
let app = appList4.queryElementAt(index, Ci.nsILocalHandlerApp);
buffer += app.executable.displayName;
buffer += "\n";
}
buffer += "\n";
for (let index = 0; index < appList4.length; index++) {
let app = appList4.queryElementAt(index, Ci.nsILocalHandlerApp);
if (AppConstants.platform == "win") {
let file = app.executable;
if (file instanceof Ci.nsILocalFileWin) {
try {
buffer += file.getVersionInfoField("FileDescription");
} catch (e) {
}
}
}
buffer += "\n";
}
buffer += "\nEnd\n";
console.log(buffer);
};
const lazy4 = {};
XPCOMUtils.defineLazyServiceGetters(lazy4, {
gMIMEService: ["@mozilla.org/mime;1", "nsIMIMEService"],
});
let mimeInfo4 = lazy4.gMIMEService.getFromTypeAndExtension("text/html", "html");
if (mimeInfo4.hasDefaultHandler) {
console.log(`HasDefaultHandler = true`);
console.log(`Description = ${mimeInfo4.defaultDescription}`);
} else {
console.log(`HasDefaultHandler = false`);
}
let appList4 = mimeInfo4.possibleLocalHandlers || [];
console.log("appList4 = ");
console.log(JSON.stringify(appList4));
printNames(appList4);
}
```
That produces output that can be seen in a pretty form here:
https://docs.google.com/spreadsheets/d/1OvtrZgMlPMJO4Wgu6wwAYvm89orj9HdS_tsDxYn7yrA/edit#gid=0
This does not fix-up things so that all calls to getName() on the LocalHandlerApp are switched to prettyNameAsync. That work is tracked here: https://bugzilla.mozilla.org/show_bug.cgi?id=1884267
Differential Revision: https://phabricator.services.mozilla.com/D203876
Renames all instances of the snake_case identifier to
camelCase to match more closely to idiomatic JavaScript
and to existing conventions throughout the code base.
Differential Revision: https://phabricator.services.mozilla.com/D198826