Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.webkit; |
| 18 | |
| 19 | /** |
| 20 | * Manages settings state for all Service Workers. These settings are not tied to |
| 21 | * the lifetime of any WebView because service workers can outlive WebView instances. |
| 22 | * The settings are similar to {@link WebSettings} but only settings relevant to |
| 23 | * Service Workers are supported. |
| 24 | */ |
| 25 | // This is an abstract base class: concrete ServiceWorkerControllers must |
| 26 | // create a class derived from this, and return an instance of it in the |
| 27 | // ServiceWorkerController.getServiceWorkerWebSettings() method implementation. |
| 28 | public abstract class ServiceWorkerWebSettings { |
| 29 | |
| 30 | /** |
| 31 | * Overrides the way the cache is used, see {@link WebSettings#setCacheMode}. |
| 32 | * |
Tim Volodine | b90f538 | 2016-04-29 12:44:41 +0100 | [diff] [blame] | 33 | * @param mode the mode to use. One of {@link WebSettings#LOAD_DEFAULT}, |
| 34 | * {@link WebSettings#LOAD_CACHE_ELSE_NETWORK}, {@link WebSettings#LOAD_NO_CACHE} |
| 35 | * or {@link WebSettings#LOAD_CACHE_ONLY}. The default value is |
| 36 | * {@link WebSettings#LOAD_DEFAULT}. |
Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 37 | */ |
Tim Volodine | b90f538 | 2016-04-29 12:44:41 +0100 | [diff] [blame] | 38 | public abstract void setCacheMode(@WebSettings.CacheMode int mode); |
Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 39 | |
| 40 | /** |
| 41 | * Gets the current setting for overriding the cache mode. |
| 42 | * |
| 43 | * @return the current setting for overriding the cache mode |
| 44 | * @see #setCacheMode |
| 45 | */ |
Tim Volodine | b90f538 | 2016-04-29 12:44:41 +0100 | [diff] [blame] | 46 | @WebSettings.CacheMode |
Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 47 | public abstract int getCacheMode(); |
| 48 | |
| 49 | /** |
| 50 | * Enables or disables content URL access from Service Workers, see |
| 51 | * {@link WebSettings#setAllowContentAccess}. |
| 52 | */ |
| 53 | public abstract void setAllowContentAccess(boolean allow); |
| 54 | |
| 55 | /** |
| 56 | * Gets whether Service Workers support content URL access. |
| 57 | * |
| 58 | * @see #setAllowContentAccess |
| 59 | */ |
| 60 | public abstract boolean getAllowContentAccess(); |
| 61 | |
| 62 | /** |
| 63 | * Enables or disables file access within Service Workers, see |
| 64 | * {@link WebSettings#setAllowFileAccess}. |
| 65 | */ |
| 66 | public abstract void setAllowFileAccess(boolean allow); |
| 67 | |
| 68 | /** |
| 69 | * Gets whether Service Workers support file access. |
| 70 | * |
| 71 | * @see #setAllowFileAccess |
| 72 | */ |
| 73 | public abstract boolean getAllowFileAccess(); |
| 74 | |
| 75 | /** |
Tim Volodine | b90f538 | 2016-04-29 12:44:41 +0100 | [diff] [blame] | 76 | * Sets whether Service Workers should not load resources from the network, |
Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 77 | * see {@link WebSettings#setBlockNetworkLoads}. |
| 78 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 79 | * @param flag {@code true} means block network loads by the Service Workers |
Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 80 | */ |
| 81 | public abstract void setBlockNetworkLoads(boolean flag); |
| 82 | |
| 83 | /** |
| 84 | * Gets whether Service Workers are prohibited from loading any resources from the network. |
| 85 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 86 | * @return {@code true} if the Service Workers are not allowed to load any resources from the |
| 87 | * network |
Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 88 | * @see #setBlockNetworkLoads |
| 89 | */ |
| 90 | public abstract boolean getBlockNetworkLoads(); |
| 91 | } |
| 92 | |