diff --git a/mobile/android/base/AndroidManifest.xml.in b/mobile/android/base/AndroidManifest.xml.in index 845d24ace4b3..327cbbf0635e 100644 --- a/mobile/android/base/AndroidManifest.xml.in +++ b/mobile/android/base/AndroidManifest.xml.in @@ -131,6 +131,23 @@ + + + + + + + + + #include @OBJDIR@/WebAppManifestFragment.xml.in diff --git a/mobile/android/base/WebApp.java.in b/mobile/android/base/WebApp.java.in index b0b16527552a..6fdff3f6c0a3 100644 --- a/mobile/android/base/WebApp.java.in +++ b/mobile/android/base/WebApp.java.in @@ -16,6 +16,7 @@ import android.widget.TextView; import android.widget.RelativeLayout; import android.content.Context; import android.content.SharedPreferences; +import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; @@ -39,10 +40,11 @@ import org.mozilla.gecko.R; import org.json.JSONObject; public class WebApp extends GeckoApp { + private static final String LOGTAG = "WebApp"; + private URL mOrigin; private TextView mTitlebarText = null; private View mTitlebar = null; - private static final String LOGTAG = "WebApp"; private View mSplashscreen = null; protected int getIndex() { return 0; } @@ -87,6 +89,22 @@ public class WebApp extends GeckoApp { } } + @Override + protected void initializeChrome(String uri, boolean isExternalURL) { + String action = getIntent().getAction(); + if (GeckoApp.ACTION_WEBAPP_PREFIX.equals(action)) { + // This action assumes the uri is not an installed WebApp. We will + // use the WebAppAllocator to register the uri with an Android + // process so it can run chromeless. + int index = WebAppAllocator.getInstance(this).findAndAllocateIndex(uri, "App", (Bitmap) null); + Intent appIntent = GeckoAppShell.getWebAppIntent(index, uri); + startActivity(appIntent); + finish(); + } + + super.initializeChrome(uri, isExternalURL); + } + private void showSplash() { mSplashscreen = (RelativeLayout) findViewById(R.id.splashscreen); @@ -238,4 +256,3 @@ public class WebApp extends GeckoApp { getLayerView().setOverScrollMode(View.OVER_SCROLL_NEVER); } }; - diff --git a/mobile/android/chrome/content/WebAppRT.js b/mobile/android/chrome/content/WebAppRT.js index a7751da24da6..8f67fa106d2a 100644 --- a/mobile/android/chrome/content/WebAppRT.js +++ b/mobile/android/chrome/content/WebAppRT.js @@ -80,11 +80,14 @@ let WebAppRT = { return; } } - aCallback(""); + + // Finally, just attempt to open the webapp as a normal web page + aCallback(aUrl); }; request.onerror = function() { - aCallback(""); + // Attempt to open the webapp as a normal web page + aCallback(aUrl); }; }, diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index 6378534054d9..fd36bfe68a15 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -279,15 +279,7 @@ var BrowserApp = { let status = this.startupStatus(); if (pinned) { WebAppRT.init(status, url, function(aUrl) { - if (aUrl) { - BrowserApp.addTab(aUrl); - } else { - let uri = Services.io.newURI(url, null, null); - if (!uri) - return; - Cc["@mozilla.org/uriloader/external-protocol-service;1"].getService(Ci.nsIExternalProtocolService).getProtocolHandlerInfo(uri.scheme).launchWithURI(uri); - BrowserApp.quit(); - } + BrowserApp.addTab(aUrl); }); } else { SearchEngines.init();