(crossposting to dev-gaia, dev-b2g, dev-webapi, reply-to: dev-webapi) Hi,
In this crazy moment where we're allowed to reinvent everything, I'd like that we take some time to think about activities. From the start activities worked but never were quite satisfying, especially because they use API instead of URLs, and use system messages. Instead, we could use URLs and HTTP verbs. We could use an URL like activity://<activity>/parameters. Gecko would be responsible for transparently transforming this into eg app://<app_name>/activities/<activity>/parameters (or a HTTP URL of course). For example, instead of : new MozActivity({ name: 'pick', data: { type: ['image/*', 'audio/*', 'video/*', 'text/vcard'] } }).then(data => { // do something with data }).catch(e => { // handle error }); we could use: fetch({ method: 'GET', url: 'activity://pick/', headers: new Headers({ Accept: ['image/*', 'audio/*', 'video/*', 'text/vcard'].join(',') }) }).then(response => { if (response.status === 404) { // no handler for this activity } else { // do something with response.blob() } }).catch(e => { // handle error }); Similar things can happen for activities that share or open an element. So instead of: new MozActivity({ name: 'open', data: { type: mimetype, filename: filename, blob: blob, allowSave: true } }).catch(e => { // handle error }); We could have: fetch({ method: 'POST', url: 'activity://open/', headers: new Headers({ 'Content-Type', mimetype }), parameters: new URLSearchParams({ filename: filename, allowSave: 1 }), // I wish body: blob }).then(response => { if (response.status === 404) { // no handler for this activity } }).catch(e => { // handle error }); Then for the caller this is a lot similar. Now for the callee this could be handled with a fetch event in a Service Worker. self.addEventListener('fetch', function(event) { event.respondWith(new Promise((resolve, reject) => { if (event.request.url.startsWith('/activity/pick')) { resolve(ImagePicker.pickImage().then(blob => new Response(blob))); } })); }); But this could just as well be handled by a server-side server. Here are some issues I foresee: * such a request could take long to fulfill and should not timeout, because sometimes the request is handled by a user action. * currently all activities come from a user action. I think we can keep the same restriction in the ActivityProtocolHandler. For Mozilla this would be great, because this would be a depart from using a proprietary API. What do you think ? -- Julien
signature.asc
Description: OpenPGP digital signature
_______________________________________________ dev-b2g mailing list dev-b2g@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-b2g