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 681dc1f6482840be0f6af0f59c1ab8febd90bebb..759556274ffd256daa5fa308b51aa23292cf02c5 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 |
| @@ -41,6 +41,7 @@ import org.chromium.chrome.browser.preferences.website.SingleCategoryPreferences |
| import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences; |
| import org.chromium.chrome.browser.preferences.website.SiteSettingsCategory; |
| import org.chromium.components.url_formatter.UrlFormatter; |
| +import org.chromium.webapk.lib.client.WebApkServiceClient; |
| import org.chromium.webapk.lib.client.WebApkValidator; |
| import java.net.URI; |
| @@ -147,16 +148,30 @@ 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) { |
| - String webApkPackage = |
| + private void queryWebApkPackage(String url, final long callbackPointer) { |
| + final String webApkPackage = |
| WebApkValidator.queryWebApkPackage(ContextUtils.getApplicationContext(), url); |
| - return webApkPackage == null ? "" : webApkPackage; |
| + if (webApkPackage == null) { |
| + nativeOnQueryWebApkPackage(mNativeNotificationPlatformBridge, "", callbackPointer); |
| + return; |
| + } |
| + |
| + WebApkValidator.IsOwnedCheckCallback callback = new WebApkValidator.IsOwnedCheckCallback() { |
|
Yaron
2017/07/14 19:52:04
rather than custom callbacks, can the two new call
Xi Han
2017/07/14 22:00:56
We can't, it will introduce dependency on base.
|
| + @Override |
| + public void onIsOwnedChecked(boolean isOwned) { |
| + nativeOnQueryWebApkPackage(mNativeNotificationPlatformBridge, |
| + isOwned ? webApkPackage : "", callbackPointer); |
| + } |
| + }; |
| + WebApkValidator.isOwnedWebApkAsync( |
| + ContextUtils.getApplicationContext(), webApkPackage, callback); |
| } |
| /** |
| @@ -717,7 +732,8 @@ public class NotificationPlatformBridge { |
| if (webApkPackage.isEmpty()) { |
| mNotificationManager.cancel(platformTag, PLATFORM_ID); |
| } else { |
| - WebApkNotificationClient.cancelNotification(webApkPackage, platformTag, PLATFORM_ID); |
| + WebApkServiceClient.cancelNotification( |
| + ContextUtils.getApplicationContext(), webApkPackage, platformTag, PLATFORM_ID); |
| } |
| } |
| @@ -769,4 +785,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 webApkPackage, long callbackPointer); |
| } |