зеркало из https://github.com/mozilla/gecko-dev.git
Bug 709013 - Handle the MozApplicationManifest event in b2g/. r=cjones
--HG-- extra : rebase_source : 56149e16c771d1aa40f9ecc6edfdbab0be8b145d
This commit is contained in:
Родитель
2a5f873f41
Коммит
b63b53aa1f
|
@ -65,11 +65,7 @@ pref("browser.cache.memory.capacity", 1024); // kilobytes
|
|||
pref("image.cache.size", 1048576); // bytes
|
||||
|
||||
/* offline cache prefs */
|
||||
pref("browser.offline-apps.notify", true);
|
||||
pref("browser.cache.offline.enable", true);
|
||||
pref("browser.cache.offline.capacity", 5120); // kilobytes
|
||||
pref("offline-apps.quota.max", 2048); // kilobytes
|
||||
pref("offline-apps.quota.warn", 1024); // kilobytes
|
||||
pref("browser.offline-apps.notify", false);
|
||||
|
||||
/* protocol warning prefs */
|
||||
pref("network.protocol-handler.warn-external.tel", false);
|
||||
|
|
|
@ -68,6 +68,7 @@ function startupHttpd(baseDir, port) {
|
|||
Services.scriptloader.loadSubScript(httpdURL, httpd);
|
||||
let server = new httpd.nsHttpServer();
|
||||
server.registerDirectory('/', new LocalFile(baseDir));
|
||||
server.registerContentType('appcache', 'text/cache-manifest');
|
||||
server.start(port);
|
||||
}
|
||||
|
||||
|
@ -114,6 +115,7 @@ var shell = {
|
|||
|
||||
window.controllers.appendController(this);
|
||||
window.addEventListener('keypress', this);
|
||||
window.addEventListener('MozApplicationManifest', this);
|
||||
this.home.addEventListener('load', this, true);
|
||||
|
||||
try {
|
||||
|
@ -147,6 +149,7 @@ var shell = {
|
|||
stop: function shell_stop() {
|
||||
window.controllers.removeController(this);
|
||||
window.removeEventListener('keypress', this);
|
||||
window.removeEventListener('MozApplicationManifest', this);
|
||||
},
|
||||
|
||||
supportsCommand: function shell_supportsCommand(cmd) {
|
||||
|
@ -195,6 +198,29 @@ var shell = {
|
|||
this.home.removeEventListener('load', this, true);
|
||||
this.sendEvent(window, 'ContentStart');
|
||||
break;
|
||||
case 'MozApplicationManifest':
|
||||
try {
|
||||
let contentWindow = evt.originalTarget.defaultView;
|
||||
let documentElement = contentWindow.document.documentElement;
|
||||
if (!documentElement)
|
||||
return;
|
||||
|
||||
let manifest = documentElement.getAttribute("manifest");
|
||||
if (!manifest)
|
||||
return;
|
||||
|
||||
let documentURI = contentWindow.document.documentURIObject;
|
||||
let manifestURI = Services.io.newURI(manifest, null, documentURI);
|
||||
Services.perms.add(documentURI, 'offline-app',
|
||||
Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
|
||||
let updateService = Cc['@mozilla.org/offlinecacheupdate-service;1']
|
||||
.getService(Ci.nsIOfflineCacheUpdateService);
|
||||
updateService.scheduleUpdate(manifestURI, documentURI, window);
|
||||
} catch (e) {
|
||||
dump('Error while creating offline cache: ' + e + '\n');
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
sendEvent: function shell_sendEvent(content, type, details) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче