Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java |
| index c0aa956dffe31ab8d34d02af2b612058b1e4c55e..0db286c29409711aec91798490a8c436bd6e01ff 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java |
| @@ -84,6 +84,8 @@ public class NotificationPlatformBridge { |
| private long mLastNotificationClickMs; |
| + private String mWebApkPackage; |
|
Yaron
2017/07/10 18:09:07
nit: make the local "final" instead. In general, I
Xi Han
2017/07/12 13:49:14
Good catch! Figure out a way to get rid of this me
|
| + |
| /** |
| * Creates a new instance of the NotificationPlatformBridge. |
| * |
| @@ -148,18 +150,40 @@ public class NotificationPlatformBridge { |
| /** |
| * Returns the package for the WebAPK which should handle the URL. |
| - * |
| * @param url The url to check. |
| + * @param callbackPointer The callback to call after we know whether a WebAPK can handle the |
| + * url. |
| * @return Package name of the WebAPK which should handle the URL. Returns empty string if the |
| * URL should not be handled by a WebAPK. |
| */ |
| @CalledByNative |
| - private String queryWebApkPackage(String url) { |
| - if (!ChromeWebApkHost.isEnabled()) return ""; |
| + private void queryWebApkPackage(String url, final long callbackPointer) { |
| + if (!ChromeWebApkHost.isEnabled()) { |
|
pkotwicz
2017/07/10 19:06:05
ChromeWebApkHost#isEnabled() no longer exists :)
Xi Han
2017/07/12 13:49:14
Rebased:)
|
| + nativeOnQueryWebApkPackage(mNativeNotificationPlatformBridge, "", callbackPointer); |
| + return; |
| + } |
| - String webApkPackage = |
| + mWebApkPackage = |
| WebApkValidator.queryWebApkPackage(ContextUtils.getApplicationContext(), url); |
| - return webApkPackage == null ? "" : webApkPackage; |
| + if (mWebApkPackage == null) { |
| + nativeOnQueryWebApkPackage(mNativeNotificationPlatformBridge, "", callbackPointer); |
| + return; |
| + } |
| + |
| + WebApkValidator.CheckRuntimeHostCallback callback = |
| + new WebApkValidator.CheckRuntimeHostCallback() { |
| + @Override |
| + public void onCheckedRuntimeHost(String runtimeHost) { |
| + if (!TextUtils.equals(runtimeHost, |
|
Yaron
2017/07/10 18:09:07
shouldn't need textutils. Just do ContextUtils.get
Xi Han
2017/07/12 13:49:14
If the package name is null, won't |ContextUtils.g
|
| + ContextUtils.getApplicationContext().getPackageName())) { |
| + mWebApkPackage = ""; |
| + } |
| + nativeOnQueryWebApkPackage( |
| + mNativeNotificationPlatformBridge, mWebApkPackage, callbackPointer); |
| + } |
| + }; |
| + |
| + WebApkValidator.queryWebApkRuntimeHostAsync(mWebApkPackage, callback); |
| } |
| /** |
| @@ -775,4 +799,6 @@ public class NotificationPlatformBridge { |
| private native void nativeOnNotificationClosed(long nativeNotificationPlatformBridgeAndroid, |
| String notificationId, String origin, String profileId, boolean incognito, String tag, |
| boolean byUser); |
| + private native void nativeOnQueryWebApkPackage( |
| + long nativeNotificationPlatformBridgeAndroid, String runtimeHost, long callbackPointer); |
| } |