2012-07-19 02:43:34 +04:00
|
|
|
/* 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/. */
|
|
|
|
let Cc = Components.classes;
|
|
|
|
let Ci = Components.interfaces;
|
|
|
|
let Cu = Components.utils;
|
|
|
|
|
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
|
2012-07-19 23:08:54 +04:00
|
|
|
function pref(name, value) {
|
|
|
|
return {
|
|
|
|
name: name,
|
|
|
|
value: value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-19 02:43:34 +04:00
|
|
|
var WebAppRT = {
|
2012-07-19 23:08:54 +04:00
|
|
|
prefs: [
|
|
|
|
// Disable all add-on locations other than the profile (which can't be disabled this way)
|
|
|
|
pref("extensions.enabledScopes", 1),
|
|
|
|
// Auto-disable any add-ons that are "dropped in" to the profile
|
|
|
|
pref("extensions.autoDisableScopes", 1),
|
|
|
|
// Disable add-on installation via the web-exposed APIs
|
|
|
|
pref("xpinstall.enabled", false),
|
|
|
|
// Disable the telemetry prompt in webapps
|
2012-07-24 04:54:37 +04:00
|
|
|
pref("toolkit.telemetry.prompted", 2)
|
2012-07-19 23:08:54 +04:00
|
|
|
],
|
|
|
|
|
|
|
|
init: function(isUpdate) {
|
2012-07-19 02:43:34 +04:00
|
|
|
this.deck = document.getElementById("browsers");
|
2012-07-19 04:56:44 +04:00
|
|
|
this.deck.addEventListener("click", this, false, true);
|
2012-07-19 23:08:54 +04:00
|
|
|
|
|
|
|
// on first run, update any prefs
|
|
|
|
if (isUpdate == "new") {
|
|
|
|
this.prefs.forEach(function(aPref) {
|
|
|
|
switch (typeof aPref.value) {
|
|
|
|
case "string":
|
|
|
|
Services.prefs.setCharPref(aPref.name, aPref.value);
|
|
|
|
break;
|
|
|
|
case "boolean":
|
|
|
|
Services.prefs.setBoolPref(aPref.name, aPref.value);
|
|
|
|
break;
|
|
|
|
case "number":
|
|
|
|
Services.prefs.setIntPref(aPref.name, aPref.value);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2012-08-02 20:57:01 +04:00
|
|
|
|
|
|
|
// update the blocklist url to use a different app id
|
|
|
|
var blocklist = Services.prefs.getCharPref("extensions.blocklist.url");
|
|
|
|
blocklist = blocklist.replace(/%APP_ID%/g, "webapprt-mobile@mozilla.org");
|
|
|
|
Services.prefs.setCharPref("extensions.blocklist.url", blocklist);
|
2012-07-19 23:08:54 +04:00
|
|
|
}
|
2012-07-19 02:43:34 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
handleEvent: function(event) {
|
|
|
|
let target = event.target;
|
|
|
|
|
|
|
|
if (!(target instanceof HTMLAnchorElement) ||
|
|
|
|
target.getAttribute("target") != "_blank") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let uri = Services.io.newURI(target.href,
|
|
|
|
target.ownerDocument.characterSet,
|
|
|
|
null);
|
|
|
|
|
|
|
|
// Direct the URL to the browser.
|
|
|
|
Cc["@mozilla.org/uriloader/external-protocol-service;1"].
|
|
|
|
getService(Ci.nsIExternalProtocolService).
|
|
|
|
getProtocolHandlerInfo(uri.scheme).
|
|
|
|
launchWithURI(uri);
|
|
|
|
|
|
|
|
// Prevent the runtime from loading the URL. We do this after directing it
|
|
|
|
// to the browser to give the runtime a shot at handling the URL if we fail
|
|
|
|
// to direct it to the browser for some reason.
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
}
|