Are there plans to expose these APIs to GeckoView?

-Heath Borders
[email protected]
Twitter: heathborders
http://heath-tech.blogspot.com


On Tue, Aug 12, 2014 at 2:12 PM, Brian Nicholson <[email protected]>
wrote:

> For awhile, we've had the ability to send requests from JS->Java with
> sendMessageToJava like so:
>
> sendMessageToJava({
>   type: "Message:ToJava",
>   data: "foo"
> }, function (result) {
>   dump("Java responded with " + result);
> });
>
>
> Since bug 967325 has landed, we can now go the opposite direction.
> Requests to Gecko look like this:
>
> GeckoAppShell.
> sendRequestToGecko(new GeckoRequest("Message:ToGecko", "foo") {
>     @Override
>     public void onResponse(NativeJSObject response) {
>         Log.d(LOGTAG, "Gecko responded with " +
> response.getString("value"));
>     }
> });
>
> On the Gecko side, a request listener is set up like so
> (RequestService is imported from Messaging.jsm):
>
> RequestService.addListener(function (data) {
>   return { value: "bar" };
> }, "Message:ToGecko");
>
>
> This API should allow us to kill off our "X:Get"/"X:Data" pattern
> we've been using. One important requirement with the listener callback
> is that it *must* return a value to be used as the response, and that
> value *must* be a serializable JS object. It will throw if you don't
> return a result, and it will throw if that result is a string, number,
> null, etc. -- anything other than an object.
>
> See testGeckoRequest.js/testGeckoRequest.java for some code samples,
> and Messaging.jsm/GeckoRequest.java for more extensive documentation.
>
> Brian
> _______________________________________________
> mobile-firefox-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/mobile-firefox-dev
>
_______________________________________________
mobile-firefox-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/mobile-firefox-dev

Reply via email to