Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/MainActivity.java

Issue 2758193002: [Android WebAPKs] Don't navigate WebAPK when launching it from launcher (Closed)
Patch Set: Merge branch 'master' into twitter Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/webapk/shell_apk/shell_apk_version.gni ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/MainActivity.java
diff --git a/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/MainActivity.java b/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/MainActivity.java
index 17d438aeed38eb314c28bcc6e21b378e76a382e0..5a0b7d4ad695cdde432daec0b660ab4e1c15195f 100644
--- a/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/MainActivity.java
+++ b/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/MainActivity.java
@@ -67,11 +67,13 @@ public class MainActivity extends Activity {
* Launches WebAPK.
*/
private void launch() {
- String startUrl = getStartUrl();
+ String overrideUrl = getOverrideUrl();
+ String startUrl = (overrideUrl != null) ? overrideUrl : getStartUrl();
if (startUrl == null) {
return;
}
- if (launchHostBrowserInWebApkMode(startUrl)) {
+
+ if (launchHostBrowserInWebApkMode(startUrl, overrideUrl)) {
return;
}
if (launchBrowser(startUrl)) {
@@ -84,19 +86,23 @@ public class MainActivity extends Activity {
* Launches host browser in WebAPK mode.
* @return True if successful.
*/
- private boolean launchHostBrowserInWebApkMode(String startUrl) {
+ private boolean launchHostBrowserInWebApkMode(String startUrl, String overrideUrl) {
Log.v(TAG, "Url of the WebAPK: " + startUrl);
String packageName = getPackageName();
Log.v(TAG, "Package name of the WebAPK:" + packageName);
String runtimeHost = WebApkUtils.getHostBrowserPackageName(this);
int source = getIntent().getIntExtra(WebApkConstants.EXTRA_SOURCE, 0);
+
+ // The override URL is non null when the WebAPK is launched from a deep link. The WebAPK
+ // should navigate to the URL in the deep link even if the WebAPK is already open.
Intent intent = new Intent();
intent.setAction(ACTION_START_WEBAPK);
intent.setPackage(runtimeHost);
intent.putExtra(WebApkConstants.EXTRA_URL, startUrl)
.putExtra(WebApkConstants.EXTRA_SOURCE, source)
- .putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, packageName);
+ .putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, packageName)
+ .putExtra(WebApkConstants.EXTRA_WEBAPK_FORCE_NAVIGATION, (overrideUrl != null));
try {
startActivity(intent);
@@ -155,15 +161,17 @@ public class MainActivity extends Activity {
}
}
- /**
- * Returns the URL that the browser should navigate to.
- */
- private String getStartUrl() {
+ /** Retrieves URL from the intent's data. Returns null if a URL could not be retrieved. */
+ private String getOverrideUrl() {
String overrideUrl = getIntent().getDataString();
if (overrideUrl != null && overrideUrl.startsWith("https:")) {
return overrideUrl;
}
+ return null;
+ }
+ /** Returns the start URL from the Android Manifest. */
+ private String getStartUrl() {
ApplicationInfo appInfo;
try {
appInfo = getPackageManager().getApplicationInfo(
« no previous file with comments | « chrome/android/webapk/shell_apk/shell_apk_version.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698