mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 736193 - Use the offline cache to load applications [r=fabrice] DONTBUILD because NPOTB
This commit is contained in:
parent
ca957d8bdd
commit
946e2bcc4e
@ -40,13 +40,34 @@
|
||||
pref("toolkit.defaultChromeURI", "chrome://browser/content/shell.xul");
|
||||
pref("browser.chromeURL", "chrome://browser/content/");
|
||||
#ifdef MOZ_OFFICIAL_BRANDING
|
||||
pref("browser.homescreenURL", "file:///system/home/homescreen.html");
|
||||
pref("browser.homescreenURL", "http://homescreen.gaiamobile.org/");
|
||||
#else
|
||||
pref("browser.homescreenURL", "file:///data/local/homescreen.html,file:///system/home/homescreen.html");
|
||||
pref("browser.homescreenURL", "http://homescreen.gaiamobile.org/");
|
||||
#endif
|
||||
|
||||
// All the privileged domains
|
||||
// XXX TODO : we should read them from a file somewhere
|
||||
pref("b2g.privileged.domains", "http://browser.gaiamobile.org,
|
||||
http://calculator.gaiamobile.org,
|
||||
http://contacts.gaiamobile.org,
|
||||
http://camera.gaiamobile.org,
|
||||
http://clock.gaiamobile.org,
|
||||
http://crystalskull.gaiamobile.org,
|
||||
http://cubevid.gaiamobile.org,
|
||||
http://dialer.gaiamobile.org,
|
||||
http://gallery.gaiamobile.org,
|
||||
http://homescreen.gaiamobile.org,
|
||||
http://maps.gaiamobile.org,
|
||||
http://market.gaiamobile.org,
|
||||
http://music.gaiamobile.org,
|
||||
http://penguinpop.gaiamobile.org,
|
||||
http://settings.gaiamobile.org,
|
||||
http://sms.gaiamobile.org,
|
||||
http://towerjelly.gaiamobile.org,
|
||||
http://video.gaiamobile.org");
|
||||
|
||||
// URL for the dialer application.
|
||||
pref("dom.telephony.app.phone.url", "http://localhost:7777/data/local/apps/dialer/dialer.html,http://localhost:7777/data/local/apps/homescreen/homescreen.html,http://localhost:7777/apps/dialer/dialer.html,http://localhost:7777/apps/homescreen/homescreen.html");
|
||||
pref("dom.telephony.app.phone.url", "http://dialer.gaiamobile.org,http://homescreen.gaiamobile.org");
|
||||
|
||||
// Device pixel to CSS px ratio, in percent. Set to -1 to calculate based on display density.
|
||||
pref("browser.viewport.scaleRatio", -1);
|
||||
@ -55,9 +76,11 @@ pref("browser.viewport.scaleRatio", -1);
|
||||
pref("browser.ignoreNativeFrameTextSelection", true);
|
||||
|
||||
/* cache prefs */
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
pref("browser.cache.disk.enable", true);
|
||||
pref("browser.cache.disk.capacity", 55000); // kilobytes
|
||||
pref("browser.cache.disk.parent_directory", "/cache");
|
||||
#endif
|
||||
pref("browser.cache.disk.smart_size.enabled", false);
|
||||
pref("browser.cache.disk.smart_size.first_run", false);
|
||||
|
||||
@ -69,7 +92,8 @@ pref("image.cache.size", 1048576); // bytes
|
||||
|
||||
/* offline cache prefs */
|
||||
pref("browser.offline-apps.notify", false);
|
||||
pref("browser.cache.offline.enable", false);
|
||||
pref("browser.cache.offline.enable", true);
|
||||
pref("offline-apps.allow_by_default", true);
|
||||
|
||||
/* protocol warning prefs */
|
||||
pref("network.protocol-handler.warn-external.tel", false);
|
||||
@ -391,7 +415,7 @@ pref("layers.acceleration.force-enabled", true);
|
||||
// screen.enabled and screen.brightness properties.
|
||||
pref("dom.screenEnabledProperty.enabled", true);
|
||||
pref("dom.screenBrightnessProperty.enabled", true);
|
||||
pref("dom.mozScreenWhitelist", "http://localhost:7777");
|
||||
pref("dom.mozScreenWhitelist", "http://homescreen.gaiamobile.org,http://settings.gaiamobile.org");
|
||||
|
||||
// handle links targeting new windows
|
||||
// 1=current window/tab, 2=new window, 3=new tab in most recent window
|
||||
@ -404,15 +428,15 @@ pref("browser.link.open_newwindow.restriction", 0);
|
||||
|
||||
// Enable browser frame
|
||||
pref("dom.mozBrowserFramesEnabled", true);
|
||||
pref("dom.mozBrowserFramesWhitelist", "http://localhost:7777");
|
||||
pref("dom.mozBrowserFramesWhitelist", "http://homescreen.gaiamobile.org,http://browser.gaiamobile.org");
|
||||
|
||||
// Temporary permission hack for WebSMS
|
||||
pref("dom.sms.enabled", true);
|
||||
pref("dom.sms.whitelist", "file://,http://localhost:7777");
|
||||
pref("dom.sms.whitelist", "file://,http://homescreen.gaiamobile.org,http://sms.gaiamobile.org");
|
||||
|
||||
// Temporary permission hack for WebContacts
|
||||
pref("dom.mozContacts.enabled", true);
|
||||
pref("dom.mozContacts.whitelist", "http://localhost:7777");
|
||||
pref("dom.mozContacts.whitelist", "http://dialer.gaiamobile.org,http://sms.gaiamobile.org");
|
||||
|
||||
// Ignore X-Frame-Options headers.
|
||||
pref("b2g.ignoreXFrameOptions", true);
|
||||
@ -440,7 +464,7 @@ pref("b2g.keys.search.enabled", false);
|
||||
|
||||
// Screen timeout in minutes
|
||||
pref("power.screen.timeout", 60);
|
||||
pref("dom.power.whitelist", "http://localhost:7777");
|
||||
pref("dom.power.whitelist", "http://homescreen.gaiamobile.org,http://settings.gaiamobile.org");
|
||||
|
||||
pref("full-screen-api.enabled", true);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,13 +7,8 @@
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
const CC = Components.Constructor;
|
||||
const Cr = Components.results;
|
||||
|
||||
const LocalFile = CC('@mozilla.org/file/local;1',
|
||||
'nsILocalFile',
|
||||
'initWithPath');
|
||||
|
||||
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
||||
Cu.import('resource://gre/modules/Services.jsm');
|
||||
Cu.import('resource://gre/modules/ContactService.jsm');
|
||||
@ -44,22 +39,6 @@ XPCOMUtils.defineLazyServiceGetter(Services, 'fm', function() {
|
||||
.getService(Ci.nsFocusManager);
|
||||
});
|
||||
|
||||
#ifndef MOZ_WIDGET_GONK
|
||||
// In order to use http:// scheme instead of file:// scheme
|
||||
// (that is much more restricted) the following code kick-off
|
||||
// a local http server listening on http://127.0.0.1:7777 and
|
||||
// http://localhost:7777.
|
||||
function startupHttpd(baseDir, port) {
|
||||
const httpdURL = 'chrome://browser/content/httpd.js';
|
||||
let httpd = {};
|
||||
Services.scriptloader.loadSubScript(httpdURL, httpd);
|
||||
let server = new httpd.nsHttpServer();
|
||||
server.registerDirectory('/', new LocalFile(baseDir));
|
||||
server.registerContentType('appcache', 'text/cache-manifest');
|
||||
server.start(port);
|
||||
}
|
||||
#endif
|
||||
|
||||
// FIXME Bug 707625
|
||||
// until we have a proper security model, add some rights to
|
||||
// the pre-installed web applications
|
||||
@ -71,6 +50,8 @@ function addPermissions(urls) {
|
||||
'geolocation'
|
||||
];
|
||||
urls.forEach(function(url) {
|
||||
url = url.trim();
|
||||
dump("XxXxX adding permissions for " + url);
|
||||
let uri = Services.io.newURI(url, null, null);
|
||||
let allow = Ci.nsIPermissionManager.ALLOW_ACTION;
|
||||
|
||||
@ -95,17 +76,7 @@ var shell = {
|
||||
return homeSrc;
|
||||
} catch (e) {}
|
||||
|
||||
let urls = Services.prefs.getCharPref('browser.homescreenURL').split(',');
|
||||
for (let i = 0; i < urls.length; i++) {
|
||||
let url = urls[i];
|
||||
if (url.substring(0, 7) != 'file://')
|
||||
return url;
|
||||
|
||||
let file = new LocalFile(url.substring(7, url.length));
|
||||
if (file.exists())
|
||||
return url;
|
||||
}
|
||||
return null;
|
||||
return Services.prefs.getCharPref('browser.homescreenURL');
|
||||
},
|
||||
|
||||
start: function shell_init() {
|
||||
@ -132,32 +103,12 @@ var shell = {
|
||||
Services.audioManager.masterVolume = 0.5;
|
||||
} catch(e) {}
|
||||
|
||||
let domains = "";
|
||||
try {
|
||||
Services.io.offline = false;
|
||||
domains = Services.prefs.getCharPref('b2g.privileged.domains');
|
||||
} catch(e) {}
|
||||
|
||||
let fileScheme = 'file://';
|
||||
if (homeURL.substring(0, fileScheme.length) == fileScheme) {
|
||||
#ifndef MOZ_WIDGET_GONK
|
||||
homeURL = homeURL.replace(fileScheme, '');
|
||||
|
||||
let baseDir = homeURL.split('/');
|
||||
baseDir.pop();
|
||||
baseDir = baseDir.join('/');
|
||||
|
||||
const SERVER_PORT = 7777;
|
||||
startupHttpd(baseDir, SERVER_PORT);
|
||||
|
||||
let baseHost = 'http://localhost';
|
||||
homeURL = homeURL.replace(baseDir, baseHost + ':' + SERVER_PORT);
|
||||
#else
|
||||
homeURL = 'http://localhost:7777' + homeURL.replace(fileScheme, '');
|
||||
#endif
|
||||
}
|
||||
addPermissions([homeURL]);
|
||||
} catch (e) {
|
||||
let msg = 'Fatal error during startup: [' + e + '[' + homeURL + ']';
|
||||
return alert(msg);
|
||||
}
|
||||
addPermissions(domains.split(","));
|
||||
|
||||
// Load webapi.js as a frame script
|
||||
let frameScriptUrl = 'chrome://browser/content/webapi.js';
|
||||
|
@ -8,9 +8,6 @@ chrome.jar:
|
||||
* content/shell.js (content/shell.js)
|
||||
#ifndef MOZ_TOUCH
|
||||
content/touch.js (content/touch.js)
|
||||
#endif
|
||||
#ifndef MOZ_WIDGET_GONK
|
||||
content/httpd.js (content/httpd.js)
|
||||
#endif
|
||||
content/webapi.js (content/webapi.js)
|
||||
content/content.css (content/content.css)
|
||||
|
@ -24,3 +24,8 @@ contract @mozilla.org/updates/update-prompt;1 {88b3eb21-d072-4e3b-886d-f89d8c49f
|
||||
component {397a7fdf-2254-47be-b74e-76625a1a66d5} MozKeyboard.js
|
||||
contract @mozilla.org/b2g-keyboard;1 {397a7fdf-2254-47be-b74e-76625a1a66d5}
|
||||
category JavaScript-navigator-property mozKeyboard @mozilla.org/b2g-keyboard;1
|
||||
|
||||
# DirectoryProvider.js
|
||||
component {9181eb7c-6f87-11e1-90b1-4f59d80dd2e5} DirectoryProvider.js
|
||||
contract @mozilla.org/browser/directory-provider;1 {9181eb7c-6f87-11e1-90b1-4f59d80dd2e5}
|
||||
category xpcom-directory-providers browser-directory-provider @mozilla.org/browser/directory-provider;1
|
||||
|
39
b2g/components/DirectoryProvider.js
Normal file
39
b2g/components/DirectoryProvider.js
Normal file
@ -0,0 +1,39 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
const Cr = Components.results;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const OFFLINE_PROFILE_DIR = "/data/local"
|
||||
|
||||
function DirectoryProvider() {
|
||||
}
|
||||
|
||||
DirectoryProvider.prototype = {
|
||||
classID: Components.ID("{9181eb7c-6f87-11e1-90b1-4f59d80dd2e5}"),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDirectoryServiceProvider]),
|
||||
|
||||
getFile: function dp_getFile(prop, persistent) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (prop == "cachePDir" || prop == "webappsDir") {
|
||||
prop.persistent = true;
|
||||
let file = Cc["@mozilla.org/file/local;1"]
|
||||
.createInstance(Ci.nsILocalFile)
|
||||
file.initWithPath(OFFLINE_PROFILE_DIR);
|
||||
return file;
|
||||
}
|
||||
#endif
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const NSGetFactory = XPCOMUtils.generateNSGetFactory([DirectoryProvider]);
|
||||
|
@ -54,6 +54,7 @@ EXTRA_PP_COMPONENTS = \
|
||||
AlertsService.js \
|
||||
ContentPermissionPrompt.js \
|
||||
MozKeyboard.js \
|
||||
DirectoryProvider.js \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_UPDATER
|
||||
|
@ -627,3 +627,4 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DLL_SUFFIX@
|
||||
@BINPATH@/components/UpdatePrompt.js
|
||||
#endif
|
||||
@BINPATH@/components/MozKeyboard.js
|
||||
@BINPATH@/components/DirectoryProvider.js
|
||||
|
@ -64,7 +64,7 @@ EXTRA_COMPONENTS = \
|
||||
Webapps.manifest \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_JS_MODULES += Webapps.jsm \
|
||||
EXTRA_PP_JS_MODULES += Webapps.jsm \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_JS_MODULES += DOMRequestHelper.jsm \
|
||||
|
@ -21,6 +21,12 @@ XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
|
||||
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
|
||||
});
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
const DIRECTORY_NAME = "webappsDir";
|
||||
#else
|
||||
const DIRECTORY_NAME = "ProfD";
|
||||
#endif
|
||||
|
||||
let DOMApplicationRegistry = {
|
||||
appsFile: null,
|
||||
webapps: { },
|
||||
@ -36,8 +42,8 @@ let DOMApplicationRegistry = {
|
||||
|
||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||
|
||||
let appsDir = FileUtils.getDir("ProfD", ["webapps"], true, true);
|
||||
this.appsFile = FileUtils.getFile("ProfD", ["webapps", "webapps.json"], true);
|
||||
let appsDir = FileUtils.getDir(DIRECTORY_NAME, ["webapps"], true, true);
|
||||
this.appsFile = FileUtils.getFile(DIRECTORY_NAME, ["webapps", "webapps.json"], true);
|
||||
|
||||
if (!this.appsFile.exists())
|
||||
return;
|
||||
@ -162,7 +168,7 @@ let DOMApplicationRegistry = {
|
||||
|
||||
// install an application again is considered as an update
|
||||
if (id) {
|
||||
let dir = FileUtils.getDir("ProfD", ["webapps", id], true, true);
|
||||
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", id], true, true);
|
||||
try {
|
||||
dir.remove(true);
|
||||
} catch(e) {
|
||||
@ -173,7 +179,7 @@ let DOMApplicationRegistry = {
|
||||
id = uuidGenerator.generateUUID().toString();
|
||||
}
|
||||
|
||||
let dir = FileUtils.getDir("ProfD", ["webapps", id], true, true);
|
||||
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", id], true, true);
|
||||
|
||||
let manFile = dir.clone();
|
||||
manFile.append("manifest.json");
|
||||
@ -217,7 +223,7 @@ let DOMApplicationRegistry = {
|
||||
|
||||
let index = aIndex || 0;
|
||||
let id = aData[index].id;
|
||||
let file = FileUtils.getFile("ProfD", ["webapps", id, "manifest.json"], true);
|
||||
let file = FileUtils.getFile(DIRECTORY_NAME, ["webapps", id, "manifest.json"], true);
|
||||
this._loadJSONAsync(file, (function(aJSON) {
|
||||
aData[index].manifest = aJSON;
|
||||
if (index == aData.length - 1)
|
||||
@ -234,7 +240,7 @@ let DOMApplicationRegistry = {
|
||||
if (app.origin == aData.origin) {
|
||||
found = true;
|
||||
delete this.webapps[id];
|
||||
let dir = FileUtils.getDir("ProfD", ["webapps", id], true, true);
|
||||
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", id], true, true);
|
||||
try {
|
||||
dir.remove(true);
|
||||
} catch (e) {
|
||||
@ -340,7 +346,7 @@ let DOMApplicationRegistry = {
|
||||
continue;
|
||||
let origin = this.webapps[record.id].origin;
|
||||
delete this.webapps[record.id];
|
||||
let dir = FileUtils.getDir("ProfD", ["webapps", record.id], true, true);
|
||||
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", record.id], true, true);
|
||||
try {
|
||||
dir.remove(true);
|
||||
} catch (e) {
|
||||
@ -378,7 +384,7 @@ let DOMApplicationRegistry = {
|
||||
let ids = this.getAllIDs();
|
||||
for (let id in ids) {
|
||||
delete this.webapps[id];
|
||||
let dir = FileUtils.getDir("ProfD", ["webapps", id], true, true);
|
||||
let dir = FileUtils.getDir(DIRECTORY_NAME, ["webapps", id], true, true);
|
||||
try {
|
||||
dir.remove(true);
|
||||
} catch (e) {
|
||||
|
Loading…
Reference in New Issue
Block a user