Bug 835399 - Allow launching non-privileged webapps with a URL r=wesj

This commit is contained in:
Mark Finkle 2013-02-13 10:26:03 -05:00
parent 79b00ac815
commit 2f067c24b8
4 changed files with 42 additions and 13 deletions

View File

@ -131,6 +131,23 @@
</intent-filter>
</activity>
<activity android:name=".WebApp"
android:label="@string/webapp_generic_name"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|orientation|screenSize"
android:windowSoftInputMode="stateUnspecified|adjustResize"
android:launchMode="singleTask"
android:taskAffinity="org.mozilla.gecko.WEBAPP"
android:process=":@ANDROID_PACKAGE_NAME@.WebApp"
android:excludeFromRecents="true"
android:theme="@style/Gecko.App">
<intent-filter>
<action android:name="org.mozilla.gecko.WEBAPP" />
</intent-filter>
<intent-filter>
<action android:name="org.mozilla.gecko.ACTION_ALERT_CALLBACK" />
</intent-filter>
</activity>
#include @OBJDIR@/WebAppManifestFragment.xml.in
<!-- Masquerade as the Resolver so that we can be opened from the Marketplace. -->

View File

@ -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);
}
};

View File

@ -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);
};
},

View File

@ -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();