# ServiceWorkerWebSettingsCompat

Artifact: [androidx.webkit:webkit](https://developer.android.com/jetpack/androidx/releases/webkit) [View Source](https://cs.android.com/search?q=file:androidx/webkit/ServiceWorkerWebSettingsCompat.java+class:androidx.webkit.ServiceWorkerWebSettingsCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

*** ** * ** ***


```
@AnyThread
abstract class ServiceWorkerWebSettingsCompat
```

<br />

*** ** * ** ***

Manages settings state for all Service Workers. These settings are not tied to the lifetime of any WebView because service workers can outlive WebView instances. The settings are similar to `https://developer.android.com/reference/android/webkit/WebSettings.html` but only settings relevant to Service Workers are supported.

## Summary

| ### Public functions |
|---|---|
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.SERVICE_WORKER_CONTENT_ACCESS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowContentAccess()()` Gets whether Service Workers support content URL access. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.SERVICE_WORKER_FILE_ACCESS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowFileAccess()()` Gets whether Service Workers support file access. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#getBlockNetworkLoads()()` Gets whether Service Workers are prohibited from loading any resources from the network. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.SERVICE_WORKER_CACHE_MODE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#getCacheMode()()` Gets the current setting for overriding the cache mode. |
| `abstract (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.REQUESTED_WITH_HEADER_ALLOW_LIST, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") [getRequestedWithHeaderOriginAllowList](https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#getRequestedWithHeaderOriginAllowList())()` **This function is deprecated.** The origin trial to disable the X-Requested-With feature has ended, so this API now just returns an empty set. <br /> |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.COOKIE_INTERCEPT, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#isIncludeCookiesOnShouldInterceptRequestEnabled()()` Returns whether cookie access during request intercept is enabled. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.SERVICE_WORKER_CONTENT_ACCESS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowContentAccess(boolean)(allow: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Enables or disables content URL access from Service Workers. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.SERVICE_WORKER_FILE_ACCESS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowFileAccess(boolean)(allow: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Enables or disables file access within Service Workers. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#setBlockNetworkLoads(boolean)(flag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether Service Workers should not load resources from the network. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.SERVICE_WORKER_CACHE_MODE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#setCacheMode(int)(mode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Overrides the way the cache is used. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.COOKIE_INTERCEPT, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#setIncludeCookiesOnShouldInterceptRequestEnabled(boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` This method controls if the relevant `Cookie` header will be added to the `https://developer.android.com/reference/android/webkit/WebResourceRequest.html` object passed to `https://developer.android.com/reference/android/webkit/ServiceWorkerClient.html#shouldInterceptRequest(android.webkit.WebResourceRequest)`. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature.REQUESTED_WITH_HEADER_ALLOW_LIST, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") [setRequestedWithHeaderOriginAllowList](https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#setRequestedWithHeaderOriginAllowList(java.util.Set<java.lang.String>))(allowList: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>)` **This function is deprecated.** The origin trial to disable the X-Requested-With feature has ended, so this API no longer does anything. <br /> |

## Public functions

### getAllowContentAccess

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
@RequiresFeature(name = WebViewFeature.SERVICE_WORKER_CONTENT_ACCESS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
abstract fun getAllowContentAccess(): Boolean
```

Gets whether Service Workers support content URL access.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#SERVICE_WORKER_CONTENT_ACCESS()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowContentAccess(boolean)` |   |

### getAllowFileAccess

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
@RequiresFeature(name = WebViewFeature.SERVICE_WORKER_FILE_ACCESS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
abstract fun getAllowFileAccess(): Boolean
```

Gets whether Service Workers support file access.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#SERVICE_WORKER_FILE_ACCESS()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowFileAccess(boolean)` |   |

### getBlockNetworkLoads

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
@RequiresFeature(name = WebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
abstract fun getBlockNetworkLoads(): Boolean
```

Gets whether Service Workers are prohibited from loading any resources from the network.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the Service Workers are not allowed to load any resources from the network |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#SERVICE_WORKER_BLOCK_NETWORK_LOADS()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#setBlockNetworkLoads(boolean)` |   |

### getCacheMode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
@RequiresFeature(name = WebViewFeature.SERVICE_WORKER_CACHE_MODE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
abstract fun getCacheMode(): Int
```

Gets the current setting for overriding the cache mode.

Value is one of the following:

- `WebSettings.LOAD_DEFAULT`
- `WebSettings.LOAD_CACHE_ELSE_NETWORK`
- `WebSettings.LOAD_NO_CACHE`
- `WebSettings.LOAD_CACHE_ONLY`

<br />

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the current setting for overriding the cache mode |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#SERVICE_WORKER_CACHE_MODE()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#setCacheMode(int)` |   |

### getRequestedWithHeaderOriginAllowList

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.6.0) Deprecated in [1.15.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.15.0)

```
@RequiresFeature(name = WebViewFeature.REQUESTED_WITH_HEADER_ALLOW_LIST, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
abstract fun [getRequestedWithHeaderOriginAllowList](https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#getRequestedWithHeaderOriginAllowList())(): (Mutable)Set<String!>
```

> [!CAUTION]
> **This function is deprecated.**   
>
> The origin trial to disable the X-Requested-With feature has ended, so this API now just returns an empty set.

Get the currently configured allow-list of origins, which is guaranteed to receive the `X-Requested-With` HTTP header on requests from service workers.

Any origin *not* on this allow-list may not receive the header, depending on the current installed WebView provider.

The format of the strings in the allow-list follows the origin rules of `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,java.lang.String,java.util.Set<java.lang.String>,androidx.webkit.WebViewCompat.WebMessageListener)`.

| Returns |
|---|---|
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | The configured set of allow-listed origins. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#REQUESTED_WITH_HEADER_ALLOW_LIST()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#setRequestedWithHeaderOriginAllowList(java.util.Set<java.lang.String>)` |   |
| `https://developer.android.com/reference/kotlin/androidx/webkit/WebSettingsCompat#getRequestedWithHeaderOriginAllowList(android.webkit.WebSettings)` |   |

### isIncludeCookiesOnShouldInterceptRequestEnabled

Added in [1.15.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.15.0)

```
@RequiresFeature(name = WebViewFeature.COOKIE_INTERCEPT, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
abstract fun isIncludeCookiesOnShouldInterceptRequestEnabled(): Boolean
```

Returns whether cookie access during request intercept is enabled.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#COOKIE_INTERCEPT()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#setIncludeCookiesOnShouldInterceptRequestEnabled(boolean)` |   |

### setAllowContentAccess

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
@RequiresFeature(name = WebViewFeature.SERVICE_WORKER_CONTENT_ACCESS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
abstract fun setAllowContentAccess(allow: Boolean): Unit
```

Enables or disables content URL access from Service Workers.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#SERVICE_WORKER_CONTENT_ACCESS()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/webkit/WebSettings.html#setAllowContentAccess(boolean)` |   |
| `https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowContentAccess()` |   |

### setAllowFileAccess

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
@RequiresFeature(name = WebViewFeature.SERVICE_WORKER_FILE_ACCESS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
abstract fun setAllowFileAccess(allow: Boolean): Unit
```

Enables or disables file access within Service Workers.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#SERVICE_WORKER_FILE_ACCESS()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/webkit/WebSettings.html#setAllowFileAccess(boolean)` |   |
| `https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowContentAccess()` |   |

### setBlockNetworkLoads

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
@RequiresFeature(name = WebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
abstract fun setBlockNetworkLoads(flag: Boolean): Unit
```

Sets whether Service Workers should not load resources from the network.

| Parameters |
|---|---|
| `flag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` means block network loads by the Service Workers |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#SERVICE_WORKER_BLOCK_NETWORK_LOADS()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/webkit/WebSettings.html#setBlockNetworkLoads(boolean)` |   |
| `https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#getBlockNetworkLoads()` |   |

### setCacheMode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.1.0)

```
@RequiresFeature(name = WebViewFeature.SERVICE_WORKER_CACHE_MODE, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
abstract fun setCacheMode(mode: Int): Unit
```

Overrides the way the cache is used.

| Parameters |
|---|---|
| `mode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the mode to use. One of `https://developer.android.com/reference/android/webkit/WebSettings.html#LOAD_DEFAULT`, `https://developer.android.com/reference/android/webkit/WebSettings.html#LOAD_CACHE_ELSE_NETWORK`, `https://developer.android.com/reference/android/webkit/WebSettings.html#LOAD_NO_CACHE` or `https://developer.android.com/reference/android/webkit/WebSettings.html#LOAD_CACHE_ONLY`. The default value is `https://developer.android.com/reference/android/webkit/WebSettings.html#LOAD_DEFAULT`. Value is one of the following: - `WebSettings.LOAD_DEFAULT` - `WebSettings.LOAD_CACHE_ELSE_NETWORK` - `WebSettings.LOAD_NO_CACHE` - `WebSettings.LOAD_CACHE_ONLY` <br /> |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#SERVICE_WORKER_CACHE_MODE()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/webkit/WebSettings.html#setCacheMode(int)` |   |
| `https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#getCacheMode()` |   |

### setIncludeCookiesOnShouldInterceptRequestEnabled

Added in [1.15.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.15.0)

```
@RequiresFeature(name = WebViewFeature.COOKIE_INTERCEPT, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
abstract fun setIncludeCookiesOnShouldInterceptRequestEnabled(enabled: Boolean): Unit
```

This method controls if the relevant `Cookie` header will be added to the `https://developer.android.com/reference/android/webkit/WebResourceRequest.html` object passed to `https://developer.android.com/reference/android/webkit/ServiceWorkerClient.html#shouldInterceptRequest(android.webkit.WebResourceRequest)`. It also enables the use of `https://developer.android.com/reference/kotlin/androidx/webkit/WebResourceResponseCompat#setCookies(java.util.List<java.lang.String>)`, which will otherwise be ignored.

Prefer using this method over calling `https://developer.android.com/reference/android/webkit/CookieManager.html` as part of intercepting requests if it is necessary to access cookies, as this approach will provide the correct set of cookies for the request.

This method should only be called if `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)` returns `true` for `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#COOKIE_INTERCEPT()`.

| Parameters |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether cookie access during request intercept should be enabled. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#COOKIE_INTERCEPT()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

### setRequestedWithHeaderOriginAllowList

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.6.0) Deprecated in [1.15.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.15.0)

```
@RequiresFeature(name = WebViewFeature.REQUESTED_WITH_HEADER_ALLOW_LIST, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
abstract fun [setRequestedWithHeaderOriginAllowList](https://developer.android.com/reference/kotlin/androidx/webkit/ServiceWorkerWebSettingsCompat#setRequestedWithHeaderOriginAllowList(java.util.Set<java.lang.String>))(allowList: (Mutable)Set<String!>): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> The origin trial to disable the X-Requested-With feature has ended, so this API no longer does anything.

Set an allow-list of origins to receive the `X-Requested-With` HTTP header from service workers.

Historically, this header was sent on all requests from WebView, containing the app package name of the embedding app. Depending on the version of installed WebView, this may no longer be the case, as the header was deprecated in late 2022, and its use discontinued.

Apps can use this method to restore the legacy behavior for servers that still rely on the deprecated header, but it should not be used to identify the WebView to first-party servers under the control of the app developer.

The format of the strings in the allow-list follows the origin rules of `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,java.lang.String,java.util.Set<java.lang.String>,androidx.webkit.WebViewCompat.WebMessageListener)`.

| Parameters |
|---|---|
| `allowList: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | Set of origins to allow-list. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the allow-list contains a malformed origin. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#REQUESTED_WITH_HEADER_ALLOW_LIST()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/WebSettingsCompat#setRequestedWithHeaderOriginAllowList(android.webkit.WebSettings,java.util.Set<java.lang.String>)` |   |