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 * 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}. 37 */ setCacheMode(@ebSettings.CacheMode int mode)38 public abstract void setCacheMode(@WebSettings.CacheMode int mode); 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 */ 46 @WebSettings.CacheMode getCacheMode()47 public abstract int getCacheMode(); 48 49 /** 50 * Enables or disables content URL access from Service Workers, see 51 * {@link WebSettings#setAllowContentAccess}. 52 */ setAllowContentAccess(boolean allow)53 public abstract void setAllowContentAccess(boolean allow); 54 55 /** 56 * Gets whether Service Workers support content URL access. 57 * 58 * @see #setAllowContentAccess 59 */ getAllowContentAccess()60 public abstract boolean getAllowContentAccess(); 61 62 /** 63 * Enables or disables file access within Service Workers, see 64 * {@link WebSettings#setAllowFileAccess}. 65 */ setAllowFileAccess(boolean allow)66 public abstract void setAllowFileAccess(boolean allow); 67 68 /** 69 * Gets whether Service Workers support file access. 70 * 71 * @see #setAllowFileAccess 72 */ getAllowFileAccess()73 public abstract boolean getAllowFileAccess(); 74 75 /** 76 * Sets whether Service Workers should not load resources from the network, 77 * see {@link WebSettings#setBlockNetworkLoads}. 78 * 79 * @param flag {@code true} means block network loads by the Service Workers 80 */ setBlockNetworkLoads(boolean flag)81 public abstract void setBlockNetworkLoads(boolean flag); 82 83 /** 84 * Gets whether Service Workers are prohibited from loading any resources from the network. 85 * 86 * @return {@code true} if the Service Workers are not allowed to load any resources from the 87 * network 88 * @see #setBlockNetworkLoads 89 */ getBlockNetworkLoads()90 public abstract boolean getBlockNetworkLoads(); 91 } 92 93