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

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
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..e1cdf50d7284364573ab26d9577a55b799fd1824 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
@@ -7,9 +7,6 @@ package org.chromium.webapk.shell_apk;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
@@ -67,11 +64,16 @@ public class MainActivity extends Activity {
* Launches WebAPK.
*/
private void launch() {
- String startUrl = getStartUrl();
- if (startUrl == null) {
+ String overrideUrl = getOverrideUrl();
+ if (launchHostBrowserInWebApkMode(overrideUrl)) {
return;
}
- if (launchHostBrowserInWebApkMode(startUrl)) {
+
+ String startUrl = overrideUrl;
+ if (startUrl == null) {
+ startUrl = getStartUrl();
+ }
+ if (startUrl == null) {
return;
}
if (launchBrowser(startUrl)) {
@@ -84,8 +86,8 @@ public class MainActivity extends Activity {
* Launches host browser in WebAPK mode.
* @return True if successful.
*/
- private boolean launchHostBrowserInWebApkMode(String startUrl) {
- Log.v(TAG, "Url of the WebAPK: " + startUrl);
+ private boolean launchHostBrowserInWebApkMode(String overrideUrl) {
+ Log.v(TAG, "Url of the WebAPK: " + overrideUrl);
String packageName = getPackageName();
Log.v(TAG, "Package name of the WebAPK:" + packageName);
@@ -94,7 +96,7 @@ public class MainActivity extends Activity {
Intent intent = new Intent();
intent.setAction(ACTION_START_WEBAPK);
intent.setPackage(runtimeHost);
- intent.putExtra(WebApkConstants.EXTRA_URL, startUrl)
+ intent.putExtra(WebApkConstants.EXTRA_URL, overrideUrl)
.putExtra(WebApkConstants.EXTRA_SOURCE, source)
.putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, packageName);
@@ -155,8 +157,18 @@ public class MainActivity extends Activity {
}
}
+ /** Returns the URL in the data URL */
+ private String getOverrideUrl() {
+ String overrideUrl = getIntent().getDataString();
+ if (overrideUrl != null && overrideUrl.startsWith("https:")) {
+ return overrideUrl;
+ }
+ return null;
+ }
+
/**
- * Returns the URL that the browser should navigate to.
+ * Returns the start URL from the Android ManifesReturns the URL that the browser should
dominickn 2017/03/20 04:00:09 Something went wrong with this comment here. Plus
pkotwicz 2017/03/20 22:58:37 Fixed. Thank you very much for catching this
+ * navigate to.
*/
private String getStartUrl() {
String overrideUrl = getIntent().getDataString();
@@ -164,13 +176,6 @@ public class MainActivity extends Activity {
return overrideUrl;
}
- ApplicationInfo appInfo;
- try {
- appInfo = getPackageManager().getApplicationInfo(
- getPackageName(), PackageManager.GET_META_DATA);
- } catch (NameNotFoundException e) {
- return null;
- }
- return appInfo.metaData.getString(WebApkMetaDataKeys.START_URL);
+ return getApplicationInfo().metaData.getString(WebApkMetaDataKeys.START_URL);
}
}

Powered by Google App Engine
This is Rietveld 408576698