Skip to content

Commit

Permalink
bug 725408 - implement WebappRT launcher/shell; r=bsmedberg
Browse files Browse the repository at this point in the history
  • Loading branch information
mykmelez committed Apr 17, 2012
1 parent 8f3fb5a commit 3ead5c0
Show file tree
Hide file tree
Showing 38 changed files with 2,196 additions and 72 deletions.
6 changes: 6 additions & 0 deletions allmakefiles.sh
Expand Up @@ -40,6 +40,12 @@ probes/Makefile
extensions/Makefile
"

if [ "$MOZ_WEBAPP_RUNTIME" ]; then
add_makefiles "
webapprt/Makefile
"
fi

if [ ! "$LIBXUL_SDK" ]; then
if [ "$STLPORT_SOURCES" ]; then
add_makefiles "
Expand Down
4 changes: 4 additions & 0 deletions browser/build.mk
Expand Up @@ -51,6 +51,10 @@ ifdef MOZ_SERVICES_SYNC
tier_app_dirs += services
endif

ifdef MOZ_WEBAPP_RUNTIME
tier_app_dirs += webapprt
endif

tier_app_dirs += browser
# Never add other tier_app_dirs after browser. They won't get packaged
# properly on mac.
Expand Down
16 changes: 15 additions & 1 deletion browser/components/BrowserComponents.manifest
Expand Up @@ -24,8 +24,22 @@ category command-line-handler x-default @mozilla.org/browser/final-clh;1 applica
category command-line-validator b-browser @mozilla.org/browser/clh;1 application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}

# nsBrowserGlue.js

# WebappRT doesn't need these instructions, and they don't necessarily work
# with it, but it does use a GRE directory that the GRE shares with Firefox,
# so in order to prevent the instructions from being processed for WebappRT,
# we need to restrict them to the applications that depend on them, i.e.:
#
# b2g: {3c2e2abc-06d4-11e1-ac3b-374f68613e61}
# browser: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
# mobile/android: {aa3c5121-dab2-40e2-81ca-7ea25febc110}
# mobile/xul: {a23983c0-fd0e-11dc-95ff-0800200c9a66}
#
# In theory we should do this for all these instructions, but in practice it is
# sufficient to do it for the app-startup one, and the file is simpler that way.

component {eab9012e-5f74-4cbc-b2b5-a590235513cc} nsBrowserGlue.js
contract @mozilla.org/browser/browserglue;1 {eab9012e-5f74-4cbc-b2b5-a590235513cc}
category app-startup nsBrowserGlue service,@mozilla.org/browser/browserglue;1
category app-startup nsBrowserGlue service,@mozilla.org/browser/browserglue;1 application={3c2e2abc-06d4-11e1-ac3b-374f68613e61} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} application={aa3c5121-dab2-40e2-81ca-7ea25febc110} application={a23983c0-fd0e-11dc-95ff-0800200c9a66}
component {d8903bf6-68d5-4e97-bcd1-e4d3012f721a} nsBrowserGlue.js
contract @mozilla.org/content-permission/prompt;1 {d8903bf6-68d5-4e97-bcd1-e4d3012f721a}
15 changes: 14 additions & 1 deletion browser/components/feeds/src/BrowserFeeds.manifest
@@ -1,3 +1,16 @@
# WebappRT doesn't need these instructions, and they don't necessarily work
# with it, but it does use a GRE directory that the GRE shares with Firefox,
# so in order to prevent the instructions from being processed for WebappRT,
# we need to restrict them to the applications that depend on them, i.e.:
#
# b2g: {3c2e2abc-06d4-11e1-ac3b-374f68613e61}
# browser: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
# mobile/android: {aa3c5121-dab2-40e2-81ca-7ea25febc110}
# mobile/xul: {a23983c0-fd0e-11dc-95ff-0800200c9a66}
#
# In theory we should do this for all these instructions, but in practice it is
# sufficient to do it for the app-startup one, and the file is simpler that way.

