This is an automated email from the ASF dual-hosted git repository. jcesarmobile pushed a commit to branch feat-sw in repository https://gitbox.apache.org/repos/asf/cordova-android.git
commit b5465c134520bf585fee477bfdacb1b85bc43366 Author: jcesarmobile <jcesarmob...@gmail.com> AuthorDate: Sun Feb 25 23:33:45 2024 +0100 feat: Add ResolveServiceWorkerRequests preference --- .../src/org/apache/cordova/engine/SystemWebViewClient.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/framework/src/org/apache/cordova/engine/SystemWebViewClient.java b/framework/src/org/apache/cordova/engine/SystemWebViewClient.java index 9f057182..a58ed420 100755 --- a/framework/src/org/apache/cordova/engine/SystemWebViewClient.java +++ b/framework/src/org/apache/cordova/engine/SystemWebViewClient.java @@ -29,6 +29,8 @@ import android.webkit.ClientCertRequest; import android.webkit.HttpAuthHandler; import android.webkit.MimeTypeMap; import android.webkit.RenderProcessGoneDetail; +import android.webkit.ServiceWorkerClient; +import android.webkit.ServiceWorkerController; import android.webkit.SslErrorHandler; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; @@ -116,6 +118,18 @@ public class SystemWebViewClient extends WebViewClient { }); this.assetLoader = assetLoaderBuilder.build(); + boolean setAsServiceWorkerClient = parentEngine.preferences.getBoolean("ResolveServiceWorkerRequests", false); + ServiceWorkerController controller = null; + + if (setAsServiceWorkerClient) { + controller = ServiceWorkerController.getInstance(); + controller.setServiceWorkerClient(new ServiceWorkerClient(){ + @Override + public WebResourceResponse shouldInterceptRequest(WebResourceRequest request) { + return assetLoader.shouldInterceptRequest(request.getUrl()); + } + }); + } } /** --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org