blob: 25058da4cd92e2e7daec8c2f759cfd14211570d2 [file] [log] [blame]
Tim Volodine28c83562016-01-20 19:23:03 +00001/*
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
17package 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.
28public abstract class ServiceWorkerWebSettings {
29
30 /**
31 * Overrides the way the cache is used, see {@link WebSettings#setCacheMode}.
32 *
Tim Volodineb90f5382016-04-29 12:44:41 +010033 * @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 Volodine28c83562016-01-20 19:23:03 +000037 */
Tim Volodineb90f5382016-04-29 12:44:41 +010038 public abstract void setCacheMode(@WebSettings.CacheMode int mode);
Tim Volodine28c83562016-01-20 19:23:03 +000039
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 Volodineb90f5382016-04-29 12:44:41 +010046 @WebSettings.CacheMode
Tim Volodine28c83562016-01-20 19:23:03 +000047 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 Volodineb90f5382016-04-29 12:44:41 +010076 * Sets whether Service Workers should not load resources from the network,
Tim Volodine28c83562016-01-20 19:23:03 +000077 * see {@link WebSettings#setBlockNetworkLoads}.
78 *
Nate Fischer0a6140d2017-09-05 12:37:49 -070079 * @param flag {@code true} means block network loads by the Service Workers
Tim Volodine28c83562016-01-20 19:23:03 +000080 */
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 Fischer0a6140d2017-09-05 12:37:49 -070086 * @return {@code true} if the Service Workers are not allowed to load any resources from the
87 * network
Tim Volodine28c83562016-01-20 19:23:03 +000088 * @see #setBlockNetworkLoads
89 */
90 public abstract boolean getBlockNetworkLoads();
91}
92