component {229fa115-9412-4d32-baf3-2fc407f76fb1} FeedConverter.js
contract @mozilla.org/streamconv;1?from=application/vnd.mozilla.maybe.feed&to=*/* {229fa115-9412-4d32-baf3-2fc407f76fb1}
contract @mozilla.org/streamconv;1?from=application/vnd.mozilla.maybe.video.feed&to=*/* {229fa115-9412-4d32-baf3-2fc407f76fb1}
Expand All @@ -13,4 +26,4 @@ contract @mozilla.org/browser/feeds/result-writer;1 {49bb6593-3aff-4eb3-a068-271
category JavaScript-global-constructor BrowserFeedWriter @mozilla.org/browser/feeds/result-writer;1
component {792a7e82-06a0-437c-af63-b2d12e808acc} WebContentConverter.js
contract @mozilla.org/embeddor.implemented/web-content-handler-registrar;1 {792a7e82-06a0-437c-af63-b2d12e808acc}
category app-startup WebContentConverter service,@mozilla.org/embeddor.implemented/web-content-handler-registrar;1
category app-startup WebContentConverter service,@mozilla.org/embeddor.implemented/web-content-handler-registrar;1 application={3c2e2abc-06d4-11e1-ac3b-374f68613e61} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} application={aa3c5121-dab2-40e2-81ca-7ea25febc110} application={a23983c0-fd0e-11dc-95ff-0800200c9a66}
@@ -1,4 +1,17 @@
# WebappRT doesn't need these instructions, and they don't necessarily work
# with it, but it does use a GRE directory that the GRE shares with Firefox,
# so in order to prevent the instructions from being processed for WebappRT,
# we need to restrict them to the applications that depend on them, i.e.:
#
# b2g: {3c2e2abc-06d4-11e1-ac3b-374f68613e61}
# browser: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
# mobile/android: {aa3c5121-dab2-40e2-81ca-7ea25febc110}
# mobile/xul: {a23983c0-fd0e-11dc-95ff-0800200c9a66}
#
# In theory we should do this for all these instructions, but in practice it is
# sufficient to do it for the app-startup one, and the file is simpler that way.

component {c31f4883-839b-45f6-82ad-a6a9bc5ad599} nsPrivateBrowsingService.js
contract @mozilla.org/privatebrowsing;1 {c31f4883-839b-45f6-82ad-a6a9bc5ad599}
category command-line-handler m-privatebrowsing @mozilla.org/privatebrowsing;1
category app-startup nsPrivateBrowsingService service,@mozilla.org/privatebrowsing;1
category app-startup nsPrivateBrowsingService service,@mozilla.org/privatebrowsing;1 application={3c2e2abc-06d4-11e1-ac3b-374f68613e61} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} application={aa3c5121-dab2-40e2-81ca-7ea25febc110} application={a23983c0-fd0e-11dc-95ff-0800200c9a66}
15 changes: 14 additions & 1 deletion browser/components/sessionstore/src/nsSessionStore.manifest
@@ -1,5 +1,18 @@
# WebappRT doesn't need these instructions, and they don't necessarily work
# with it, but it does use a GRE directory that the GRE shares with Firefox,
# so in order to prevent the instructions from being processed for WebappRT,
# we need to restrict them to the applications that depend on them, i.e.:
#
# b2g: {3c2e2abc-06d4-11e1-ac3b-374f68613e61}
# browser: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
# mobile/android: {aa3c5121-dab2-40e2-81ca-7ea25febc110}
# mobile/xul: {a23983c0-fd0e-11dc-95ff-0800200c9a66}
#
# In theory we should do this for all these instructions, but in practice it is
# sufficient to do it for the app-startup one, and the file is simpler that way.

