зеркало из https://github.com/mozilla/gecko-dev.git
Bug 835399 - Allow launching non-privileged webapps with a URL r=wesj
This commit is contained in:
Родитель
ed986a4140
Коммит
4ed52610f6
|
@ -131,6 +131,23 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</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
|
#include @OBJDIR@/WebAppManifestFragment.xml.in
|
||||||
|
|
||||||
<!-- Masquerade as the Resolver so that we can be opened from the Marketplace. -->
|
<!-- Masquerade as the Resolver so that we can be opened from the Marketplace. -->
|
||||||
|
|
|
@ -16,6 +16,7 @@ import android.widget.TextView;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.GradientDrawable;
|
import android.graphics.drawable.GradientDrawable;
|
||||||
|
@ -39,10 +40,11 @@ import org.mozilla.gecko.R;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class WebApp extends GeckoApp {
|
public class WebApp extends GeckoApp {
|
||||||
|
private static final String LOGTAG = "WebApp";
|
||||||
|
|
||||||
private URL mOrigin;
|
private URL mOrigin;
|
||||||
private TextView mTitlebarText = null;
|
private TextView mTitlebarText = null;
|
||||||
private View mTitlebar = null;
|
private View mTitlebar = null;
|
||||||
private static final String LOGTAG = "WebApp";
|
|
||||||
private View mSplashscreen = null;
|
private View mSplashscreen = null;
|
||||||
|
|
||||||
protected int getIndex() { return 0; }
|
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() {
|
private void showSplash() {
|
||||||
mSplashscreen = (RelativeLayout) findViewById(R.id.splashscreen);
|
mSplashscreen = (RelativeLayout) findViewById(R.id.splashscreen);
|
||||||
|
|
||||||
|
@ -238,4 +256,3 @@ public class WebApp extends GeckoApp {
|
||||||
getLayerView().setOverScrollMode(View.OVER_SCROLL_NEVER);
|
getLayerView().setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -80,11 +80,14 @@ let WebAppRT = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aCallback("");
|
|
||||||
|
// Finally, just attempt to open the webapp as a normal web page
|
||||||
|
aCallback(aUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
request.onerror = function() {
|
request.onerror = function() {
|
||||||
aCallback("");
|
// Attempt to open the webapp as a normal web page
|
||||||
|
aCallback(aUrl);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -279,15 +279,7 @@ var BrowserApp = {
|
||||||
let status = this.startupStatus();
|
let status = this.startupStatus();
|
||||||
if (pinned) {
|
if (pinned) {
|
||||||
WebAppRT.init(status, url, function(aUrl) {
|
WebAppRT.init(status, url, function(aUrl) {
|
||||||
if (aUrl) {
|
BrowserApp.addTab(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();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
SearchEngines.init();
|
SearchEngines.init();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче