lundi 1 décembre 2014

Getting data from Google Chrome Webview to Caller/Parent window


I'm working on a Chrome Kiosk Application (So packaged app limitations apply) that's essentially a web browser that will be deployed to some Chrome devices. I'm looking to support screenshots, and I'm using HTML2Canvas to do this, but I need to store them to be uploaded later on.


I'm calling HTML2Canvas by using webview.executeScript{file:} with a callback. In the callback I'm executing the actual html2canvas call



webview.executeScript({ file: "kiosk/html2canvas.js" }, handleHTML2CanvasInjected);

function handleHTML2CanvasInjected(event) {
var webview = document.querySelector('webview');
webview.executeScript({code: "html2canvas(document.body).then(function(canvas){ //whatever });"});
}


I can append the canvas object to the body and see that the screenshot is working. However, I need this to be returned to the caller.


I've tried to use localStorage, but it seems the webviews storage and the caller's storage are two different things.


It really boils down to the fact that I need to be able to communicate "stuff" between a Webview and the Window that created the Webview.





Aucun commentaire:

Enregistrer un commentaire