component {5280606b-2510-4fe0-97ef-9b5a22eafe6b} nsSessionStore.js
contract @mozilla.org/browser/sessionstore;1 {5280606b-2510-4fe0-97ef-9b5a22eafe6b}
component {ec7a6c20-e081-11da-8ad9-0800200c9a66} nsSessionStartup.js
contract @mozilla.org/browser/sessionstartup;1 {ec7a6c20-e081-11da-8ad9-0800200c9a66}
category app-startup nsSessionStartup service,@mozilla.org/browser/sessionstartup;1
category app-startup nsSessionStartup service,@mozilla.org/browser/sessionstartup;1 application={3c2e2abc-06d4-11e1-ac3b-374f68613e61} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} application={aa3c5121-dab2-40e2-81ca-7ea25febc110} application={a23983c0-fd0e-11dc-95ff-0800200c9a66}
14 changes: 14 additions & 0 deletions browser/installer/package-manifest.in
Expand Up @@ -503,6 +503,9 @@
#ifdef MOZ_SERVICES_SYNC
@BINPATH@/@PREF_DIR@/services-sync.js
#endif
#ifdef MOZ_WEBAPP_RUNTIME
@BINPATH@/@PREF_DIR@/webapprt@mozilla.org/prefs.js
#endif
@BINPATH@/greprefs.js
@BINPATH@/defaults/autoconfig/platform.js
@BINPATH@/defaults/autoconfig/prefcalls.js
Expand Down Expand Up @@ -624,3 +627,14 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DLL_SUFFIX@
@BINPATH@/*.xqs
@BINPATH@/components/*.xqs
#endif

#ifdef MOZ_WEBAPP_RUNTIME
; [Webapp Runtime]
@BINPATH@/webapprt-stub@BIN_SUFFIX@
@BINPATH@/chrome/webapprt@JAREXT@
@BINPATH@/chrome/webapprt.manifest
@BINPATH@/components/WebappRTComponents.manifest
@BINPATH@/components/WebappRTDirectoryProvider.js
@BINPATH@/components/WebappRTCommandLineHandler.js
@BINPATH@/webapprt.ini
#endif
49 changes: 49 additions & 0 deletions browser/locales/en-US/webapprt/webapp.dtd
@@ -0,0 +1,49 @@
<!-- 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/. -->

<!-- LOCALIZATION NOTE: These are localized strings for the webapp runtime,
- which loads a webapp in a separate process from Firefox. Webapps loaded
- in this way have very little application chrome, but the runtime does
- provide them with some default functionality, like the standard OS
- menus/menuitems. -->

<!ENTITY fileMenu.label "File">
<!ENTITY fileMenu.accesskey "F">

<!ENTITY quitApplicationCmdWin.label "Exit">
<!ENTITY quitApplicationCmdWin.accesskey "x">
<!ENTITY quitApplicationCmd.label "Quit">
<!ENTITY quitApplicationCmd.accesskey "Q">
<!-- On Mac, we create the Quit and Hide command labels dynamically,
- using properties in window.properties, in order to include the name
- of the webapp in the labels without creating a DTD file for it. -->
<!ENTITY quitApplicationCmdMac.key "Q">
<!ENTITY hideThisAppCmdMac.key "H">
<!ENTITY hideOtherAppsCmdMac.label "Hide Others">
<!ENTITY hideOtherAppsCmdMac.key "H">
<!ENTITY showAllAppsCmdMac.label "Show All">

<!ENTITY editMenu.label "Edit">
<!ENTITY editMenu.accesskey "E">
<!ENTITY undoCmd.label "Undo">
<!ENTITY undoCmd.key "Z">
<!ENTITY undoCmd.accesskey "U">
<!ENTITY redoCmd.label "Redo">
<!ENTITY redoCmd.key "Y">
<!ENTITY redoCmd.accesskey "R">
<!ENTITY cutCmd.label "Cut">
<!ENTITY cutCmd.key "X">
<!ENTITY cutCmd.accesskey "t">
<!ENTITY copyCmd.label "Copy">
<!ENTITY copyCmd.key "C">
<!ENTITY copyCmd.accesskey "C">
<!ENTITY pasteCmd.label "Paste">
<!ENTITY pasteCmd.key "V">
<!ENTITY pasteCmd.accesskey "P">
<!ENTITY deleteCmd.label "Delete">
<!ENTITY deleteCmd.key "D">
<!ENTITY deleteCmd.accesskey "D">
<!ENTITY selectAllCmd.label "Select All">
<!ENTITY selectAllCmd.key "A">
<!ENTITY selectAllCmd.accesskey "A">
17 changes: 17 additions & 0 deletions browser/locales/en-US/webapprt/webapp.properties
@@ -0,0 +1,17 @@
# 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/.

# LOCALIZATION NOTE: These are localized strings for the webapp runtime,
# which loads a webapp in a separate process from Firefox. Webapps loaded
# in this way have very little application chrome, but the runtime does
# provide them with some default functionality, like the standard OS
# menus/menuitems.

# LOCALIZATION NOTE (quitApplicationCmdMac.label): %S will be replaced with
# the name of the webapp.
quitApplicationCmdMac.label=Quit %S

# LOCALIZATION NOTE (hideApplicationCmdMac.label): %S will be replaced with
# the name of the webapp.
hideApplicationCmdMac.label=Hide %S
3 changes: 3 additions & 0 deletions browser/locales/jar.mn
Expand Up @@ -110,3 +110,6 @@
% locale testpilot @AB_CD@ %locale/feedback/
locale/feedback/main.dtd (%feedback/main.dtd)
locale/feedback/main.properties (%feedback/main.properties)
% locale webapprt @AB_CD@ %locale/webapprt/
locale/webapprt/webapp.dtd (%webapprt/webapp.dtd)
locale/webapprt/webapp.properties (%webapprt/webapp.properties)
2 changes: 2 additions & 0 deletions config/autoconf.mk.in
Expand Up @@ -680,6 +680,8 @@ MOZ_THEME_FASTSTRIPE = @MOZ_THEME_FASTSTRIPE@

MOZ_SERVICES_SYNC = @MOZ_SERVICES_SYNC@

MOZ_WEBAPP_RUNTIME = @MOZ_WEBAPP_RUNTIME@

MOZ_OFFICIAL_BRANDING = @MOZ_OFFICIAL_BRANDING@

HAVE_CLOCK_MONOTONIC = @HAVE_CLOCK_MONOTONIC@
Expand Down
41 changes: 41 additions & 0 deletions configure.in
Expand Up @@ -4497,6 +4497,7 @@ MOZ_BRANDING_DIRECTORY=
MOZ_OFFICIAL_BRANDING=
MOZ_FEEDS=1
MOZ_FLEXBOX=
MOZ_WEBAPP_RUNTIME=
MOZ_JSDEBUGGER=1
MOZ_AUTH_EXTENSION=1
MOZ_OGG=1
Expand Down Expand Up @@ -4559,6 +4560,7 @@ MOZ_GRAPHITE=1
case "${target}" in
*darwin*)
ACCESSIBILITY=
MOZ_WEBAPP_RUNTIME=1
;;
*)
ACCESSIBILITY=1
Expand All @@ -4569,6 +4571,7 @@ case "$target_os" in
mingw*)
NS_ENABLE_TSF=1
AC_DEFINE(NS_ENABLE_TSF)
MOZ_WEBAPP_RUNTIME=1
;;
esac

Expand Down Expand Up @@ -6274,6 +6277,44 @@ if test -n "$MOZ_TREE_FREETYPE"; then
AC_SUBST(CAIRO_FT_CFLAGS)
fi

dnl ========================================================
dnl Web App Runtime
dnl ========================================================
MOZ_ARG_DISABLE_BOOL(webapp-runtime,
[ --disable-webapp-runtime Disable Web App Runtime],
MOZ_WEBAPP_RUNTIME=,
MOZ_WEBAPP_RUNTIME=1)
if test -n "$MOZ_WEBAPP_RUNTIME" -a "$OS_ARCH" = "WINNT"; then
# Disable Web App Runtime for Windows builds that use the new toolkit if the
# required major version and minimum minor version of Unicode NSIS isn't in
# the path.
REQ_NSIS_MAJOR_VER=2
MIN_NSIS_MINOR_VER=33
MOZ_PATH_PROGS(MAKENSISU, $MAKENSISU makensisu-2.46 makensisu makensis)
if test -z "$MAKENSISU" -o "$MAKENSISU" = ":"; then
AC_MSG_ERROR([To build the Web App Runtime you must have the latest MozillaBuild or Unicode NSIS with a major version of $REQ_NSIS_MAJOR_VER and a minimum minor version of $MIN_NSIS_MINOR_VER in your path. To build without the Web App Runtime reconfigure using --disable-webapp-runtime.])
fi
changequote(,)
MAKENSISU_VER=`"$MAKENSISU" -version 2>/dev/null | sed -e '/-Unicode/!s/.*//g' -e 's/^v\([0-9]\+\.[0-9]\+\)\-Unicode$/\1/g'`
changequote([,])
if test ! "$MAKENSISU_VER" = ""; then
MAKENSISU_MAJOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $1 }'`
MAKENSISU_MINOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $2 }'`
fi
AC_MSG_CHECKING([for Unicode NSIS with major version == $REQ_NSIS_MAJOR_VER and minor version >= $MIN_NSIS_MINOR_VER])
if test "$MAKENSISU_VER" = "" ||
test ! "$MAKENSISU_MAJOR_VER" = "$REQ_NSIS_MAJOR_VER" -o \
! "$MAKENSISU_MINOR_VER" -ge $MIN_NSIS_MINOR_VER; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([To build the Web App Runtime you must have the latest MozillaBuild or Unicode NSIS with a major version of $REQ_NSIS_MAJOR_VER and a minimum minor version of $MIN_NSIS_MINOR_VER in your path. To build without the Web App Runtime reconfigure using --disable-webapp-runtime.])
fi
AC_MSG_RESULT([yes])
fi
AC_SUBST(MOZ_WEBAPP_RUNTIME)
if test "$MOZ_WEBAPP_RUNTIME"; then
AC_DEFINE(MOZ_WEBAPP_RUNTIME)
fi

