Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ServiceTabLauncher.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ServiceTabLauncher.java b/chrome/android/java/src/org/chromium/chrome/browser/ServiceTabLauncher.java |
| index efb09f15f144d8bc09afecebe11f498aa56ea8e1..bdc6c717841c1d2c4cf31c7524510c250517b791 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ServiceTabLauncher.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ServiceTabLauncher.java |
| @@ -5,12 +5,14 @@ |
| package org.chromium.chrome.browser; |
| import android.app.Activity; |
| +import android.content.Context; |
| import android.content.Intent; |
| import android.net.Uri; |
| import android.os.AsyncTask; |
| import android.provider.Browser; |
| import android.support.annotation.Nullable; |
| import android.support.customtabs.CustomTabsIntent; |
| +import android.text.TextUtils; |
| import org.chromium.base.ApplicationStatus; |
| import org.chromium.base.ContextUtils; |
| @@ -77,24 +79,44 @@ public class ServiceTabLauncher { |
| return; |
| } |
| - final TabDelegate tabDelegate = new TabDelegate(incognito); |
| - |
| - // 1. Launch WebAPK if one matches the target URL. |
| + // Launch WebAPK if one matches the target URL. |
| if (ChromeWebApkHost.isEnabled()) { |
|
Yaron
2017/07/10 18:09:07
you need to rebase - this is always true now
Xi Han
2017/07/12 13:49:14
Done.
|
| - String webApkPackageName = |
| - WebApkValidator.queryWebApkPackage(ContextUtils.getApplicationContext(), url); |
| + final Context context = ContextUtils.getApplicationContext(); |
| + final String webApkPackageName = WebApkValidator.queryWebApkPackage(context, url); |
| if (webApkPackageName != null) { |
|
Yaron
2017/07/10 18:09:07
these else case for this is unhandled. I'd also co
Xi Han
2017/07/12 13:49:14
Done.
|
| - Intent intent = WebApkNavigationClient.createLaunchWebApkIntent( |
| - webApkPackageName, url, true /* forceNavigation */); |
| - if (intent != null) { |
| - intent.putExtra(ShortcutHelper.EXTRA_SOURCE, ShortcutSource.NOTIFICATION); |
| - ContextUtils.getApplicationContext().startActivity(intent); |
| - return; |
| - } |
| + WebApkValidator.CheckRuntimeHostCallback callback = |
| + new WebApkValidator.CheckRuntimeHostCallback() { |
| + @Override |
| + public void onCheckedRuntimeHost(String runtimeHost) { |
| + if (TextUtils.equals(runtimeHost, context.getPackageName())) { |
| + Intent intent = WebApkNavigationClient.createLaunchWebApkIntent( |
| + webApkPackageName, url, true /* forceNavigation */); |
| + if (intent != null) { |
| + intent.putExtra(ShortcutHelper.EXTRA_SOURCE, |
| + ShortcutSource.NOTIFICATION); |
| + context.startActivity(intent); |
| + return; |
| + } |
| + } |
| + launchTab(requestId, incognito, url, referrerUrl, referrerPolicy, |
| + extraHeaders, postData); |
| + } |
| + }; |
| + |
| + WebApkValidator.queryWebApkRuntimeHostAsync(webApkPackageName, callback); |
|
Yaron
2017/07/10 18:09:07
are we able to do this in all cases where we'd wan
Xi Han
2017/07/12 13:49:14
I think the navigation one requires significant re
|
| } |
| + } else { |
| + launchTab( |
| + requestId, incognito, url, referrerUrl, referrerPolicy, extraHeaders, postData); |
| } |
| + } |
| + |
| + private static void launchTab(int requestId, boolean incognito, final String url, |
| + String referrerUrl, int referrerPolicy, String extraHeaders, |
| + ResourceRequestBody postData) { |
| + final TabDelegate tabDelegate = new TabDelegate(incognito); |
| - // 2. Launch WebappActivity if one matches the target URL and was opened recently. |
| + // Launch WebappActivity if one matches the target URL and was opened recently. |
| // Otherwise, open the URL in a tab. |
| final WebappDataStorage storage = |
| WebappRegistry.getInstance().getWebappDataStorageForUrl(url); |