- From: James Hawkins <jhawkins@google.com>
- Date: Sun, 29 Jan 2012 18:18:17 -0800
- To: WebIntents <public-web-intents@w3.org>
Many use cases require passing optional, extra parameters from the client to the service and vice versa. Consider an example client invoking the Pick intent: a web mail client using Pick for attachments. The current implementation allows the user browse the file system and pick a file to attach: this file has a filename, and that filename is displayed in the UI. Using the Pick intent, the mail client can receive, say, an image to attach, but currently there is no way to correlate a filename with the picked image. I propose following the precedence set by Android Intents [1] to solve this problem: add an optional |extras| dictionary to the Intent object. Documentation for intent actions could specify handling of optional extra parameters, e.g., filename for Pick. [Constructor(in string action, in string type, in any data)] interface Intent { readonly attribute DOMString action; readonly attribute DOMString type; readonly attribute any data; readonly attribute Dictionary extras; <--- Added void postResult (any data, optional Dictionary extras); <--- |extras| added void postFailure (any data); }; Client: document.getElementById('attach').onclick = function() { var intent = new Intent("http://webintents.org/pick", "*"); navigator.startActivity(intent, filePicked); }); Service: if (window.intent) { .... window.intent.postResult(selectedFile, {filename: selectedFilename}); } What do you think? [1] http://developer.android.com/reference/android/content/Intent.html, search for 'extras'. Thanks, James
Received on Monday, 30 January 2012 02:19:25 UTC