This is an automated email from the ASF dual-hosted git repository.

erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-android.git


The following commit(s) were added to refs/heads/master by this push:
     new ebf0b105 feat: Add ResolveServiceWorkerRequests preference (#1696)
ebf0b105 is described below

commit ebf0b105a3323a643866f8fe87aba445bb79dbb4
Author: jcesarmobile <jcesarmob...@gmail.com>
AuthorDate: Wed May 8 13:53:09 2024 +0200

    feat: Add ResolveServiceWorkerRequests preference (#1696)
    
    * feat: Add ResolveServiceWorkerRequests preference
    * Change default to true
---
 .../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..fd719f09 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", true);
+        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

Reply via email to