VulpesOS/gaia/tools/extensions/browser-helper@gaiamobile.org/content/panel/controls.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

78 lines
1.8 KiB
JavaScript
Executable file

!function() {
function sendChromeEvent(detail) {
var contentDetail = Components.utils.createObjectIn(tab);
for (var i in detail) {
contentDetail[i] = detail[i];
}
Components.utils.makeObjectPropsNormal(contentDetail);
var customEvt = tab.document.createEvent('CustomEvent');
customEvt.initCustomEvent('mozChromeEvent', true, true, contentDetail);
tab.dispatchEvent(customEvt);
}
function sendEvent(type, details) {
var event = new tab.CustomEvent(type, details);
tab.dispatchEvent(event);
}
function takeScreenshot() {
var canvas = document.createElementNS('http://www.w3.org/1999/xhtml',
'canvas');
var width = tab.innerWidth;
var height = tab.innerHeight;
canvas.setAttribute('width', width);
canvas.setAttribute('height', height);
var context = canvas.getContext('2d');
var flags =
context.DRAWWINDOW_DRAW_CARET |
context.DRAWWINDOW_DRAW_VIEW |
context.DRAWWINDOW_USE_WIDGET_LAYERS;
context.drawWindow(tab, 0, 0, width, height,
'rgb(255,255,255)', flags);
sendChromeEvent({
type: 'take-screenshot-success',
file: canvas.mozGetAsFile('screenshot', 'image/png')
});
}
function Emulation() {
}
Emulation.prototype = {
notification: function() {
sendChromeEvent({
type: 'desktop-notification',
id: 123,
title: 'Some Notification',
text: 'I love notifications.',
manifestURL: 'http://sytem.gaiamobile.org:8080/manifest.webapp'
});
}
};
window.emulation = new Emulation();
function Workflow() {
}
Workflow.prototype = {
reload: function() {
var global = tab.wrappedJSObject;
var app = global.System.curentApp;
app.reload();
},
screenshot: function() {
takeScreenshot();
}
}
window.workflow = new Workflow();
}();