mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 766094 - Set default prefs for webapps in js. r=mfinkle
This commit is contained in:
parent
011c398419
commit
4c482a881d
@ -1256,7 +1256,7 @@ abstract public class GeckoApp
|
||||
String launchPath = message.getString("launchPath");
|
||||
String iconURL = message.getString("iconURL");
|
||||
String uniqueURI = message.getString("uniqueURI");
|
||||
GeckoAppShell.installWebApp(name, launchPath, uniqueURI, iconURL);
|
||||
GeckoAppShell.createShortcut(name, launchPath, uniqueURI, iconURL, "webapp");
|
||||
} else if (event.equals("WebApps:Uninstall")) {
|
||||
String uniqueURI = message.getString("uniqueURI");
|
||||
GeckoAppShell.uninstallWebApp(uniqueURI);
|
||||
|
@ -852,35 +852,6 @@ public class GeckoAppShell
|
||||
});
|
||||
}
|
||||
|
||||
public static void installWebApp(String aTitle, String aURI, String aUniqueURI, String aIconURL) {
|
||||
int index = WebAppAllocator.getInstance(GeckoApp.mAppContext).findAndAllocateIndex(aUniqueURI);
|
||||
GeckoProfile profile = GeckoProfile.get(GeckoApp.mAppContext, "webapp" + index);
|
||||
File prefs = profile.getFile("prefs.js");
|
||||
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
in = GeckoApp.mAppContext.getResources().openRawResource(R.raw.webapp_prefs_js);
|
||||
out = new FileOutputStream(prefs);
|
||||
byte buf[]=new byte[1024];
|
||||
int len;
|
||||
while ((len = in.read(buf)) > 0) {
|
||||
out.write(buf, 0, len);
|
||||
}
|
||||
} catch(FileNotFoundException ex) {
|
||||
} catch(IOException ex) {
|
||||
} finally {
|
||||
try {
|
||||
if (out != null)
|
||||
out.close();
|
||||
if (in != null)
|
||||
in.close();
|
||||
} catch(IOException ex) {
|
||||
}
|
||||
}
|
||||
createShortcut(aTitle, aURI, aUniqueURI, aIconURL, "webapp");
|
||||
}
|
||||
|
||||
public static void uninstallWebApp(final String uniqueURI) {
|
||||
// On uninstall, we need to do a couple of things:
|
||||
// 1. nuke the running app process.
|
||||
|
@ -848,10 +848,6 @@ RES_MENU = \
|
||||
res/menu/titlebar_contextmenu.xml \
|
||||
$(NULL)
|
||||
|
||||
RES_RAW = \
|
||||
res/raw/webapp_prefs_js \
|
||||
$(NULL)
|
||||
|
||||
JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar
|
||||
|
||||
ifdef MOZ_CRASHREPORTER
|
||||
@ -911,7 +907,7 @@ MOZ_ANDROID_DRAWABLES += \
|
||||
|
||||
MOZ_ANDROID_DRAWABLES += $(shell if test -e $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/android-resources.mn; then cat $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/android-resources.mn | tr '\n' ' '; fi)
|
||||
|
||||
RESOURCES=$(RES_LAYOUT) $(RES_LAYOUT_LAND_V14) $(RES_LAYOUT_XLARGE) $(RES_VALUES) $(RES_VALUES_V11) $(RES_VALUES_XLARGE) $(RES_VALUES_LAND_V14) $(RES_VALUES_XLARGE_V14) $(RES_XML) $(RES_ANIM) $(RES_DRAWABLE_NODPI) $(RES_DRAWABLE_BASE) $(RES_DRAWABLE_LDPI) $(RES_DRAWABLE_HDPI) $(RES_DRAWABLE_XHDPI) $(RES_DRAWABLE_MDPI_V11) $(RES_DRAWABLE_HDPI_V11) $(RES_DRAWABLE_XHDPI_V11) $(RES_DRAWABLE_LAND_V14) $(RES_DRAWABLE_LAND_MDPI_V14) $(RES_DRAWABLE_LAND_HDPI_V14) $(RES_DRAWABLE_LAND_XHDPI_V14) $(RES_DRAWABLE_XLARGE_MDPI) $(RES_DRAWABLE_XLARGE_HDPI) $(RES_DRAWABLE_XLARGE_XHDPI) $(RES_COLOR) $(RES_MENU) $(RES_RAW)
|
||||
RESOURCES=$(RES_LAYOUT) $(RES_LAYOUT_LAND_V14) $(RES_LAYOUT_XLARGE) $(RES_VALUES) $(RES_VALUES_V11) $(RES_VALUES_XLARGE) $(RES_VALUES_LAND_V14) $(RES_VALUES_XLARGE_V14) $(RES_XML) $(RES_ANIM) $(RES_DRAWABLE_NODPI) $(RES_DRAWABLE_BASE) $(RES_DRAWABLE_LDPI) $(RES_DRAWABLE_HDPI) $(RES_DRAWABLE_XHDPI) $(RES_DRAWABLE_MDPI_V11) $(RES_DRAWABLE_HDPI_V11) $(RES_DRAWABLE_XHDPI_V11) $(RES_DRAWABLE_LAND_V14) $(RES_DRAWABLE_LAND_MDPI_V14) $(RES_DRAWABLE_LAND_HDPI_V14) $(RES_DRAWABLE_LAND_XHDPI_V14) $(RES_DRAWABLE_XLARGE_MDPI) $(RES_DRAWABLE_XLARGE_HDPI) $(RES_DRAWABLE_XLARGE_XHDPI) $(RES_COLOR) $(RES_MENU)
|
||||
|
||||
RES_DIRS= \
|
||||
res/layout \
|
||||
|
@ -1,25 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
pref("browser.download.folderList", 1);
|
||||
|
||||
// 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);
|
||||
|
||||
// Blocklist preferences
|
||||
pref("extensions.blocklist.enabled", true);
|
||||
pref("extensions.blocklist.interval", 86400);
|
||||
// Controls what level the blocklist switches from warning about items to forcibly
|
||||
// blocking them.
|
||||
pref("extensions.blocklist.level", 2);
|
||||
pref("extensions.blocklist.url", "https://addons.mozilla.org/blocklist/3/%APP_ID%/%APP_VERSION%/%PRODUCT%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/%PING_COUNT%/%TOTAL_PING_COUNT%/%DAYS_SINCE_LAST_PING%/");
|
||||
pref("extensions.blocklist.detailsURL", "https://www.mozilla.com/%LOCALE%/blocklist/");
|
||||
pref("extensions.blocklist.itemURL", "https://addons.mozilla.org/%LOCALE%/%APP%/blocked/%blockID%");
|
||||
|
||||
// Disable the telemetry prompt in webapps
|
||||
pref("toolkit.telemetry.prompted", true);
|
@ -7,10 +7,45 @@ let Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function pref(name, value) {
|
||||
return {
|
||||
name: name,
|
||||
value: value
|
||||
}
|
||||
}
|
||||
|
||||
var WebAppRT = {
|
||||
init: function() {
|
||||
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
|
||||
pref("toolkit.telemetry.prompted", true)
|
||||
],
|
||||
|
||||
init: function(isUpdate) {
|
||||
this.deck = document.getElementById("browsers");
|
||||
this.deck.addEventListener("click", this, false, true);
|
||||
|
||||
// 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;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
handleEvent: function(event) {
|
||||
|
@ -242,6 +242,10 @@ var BrowserApp = {
|
||||
pinned = window.arguments[4];
|
||||
}
|
||||
|
||||
let updated = this.isAppUpdated();
|
||||
if (pinned)
|
||||
WebAppRT.init(updated);
|
||||
|
||||
if (url == "about:empty")
|
||||
loadParams.flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY;
|
||||
|
||||
@ -310,10 +314,7 @@ var BrowserApp = {
|
||||
#endif
|
||||
}
|
||||
|
||||
if (pinned)
|
||||
WebAppRT.init();
|
||||
|
||||
if (this.isAppUpdated())
|
||||
if (updated)
|
||||
this.onAppUpdated();
|
||||
|
||||
// notify java that gecko has loaded
|
||||
|
Loading…
Reference in New Issue
Block a user