
Interaction between web applications through Web Intents
- Transfer
Note: I usually don’t do translations, but the news slipped interesting.
In today's browser ecosystem, web applications are completely isolated from each other, and in order to, for example, send a comment to Twitter via a third-party service from your website, you need to use complex ( Note: well, I would just say “diverse” ) . But what if we could give sites the opportunity to use such services without knowing what specific service we will use, but only knowing that it provides some functionality.
On Android OS, this problem is solved with Intents [1]- An architecture that allows the components of one or more different applications to interact. According to this scheme, the client application creates a request (for example, send something) and sets the parameters that will be transferred to another service application. After that, the user is presented with a list of applications that registered their ability to process this type of intent request. Then the application selected by the user is launched in a new context, and parameters passed to it by the client in a certain format predefined for a particular type of intent are passed to it.
At the moment, we are making great efforts to create a similar system for SheB: Web Intents . This system will provide the same amenities as Intents for Android, but will be adapted for web applications.
We consider it our main and most important task to develop a simple and easy-to-use API. Using Web Intents, you can connect a web application to the necessary service using only two lines of code! Chome will do the rest for you.
As in Android, Web Intents will cover a basic set of actions (such as editing, browsing, etc.) that should satisfy most of the needs of modern sites. However, with the growth of the world wide web, sites offer more and more functionality. And so they will be given the opportunity to create new types of Intent, which they themselves will be able to publish and document. We also plan to create a special site where you can view existing and new intents.
Consider, for example, a site that hosts photo hosting, whose developers are not able to afford to add an online image editor to the site, but understand that without this feature the service will not become popular. Web Intent will allow them to get what they want with a minimum of effort:
Any site, for example, a meme generator (note: well, or demotivators, if you want) that the user visits, will be able to declare the ability to process intent of type EDIT (editing) for files of type image / * using the following declaration:
When a user needs to edit an image, this service will be offered to the user along with other registered image editors. And if the user selects the meme generator, in the new context, the corresponding site will open, which can receive data from intent in the following way:
After calling postResult (), the context created for the meme generator will be closed, and the received data will be passed to our application through a callback passed to startActivity (). (Note: in this example, loadEditedImage)
The Mozilla guys are also working in this direction . Moreover, we work closely with their engineers to create a single simple and useful API.
We suggest you try a new opportunity in any modern browser on the page with examples . Those who want to try the Intents API on their site can use this patch for browsers that do not support this feature.
We are quickly prototyping this feature, so check back soon to announce when Web Intents will be available behind the flag in Chrome. We are working intensively on the prototype, so wait for the announcement when Web Intents become an option in Chome, in the near future!
- [1] - intent - literally “intention”. Write in the comments how best to translate this term ... if at all it needs to be translated
In today's browser ecosystem, web applications are completely isolated from each other, and in order to, for example, send a comment to Twitter via a third-party service from your website, you need to use complex ( Note: well, I would just say “diverse” ) . But what if we could give sites the opportunity to use such services without knowing what specific service we will use, but only knowing that it provides some functionality.
On Android OS, this problem is solved with Intents [1]- An architecture that allows the components of one or more different applications to interact. According to this scheme, the client application creates a request (for example, send something) and sets the parameters that will be transferred to another service application. After that, the user is presented with a list of applications that registered their ability to process this type of intent request. Then the application selected by the user is launched in a new context, and parameters passed to it by the client in a certain format predefined for a particular type of intent are passed to it.
At the moment, we are making great efforts to create a similar system for SheB: Web Intents . This system will provide the same amenities as Intents for Android, but will be adapted for web applications.
We consider it our main and most important task to develop a simple and easy-to-use API. Using Web Intents, you can connect a web application to the necessary service using only two lines of code! Chome will do the rest for you.
As in Android, Web Intents will cover a basic set of actions (such as editing, browsing, etc.) that should satisfy most of the needs of modern sites. However, with the growth of the world wide web, sites offer more and more functionality. And so they will be given the opportunity to create new types of Intent, which they themselves will be able to publish and document. We also plan to create a special site where you can view existing and new intents.
Consider, for example, a site that hosts photo hosting, whose developers are not able to afford to add an online image editor to the site, but understand that without this feature the service will not become popular. Web Intent will allow them to get what they want with a minimum of effort:
var intent = new Intent(Intent.EDIT, ‘image/png’, getImageDataURI());
window.navigator.startActivity(intent, loadEditedImage);
// This callback will be called when the service replies with the edited
// image data.
function loadEditedImage(data) {
var image = document.getElementById(‘image’);
setImageData(image, data);
}
Any site, for example, a meme generator (note: well, or demotivators, if you want) that the user visits, will be able to declare the ability to process intent of type EDIT (editing) for files of type image / * using the following declaration:
When a user needs to edit an image, this service will be offered to the user along with other registered image editors. And if the user selects the meme generator, in the new context, the corresponding site will open, which can receive data from intent in the following way:
var intent = window.intent;
memeImg.src = intent.data;
memegenForm.onsubmit = function() {
// Transform the image - meme it.
addMemeTaglines(memeImg, memeTopText, memeBottomText);
// Send the generated meme back to the client.
intent.postResult(getImageData(memeImg));
};
After calling postResult (), the context created for the meme generator will be closed, and the received data will be passed to our application through a callback passed to startActivity (). (Note: in this example, loadEditedImage)
The Mozilla guys are also working in this direction . Moreover, we work closely with their engineers to create a single simple and useful API.
We suggest you try a new opportunity in any modern browser on the page with examples . Those who want to try the Intents API on their site can use this patch for browsers that do not support this feature.
- [1] - intent - literally “intention”. Write in the comments how best to translate this term ... if at all it needs to be translated