mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
bug 749029 - set appcache permissions on webapp firstrun so apps can use the appcache to run offline; r=felipe
This commit is contained in:
parent
3365e3b04a
commit
05efd2deaa
@ -9,14 +9,6 @@ const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// Initialize DOMApplicationRegistry so it can receive and respond to messages.
|
||||
// We catch an exception here on the off chance the registry throws one, as we
|
||||
// don't need it for most apps, and exceptions it throws shouldn't prevent apps
|
||||
// from loading.
|
||||
try {
|
||||
Cu.import("resource://gre/modules/Webapps.jsm");
|
||||
} catch(ex) {}
|
||||
|
||||
function CommandLineHandler() {}
|
||||
|
||||
CommandLineHandler.prototype = {
|
||||
@ -38,3 +30,36 @@ CommandLineHandler.prototype = {
|
||||
|
||||
let components = [CommandLineHandler];
|
||||
let NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
|
||||
|
||||
/* There's some work we need to do on startup, before we load the webapp,
|
||||
* and this seems as good a place as any to do it, although it's possible
|
||||
* that in the future we will find a lazier place to do it.
|
||||
*
|
||||
* NOTE: it's very important that the stuff we do here doesn't prevent
|
||||
* the command-line handler from being registered/accessible, since otherwise
|
||||
* the app won't start, which is catastrophic failure. That's why it's all
|
||||
* wrapped in a try/catch block. */
|
||||
|
||||
try {
|
||||
// Initialize DOMApplicationRegistry so it can receive/respond to messages.
|
||||
Cu.import("resource://gre/modules/Webapps.jsm");
|
||||
|
||||
// On firstrun, set permissions to their default values.
|
||||
if (!Services.prefs.getBoolPref("webapprt.firstrun")) {
|
||||
Cu.import("resource://webapprt/modules/WebappRT.jsm");
|
||||
let uri = Services.io.newURI(WebappRT.config.app.origin, null, null);
|
||||
|
||||
// Set AppCache-related permissions.
|
||||
Services.perms.add(uri, "pin-app", Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
Services.perms.add(uri, "offline-app",
|
||||
Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
|
||||
// Now that we've set the appropriate permissions, twiddle the firstrun flag
|
||||
// so we don't try to do so again.
|
||||
Services.prefs.setBoolPref("webapprt.firstrun", true);
|
||||
}
|
||||
} catch(ex) {
|
||||
#ifdef MOZ_DEBUG
|
||||
dump(ex + "\n");
|
||||
#endif
|
||||
}
|
||||
|
@ -39,6 +39,10 @@ EXTRA_JS_MODULES = \
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifdef MOZ_DEBUG
|
||||
DEFINES += -DMOZ_DEBUG=1
|
||||
endif
|
||||
|
||||
libs::
|
||||
$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "resource webapprt ./"
|
||||
|
||||
|
@ -11,3 +11,6 @@ pref("extensions.enabledScopes", 1);
|
||||
pref("extensions.autoDisableScopes", 1);
|
||||
// Disable add-on installation via the web-exposed APIs
|
||||
pref("xpinstall.enabled", false);
|
||||
|
||||
// Whether or not we've ever run. We use this to set permissions on firstrun.
|
||||
pref("webapprt.firstrun", false);
|
||||
|
Loading…
Reference in New Issue
Block a user