dnl ========================================================
dnl Installer
dnl ========================================================
Expand Down
7 changes: 6 additions & 1 deletion dom/base/Webapps.jsm
Expand Up @@ -12,6 +12,8 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");

const WEBAPP_RUNTIME = Services.appinfo.ID == "webapprt@mozilla.org";

XPCOMUtils.defineLazyGetter(this, "NetUtil", function() {
Cu.import("resource://gre/modules/NetUtil.jsm");
return NetUtil;
Expand All @@ -24,7 +26,10 @@ XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
#ifdef MOZ_WIDGET_GONK
const DIRECTORY_NAME = "webappsDir";
#else
const DIRECTORY_NAME = "ProfD";
// If we're executing in the context of the webapp runtime, the data files
// are in a different directory (currently the Firefox profile that installed
// the webapp); otherwise, they're in the current profile.
const DIRECTORY_NAME = WEBAPP_RUNTIME ? "WebappRegD" : "ProfD";
#endif

let DOMApplicationRegistry = {
Expand Down
35 changes: 35 additions & 0 deletions modules/libpref/src/Preferences.cpp
Expand Up @@ -43,6 +43,7 @@
#include "mozilla/HashFunctions.h"

#include "nsXULAppAPI.h"
#include "nsIXULAppInfo.h"

#include "mozilla/Preferences.h"
#include "nsAppDirectoryServiceDefs.h"
Expand Down Expand Up @@ -84,6 +85,8 @@ namespace mozilla {
#define INITIAL_PREF_FILES 10
static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);

#define WEBAPPRT_APPID "webapprt@mozilla.org"

// Prototypes
static nsresult openPrefFile(nsIFile* aFile);
static nsresult pref_InitInitialObjects(void);
Expand Down Expand Up @@ -1015,6 +1018,14 @@ static nsresult pref_InitInitialObjects()
// - $app/defaults/preferences/*.js
// and in non omni.jar case:
// - $app/defaults/preferences/*.js
//
// When we're running WebappRT (i.e. $app == WEBAPPRT_APPID), in omni.jar
// case, we also load:
// - jar:$gre/omni.jar!/defaults/pref/$WEBAPPRT_APPID/*.js
// This allows WebappRT-specific prefs to override those of another app
// with whom it shares an app dir (i.e. Firefox).
// (A $WEBAPPRT_APPID dir is similarly hardcoded into the app pref dir list
// in nsXREDirProvider for when we're running WebappRT in non omni.jar case.)

nsZipFind *findPtr;
nsAutoPtr<nsZipFind> find;
Expand All @@ -1038,6 +1049,30 @@ static nsresult pref_InitInitialObjects()
}

prefEntries.Sort();

// Load jar:$gre/omni.jar!/defaults/pref/$WEBAPPRT_APPID/*.js
// if we're running WebappRT.
nsCOMPtr<nsIXULAppInfo> appInfo =
do_GetService("@mozilla.org/xre/app-info;1", &rv);
if (NS_SUCCEEDED(rv)) {
nsCAutoString appID;
if (NS_SUCCEEDED(appInfo->GetID(appID)) && appID.Equals(WEBAPPRT_APPID)) {
nsCAutoString prefsPath("defaults/pref/");
prefsPath.Append(appID);
prefsPath.AppendLiteral("/*.js$");
rv = jarReader->FindInit(prefsPath.get(), &findPtr);
NS_ENSURE_SUCCESS(rv, rv);

// Make sure the files get read last by putting them at the beginning
// of the list of pref entries (which is processed backwards), so prefs
// in these app-specific files override those in non-app-specific ones.
find = findPtr;
while (NS_SUCCEEDED(find->FindNext(&entryName, &entryNameLen))) {
prefEntries.InsertElementAt(0, Substring(entryName, entryNameLen));
}
}
}

for (PRUint32 i = prefEntries.Length(); i--; ) {
rv = pref_ReadPrefFromJar(jarReader, prefEntries[i].get());
if (NS_FAILED(rv))
Expand Down
15 changes: 14 additions & 1 deletion services/sync/SyncComponents.manifest
@@ -1,7 +1,20 @@
# WebappRT doesn't need these instructions, and they don't necessarily work
# with it, but it does use a GRE directory that the GRE shares with Firefox,
# so in order to prevent the instructions from being processed for WebappRT,
# we need to restrict them to the applications that depend on them, i.e.:
#
# b2g: {3c2e2abc-06d4-11e1-ac3b-374f68613e61}
# browser: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
# mobile/android: {aa3c5121-dab2-40e2-81ca-7ea25febc110}
# mobile/xul: {a23983c0-fd0e-11dc-95ff-0800200c9a66}
#
# In theory we should do this for all these instructions, but in practice it is
# sufficient to do it for the app-startup one, and the file is simpler that way.

# Weave.js
component {74b89fb0-f200-4ae8-a3ec-dd164117f6de} Weave.js
contract @mozilla.org/weave/service;1 {74b89fb0-f200-4ae8-a3ec-dd164117f6de}
category app-startup WeaveService service,@mozilla.org/weave/service;1
category app-startup WeaveService service,@mozilla.org/weave/service;1 application={3c2e2abc-06d4-11e1-ac3b-374f68613e61} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} application={aa3c5121-dab2-40e2-81ca-7ea25febc110} application={a23983c0-fd0e-11dc-95ff-0800200c9a66}
component {d28f8a0b-95da-48f4-b712-caf37097be41} Weave.js
contract @mozilla.org/network/protocol/about;1?what=sync-log {d28f8a0b-95da-48f4-b712-caf37097be41}
# Register resource aliases
Expand Down

0 comments on commit 3ead5c0

Please sign in to comment.