Bug 766297 - Create a default prefs.js for webapps. r=mfinkle

This commit is contained in:
Wes Johnston 2012-06-26 11:56:03 -07:00
Родитель bd41daf495
Коммит 0ae7622a49
6 изменённых файлов: 65 добавлений и 5 удалений

Просмотреть файл

@ -26,11 +26,8 @@ pref("toolkit.browser.contentViewExpire", 3000);
pref("toolkit.defaultChromeURI", "chrome://browser/content/browser.xul");
pref("browser.chromeURL", "chrome://browser/content/");
pref("browser.tabs.warnOnClose", true);
pref("browser.tabs.remote", false);
pref("toolkit.screen.lock", false);
// From libpref/src/init/all.js, extended to allow a slightly wider zoom range.
pref("zoom.minPercent", 20);
pref("zoom.maxPercent", 400);

Просмотреть файл

@ -1228,7 +1228,7 @@ abstract public class GeckoApp
String launchPath = message.getString("launchPath");
String iconURL = message.getString("iconURL");
String uniqueURI = message.getString("uniqueURI");
GeckoAppShell.createShortcut(name, launchPath, uniqueURI, iconURL, "webapp");
GeckoAppShell.installWebApp(name, launchPath, uniqueURI, iconURL);
} else if (event.equals("WebApps:Uninstall")) {
String uniqueURI = message.getString("uniqueURI");
GeckoAppShell.uninstallWebApp(uniqueURI);

Просмотреть файл

@ -845,6 +845,35 @@ 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.

Просмотреть файл

@ -143,6 +143,14 @@ public final class GeckoProfile {
return mDir;
}
public File getFile(String aFile) {
File f = getDir();
if (f == null)
return null;
return new File(f, aFile);
}
public File getFilesDir() {
return mContext.getFilesDir();
}

Просмотреть файл

@ -870,6 +870,10 @@ 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
@ -926,7 +930,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_LAYOUT_SW600DP) $(RES_VALUES) $(RES_VALUES_V11) $(RES_VALUES_XLARGE) $(RES_VALUES_SW600DP) $(RES_VALUES_LAND_V14) $(RES_VALUES_SW600DP_V14) $(RES_XML) $(RES_ANIM) $(RES_DRAWABLE_NODPI) $(RES_DRAWABLE_BASE) $(RES_DRAWABLE_LDPI) $(RES_DRAWABLE_HDPI) $(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_DRAWABLE_SW600DP_MDPI) $(RES_DRAWABLE_SW600DP_HDPI) $(RES_DRAWABLE_SW600DP_XHDPI) $(RES_COLOR) $(RES_MENU)
RESOURCES=$(RES_LAYOUT) $(RES_LAYOUT_LAND_V14) $(RES_LAYOUT_XLARGE) $(RES_LAYOUT_SW600DP) $(RES_VALUES) $(RES_VALUES_V11) $(RES_VALUES_XLARGE) $(RES_VALUES_SW600DP) $(RES_VALUES_LAND_V14) $(RES_VALUES_SW600DP_V14) $(RES_XML) $(RES_ANIM) $(RES_DRAWABLE_NODPI) $(RES_DRAWABLE_BASE) $(RES_DRAWABLE_LDPI) $(RES_DRAWABLE_HDPI) $(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_DRAWABLE_SW600DP_MDPI) $(RES_DRAWABLE_SW600DP_HDPI) $(RES_DRAWABLE_SW600DP_XHDPI) $(RES_COLOR) $(RES_MENU) $(RES_RAW)
RES_DIRS= \
res/layout \

Просмотреть файл

@ -0,0 +1,22 @@
/* 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%");