mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 710548 - Add offline-app and webapp-manage permissions to pre-installed apps r=cjones DONTBUILD since this is b2g/ only
This commit is contained in:
parent
1ab4c87fe8
commit
a486f20abe
@ -66,6 +66,7 @@ pref("image.cache.size", 1048576); // bytes
|
||||
|
||||
/* offline cache prefs */
|
||||
pref("browser.offline-apps.notify", false);
|
||||
pref("browser.cache.offline.enable", false);
|
||||
|
||||
/* protocol warning prefs */
|
||||
pref("network.protocol-handler.warn-external.tel", false);
|
||||
|
@ -72,11 +72,19 @@ function startupHttpd(baseDir, port) {
|
||||
server.start(port);
|
||||
}
|
||||
|
||||
// XXX until we have a security model, just let the pre-installed
|
||||
// app used indexedDB.
|
||||
function allowIndexedDB(url) {
|
||||
let uri = Services.io.newURI(url, null, null);
|
||||
Services.perms.add(uri, 'indexedDB', Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
// FIXME Bug 707625
|
||||
// until we have a proper security model, add some rights to
|
||||
// the pre-installed web applications
|
||||
function addPermissions(urls) {
|
||||
let permissions = ['indexedDB', 'webapps-manage', 'offline-app'];
|
||||
urls.forEach(function(url) {
|
||||
let uri = Services.io.newURI(url, null, null);
|
||||
let allow = Ci.nsIPermissionManager.ALLOW_ACTION;
|
||||
|
||||
permissions.forEach(function(permission) {
|
||||
Services.perms.add(uri, permission, allow);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -135,7 +143,7 @@ var shell = {
|
||||
let baseHost = 'http://localhost';
|
||||
homeURL = homeURL.replace(baseDir, baseHost + ':' + SERVER_PORT);
|
||||
}
|
||||
allowIndexedDB(homeURL);
|
||||
addPermissions([homeURL]);
|
||||
} catch (e) {
|
||||
let msg = 'Fatal error during startup: [' + e + '[' + homeURL + ']';
|
||||
return alert(msg);
|
||||
@ -200,6 +208,9 @@ var shell = {
|
||||
break;
|
||||
case 'MozApplicationManifest':
|
||||
try {
|
||||
if (!Services.prefs.getBoolPref('browser.cache.offline.enable'))
|
||||
return;
|
||||
|
||||
let contentWindow = evt.originalTarget.defaultView;
|
||||
let documentElement = contentWindow.document.documentElement;
|
||||
if (!documentElement)
|
||||
@ -210,10 +221,18 @@ var shell = {
|
||||
return;
|
||||
|
||||
let documentURI = contentWindow.document.documentURIObject;
|
||||
let manifestURI = Services.io.newURI(manifest, null, documentURI);
|
||||
if (!Services.perms.testPermission(documentURI, 'offline-app')) {
|
||||
if (Services.prefs.getBoolPref('browser.offline-apps.notify')) {
|
||||
// FIXME Bug 710729 - Add a UI for offline cache notifications
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Services.perms.add(documentURI, 'offline-app',
|
||||
Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
|
||||
let manifestURI = Services.io.newURI(manifest, null, documentURI);
|
||||
let updateService = Cc['@mozilla.org/offlinecacheupdate-service;1']
|
||||
.getService(Ci.nsIOfflineCacheUpdateService);
|
||||
updateService.scheduleUpdate(manifestURI, documentURI, window);
|
||||
|
Loading…
Reference in New Issue
Block a user