VulpesOS/gaia/apps/system/js/import.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

42 lines
991 B
JavaScript
Executable file

'use strict';
(function(exports) {
/**
* Handles importing of blobs into the system app.
* Currently supports the 'import-app' activity, which
* installs a blob on the device if developer mode is enabled.
*/
function Import() {}
Import.prototype = {
/**
* Starts listening to activities.
*/
start: function() {
window.addEventListener('activity-import-app',
this.handleActivity.bind(this));
},
/**
* Imports an application into the system.
*/
handleActivity: function(e) {
var blob = e.detail.source.data.blob;
navigator.mozApps.mgmt.import(blob)
.then((addon) => {
// Enable the addon by default.
navigator.mozApps.mgmt.setEnabled(addon, true);
e.detail.postResult({
manifestURL: addon.manifestURL
});
})
.catch((error) => {
e.detail.postError(error);
});
}
};
exports.Import = Import;
}(window));