Changes

Jump to: navigation, search

WebAPI/WebActivities

2,532 bytes added, 18:09, 30 May 2012
Add some explanations
bool isActivityHandlerRegistered(ActivityHandler handler);
};
 
== More information ==
Some various explanation regarding part of this API that are not self-explanatory.
 
=== Handling an activiy ===
Handling activities will be done trough [https://groups.google.com/group/mozilla.dev.webapi/browse_thread/thread/a3c6e4c31d04b663/ System Message Handler]. An ''ActivityHandlerRequest'' will be passed in the Message.
 
=== More information about ActivityOptions ===
 
Activities are defined with a name and some data. Those data can be stuff like the image to send, the type of the object or anything the activity will require. Activities with a specific name should have
specific data the handlers will expect to see. <br>
That means the initial specification should specify a set of basic activities.
 
=== More information about ActivityHandlerDescription ===
 
* ''href'': can be used to register an activity handler in another page. Needs to be same origin.
* ''disposition'': could be ''window'' or ''inline'' for the moment. ''window'' means it will show a new window/tab. ''inline'' means it will be shown above the current content. This is only a hint for the UA.
* ''returnValue'': the UA might want to know if the activity will return a value. For the basic activities (view, edit, etc.) the UA knows that but we need that at least for proprietary activities.<br>This seems seems to be needed to be able to send a ''success'' or ''error'' event when appropriate. If an application doesn't return a value, the UA might want to send a ''success'' event as soon as an application has been picked. If a value is expected, this event will have to wait ''postResult()'' to be called. Note that UA is expected to send an ''error'' event at some point if ''postError'' nor ''postResult'' are called. For example, if the user leaves the application (close the tab on desktop or goes back to the homescreen on a mobile device).
* ''filters'': this object should mirror ''data'' from ''ActivityOptions'' but the values for each fields can be an Array of string, a string or a regexp.An activity will be considered as able to handle an activity only if the filters are all satisfied. An array means OR for each items. If there is no filter value for a field, that means it is always satisfied.
 
=== Registration ===
 
You do not need to pass the same ''ActivityHandlerDescription'' object to have ''registerActivityHandler'', ''unregisterActivityHandler'' and ''isActivityHandlerRegistered'' working. You only need to pass an instance of ''ActivityHandlerDescription'' with the same attribute values.
== Examples ==
The ''data'' structure used in those the activities used in those examples shouldn't be considered as near to anything final. It is just a snapshot on how it could look like. Those examples goal is to underline the use of the API.
 
=== Launch an activity ===
View a png image:
Confirm
368
edits

Navigation menu