mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1055144 - Change callback-based sendMessageToJava calls to Messaging.sendRequestForResult. r=wesj
This commit is contained in:
parent
3897b56bac
commit
c4e17bbd52
@ -233,28 +233,18 @@ function getSelectionHandler() {
|
||||
}
|
||||
|
||||
function ok(one, msg) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
sendMessageToJava({
|
||||
type: "Robocop:testSelectionHandler",
|
||||
result: one,
|
||||
msg: msg
|
||||
},
|
||||
function (res, err) {
|
||||
(err) ? reject(err) : resolve(res);
|
||||
});
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testSelectionHandler",
|
||||
result: one,
|
||||
msg: msg
|
||||
});
|
||||
}
|
||||
|
||||
function is(one, two, msg) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
sendMessageToJava({
|
||||
type: "Robocop:testSelectionHandler",
|
||||
result: one === two,
|
||||
msg: msg + " : " + one + " === " + two
|
||||
},
|
||||
function (res, err) {
|
||||
(err) ? reject(err) : resolve(res);
|
||||
});
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Robocop:testSelectionHandler",
|
||||
result: one === two,
|
||||
msg: msg + " : " + one + " === " + two
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -32,20 +32,11 @@ function send_test_message(type) {
|
||||
}
|
||||
|
||||
function send_message_for_response(type, response) {
|
||||
sendMessageToJava({
|
||||
Messaging.sendRequestForResult({
|
||||
type: type,
|
||||
response: response,
|
||||
}, (success, error) => {
|
||||
if (response === "success") {
|
||||
do_check_eq(success, response);
|
||||
do_check_eq(error, null);
|
||||
} else if (response === "error") {
|
||||
do_check_eq(success, null);
|
||||
do_check_eq(error, response);
|
||||
} else {
|
||||
do_throw("Unexpected response: " + response);
|
||||
}
|
||||
});
|
||||
}).then(result => do_check_eq(result, response),
|
||||
error => do_check_eq(error, response));
|
||||
}
|
||||
|
||||
function finish_test() {
|
||||
|
@ -64,7 +64,7 @@ let WebappRT = {
|
||||
}
|
||||
|
||||
// If the app is in debug mode, configure and enable the remote debugger.
|
||||
sendMessageToJava({ type: "NativeApp:IsDebuggable" }, (response) => {
|
||||
Messaging.sendRequestForResult({ type: "NativeApp:IsDebuggable" }).then((response) => {
|
||||
if (response.isDebuggable) {
|
||||
this._enableRemoteDebugger(aUrl);
|
||||
}
|
||||
|
@ -19,10 +19,10 @@ ActivitiesGlue.prototype = {
|
||||
|
||||
// Ignore aActivities results on Android, go straight to Android intents.
|
||||
chooseActivity: function ap_chooseActivity(aOptions, aActivities, aCallback) {
|
||||
sendMessageToJava({
|
||||
Messaging.sendRequestForResult({
|
||||
type: "WebActivity:Open",
|
||||
activity: { name: aOptions.name, data: aOptions.data }
|
||||
}, (result) => {
|
||||
}).then((result) => {
|
||||
aCallback.handleEvent(Ci.nsIActivityUIGlueCallback.NATIVE_ACTIVITY, result);
|
||||
});
|
||||
}
|
||||
|
@ -33,20 +33,10 @@ Cu.import("resource://gre/modules/Promise.jsm");
|
||||
*/
|
||||
let Accounts = Object.freeze({
|
||||
_accountsExist: function (kind) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
sendMessageToJava({
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Accounts:Exist",
|
||||
kind: kind,
|
||||
}, (data, error) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
deferred.resolve(data.exists);
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}).then(data => data.exists);
|
||||
},
|
||||
|
||||
firefoxAccountsExist: function () {
|
||||
|
@ -14,9 +14,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "Prompt",
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Messaging",
|
||||
"resource://gre/modules/Messaging.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "sendMessageToJava",
|
||||
"resource://gre/modules/Messaging.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "ContentAreaUtils", function() {
|
||||
let ContentAreaUtils = {};
|
||||
Services.scriptloader.loadSubScript("chrome://global/content/contentAreaUtils.js", ContentAreaUtils);
|
||||
@ -147,7 +144,7 @@ var HelperApps = {
|
||||
return [];
|
||||
return parseData(data);
|
||||
} else {
|
||||
sendMessageToJava(msg, function(data) {
|
||||
Messaging.sendRequestForResult(msg).then(function(data) {
|
||||
callback(parseData(data));
|
||||
});
|
||||
}
|
||||
@ -196,9 +193,7 @@ var HelperApps = {
|
||||
className: app.activityName
|
||||
});
|
||||
|
||||
sendMessageToJava(msg, function(data) {
|
||||
callback(data);
|
||||
});
|
||||
Messaging.sendRequestForResult(msg).then(callback);
|
||||
} else {
|
||||
let msg = this._getMessage("Intent:Open", uri, {
|
||||
packageName: app.packageName,
|
||||
@ -211,7 +206,7 @@ var HelperApps = {
|
||||
|
||||
_sendMessageSync: function(msg) {
|
||||
let res = null;
|
||||
sendMessageToJava(msg, function(data) {
|
||||
Messaging.sendRequestForResult(msg).then(function(data) {
|
||||
res = data;
|
||||
});
|
||||
|
||||
|
@ -23,7 +23,9 @@ function send(type, data, callback) {
|
||||
msg[i] = data[i];
|
||||
}
|
||||
|
||||
sendMessageToJava(msg, callback);
|
||||
Messaging.sendRequestForResult(msg)
|
||||
.then(result => callback(result, null),
|
||||
error => callback(null, error));
|
||||
}
|
||||
|
||||
/* These apps represent players supported natively by the platform. This class will proxy commands
|
||||
|
@ -171,7 +171,7 @@ Prompt.prototype = {
|
||||
},
|
||||
|
||||
_innerShow: function() {
|
||||
sendMessageToJava(this.msg, (data) => {
|
||||
Messaging.sendRequestForResult(this.msg).then((data) => {
|
||||
if (this.callback)
|
||||
this.callback(data);
|
||||
});
|
||||
|
@ -153,8 +153,9 @@ Sanitizer.prototype = {
|
||||
history: {
|
||||
clear: function ()
|
||||
{
|
||||
return new Promise(function(resolve, reject) {
|
||||
sendMessageToJava({ type: "Sanitize:ClearHistory" }, function() {
|
||||
return Messaging.sendRequestForResult({ type: "Sanitize:ClearHistory" })
|
||||
.catch() // Purge Gecko-side data even if request failed
|
||||
.then(function() {
|
||||
try {
|
||||
Services.obs.notifyObservers(null, "browser:purge-session-history", "");
|
||||
}
|
||||
@ -164,10 +165,7 @@ Sanitizer.prototype = {
|
||||
var predictor = Cc["@mozilla.org/network/predictor;1"].getService(Ci.nsINetworkPredictor);
|
||||
predictor.reset();
|
||||
} catch (e) { }
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
get canClear()
|
||||
|
@ -109,13 +109,13 @@ SharedPreferencesImpl.prototype = Object.freeze({
|
||||
|
||||
_get: function _get(prefs, callback) {
|
||||
let result = null;
|
||||
sendMessageToJava({
|
||||
Messaging.sendRequestForResult({
|
||||
type: "SharedPreferences:Get",
|
||||
preferences: prefs,
|
||||
scope: this._scope,
|
||||
profileName: this._profileName,
|
||||
branch: this._branch,
|
||||
}, (data) => {
|
||||
}).then((data) => {
|
||||
result = data.values;
|
||||
});
|
||||
|
||||
|
@ -176,7 +176,7 @@ var SimpleServiceDiscovery = {
|
||||
},
|
||||
|
||||
getAndroidDevices: function() {
|
||||
sendMessageToJava({ type: "MediaPlayer:Get" }, (result) => {
|
||||
Messaging.sendRequestForResult({ type: "MediaPlayer:Get" }).then((result) => {
|
||||
for (let id in result.displays) {
|
||||
let display = result.displays[id];
|
||||
|
||||
@ -193,7 +193,7 @@ var SimpleServiceDiscovery = {
|
||||
|
||||
this._addService(service);
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
_searchFixedTargets: function _searchFixedTargets() {
|
||||
|
@ -23,7 +23,6 @@ Cu.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Notifications", "resource://gre/modules/Notifications.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Messaging", "resource://gre/modules/Messaging.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "sendMessageToJava", "resource://gre/modules/Messaging.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm", "resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "Strings", function() {
|
||||
@ -107,16 +106,14 @@ this.WebappManager = {
|
||||
return;
|
||||
}
|
||||
|
||||
sendMessageToJava({
|
||||
Messaging.sendRequestForResult({
|
||||
type: "Webapps:InstallApk",
|
||||
filePath: filePath,
|
||||
data: aMessage,
|
||||
}, (data, error) => {
|
||||
if (!!error) {
|
||||
aMessage.error = error;
|
||||
aMessageManager.sendAsyncMessage("Webapps:Install:Return:KO", aMessage);
|
||||
debug("error downloading APK: " + error);
|
||||
}
|
||||
}).catch(function (error) {
|
||||
aMessage.error = error;
|
||||
aMessageManager.sendAsyncMessage("Webapps:Install:Return:KO", aMessage);
|
||||
debug("error downloading APK: " + error);
|
||||
});
|
||||
}).bind(this)); },
|
||||
|
||||
@ -460,14 +457,10 @@ this.WebappManager = {
|
||||
}).bind(this)); },
|
||||
|
||||
_getAPKVersions: function(packageNames) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
sendMessageToJava({
|
||||
return Messaging.sendRequestForResult({
|
||||
type: "Webapps:GetApkVersions",
|
||||
packageNames: packageNames
|
||||
}, data => deferred.resolve(data.versions));
|
||||
|
||||
return deferred.promise;
|
||||
}).then(data => data.versions);
|
||||
},
|
||||
|
||||
_getInstalledApps: function() {
|
||||
@ -585,16 +578,14 @@ this.WebappManager = {
|
||||
// TODO: figure out why Webapps:InstallApk needs the "from" property.
|
||||
from: apk.app.installOrigin,
|
||||
};
|
||||
sendMessageToJava({
|
||||
Messaging.sendRequestForResult({
|
||||
type: "Webapps:InstallApk",
|
||||
filePath: apk.filePath,
|
||||
data: msg,
|
||||
}, (data, error) => {
|
||||
if (!!error) {
|
||||
// There's no page to report back to so drop the error.
|
||||
// TODO: we should notify the user about this failure.
|
||||
debug("APK install failed : " + returnError);
|
||||
}
|
||||
}).catch((error) => {
|
||||
// There's no page to report back to so drop the error.
|
||||
// TODO: we should notify the user about this failure.
|
||||
debug("APK install failed : " + error);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user