Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Web Intents: What They Are and Their Current Implementation Status

Web Intents: What They Are and Their Current Implementation Status

Leia em Português

This article shortly explains what Web Intents are and why they are useful. Google has enabled Web Intents in Chrome 19, the implementation being available to Safari via WebKit, and Mozilla is also working on it.

Web Intents are a relatively new RPC-like mechanism enabling communication between web applications by passing data between a client -typically a web page but not only-, and services – web page, extension APIs, plug-ins, OS handlers, etc.- that know how to handle and process the respective data, sending back a result. The entire process is mediated by the User Agent, usually a browser, that lets the user decide which service to perform the action associated with the intent. Web Intents are similar to Android Intents, and was initially proposed by Google last year, being accepted as a draft document by W3C with the aim to be included in HTML.Next.

Google has been the first to implement Web Intents in Google Chrome, an experimental version being included in the recently released Chrome 19. To be able to use intents, a client needs to declare one, using the <intent> tag, specifying the action to be performed and the type of data that needs to be processed, as show in the following snippet:

<intent    action=""    type="image/*" />

The client should also include intent invocation code, which for a web page looks like this:

var intent = new Intent(      "",      "image/*",      ""  ); window.navigator.startActivity(intent);

When the intent is invoked, the User Agent will ask the user to select a service from a list of known services, passing the data (in this case “image.png”) to the selected service which will process it and possibly return a result back. For the moment, intent services need to be registered as Chrome extensions via the Chrome Web Store, but in the future other solutions may be available. The W3C draft also mentions Explicit Intents, an option for the client to specify which service wants to use, the User Agent having the option to inform or not the user on using the respective service. This option is useful when the web app author wants to employ a certain service.

Currently, the following actions are available for intents: share, view, edit, save, pick, and subscribe. Developers can create their own actions if these are not enough.

Web Intents represent the next logical step beyond mashups. Instead of just aggregating data from multiple sources, Web Intents enables data processing by various services belonging to different entities. Possible use cases are: integrating third party search results, editing images, authenticating logins, and others., a website with related resources, provides a number of demos including a Twitter poster and a URL shortener.

Since Google has committed their code to WebKit, it is expected that Safari will include Web Intents in a future version. Firefox has also started work on intents, a Firefox bug being opened and quite active. Mozilla has decided to prototype the intents in Gaia, moving them to Gecko when they are stable. We are not aware of Microsoft’s plans on Web Intents.

Website owners do not need to wait until all major browsers will support Web Intents, they being able to use a JavaScript shim library which will automatically defer to the browser implementation when done.

Rate this Article