Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2181)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java

Issue 2974573002: Refactor WebApkServiceConnectionManager. (Closed)
Patch Set: Clean up. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..5f132ae1198dda62e993b612c919fcdb94e9343d 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,31 @@ 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.CheckBacksWebApkCallback callback =
+ new WebApkIdentityServiceClient.CheckBacksWebApkCallback() {
+ @Override
+ public void onChecked(boolean isValid) {
+ nativeOnQueryWebApkPackage(mNativeNotificationPlatformBridge,
+ isValid ? webApkPackage : "", callbackPointer);
+ }
+ };
+ ChromeWebApkHost.checkChromeBacksWebApkAsync(
+ ContextUtils.getApplicationContext(), webApkPackage, callback);
}
/**
@@ -584,7 +602,7 @@ public class NotificationPlatformBridge {
String platformTag = makePlatformTag(notificationId, origin, tag);
if (forWebApk) {
- WebApkNotificationClient.notifyNotification(
+ WebApkServiceClient.notifyNotification(
webApkPackage, notificationBuilder, platformTag, PLATFORM_ID);
} else {
// Set up a pending intent for going to the settings screen for |origin|.
@@ -717,7 +735,7 @@ public class NotificationPlatformBridge {
if (webApkPackage.isEmpty()) {
mNotificationManager.cancel(platformTag, PLATFORM_ID);
} else {
- WebApkNotificationClient.cancelNotification(webApkPackage, platformTag, PLATFORM_ID);
+ WebApkServiceClient.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);
}

Powered by Google App Engine
This is Rietveld 408576698