| 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..52020c1108b033a02a590da1e798a1f072dc2733 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
|
| @@ -40,7 +40,10 @@ import org.chromium.chrome.browser.preferences.PreferencesLauncher;
|
| 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.chrome.browser.webapps.ChromeWebApkHost;
|
| +import org.chromium.chrome.browser.webapps.WebApkServiceClient;
|
| import org.chromium.components.url_formatter.UrlFormatter;
|
| +import org.chromium.webapk.lib.client.WebApkIdentityServiceClient;
|
| import org.chromium.webapk.lib.client.WebApkValidator;
|
|
|
| import java.net.URI;
|
| @@ -147,16 +150,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;
|
| + }
|
| +
|
| + WebApkIdentityServiceClient.CheckBrowserBacksWebApkCallback callback =
|
| + new WebApkIdentityServiceClient.CheckBrowserBacksWebApkCallback() {
|
| + @Override
|
| + public void onChecked(boolean doesBrowserBackWebApk) {
|
| + nativeOnQueryWebApkPackage(mNativeNotificationPlatformBridge,
|
| + doesBrowserBackWebApk ? webApkPackage : "", callbackPointer);
|
| + }
|
| + };
|
| + ChromeWebApkHost.checkChromeBacksWebApkAsync(webApkPackage, callback);
|
| }
|
|
|
| /**
|
| @@ -584,7 +601,7 @@ public class NotificationPlatformBridge {
|
|
|
| String platformTag = makePlatformTag(notificationId, origin, tag);
|
| if (forWebApk) {
|
| - WebApkNotificationClient.notifyNotification(
|
| + WebApkServiceClient.getInstance().notifyNotification(
|
| webApkPackage, notificationBuilder, platformTag, PLATFORM_ID);
|
| } else {
|
| // Set up a pending intent for going to the settings screen for |origin|.
|
| @@ -717,7 +734,8 @@ public class NotificationPlatformBridge {
|
| if (webApkPackage.isEmpty()) {
|
| mNotificationManager.cancel(platformTag, PLATFORM_ID);
|
| } else {
|
| - WebApkNotificationClient.cancelNotification(webApkPackage, platformTag, PLATFORM_ID);
|
| + WebApkServiceClient.getInstance().cancelNotification(
|
| + webApkPackage, platformTag, PLATFORM_ID);
|
| }
|
| }
|
|
|
| @@ -769,4 +787,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);
|
| }
|
|
|