Bug 1121318 - Cleanup formatting in HelperApps.jsm r=rnewman
--- a/mobile/android/modules/HelperApps.jsm
+++ b/mobile/android/modules/HelperApps.jsm
@@ -105,19 +105,19 @@ var HelperApps = {
getAppsForUri: function getAppsForUri(uri, flags = { }, callback) {
flags.filterBrowsers = "filterBrowsers" in flags ? flags.filterBrowsers : true;
flags.filterHtml = "filterHtml" in flags ? flags.filterHtml : true;
// Query for apps that can/can't handle the mimetype
let msg = this._getMessage("Intent:GetHandlers", uri, flags);
let parseData = (d) => {
let apps = []
-
- if (!d)
+ if (!d) {
return apps;
+ }
apps = this._parseApps(d.apps);
if (flags.filterBrowsers) {
apps = apps.filter((app) => {
return app.name && !this.defaultBrowsers[app.name];
});
}
@@ -135,18 +135,16 @@ var HelperApps = {
}
}
return apps;
};
if (!callback) {
let data = this._sendMessageSync(msg);
- if (!data)
- return [];
return parseData(data);
} else {
Messaging.sendRequestForResult(msg).then(function(data) {
callback(parseData(data));
});
}
},
@@ -168,19 +166,20 @@ var HelperApps = {
"activityName" : appInfo[i+3]}));
}
return apps;
},
_getMessage: function(type, uri, options = {}) {
let mimeType = options.mimeType;
- if (uri && mimeType == undefined)
+ if (uri && mimeType == undefined) {
mimeType = ContentAreaUtils.getMIMETypeForURI(uri) || "";
-
+ }
+
return {
type: type,
mime: mimeType,
action: options.action || "", // empty action string defaults to android.intent.action.VIEW
url: uri ? uri.spec : "",
packageName: options.packageName || "",
className: options.className || ""
};
@@ -206,14 +205,15 @@ var HelperApps = {
_sendMessageSync: function(msg) {
let res = null;
Messaging.sendRequestForResult(msg).then(function(data) {
res = data;
});
let thread = Services.tm.currentThread;
- while (res == null)
+ while (res == null) {
thread.processNextEvent(true);
+ }
return res;
},
};