mirror of
https://github.com/apache/cordova-android.git
synced 2025-04-05 22:41:53 +08:00
feat: Add ResolveServiceWorkerRequests preference (#1696)
* feat: Add ResolveServiceWorkerRequests preference * Change default to true
This commit is contained in:
parent
9261b29cf2
commit
ebf0b105a3
@ -29,6 +29,8 @@ import android.webkit.ClientCertRequest;
|
|||||||
import android.webkit.HttpAuthHandler;
|
import android.webkit.HttpAuthHandler;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
import android.webkit.RenderProcessGoneDetail;
|
import android.webkit.RenderProcessGoneDetail;
|
||||||
|
import android.webkit.ServiceWorkerClient;
|
||||||
|
import android.webkit.ServiceWorkerController;
|
||||||
import android.webkit.SslErrorHandler;
|
import android.webkit.SslErrorHandler;
|
||||||
import android.webkit.WebResourceRequest;
|
import android.webkit.WebResourceRequest;
|
||||||
import android.webkit.WebResourceResponse;
|
import android.webkit.WebResourceResponse;
|
||||||
@ -116,6 +118,18 @@ public class SystemWebViewClient extends WebViewClient {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.assetLoader = assetLoaderBuilder.build();
|
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());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user