Chromium Code Reviews| 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..665f6eb70f2b459415ceac3448093fe9a80b0ce6 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,24 @@ 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 startUrl, String overrideUrl) { |
| + Log.v(TAG, "Url of the WebAPK: " + overrideUrl); |
| 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. |
| + boolean navigateIfAlreadyOpen = (overrideUrl != null); |
|
dominickn
2017/03/21 02:09:33
Inline this in the putExtra call (but leave the co
|
| 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_NAVIGATE_IF_ALREADY_OPEN, |
| + navigateIfAlreadyOpen); |
| try { |
| startActivity(intent); |
| @@ -155,15 +162,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( |