blob: e224e84a56fecb2530098199d08c0f97f7bfff42 [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2007 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
Hui Shu539b0772016-04-20 15:21:37 -070019import android.annotation.IntDef;
Nate Fischer3442c742017-09-08 17:02:00 -070020import android.annotation.Nullable;
Yuncheol Heoeeba0252014-07-08 19:43:00 +090021import android.annotation.SystemApi;
Artur Satayevad9254c2019-12-10 17:47:54 +000022import android.compat.annotation.UnsupportedAppUsage;
George Mount9f410c52012-08-10 15:29:30 -070023import android.content.Context;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070024
Hui Shu539b0772016-04-20 15:21:37 -070025import java.lang.annotation.ElementType;
26import java.lang.annotation.Retention;
27import java.lang.annotation.RetentionPolicy;
28import java.lang.annotation.Target;
29
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070030/**
31 * Manages settings state for a WebView. When a WebView is first created, it
32 * obtains a set of default settings. These default settings will be returned
Nate Fischer4ea92402017-11-17 18:48:13 -080033 * from any getter call. A {@code WebSettings} object obtained from
34 * {@link WebView#getSettings()} is tied to the life of the WebView. If a WebView has
35 * been destroyed, any method call on {@code WebSettings} will throw an
36 * {@link IllegalStateException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070037 */
Jonathan Dixond3101b12012-04-12 20:51:51 +010038// This is an abstract base class: concrete WebViewProviders must
Jonathan Dixon3c909522012-02-28 18:45:06 +000039// create a class derived from this, and return an instance of it in the
40// WebViewProvider.getWebSettingsProvider() method implementation.
Selim Gurun0ea6dad2012-03-29 18:19:01 -070041public abstract class WebSettings {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070042 /**
43 * Enum for controlling the layout of html.
Steve Block4e584df2012-04-24 23:12:47 +010044 * <ul>
Nate Fischer4ea92402017-11-17 18:48:13 -080045 * <li>{@code NORMAL} means no rendering changes. This is the recommended choice for maximum
Jonathan Dixon5545d082013-08-31 22:43:11 -070046 * compatibility across different platforms and Android versions.</li>
Nate Fischer4ea92402017-11-17 18:48:13 -080047 * <li>{@code SINGLE_COLUMN} moves all content into one column that is the width of the
Steve Block4e584df2012-04-24 23:12:47 +010048 * view.</li>
Nate Fischer4ea92402017-11-17 18:48:13 -080049 * <li>{@code NARROW_COLUMNS} makes all columns no wider than the screen if possible. Only use
Jonathan Dixon5545d082013-08-31 22:43:11 -070050 * this for API levels prior to {@link android.os.Build.VERSION_CODES#KITKAT}.</li>
Nate Fischer4ea92402017-11-17 18:48:13 -080051 * <li>{@code TEXT_AUTOSIZING} boosts font size of paragraphs based on heuristics to make
Mikhail Naganov94e0bd32012-12-14 17:01:25 +000052 * the text readable when viewing a wide-viewport layout in the overview mode.
53 * It is recommended to enable zoom support {@link #setSupportZoom} when
Jonathan Dixon5545d082013-08-31 22:43:11 -070054 * using this mode. Supported from API level
55 * {@link android.os.Build.VERSION_CODES#KITKAT}</li>
Steve Block4e584df2012-04-24 23:12:47 +010056 * </ul>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070057 */
58 // XXX: These must match LayoutAlgorithm in Settings.h in WebCore.
59 public enum LayoutAlgorithm {
60 NORMAL,
John Reck5a1ef4132011-10-26 10:37:00 -070061 /**
62 * @deprecated This algorithm is now obsolete.
63 */
64 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070065 SINGLE_COLUMN,
Mikhail Naganov94e0bd32012-12-14 17:01:25 +000066 /**
Jonathan Dixon5545d082013-08-31 22:43:11 -070067 * @deprecated This algorithm is now obsolete.
Mikhail Naganov94e0bd32012-12-14 17:01:25 +000068 */
Jonathan Dixon5545d082013-08-31 22:43:11 -070069 @Deprecated
70 NARROW_COLUMNS,
Mikhail Naganov94e0bd32012-12-14 17:01:25 +000071 TEXT_AUTOSIZING
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070072 }
73
74 /**
75 * Enum for specifying the text size.
Steve Block4e584df2012-04-24 23:12:47 +010076 * <ul>
77 * <li>SMALLEST is 50%</li>
78 * <li>SMALLER is 75%</li>
79 * <li>NORMAL is 100%</li>
80 * <li>LARGER is 150%</li>
81 * <li>LARGEST is 200%</li>
82 * </ul>
83 *
John Reckcaeb1202011-06-17 11:50:15 -070084 * @deprecated Use {@link WebSettings#setTextZoom(int)} and {@link WebSettings#getTextZoom()} instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070085 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -070086 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070087 public enum TextSize {
88 SMALLEST(50),
89 SMALLER(75),
90 NORMAL(100),
91 LARGER(150),
92 LARGEST(200);
93 TextSize(int size) {
94 value = size;
95 }
Mathew Inwood62d83fb2018-08-16 19:09:48 +010096 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070097 int value;
98 }
Grace Kloba0d8b77c2009-06-25 11:20:51 -070099
100 /**
101 * Enum for specifying the WebView's desired density.
Steve Block4e584df2012-04-24 23:12:47 +0100102 * <ul>
Nate Fischer4ea92402017-11-17 18:48:13 -0800103 * <li>{@code FAR} makes 100% looking like in 240dpi</li>
104 * <li>{@code MEDIUM} makes 100% looking like in 160dpi</li>
105 * <li>{@code CLOSE} makes 100% looking like in 120dpi</li>
Steve Block4e584df2012-04-24 23:12:47 +0100106 * </ul>
Grace Kloba0d8b77c2009-06-25 11:20:51 -0700107 */
108 public enum ZoomDensity {
109 FAR(150), // 240dpi
110 MEDIUM(100), // 160dpi
111 CLOSE(75); // 120dpi
112 ZoomDensity(int size) {
113 value = size;
114 }
Mikhail Naganovce76ca52012-07-27 12:00:05 +0100115
116 /**
117 * @hide Only for use by WebViewProvider implementations
118 */
119 public int getValue() {
120 return value;
121 }
122
Grace Kloba0d8b77c2009-06-25 11:20:51 -0700123 int value;
124 }
125
Tim Volodineb90f5382016-04-29 12:44:41 +0100126 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -0700127 @IntDef(prefix = { "LOAD_" }, value = {
128 LOAD_DEFAULT,
129 LOAD_NORMAL,
130 LOAD_CACHE_ELSE_NETWORK,
131 LOAD_NO_CACHE,
132 LOAD_CACHE_ONLY
133 })
Tim Volodineb90f5382016-04-29 12:44:41 +0100134 @Retention(RetentionPolicy.SOURCE)
135 public @interface CacheMode {}
136
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700137 /**
Mikhail Naganov500b0032012-07-25 13:06:14 +0100138 * Default cache usage mode. If the navigation type doesn't impose any
139 * specific behavior, use cached resources when they are available
140 * and not expired, otherwise load resources from the network.
141 * Use with {@link #setCacheMode}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700142 */
143 public static final int LOAD_DEFAULT = -1;
144
145 /**
Mikhail Naganov500b0032012-07-25 13:06:14 +0100146 * Normal cache usage mode. Use with {@link #setCacheMode}.
Mikhail Naganov56936a12012-07-25 13:07:18 +0100147 *
148 * @deprecated This value is obsolete, as from API level
149 * {@link android.os.Build.VERSION_CODES#HONEYCOMB} and onwards it has the
150 * same effect as {@link #LOAD_DEFAULT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700151 */
Kristian Monsen5cc23512012-08-09 15:33:08 -0400152 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700153 public static final int LOAD_NORMAL = 0;
154
155 /**
Mikhail Naganov500b0032012-07-25 13:06:14 +0100156 * Use cached resources when they are available, even if they have expired.
157 * Otherwise load resources from the network.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700158 * Use with {@link #setCacheMode}.
159 */
160 public static final int LOAD_CACHE_ELSE_NETWORK = 1;
161
162 /**
Mikhail Naganov500b0032012-07-25 13:06:14 +0100163 * Don't use the cache, load from the network.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700164 * Use with {@link #setCacheMode}.
165 */
166 public static final int LOAD_NO_CACHE = 2;
Michael Kolba172e7d2010-06-30 12:35:26 -0700167
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700168 /**
Mikhail Naganov500b0032012-07-25 13:06:14 +0100169 * Don't use the network, load from the cache.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700170 * Use with {@link #setCacheMode}.
171 */
172 public static final int LOAD_CACHE_ONLY = 3;
173
174 public enum RenderPriority {
175 NORMAL,
176 HIGH,
177 LOW
178 }
179
Patrick Scott300f2e92010-03-22 10:20:45 -0400180 /**
181 * The plugin state effects how plugins are treated on a page. ON means
182 * that any object will be loaded even if a plugin does not exist to handle
183 * the content. ON_DEMAND means that if there is a plugin installed that
184 * can handle the content, a placeholder is shown until the user clicks on
185 * the placeholder. Once clicked, the plugin will be enabled on the page.
186 * OFF means that all plugins will be turned off and any fallback content
187 * will be used.
188 */
189 public enum PluginState {
190 ON,
191 ON_DEMAND,
192 OFF
193 }
194
Ben Murdoche9e3ccd2010-10-06 14:33:02 +0100195 /**
Ben Murdochfe9fc3d2014-04-10 15:31:06 +0100196 * In this mode, the WebView will allow a secure origin to load content from any other origin,
197 * even if that origin is insecure. This is the least secure mode of operation for the WebView,
198 * and where possible apps should not set this mode.
Anna Malova7374ce12019-09-25 12:19:27 +0100199 *
200 * @see #setMixedContentMode
Ben Murdochfe9fc3d2014-04-10 15:31:06 +0100201 */
202 public static final int MIXED_CONTENT_ALWAYS_ALLOW = 0;
203
204 /**
Ben Murdochfe9fc3d2014-04-10 15:31:06 +0100205 * In this mode, the WebView will not allow a secure origin to load content from an insecure
206 * origin. This is the preferred and most secure mode of operation for the WebView and apps are
207 * strongly advised to use this mode.
Anna Malova7374ce12019-09-25 12:19:27 +0100208 *
209 * @see #setMixedContentMode
Ben Murdochfe9fc3d2014-04-10 15:31:06 +0100210 */
211 public static final int MIXED_CONTENT_NEVER_ALLOW = 1;
212
213 /**
Ben Murdochfe9fc3d2014-04-10 15:31:06 +0100214 * In this mode, the WebView will attempt to be compatible with the approach of a modern web
215 * browser with regard to mixed content. Some insecure content may be allowed to be loaded by
216 * a secure origin and other types of content will be blocked. The types of content are allowed
217 * or blocked may change release to release and are not explicitly defined.
218 *
219 * This mode is intended to be used by apps that are not in control of the content that they
220 * render but desire to operate in a reasonably secure environment. For highest security, apps
221 * are recommended to use {@link #MIXED_CONTENT_NEVER_ALLOW}.
Anna Malova7374ce12019-09-25 12:19:27 +0100222 *
223 * @see #setMixedContentMode
Ben Murdochfe9fc3d2014-04-10 15:31:06 +0100224 */
225 public static final int MIXED_CONTENT_COMPATIBILITY_MODE = 2;
226
Tobias Sargeantfec405a32018-12-06 15:22:18 +0000227 /** @hide */
228 @IntDef(prefix = { "FORCE_DARK_" }, value = {
229 FORCE_DARK_OFF,
230 FORCE_DARK_AUTO,
231 FORCE_DARK_ON
232 })
233 @Retention(RetentionPolicy.SOURCE)
Tobias Sargeantbbb043a2019-03-11 10:14:28 +0000234 public @interface ForceDark {}
Tobias Sargeantfec405a32018-12-06 15:22:18 +0000235
236 /**
Tobias Sargeantfec405a32018-12-06 15:22:18 +0000237 * Disable force dark, irrespective of the force dark mode of the WebView parent. In this mode,
238 * WebView content will always be rendered as-is, regardless of whether native views are being
239 * automatically darkened.
Anna Malova7374ce12019-09-25 12:19:27 +0100240 *
241 * @see #setForceDark
Tobias Sargeantfec405a32018-12-06 15:22:18 +0000242 */
Tobias Sargeantbbb043a2019-03-11 10:14:28 +0000243 public static final int FORCE_DARK_OFF = 0;
Tobias Sargeantfec405a32018-12-06 15:22:18 +0000244
245 /**
Tobias Sargeante1fc7912019-03-19 12:16:22 +0000246 * Enable force dark dependent on the state of the WebView parent view. If the WebView parent
247 * view is being automatically force darkened
248 * (see: {@link android.view.View#setForceDarkAllowed}), then WebView content will be rendered
249 * so as to emulate a dark theme. WebViews that are not attached to the view hierarchy will not
250 * be inverted.
Anna Malova7374ce12019-09-25 12:19:27 +0100251 *
252 * @see #setForceDark
Tobias Sargeantfec405a32018-12-06 15:22:18 +0000253 */
Tobias Sargeantbbb043a2019-03-11 10:14:28 +0000254 public static final int FORCE_DARK_AUTO = 1;
Tobias Sargeantfec405a32018-12-06 15:22:18 +0000255
256 /**
Tobias Sargeantfec405a32018-12-06 15:22:18 +0000257 * Unconditionally enable force dark. In this mode WebView content will always be rendered so
258 * as to emulate a dark theme.
Anna Malova7374ce12019-09-25 12:19:27 +0100259 *
260 * @see #setForceDark
Tobias Sargeantfec405a32018-12-06 15:22:18 +0000261 */
Tobias Sargeantbbb043a2019-03-11 10:14:28 +0000262 public static final int FORCE_DARK_ON = 2;
Tobias Sargeantfec405a32018-12-06 15:22:18 +0000263
Ben Murdochfe9fc3d2014-04-10 15:31:06 +0100264 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100265 * Enables dumping the pages navigation cache to a text file. The default
Nate Fischer0a6140d2017-09-05 12:37:49 -0700266 * is {@code false}.
Steve Block4e584df2012-04-24 23:12:47 +0100267 *
Kristian Monsenfc771652011-05-10 16:44:05 +0100268 * @deprecated This method is now obsolete.
Kristian Monsenf4912582012-08-16 15:26:24 -0400269 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700270 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000271 @SystemApi
Kristian Monsenfc771652011-05-10 16:44:05 +0100272 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000273 public abstract void setNavDump(boolean enabled);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700274
275 /**
Steve Block4e584df2012-04-24 23:12:47 +0100276 * Gets whether dumping the navigation cache is enabled.
277 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100278 * @return whether dumping the navigation cache is enabled
279 * @see #setNavDump
Kristian Monsenfc771652011-05-10 16:44:05 +0100280 * @deprecated This method is now obsolete.
Kristian Monsenf4912582012-08-16 15:26:24 -0400281 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700282 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000283 @SystemApi
Kristian Monsenfc771652011-05-10 16:44:05 +0100284 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000285 public abstract boolean getNavDump();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700286
287 /**
Mikhail Naganovb533fb42012-04-05 14:50:02 +0100288 * Sets whether the WebView should support zooming using its on-screen zoom
289 * controls and gestures. The particular zoom mechanisms that should be used
290 * can be set with {@link #setBuiltInZoomControls}. This setting does not
291 * affect zooming performed using the {@link WebView#zoomIn()} and
Nate Fischer0a6140d2017-09-05 12:37:49 -0700292 * {@link WebView#zoomOut()} methods. The default is {@code true}.
Steve Block4e584df2012-04-24 23:12:47 +0100293 *
294 * @param support whether the WebView should support zoom
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700295 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000296 public abstract void setSupportZoom(boolean support);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700297
298 /**
Steve Block4e584df2012-04-24 23:12:47 +0100299 * Gets whether the WebView supports zoom.
300 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700301 * @return {@code true} if the WebView supports zoom
Steve Block4e584df2012-04-24 23:12:47 +0100302 * @see #setSupportZoom
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700303 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000304 public abstract boolean supportZoom();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700305
306 /**
Teng-Hui Zhu0e5b1602012-07-17 17:19:13 -0700307 * Sets whether the WebView requires a user gesture to play media.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700308 * The default is {@code true}.
Teng-Hui Zhu0e5b1602012-07-17 17:19:13 -0700309 *
310 * @param require whether the WebView requires a user gesture to play media
311 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000312 public abstract void setMediaPlaybackRequiresUserGesture(boolean require);
Teng-Hui Zhu0e5b1602012-07-17 17:19:13 -0700313
314 /**
315 * Gets whether the WebView requires a user gesture to play media.
316 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700317 * @return {@code true} if the WebView requires a user gesture to play media
Teng-Hui Zhu0e5b1602012-07-17 17:19:13 -0700318 * @see #setMediaPlaybackRequiresUserGesture
319 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000320 public abstract boolean getMediaPlaybackRequiresUserGesture();
Teng-Hui Zhu0e5b1602012-07-17 17:19:13 -0700321
322 /**
Steve Block06d268e2012-04-16 14:10:54 +0100323 * Sets whether the WebView should use its built-in zoom mechanisms. The
324 * built-in zoom mechanisms comprise on-screen zoom controls, which are
325 * displayed over the WebView's content, and the use of a pinch gesture to
326 * control zooming. Whether or not these on-screen controls are displayed
Nate Fischer0a6140d2017-09-05 12:37:49 -0700327 * can be set with {@link #setDisplayZoomControls}. The default is {@code false}.
Steve Block06d268e2012-04-16 14:10:54 +0100328 * <p>
329 * The built-in mechanisms are the only currently supported zoom
330 * mechanisms, so it is recommended that this setting is always enabled.
Torne (Richard Coles)41c64862019-10-25 16:38:30 -0400331 * However, on-screen zoom controls are deprecated in Android (see
332 * {@link android.widget.ZoomButtonsController}) so it's recommended to
333 * disable {@link #setDisplayZoomControls}.
Steve Block4e584df2012-04-24 23:12:47 +0100334 *
335 * @param enabled whether the WebView should use its built-in zoom mechanisms
The Android Open Source Project10592532009-03-18 17:39:46 -0700336 */
Steve Block06d268e2012-04-16 14:10:54 +0100337 // This method was intended to select between the built-in zoom mechanisms
338 // and the separate zoom controls. The latter were obtained using
339 // {@link WebView#getZoomControls}, which is now hidden.
Ignacio Solla451e3382014-11-10 10:35:54 +0000340 public abstract void setBuiltInZoomControls(boolean enabled);
Michael Kolba172e7d2010-06-30 12:35:26 -0700341
The Android Open Source Project10592532009-03-18 17:39:46 -0700342 /**
Steve Block4e584df2012-04-24 23:12:47 +0100343 * Gets whether the zoom mechanisms built into WebView are being used.
344 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700345 * @return {@code true} if the zoom mechanisms built into WebView are being used
Steve Block4e584df2012-04-24 23:12:47 +0100346 * @see #setBuiltInZoomControls
The Android Open Source Project10592532009-03-18 17:39:46 -0700347 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000348 public abstract boolean getBuiltInZoomControls();
Michael Kolba172e7d2010-06-30 12:35:26 -0700349
The Android Open Source Project10592532009-03-18 17:39:46 -0700350 /**
Mikhail Naganovb533fb42012-04-05 14:50:02 +0100351 * Sets whether the WebView should display on-screen zoom controls when
352 * using the built-in zoom mechanisms. See {@link #setBuiltInZoomControls}.
Torne (Richard Coles)41c64862019-10-25 16:38:30 -0400353 * The default is {@code true}. However, on-screen zoom controls are deprecated
354 * in Android (see {@link android.widget.ZoomButtonsController}) so it's
355 * recommended to set this to {@code false}.
Steve Block4e584df2012-04-24 23:12:47 +0100356 *
357 * @param enabled whether the WebView should display on-screen zoom controls
Michael Kolb6fe3b422010-08-19 12:41:24 -0700358 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000359 public abstract void setDisplayZoomControls(boolean enabled);
Michael Kolb6fe3b422010-08-19 12:41:24 -0700360
361 /**
Steve Block4e584df2012-04-24 23:12:47 +0100362 * Gets whether the WebView displays on-screen zoom controls when using
Mikhail Naganovb533fb42012-04-05 14:50:02 +0100363 * the built-in zoom mechanisms.
Steve Block4e584df2012-04-24 23:12:47 +0100364 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700365 * @return {@code true} if the WebView displays on-screen zoom controls when using
Steve Block4e584df2012-04-24 23:12:47 +0100366 * the built-in zoom mechanisms
367 * @see #setDisplayZoomControls
Michael Kolb6fe3b422010-08-19 12:41:24 -0700368 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000369 public abstract boolean getDisplayZoomControls();
Michael Kolb6fe3b422010-08-19 12:41:24 -0700370
371 /**
Hazem Ashmawyee824f02020-02-14 16:27:38 +0000372 * Enables or disables file access within WebView.
373 * Note that this enables or disables file system access only. Assets and resources
374 * are still accessible using file:///android_asset and file:///android_res.
375 * <p class="note">
376 * <b>Note:</b> Apps should not open {@code file://} URLs from any external source in
377 * WebView, don't enable this if your app accepts arbitrary URLs from external sources.
378 * It's recommended to always use
379 * <a href="{@docRoot}reference/androidx/webkit/WebViewAssetLoader">
380 * androidx.webkit.WebViewAssetLoader</a> to access files including assets and resources over
381 * {@code http(s)://} schemes, instead of {@code file://} URLs. To prevent possible security
382 * issues targeting {@link android.os.Build.VERSION_CODES#Q} and earlier, you should explicitly
383 * set this value to {@code false}.
384 * <p>
385 * The default value is {@code true} for apps targeting
386 * {@link android.os.Build.VERSION_CODES#Q} and below, and {@code false} when targeting
387 * {@link android.os.Build.VERSION_CODES#R} and above.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800388 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000389 public abstract void setAllowFileAccess(boolean allow);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800390
391 /**
Steve Block4e584df2012-04-24 23:12:47 +0100392 * Gets whether this WebView supports file access.
393 *
394 * @see #setAllowFileAccess
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800395 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000396 public abstract boolean getAllowFileAccess();
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800397
398 /**
Steve Block4e584df2012-04-24 23:12:47 +0100399 * Enables or disables content URL access within WebView. Content URL
400 * access allows WebView to load content from a content provider installed
401 * in the system. The default is enabled.
Patrick Scottd1737ed2011-01-05 11:36:48 -0500402 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000403 public abstract void setAllowContentAccess(boolean allow);
Patrick Scottd1737ed2011-01-05 11:36:48 -0500404
405 /**
Steve Block4e584df2012-04-24 23:12:47 +0100406 * Gets whether this WebView supports content URL access.
407 *
408 * @see #setAllowContentAccess
Patrick Scottd1737ed2011-01-05 11:36:48 -0500409 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000410 public abstract boolean getAllowContentAccess();
Patrick Scottd1737ed2011-01-05 11:36:48 -0500411
412 /**
Mikhail Naganov00303362013-09-02 10:57:04 +0100413 * Sets whether the WebView loads pages in overview mode, that is,
414 * zooms out the content to fit on screen by width. This setting is
415 * taken into account when the content width is greater than the width
416 * of the WebView control, for example, when {@link #getUseWideViewPort}
Nate Fischer0a6140d2017-09-05 12:37:49 -0700417 * is enabled. The default is {@code false}.
Grace Klobae397a882009-08-06 12:04:14 -0700418 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000419 public abstract void setLoadWithOverviewMode(boolean overview);
Grace Klobae397a882009-08-06 12:04:14 -0700420
421 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100422 * Gets whether this WebView loads pages in overview mode.
423 *
424 * @return whether this WebView loads pages in overview mode
425 * @see #setLoadWithOverviewMode
Grace Klobae397a882009-08-06 12:04:14 -0700426 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000427 public abstract boolean getLoadWithOverviewMode();
Grace Klobae397a882009-08-06 12:04:14 -0700428
429 /**
Steve Block4e584df2012-04-24 23:12:47 +0100430 * Sets whether the WebView will enable smooth transition while panning or
Adam Powelle00e8a782011-09-11 17:48:42 -0700431 * zooming or while the window hosting the WebView does not have focus.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700432 * If it is {@code true}, WebView will choose a solution to maximize the performance.
Adam Powelle00e8a782011-09-11 17:48:42 -0700433 * e.g. the WebView's content may not be updated during the transition.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700434 * If it is false, WebView will keep its fidelity. The default value is {@code false}.
Kristian Monsen5cc23512012-08-09 15:33:08 -0400435 *
436 * @deprecated This method is now obsolete, and will become a no-op in future.
Grace Klobaf9b731d2010-06-21 19:23:57 -0700437 */
Kristian Monsen5cc23512012-08-09 15:33:08 -0400438 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000439 public abstract void setEnableSmoothTransition(boolean enable);
Steve Block4e584df2012-04-24 23:12:47 +0100440
Grace Klobaf9b731d2010-06-21 19:23:57 -0700441 /**
Steve Block4e584df2012-04-24 23:12:47 +0100442 * Gets whether the WebView enables smooth transition while panning or
Grace Klobaf9b731d2010-06-21 19:23:57 -0700443 * zooming.
Steve Block4e584df2012-04-24 23:12:47 +0100444 *
445 * @see #setEnableSmoothTransition
Kristian Monsen5cc23512012-08-09 15:33:08 -0400446 *
447 * @deprecated This method is now obsolete, and will become a no-op in future.
Grace Klobaf9b731d2010-06-21 19:23:57 -0700448 */
Kristian Monsen5cc23512012-08-09 15:33:08 -0400449 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000450 public abstract boolean enableSmoothTransition();
Grace Klobaf9b731d2010-06-21 19:23:57 -0700451
452 /**
Steve Block4e584df2012-04-24 23:12:47 +0100453 * Sets whether the WebView uses its background for over scroll background.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700454 * If {@code true}, it will use the WebView's background. If {@code false}, it will use an
455 * internal pattern. Default is {@code true}.
Steve Block4e584df2012-04-24 23:12:47 +0100456 *
Kristian Monsenfc771652011-05-10 16:44:05 +0100457 * @deprecated This method is now obsolete.
Kristian Monsend0b90d32012-09-24 12:30:45 -0400458 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
Adam Powell637d3372010-08-25 14:37:03 -0700459 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000460 @SystemApi
Kristian Monsenfc771652011-05-10 16:44:05 +0100461 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000462 public abstract void setUseWebViewBackgroundForOverscrollBackground(boolean view);
Adam Powell637d3372010-08-25 14:37:03 -0700463
464 /**
Steve Block4e584df2012-04-24 23:12:47 +0100465 * Gets whether this WebView uses WebView's background instead of
Adam Powell637d3372010-08-25 14:37:03 -0700466 * internal pattern for over scroll background.
Steve Block4e584df2012-04-24 23:12:47 +0100467 *
468 * @see #setUseWebViewBackgroundForOverscrollBackground
Kristian Monsenfc771652011-05-10 16:44:05 +0100469 * @deprecated This method is now obsolete.
Kristian Monsenf4912582012-08-16 15:26:24 -0400470 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
Adam Powell637d3372010-08-25 14:37:03 -0700471 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000472 @SystemApi
Kristian Monsenfc771652011-05-10 16:44:05 +0100473 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000474 public abstract boolean getUseWebViewBackgroundForOverscrollBackground();
Adam Powell637d3372010-08-25 14:37:03 -0700475
476 /**
Selim Gurun13e5b0b2017-04-03 14:29:14 -0700477 * Sets whether the WebView should save form data. In Android O, the
478 * platform has implemented a fully functional Autofill feature to store
479 * form data. Therefore, the Webview form data save feature is disabled.
480 *
481 * Note that the feature will continue to be supported on older versions of
482 * Android as before.
483 *
Tao Bai990f9a92019-07-02 20:32:47 +0000484 * @deprecated In Android O and afterwards, this function does not have
485 * any effect, the form data will be saved to platform's autofill service
486 * if applicable.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700487 */
Selim Gurun13e5b0b2017-04-03 14:29:14 -0700488 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000489 public abstract void setSaveFormData(boolean save);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700490
491 /**
Selim Gurun5c11ef12013-01-04 14:58:36 -0800492 * Gets whether the WebView saves form data.
Steve Blockb0e0f332012-06-13 22:01:11 +0100493 *
494 * @return whether the WebView saves form data
495 * @see #setSaveFormData
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700496 */
Selim Gurun13e5b0b2017-04-03 14:29:14 -0700497 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000498 public abstract boolean getSaveFormData();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700499
500 /**
Nate Fischer0a6140d2017-09-05 12:37:49 -0700501 * Sets whether the WebView should save passwords. The default is {@code true}.
Jonathan Dixon835b1fc2013-02-25 12:29:33 -0800502 * @deprecated Saving passwords in WebView will not be supported in future versions.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700503 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -0800504 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000505 public abstract void setSavePassword(boolean save);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700506
507 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100508 * Gets whether the WebView saves passwords.
509 *
510 * @return whether the WebView saves passwords
511 * @see #setSavePassword
Jonathan Dixon835b1fc2013-02-25 12:29:33 -0800512 * @deprecated Saving passwords in WebView will not be supported in future versions.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700513 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -0800514 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000515 public abstract boolean getSavePassword();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700516
517 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100518 * Sets the text zoom of the page in percent. The default is 100.
Steve Block4e584df2012-04-24 23:12:47 +0100519 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100520 * @param textZoom the text zoom in percent
John Reckff56bcd2011-06-16 17:12:08 -0700521 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000522 public abstract void setTextZoom(int textZoom);
John Reckff56bcd2011-06-16 17:12:08 -0700523
524 /**
Steve Block4e584df2012-04-24 23:12:47 +0100525 * Gets the text zoom of the page in percent.
526 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100527 * @return the text zoom of the page in percent
Mikhail Naganov1202d662012-08-07 18:26:52 +0100528 * @see #setTextZoom
John Reckff56bcd2011-06-16 17:12:08 -0700529 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000530 public abstract int getTextZoom();
John Reckff56bcd2011-06-16 17:12:08 -0700531
532 /**
Hector Dearmanfc9a27a2014-06-05 13:45:28 +0100533 * Sets policy for third party cookies.
534 * Developers should access this via {@link CookieManager#setShouldAcceptThirdPartyCookies}.
535 * @hide Internal API.
536 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000537 @SystemApi
538 public abstract void setAcceptThirdPartyCookies(boolean accept);
Hector Dearmanfc9a27a2014-06-05 13:45:28 +0100539
540 /**
541 * Gets policy for third party cookies.
542 * Developers should access this via {@link CookieManager#getShouldAcceptThirdPartyCookies}.
543 * @hide Internal API
544 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000545 @SystemApi
546 public abstract boolean getAcceptThirdPartyCookies();
Hector Dearmanfc9a27a2014-06-05 13:45:28 +0100547
548 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100549 * Sets the text size of the page. The default is {@link TextSize#NORMAL}.
Steve Block4e584df2012-04-24 23:12:47 +0100550 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100551 * @param t the text size as a {@link TextSize} value
552 * @deprecated Use {@link #setTextZoom} instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700553 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -0700554 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700555 public synchronized void setTextSize(TextSize t) {
Mikhail Naganov1202d662012-08-07 18:26:52 +0100556 setTextZoom(t.value);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700557 }
558
559 /**
Steve Block4e584df2012-04-24 23:12:47 +0100560 * Gets the text size of the page. If the text size was previously specified
Steve Blockb0e0f332012-06-13 22:01:11 +0100561 * in percent using {@link #setTextZoom}, this will return the closest
562 * matching {@link TextSize}.
Steve Block4e584df2012-04-24 23:12:47 +0100563 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100564 * @return the text size as a {@link TextSize} value
565 * @see #setTextSize
566 * @deprecated Use {@link #getTextZoom} instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700567 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -0700568 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700569 public synchronized TextSize getTextSize() {
Mikhail Naganov1202d662012-08-07 18:26:52 +0100570 TextSize closestSize = null;
571 int smallestDelta = Integer.MAX_VALUE;
572 int textSize = getTextZoom();
573 for (TextSize size : TextSize.values()) {
574 int delta = Math.abs(textSize - size.value);
575 if (delta == 0) {
576 return size;
577 }
578 if (delta < smallestDelta) {
579 smallestDelta = delta;
580 closestSize = size;
581 }
582 }
583 return closestSize != null ? closestSize : TextSize.NORMAL;
Mangesh Ghiwareedb528e2011-10-12 14:25:41 -0700584 }
585
586 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100587 * Sets the default zoom density of the page. This must be called from the UI
588 * thread. The default is {@link ZoomDensity#MEDIUM}.
Steve Block4e584df2012-04-24 23:12:47 +0100589 *
Mikhail Naganov8887b2b2013-05-28 10:34:43 +0100590 * This setting is not recommended for use in new applications. If the WebView
591 * is utilized to display mobile-oriented pages, the desired effect can be achieved by
592 * adjusting 'width' and 'initial-scale' attributes of page's 'meta viewport'
593 * tag. For pages lacking the tag, {@link android.webkit.WebView#setInitialScale}
594 * and {@link #setUseWideViewPort} can be used.
595 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100596 * @param zoom the zoom density
Jonathan Dixon5545d082013-08-31 22:43:11 -0700597 * @deprecated This method is no longer supported, see the function documentation for
598 * recommended alternatives.
Grace Kloba0d8b77c2009-06-25 11:20:51 -0700599 */
Jonathan Dixon5545d082013-08-31 22:43:11 -0700600 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000601 public abstract void setDefaultZoom(ZoomDensity zoom);
Grace Kloba0d8b77c2009-06-25 11:20:51 -0700602
603 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100604 * Gets the default zoom density of the page. This should be called from
605 * the UI thread.
606 *
Mikhail Naganov8887b2b2013-05-28 10:34:43 +0100607 * This setting is not recommended for use in new applications.
608 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100609 * @return the zoom density
610 * @see #setDefaultZoom
Jonathan Dixon5545d082013-08-31 22:43:11 -0700611 * @deprecated Will only return the default value.
Grace Kloba0d8b77c2009-06-25 11:20:51 -0700612 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -0700613 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000614 public abstract ZoomDensity getDefaultZoom();
Grace Kloba0d8b77c2009-06-25 11:20:51 -0700615
616 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700617 * Enables using light touches to make a selection and activate mouseovers.
Jonathan Dixon835b1fc2013-02-25 12:29:33 -0800618 * @deprecated From {@link android.os.Build.VERSION_CODES#JELLY_BEAN} this
619 * setting is obsolete and has no effect.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700620 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -0800621 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000622 public abstract void setLightTouchEnabled(boolean enabled);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700623
624 /**
Steve Block4e584df2012-04-24 23:12:47 +0100625 * Gets whether light touches are enabled.
Steve Blockb0e0f332012-06-13 22:01:11 +0100626 * @see #setLightTouchEnabled
Jonathan Dixon98fac172013-02-28 15:32:10 -0800627 * @deprecated This setting is obsolete.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700628 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -0800629 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000630 public abstract boolean getLightTouchEnabled();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700631
632 /**
Steve Block4e584df2012-04-24 23:12:47 +0100633 * Controlled a rendering optimization that is no longer present. Setting
634 * it now has no effect.
635 *
636 * @deprecated This setting now has no effect.
Kristian Monsenf4912582012-08-16 15:26:24 -0400637 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700638 */
Mike Hearnadcd2ed2009-01-21 16:44:36 +0100639 @Deprecated
Mathew Inwood62d83fb2018-08-16 19:09:48 +0100640 @UnsupportedAppUsage
Ignacio Solla451e3382014-11-10 10:35:54 +0000641 public void setUseDoubleTree(boolean use) {
Jonathan Dixon3c909522012-02-28 18:45:06 +0000642 // Specified to do nothing, so no need for derived classes to override.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700643 }
644
645 /**
Steve Block4e584df2012-04-24 23:12:47 +0100646 * Controlled a rendering optimization that is no longer present. Setting
647 * it now has no effect.
648 *
649 * @deprecated This setting now has no effect.
Kristian Monsenf4912582012-08-16 15:26:24 -0400650 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700651 */
Mike Hearnadcd2ed2009-01-21 16:44:36 +0100652 @Deprecated
Mathew Inwood62d83fb2018-08-16 19:09:48 +0100653 @UnsupportedAppUsage
Ignacio Solla451e3382014-11-10 10:35:54 +0000654 public boolean getUseDoubleTree() {
Jonathan Dixon3c909522012-02-28 18:45:06 +0000655 // Returns false unconditionally, so no need for derived classes to override.
Mike Hearnadcd2ed2009-01-21 16:44:36 +0100656 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700657 }
658
659 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100660 * Sets the user-agent string using an integer code.
661 * <ul>
662 * <li>0 means the WebView should use an Android user-agent string</li>
663 * <li>1 means the WebView should use a desktop user-agent string</li>
664 * </ul>
665 * Other values are ignored. The default is an Android user-agent string,
666 * i.e. code value 0.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800667 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100668 * @param ua the integer code for the user-agent string
669 * @deprecated Please use {@link #setUserAgentString} instead.
Kristian Monsenf4912582012-08-16 15:26:24 -0400670 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700671 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000672 @SystemApi
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800673 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000674 public abstract void setUserAgent(int ua);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700675
676 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100677 * Gets the user-agent as an integer code.
678 * <ul>
679 * <li>-1 means the WebView is using a custom user-agent string set with
680 * {@link #setUserAgentString}</li>
681 * <li>0 means the WebView should use an Android user-agent string</li>
682 * <li>1 means the WebView should use a desktop user-agent string</li>
683 * </ul>
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800684 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100685 * @return the integer code for the user-agent string
686 * @see #setUserAgent
687 * @deprecated Please use {@link #getUserAgentString} instead.
Kristian Monsenf4912582012-08-16 15:26:24 -0400688 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700689 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000690 @SystemApi
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800691 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000692 public abstract int getUserAgent();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700693
694 /**
Mikhail Naganovcb000a62013-01-04 18:02:54 +0000695 * Sets whether the WebView should enable support for the &quot;viewport&quot;
696 * HTML meta tag or should use a wide viewport.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700697 * When the value of the setting is {@code false}, the layout width is always set to the
Mikhail Naganovcb000a62013-01-04 18:02:54 +0000698 * width of the WebView control in device-independent (CSS) pixels.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700699 * When the value is {@code true} and the page contains the viewport meta tag, the value
Mikhail Naganovcb000a62013-01-04 18:02:54 +0000700 * of the width specified in the tag is used. If the page does not contain the tag or
701 * does not provide a width, then a wide viewport will be used.
Steve Blockb0e0f332012-06-13 22:01:11 +0100702 *
Mikhail Naganovcb000a62013-01-04 18:02:54 +0000703 * @param use whether to enable support for the viewport meta tag
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700704 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000705 public abstract void setUseWideViewPort(boolean use);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700706
707 /**
Mikhail Naganovcb000a62013-01-04 18:02:54 +0000708 * Gets whether the WebView supports the &quot;viewport&quot;
709 * HTML meta tag or will use a wide viewport.
Steve Block4e584df2012-04-24 23:12:47 +0100710 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700711 * @return {@code true} if the WebView supports the viewport meta tag
Steve Blockb0e0f332012-06-13 22:01:11 +0100712 * @see #setUseWideViewPort
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700713 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000714 public abstract boolean getUseWideViewPort();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700715
716 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100717 * Sets whether the WebView whether supports multiple windows. If set to
718 * true, {@link WebChromeClient#onCreateWindow} must be implemented by the
Nate Fischer0a6140d2017-09-05 12:37:49 -0700719 * host application. The default is {@code false}.
Steve Blockb0e0f332012-06-13 22:01:11 +0100720 *
Nate Fischer4ea92402017-11-17 18:48:13 -0800721 * @param support whether to support multiple windows
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700722 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000723 public abstract void setSupportMultipleWindows(boolean support);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700724
725 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100726 * Gets whether the WebView supports multiple windows.
Steve Block4e584df2012-04-24 23:12:47 +0100727 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700728 * @return {@code true} if the WebView supports multiple windows
Steve Blockb0e0f332012-06-13 22:01:11 +0100729 * @see #setSupportMultipleWindows
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700730 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000731 public abstract boolean supportMultipleWindows();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700732
733 /**
Nate Fischer4ea92402017-11-17 18:48:13 -0800734 * Sets the underlying layout algorithm. This will cause a re-layout of the
Steve Blockb0e0f332012-06-13 22:01:11 +0100735 * WebView. The default is {@link LayoutAlgorithm#NARROW_COLUMNS}.
Steve Block4e584df2012-04-24 23:12:47 +0100736 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100737 * @param l the layout algorithm to use, as a {@link LayoutAlgorithm} value
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700738 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000739 public abstract void setLayoutAlgorithm(LayoutAlgorithm l);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700740
741 /**
Steve Block4e584df2012-04-24 23:12:47 +0100742 * Gets the current layout algorithm.
743 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100744 * @return the layout algorithm in use, as a {@link LayoutAlgorithm} value
Steve Block4e584df2012-04-24 23:12:47 +0100745 * @see #setLayoutAlgorithm
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700746 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000747 public abstract LayoutAlgorithm getLayoutAlgorithm();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700748
749 /**
Steve Block4e584df2012-04-24 23:12:47 +0100750 * Sets the standard font family name. The default is "sans-serif".
751 *
752 * @param font a font family name
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700753 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000754 public abstract void setStandardFontFamily(String font);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700755
756 /**
Steve Block4e584df2012-04-24 23:12:47 +0100757 * Gets the standard font family name.
758 *
759 * @return the standard font family name as a string
760 * @see #setStandardFontFamily
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700761 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000762 public abstract String getStandardFontFamily();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700763
764 /**
Steve Block4e584df2012-04-24 23:12:47 +0100765 * Sets the fixed font family name. The default is "monospace".
766 *
767 * @param font a font family name
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700768 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000769 public abstract void setFixedFontFamily(String font);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700770
771 /**
Steve Block4e584df2012-04-24 23:12:47 +0100772 * Gets the fixed font family name.
773 *
774 * @return the fixed font family name as a string
775 * @see #setFixedFontFamily
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700776 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000777 public abstract String getFixedFontFamily();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700778
779 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100780 * Sets the sans-serif font family name. The default is "sans-serif".
Steve Block4e584df2012-04-24 23:12:47 +0100781 *
782 * @param font a font family name
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700783 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000784 public abstract void setSansSerifFontFamily(String font);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700785
786 /**
Steve Block4e584df2012-04-24 23:12:47 +0100787 * Gets the sans-serif font family name.
788 *
789 * @return the sans-serif font family name as a string
Steve Blockb0e0f332012-06-13 22:01:11 +0100790 * @see #setSansSerifFontFamily
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700791 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000792 public abstract String getSansSerifFontFamily();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700793
794 /**
Steve Block4e584df2012-04-24 23:12:47 +0100795 * Sets the serif font family name. The default is "sans-serif".
796 *
797 * @param font a font family name
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700798 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000799 public abstract void setSerifFontFamily(String font);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700800
801 /**
Steve Block4e584df2012-04-24 23:12:47 +0100802 * Gets the serif font family name. The default is "serif".
803 *
804 * @return the serif font family name as a string
805 * @see #setSerifFontFamily
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700806 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000807 public abstract String getSerifFontFamily();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700808
809 /**
Steve Block4e584df2012-04-24 23:12:47 +0100810 * Sets the cursive font family name. The default is "cursive".
811 *
812 * @param font a font family name
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700813 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000814 public abstract void setCursiveFontFamily(String font);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700815
816 /**
Steve Block4e584df2012-04-24 23:12:47 +0100817 * Gets the cursive font family name.
818 *
819 * @return the cursive font family name as a string
820 * @see #setCursiveFontFamily
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700821 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000822 public abstract String getCursiveFontFamily();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700823
824 /**
Steve Block4e584df2012-04-24 23:12:47 +0100825 * Sets the fantasy font family name. The default is "fantasy".
826 *
827 * @param font a font family name
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700828 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000829 public abstract void setFantasyFontFamily(String font);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700830
831 /**
Steve Block4e584df2012-04-24 23:12:47 +0100832 * Gets the fantasy font family name.
833 *
834 * @return the fantasy font family name as a string
835 * @see #setFantasyFontFamily
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700836 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000837 public abstract String getFantasyFontFamily();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700838
839 /**
Steve Block4e584df2012-04-24 23:12:47 +0100840 * Sets the minimum font size. The default is 8.
841 *
842 * @param size a non-negative integer between 1 and 72. Any number outside
843 * the specified range will be pinned.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700844 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000845 public abstract void setMinimumFontSize(int size);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700846
847 /**
Steve Block4e584df2012-04-24 23:12:47 +0100848 * Gets the minimum font size.
849 *
850 * @return a non-negative integer between 1 and 72
851 * @see #setMinimumFontSize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700852 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000853 public abstract int getMinimumFontSize();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700854
855 /**
Steve Block4e584df2012-04-24 23:12:47 +0100856 * Sets the minimum logical font size. The default is 8.
857 *
858 * @param size a non-negative integer between 1 and 72. Any number outside
859 * the specified range will be pinned.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700860 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000861 public abstract void setMinimumLogicalFontSize(int size);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700862
863 /**
Steve Block4e584df2012-04-24 23:12:47 +0100864 * Gets the minimum logical font size.
865 *
866 * @return a non-negative integer between 1 and 72
867 * @see #setMinimumLogicalFontSize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700868 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000869 public abstract int getMinimumLogicalFontSize();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700870
871 /**
Steve Block4e584df2012-04-24 23:12:47 +0100872 * Sets the default font size. The default is 16.
873 *
874 * @param size a non-negative integer between 1 and 72. Any number outside
875 * the specified range will be pinned.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700876 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000877 public abstract void setDefaultFontSize(int size);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700878
879 /**
Steve Block4e584df2012-04-24 23:12:47 +0100880 * Gets the default font size.
881 *
882 * @return a non-negative integer between 1 and 72
883 * @see #setDefaultFontSize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700884 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000885 public abstract int getDefaultFontSize();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700886
887 /**
Steve Block4e584df2012-04-24 23:12:47 +0100888 * Sets the default fixed font size. The default is 16.
889 *
890 * @param size a non-negative integer between 1 and 72. Any number outside
891 * the specified range will be pinned.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700892 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000893 public abstract void setDefaultFixedFontSize(int size);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700894
895 /**
Steve Block4e584df2012-04-24 23:12:47 +0100896 * Gets the default fixed font size.
897 *
898 * @return a non-negative integer between 1 and 72
899 * @see #setDefaultFixedFontSize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700900 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000901 public abstract int getDefaultFixedFontSize();
Grace Kloba097b1e772009-11-24 14:23:18 -0800902
903 /**
Mikhail Naganov605a4912012-02-03 16:53:10 +0000904 * Sets whether the WebView should load image resources. Note that this method
905 * controls loading of all images, including those embedded using the data
906 * URI scheme. Use {@link #setBlockNetworkImage} to control loading only
907 * of images specified using network URI schemes. Note that if the value of this
Nate Fischer0a6140d2017-09-05 12:37:49 -0700908 * setting is changed from {@code false} to {@code true}, all images resources referenced
Mikhail Naganov605a4912012-02-03 16:53:10 +0000909 * by content currently displayed by the WebView are loaded automatically.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700910 * The default is {@code true}.
Steve Block4e584df2012-04-24 23:12:47 +0100911 *
912 * @param flag whether the WebView should load image resources
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700913 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000914 public abstract void setLoadsImagesAutomatically(boolean flag);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700915
916 /**
Steve Block4e584df2012-04-24 23:12:47 +0100917 * Gets whether the WebView loads image resources. This includes
918 * images embedded using the data URI scheme.
919 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700920 * @return {@code true} if the WebView loads image resources
Steve Block4e584df2012-04-24 23:12:47 +0100921 * @see #setLoadsImagesAutomatically
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700922 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000923 public abstract boolean getLoadsImagesAutomatically();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700924
925 /**
Mikhail Naganov605a4912012-02-03 16:53:10 +0000926 * Sets whether the WebView should not load image resources from the
927 * network (resources accessed via http and https URI schemes). Note
928 * that this method has no effect unless
Nate Fischer0a6140d2017-09-05 12:37:49 -0700929 * {@link #getLoadsImagesAutomatically} returns {@code true}. Also note that
Mikhail Naganov605a4912012-02-03 16:53:10 +0000930 * disabling all network loads using {@link #setBlockNetworkLoads}
931 * will also prevent network images from loading, even if this flag is set
Nate Fischer0a6140d2017-09-05 12:37:49 -0700932 * to false. When the value of this setting is changed from {@code true} to {@code false},
Mikhail Naganov605a4912012-02-03 16:53:10 +0000933 * network images resources referenced by content currently displayed by
Nate Fischer0a6140d2017-09-05 12:37:49 -0700934 * the WebView are fetched automatically. The default is {@code false}.
Steve Block4e584df2012-04-24 23:12:47 +0100935 *
936 * @param flag whether the WebView should not load image resources from the
937 * network
Patrick Scottf43113f2010-02-18 09:13:12 -0500938 * @see #setBlockNetworkLoads
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700939 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000940 public abstract void setBlockNetworkImage(boolean flag);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700941
942 /**
Steve Block4e584df2012-04-24 23:12:47 +0100943 * Gets whether the WebView does not load image resources from the network.
944 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700945 * @return {@code true} if the WebView does not load image resources from the network
Steve Block4e584df2012-04-24 23:12:47 +0100946 * @see #setBlockNetworkImage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700947 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000948 public abstract boolean getBlockNetworkImage();
Mike Hearnadcd2ed2009-01-21 16:44:36 +0100949
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800950 /**
Mikhail Naganov605a4912012-02-03 16:53:10 +0000951 * Sets whether the WebView should not load resources from the network.
952 * Use {@link #setBlockNetworkImage} to only avoid loading
953 * image resources. Note that if the value of this setting is
Nate Fischer0a6140d2017-09-05 12:37:49 -0700954 * changed from {@code true} to {@code false}, network resources referenced by content
Mikhail Naganov605a4912012-02-03 16:53:10 +0000955 * currently displayed by the WebView are not fetched until
956 * {@link android.webkit.WebView#reload} is called.
957 * If the application does not have the
958 * {@link android.Manifest.permission#INTERNET} permission, attempts to set
Nate Fischer0a6140d2017-09-05 12:37:49 -0700959 * a value of {@code false} will cause a {@link java.lang.SecurityException}
960 * to be thrown. The default value is {@code false} if the application has the
Steve Block4e584df2012-04-24 23:12:47 +0100961 * {@link android.Manifest.permission#INTERNET} permission, otherwise it is
Nate Fischer0a6140d2017-09-05 12:37:49 -0700962 * {@code true}.
Steve Block4e584df2012-04-24 23:12:47 +0100963 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700964 * @param flag {@code true} means block network loads by the WebView
Patrick Scottf43113f2010-02-18 09:13:12 -0500965 * @see android.webkit.WebView#reload
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800966 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000967 public abstract void setBlockNetworkLoads(boolean flag);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800968
969 /**
Steve Block4e584df2012-04-24 23:12:47 +0100970 * Gets whether the WebView does not load any resources from the network.
971 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700972 * @return {@code true} if the WebView does not load any resources from the network
Steve Block4e584df2012-04-24 23:12:47 +0100973 * @see #setBlockNetworkLoads
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800974 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000975 public abstract boolean getBlockNetworkLoads();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700976
977 /**
Steve Block4e584df2012-04-24 23:12:47 +0100978 * Tells the WebView to enable JavaScript execution.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700979 * <b>The default is {@code false}.</b>
Steve Block4e584df2012-04-24 23:12:47 +0100980 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700981 * @param flag {@code true} if the WebView should execute JavaScript
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700982 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000983 public abstract void setJavaScriptEnabled(boolean flag);
Teng-Hui Zhuda7378e2011-02-16 11:25:03 -0800984
985 /**
Hazem Ashmawy7536c2b2020-02-20 19:39:27 +0000986 * Sets whether cross-origin requests in the context of a file scheme URL should be allowed to
987 * access content from <i>any</i> origin. This includes access to content from other file
988 * scheme URLs or web contexts. Note that some access such as image HTML elements doesn't
989 * follow same-origin rules and isn't affected by this setting.
990 * <p>
991 * <b>Don't</b> enable this setting if you open files that may be created or altered by
992 * external sources. Enabling this setting allows malicious scripts loaded in a {@code file://}
993 * context to launch cross-site scripting attacks, either accessing arbitrary local files
994 * including WebView cookies, app private data or even credentials used on arbitrary web sites.
995 * <p class="note">
996 * Loading content via {@code file://} URLs is generally discouraged. See the note in
997 * {@link #setAllowFileAccess}.
Steve Blockef163152012-04-23 18:08:06 +0100998 * <p>
Nate Fischer8cc15362018-01-23 16:51:30 -0800999 * The default value is {@code true} for apps targeting
Hazem Ashmawy7536c2b2020-02-20 19:39:27 +00001000 * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and below, and {@code false}
1001 * when targeting {@link android.os.Build.VERSION_CODES#JELLY_BEAN} and above. To prevent
1002 * possible violation of same domain policy when targeting
1003 * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and earlier, you should
1004 * explicitly set this value to {@code false}.
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001005 *
Hazem Ashmawy7536c2b2020-02-20 19:39:27 +00001006 * @param flag whether JavaScript running in the context of a file scheme URL should be allowed
1007 * to access content from any origin
1008 * @deprecated This setting is not secure, please use
1009 * <a href="{@docRoot}reference/androidx/webkit/WebViewAssetLoader.html">
1010 * androidx.webkit.WebViewAssetLoader</a> to load file content securely.
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001011 */
Hazem Ashmawy7536c2b2020-02-20 19:39:27 +00001012 @Deprecated
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001013 public abstract void setAllowUniversalAccessFromFileURLs(boolean flag);
1014
1015 /**
Hazem Ashmawy7536c2b2020-02-20 19:39:27 +00001016 * Sets whether cross-origin requests in the context of a file scheme URL should be allowed to
1017 * access content from other file scheme URLs. Note that some accesses such as image HTML
1018 * elements don't follow same-origin rules and aren't affected by this setting.
Steve Blockef163152012-04-23 18:08:06 +01001019 * <p>
Hazem Ashmawy7536c2b2020-02-20 19:39:27 +00001020 * <b>Don't</b> enable this setting if you open files that may be created or altered by
1021 * external sources. Enabling this setting allows malicious scripts loaded in a {@code file://}
1022 * context to access arbitrary local files including WebView cookies and app private data.
1023 * <p class="note">
1024 * Loading content via {@code file://} URLs is generally discouraged. See the note in
1025 * {@link #setAllowFileAccess}.
1026 * <p>
1027 * Note that the value of this setting is ignored if the value of
1028 * {@link #getAllowUniversalAccessFromFileURLs} is {@code true}. The default value is
1029 * {@code true} for apps targeting {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1}
1030 * and below, and {@code false} when targeting {@link android.os.Build.VERSION_CODES#JELLY_BEAN}
1031 * and above. To prevent possible violation of same domain policy when targeting
1032 * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and earlier, you should
1033 * explicitly set this value to {@code false}.
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001034 *
Steve Blockef163152012-04-23 18:08:06 +01001035 * @param flag whether JavaScript running in the context of a file scheme
1036 * URL should be allowed to access content from other file
1037 * scheme URLs
Hazem Ashmawy7536c2b2020-02-20 19:39:27 +00001038 * @deprecated This setting is not secure, please use
1039 * <a href="{@docRoot}reference/androidx/webkit/WebViewAssetLoader.html">
1040 * androidx.webkit.WebViewAssetLoader</a> to load file content securely.
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001041 */
Hazem Ashmawy7536c2b2020-02-20 19:39:27 +00001042 @Deprecated
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001043 public abstract void setAllowFileAccessFromFileURLs(boolean flag);
1044
1045 /**
Nate Fischer0a6140d2017-09-05 12:37:49 -07001046 * Sets whether the WebView should enable plugins. The default is {@code false}.
Steve Block4e584df2012-04-24 23:12:47 +01001047 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001048 * @param flag {@code true} if plugins should be enabled
Patrick Scott300f2e92010-03-22 10:20:45 -04001049 * @deprecated This method has been deprecated in favor of
1050 * {@link #setPluginState}
Jonathan Dixon0bf47812013-03-07 17:20:08 -08001051 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001052 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001053 @SystemApi
Michael Kolba172e7d2010-06-30 12:35:26 -07001054 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001055 public abstract void setPluginsEnabled(boolean flag);
Patrick Scott300f2e92010-03-22 10:20:45 -04001056
1057 /**
Steve Block4e584df2012-04-24 23:12:47 +01001058 * Tells the WebView to enable, disable, or have plugins on demand. On
Patrick Scott300f2e92010-03-22 10:20:45 -04001059 * demand mode means that if a plugin exists that can handle the embedded
1060 * content, a placeholder icon will be shown instead of the plugin. When
Steve Blockb0e0f332012-06-13 22:01:11 +01001061 * the placeholder is clicked, the plugin will be enabled. The default is
1062 * {@link PluginState#OFF}.
Steve Block4e584df2012-04-24 23:12:47 +01001063 *
1064 * @param state a PluginState value
Torne (Richard Coles)1676c952018-06-28 19:33:27 -04001065 * @deprecated Plugins are not supported in API level
1066 * {@link android.os.Build.VERSION_CODES#KITKAT} or later;
1067 * enabling plugins is a no-op.
Patrick Scott300f2e92010-03-22 10:20:45 -04001068 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -08001069 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001070 public abstract void setPluginState(PluginState state);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001071
1072 /**
Steve Block4e584df2012-04-24 23:12:47 +01001073 * Sets a custom path to plugins used by the WebView. This method is
Derek Sollenbergerfdbdeb32010-08-12 11:20:13 -04001074 * obsolete since each plugin is now loaded from its own package.
Steve Block4e584df2012-04-24 23:12:47 +01001075 *
1076 * @param pluginsPath a String path to the directory containing plugins
Derek Sollenbergerfdbdeb32010-08-12 11:20:13 -04001077 * @deprecated This method is no longer used as plugins are loaded from
Steve Block4e584df2012-04-24 23:12:47 +01001078 * their own APK via the system's package manager.
Jonathan Dixon0bf47812013-03-07 17:20:08 -08001079 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001080 */
Jason Chen9dc2e752010-09-01 19:11:14 -07001081 @Deprecated
Mathew Inwood62d83fb2018-08-16 19:09:48 +01001082 @UnsupportedAppUsage
Ignacio Solla451e3382014-11-10 10:35:54 +00001083 public void setPluginsPath(String pluginsPath) {
Jonathan Dixon3c909522012-02-28 18:45:06 +00001084 // Specified to do nothing, so no need for derived classes to override.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001085 }
1086
1087 /**
Steve Block4e584df2012-04-24 23:12:47 +01001088 * Sets the path to where database storage API databases should be saved.
Steve Block72ca7a42012-06-13 22:00:30 +01001089 * In order for the database storage API to function correctly, this method
1090 * must be called with a path to which the application can write. This
1091 * method should only be called once: repeated calls are ignored.
Steve Block4e584df2012-04-24 23:12:47 +01001092 *
Steve Block72ca7a42012-06-13 22:00:30 +01001093 * @param databasePath a path to the directory where databases should be
1094 * saved.
Jonathan Dixon5545d082013-08-31 22:43:11 -07001095 * @deprecated Database paths are managed by the implementation and calling this method
1096 * will have no effect.
Ben Murdoch7df19852009-04-22 13:07:58 +01001097 */
Jonathan Dixon5545d082013-08-31 22:43:11 -07001098 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001099 public abstract void setDatabasePath(String databasePath);
Ben Murdoch7df19852009-04-22 13:07:58 +01001100
1101 /**
Steve Block72ca7a42012-06-13 22:00:30 +01001102 * Sets the path where the Geolocation databases should be saved. In order
1103 * for Geolocation permissions and cached positions to be persisted, this
1104 * method must be called with a path to which the application can write.
Steve Block4e584df2012-04-24 23:12:47 +01001105 *
Steve Block72ca7a42012-06-13 22:00:30 +01001106 * @param databasePath a path to the directory where databases should be
1107 * saved.
Hui Shu89eb9b42016-01-07 11:32:23 -08001108 * @deprecated Geolocation database are managed by the implementation and calling this method
1109 * will have no effect.
Steve Block9d3273f2009-08-21 13:16:27 +01001110 */
Hui Shu89eb9b42016-01-07 11:32:23 -08001111 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001112 public abstract void setGeolocationDatabasePath(String databasePath);
Steve Block9d3273f2009-08-21 13:16:27 +01001113
1114 /**
Steve Block72ca7a42012-06-13 22:00:30 +01001115 * Sets whether the Application Caches API should be enabled. The default
Nate Fischer0a6140d2017-09-05 12:37:49 -07001116 * is {@code false}. Note that in order for the Application Caches API to be
Steve Block72ca7a42012-06-13 22:00:30 +01001117 * enabled, a valid database path must also be supplied to
1118 * {@link #setAppCachePath}.
Steve Block4e584df2012-04-24 23:12:47 +01001119 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001120 * @param flag {@code true} if the WebView should enable Application Caches
Torne (Richard Coles)76752c82020-05-11 14:58:53 -04001121 * @deprecated The Application Cache API is deprecated and this method will
1122 * become a no-op on all Android versions once support is
1123 * removed in Chromium. Consider using Service Workers instead.
Andrei Popescu60a9a7d2009-04-17 10:43:42 +01001124 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001125 public abstract void setAppCacheEnabled(boolean flag);
Andrei Popescu60a9a7d2009-04-17 10:43:42 +01001126
1127 /**
Steve Block72ca7a42012-06-13 22:00:30 +01001128 * Sets the path to the Application Caches files. In order for the
1129 * Application Caches API to be enabled, this method must be called with a
1130 * path to which the application can write. This method should only be
1131 * called once: repeated calls are ignored.
Steve Block4e584df2012-04-24 23:12:47 +01001132 *
1133 * @param appCachePath a String path to the directory containing
Steve Block72ca7a42012-06-13 22:00:30 +01001134 * Application Caches files.
Jonathan Dixon47aaba32012-11-30 16:32:17 -08001135 * @see #setAppCacheEnabled
Torne (Richard Coles)76752c82020-05-11 14:58:53 -04001136 * @deprecated The Application Cache API is deprecated and this method will
1137 * become a no-op on all Android versions once support is
1138 * removed in Chromium. Consider using Service Workers instead.
Andrei Popescu60a9a7d2009-04-17 10:43:42 +01001139 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001140 public abstract void setAppCachePath(String appCachePath);
Andrei Popescu60a9a7d2009-04-17 10:43:42 +01001141
1142 /**
Selim Gurunb632adf2012-06-28 11:21:05 -07001143 * Sets the maximum size for the Application Cache content. The passed size
1144 * will be rounded to the nearest value that the database can support, so
1145 * this should be viewed as a guide, not a hard limit. Setting the
1146 * size to a value less than current database size does not cause the
Selim Gurunf27ac092012-06-28 11:21:05 -07001147 * database to be trimmed. The default size is {@link Long#MAX_VALUE}.
Jonathan Dixon835b1fc2013-02-25 12:29:33 -08001148 * It is recommended to leave the maximum size set to the default value.
Steve Block4e584df2012-04-24 23:12:47 +01001149 *
1150 * @param appCacheMaxSize the maximum size in bytes
Torne (Richard Coles)76752c82020-05-11 14:58:53 -04001151 * @deprecated Quota is managed automatically; this method is a no-op.
Andrei Popescu1c829202009-07-22 16:47:52 +01001152 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -08001153 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001154 public abstract void setAppCacheMaxSize(long appCacheMaxSize);
Andrei Popescu1c829202009-07-22 16:47:52 +01001155
1156 /**
Steve Blockb0e0f332012-06-13 22:01:11 +01001157 * Sets whether the database storage API is enabled. The default value is
1158 * false. See also {@link #setDatabasePath} for how to correctly set up the
1159 * database storage API.
Steve Block4e584df2012-04-24 23:12:47 +01001160 *
Selim Gurun2bca22b2013-02-28 17:47:21 -08001161 * This setting is global in effect, across all WebView instances in a process.
1162 * Note you should only modify this setting prior to making <b>any</b> WebView
1163 * page load within a given process, as the WebView implementation may ignore
1164 * changes to this setting after that point.
1165 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001166 * @param flag {@code true} if the WebView should use the database storage API
Ben Murdoch7df19852009-04-22 13:07:58 +01001167 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001168 public abstract void setDatabaseEnabled(boolean flag);
Ben Murdoch7df19852009-04-22 13:07:58 +01001169
1170 /**
Nate Fischer0a6140d2017-09-05 12:37:49 -07001171 * Sets whether the DOM storage API is enabled. The default value is {@code false}.
Steve Block4e584df2012-04-24 23:12:47 +01001172 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001173 * @param flag {@code true} if the WebView should use the DOM storage API
Ben Murdoch274680d2009-05-28 13:44:44 +01001174 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001175 public abstract void setDomStorageEnabled(boolean flag);
Ben Murdoch274680d2009-05-28 13:44:44 +01001176
1177 /**
Steve Block4e584df2012-04-24 23:12:47 +01001178 * Gets whether the DOM Storage APIs are enabled.
1179 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001180 * @return {@code true} if the DOM Storage APIs are enabled
Steve Blockb0e0f332012-06-13 22:01:11 +01001181 * @see #setDomStorageEnabled
Ben Murdoch274680d2009-05-28 13:44:44 +01001182 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001183 public abstract boolean getDomStorageEnabled();
1184
Ben Murdoch274680d2009-05-28 13:44:44 +01001185 /**
Steve Blockb0e0f332012-06-13 22:01:11 +01001186 * Gets the path to where database storage API databases are saved.
Steve Block4e584df2012-04-24 23:12:47 +01001187 *
1188 * @return the String path to the database storage API databases
Steve Blockb0e0f332012-06-13 22:01:11 +01001189 * @see #setDatabasePath
Jonathan Dixon5545d082013-08-31 22:43:11 -07001190 * @deprecated Database paths are managed by the implementation this method is obsolete.
Ben Murdoch7df19852009-04-22 13:07:58 +01001191 */
Jonathan Dixon5545d082013-08-31 22:43:11 -07001192 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001193 public abstract String getDatabasePath();
Ben Murdoch7df19852009-04-22 13:07:58 +01001194
1195 /**
Steve Block4e584df2012-04-24 23:12:47 +01001196 * Gets whether the database storage API is enabled.
1197 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001198 * @return {@code true} if the database storage API is enabled
Steve Blockb0e0f332012-06-13 22:01:11 +01001199 * @see #setDatabaseEnabled
Ben Murdoch7df19852009-04-22 13:07:58 +01001200 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001201 public abstract boolean getDatabaseEnabled();
Andrei Popescuc27a9ac2009-08-03 15:59:24 +01001202
1203 /**
Nate Fischer0a6140d2017-09-05 12:37:49 -07001204 * Sets whether Geolocation is enabled. The default is {@code true}.
Mikhail Naganov6cb296a2012-08-28 16:57:24 +01001205 * <p>
1206 * Please note that in order for the Geolocation API to be usable
1207 * by a page in the WebView, the following requirements must be met:
1208 * <ul>
1209 * <li>an application must have permission to access the device location,
1210 * see {@link android.Manifest.permission#ACCESS_COARSE_LOCATION},
1211 * {@link android.Manifest.permission#ACCESS_FINE_LOCATION};
1212 * <li>an application must provide an implementation of the
1213 * {@link WebChromeClient#onGeolocationPermissionsShowPrompt} callback
1214 * to receive notifications that a page is requesting access to location
1215 * via the JavaScript Geolocation API.
1216 * </ul>
1217 * <p>
Steve Block4e584df2012-04-24 23:12:47 +01001218 *
1219 * @param flag whether Geolocation should be enabled
Steve Block06cd7512009-08-21 10:26:37 +01001220 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001221 public abstract void setGeolocationEnabled(boolean flag);
Elliott Slaughter5dc0c822010-06-22 11:31:54 -07001222
1223 /**
Steve Block4e584df2012-04-24 23:12:47 +01001224 * Gets whether JavaScript is enabled.
1225 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001226 * @return {@code true} if JavaScript is enabled
Steve Block4e584df2012-04-24 23:12:47 +01001227 * @see #setJavaScriptEnabled
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001228 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001229 public abstract boolean getJavaScriptEnabled();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001230
1231 /**
Steve Blockef163152012-04-23 18:08:06 +01001232 * Gets whether JavaScript running in the context of a file scheme URL can
1233 * access content from any origin. This includes access to content from
1234 * other file scheme URLs.
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001235 *
Steve Blockef163152012-04-23 18:08:06 +01001236 * @return whether JavaScript running in the context of a file scheme URL
1237 * can access content from any origin
Steve Block4e584df2012-04-24 23:12:47 +01001238 * @see #setAllowUniversalAccessFromFileURLs
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001239 */
1240 public abstract boolean getAllowUniversalAccessFromFileURLs();
1241
1242 /**
Steve Blockef163152012-04-23 18:08:06 +01001243 * Gets whether JavaScript running in the context of a file scheme URL can
1244 * access content from other file scheme URLs.
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001245 *
Steve Blockef163152012-04-23 18:08:06 +01001246 * @return whether JavaScript running in the context of a file scheme URL
1247 * can access content from other file scheme URLs
Steve Block4e584df2012-04-24 23:12:47 +01001248 * @see #setAllowFileAccessFromFileURLs
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001249 */
1250 public abstract boolean getAllowFileAccessFromFileURLs();
1251
1252 /**
Steve Block4e584df2012-04-24 23:12:47 +01001253 * Gets whether plugins are enabled.
1254 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001255 * @return {@code true} if plugins are enabled
Steve Blockb0e0f332012-06-13 22:01:11 +01001256 * @see #setPluginsEnabled
Patrick Scott300f2e92010-03-22 10:20:45 -04001257 * @deprecated This method has been replaced by {@link #getPluginState}
Jonathan Dixon0bf47812013-03-07 17:20:08 -08001258 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001259 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001260 @SystemApi
Michael Kolba172e7d2010-06-30 12:35:26 -07001261 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001262 public abstract boolean getPluginsEnabled();
Patrick Scott300f2e92010-03-22 10:20:45 -04001263
1264 /**
Steve Blockb0e0f332012-06-13 22:01:11 +01001265 * Gets the current state regarding whether plugins are enabled.
Steve Block4e584df2012-04-24 23:12:47 +01001266 *
Steve Blockb0e0f332012-06-13 22:01:11 +01001267 * @return the plugin state as a {@link PluginState} value
1268 * @see #setPluginState
Torne (Richard Coles)1676c952018-06-28 19:33:27 -04001269 * @deprecated Plugins are not supported in API level
1270 * {@link android.os.Build.VERSION_CODES#KITKAT} or later;
1271 * enabling plugins is a no-op.
Patrick Scott300f2e92010-03-22 10:20:45 -04001272 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -08001273 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001274 public abstract PluginState getPluginState();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001275
1276 /**
Steve Block4e584df2012-04-24 23:12:47 +01001277 * Gets the directory that contains the plugin libraries. This method is
Derek Sollenbergerfdbdeb32010-08-12 11:20:13 -04001278 * obsolete since each plugin is now loaded from its own package.
Steve Block4e584df2012-04-24 23:12:47 +01001279 *
1280 * @return an empty string
Derek Sollenbergerfdbdeb32010-08-12 11:20:13 -04001281 * @deprecated This method is no longer used as plugins are loaded from
1282 * their own APK via the system's package manager.
Jonathan Dixon0bf47812013-03-07 17:20:08 -08001283 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001284 */
Jason Chen9dc2e752010-09-01 19:11:14 -07001285 @Deprecated
Mathew Inwood62d83fb2018-08-16 19:09:48 +01001286 @UnsupportedAppUsage
Ignacio Solla451e3382014-11-10 10:35:54 +00001287 public String getPluginsPath() {
Jonathan Dixon3c909522012-02-28 18:45:06 +00001288 // Unconditionally returns empty string, so no need for derived classes to override.
Grace Kloba658ab7d2009-05-14 14:45:26 -07001289 return "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001290 }
1291
1292 /**
Steve Block4e584df2012-04-24 23:12:47 +01001293 * Tells JavaScript to open windows automatically. This applies to the
Nate Fischer4ea92402017-11-17 18:48:13 -08001294 * JavaScript function {@code window.open()}. The default is {@code false}.
Steve Block4e584df2012-04-24 23:12:47 +01001295 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001296 * @param flag {@code true} if JavaScript can open windows automatically
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001297 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001298 public abstract void setJavaScriptCanOpenWindowsAutomatically(boolean flag);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001299
1300 /**
Steve Block4e584df2012-04-24 23:12:47 +01001301 * Gets whether JavaScript can open windows automatically.
1302 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001303 * @return {@code true} if JavaScript can open windows automatically during
Nate Fischer4ea92402017-11-17 18:48:13 -08001304 * {@code window.open()}
Steve Block4e584df2012-04-24 23:12:47 +01001305 * @see #setJavaScriptCanOpenWindowsAutomatically
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001306 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001307 public abstract boolean getJavaScriptCanOpenWindowsAutomatically();
Marcin Kosibafd1ac832014-10-10 17:12:49 +01001308
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001309 /**
Steve Block4e584df2012-04-24 23:12:47 +01001310 * Sets the default text encoding name to use when decoding html pages.
Marcin Kosibafd1ac832014-10-10 17:12:49 +01001311 * The default is "UTF-8".
Steve Block4e584df2012-04-24 23:12:47 +01001312 *
1313 * @param encoding the text encoding name
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001314 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001315 public abstract void setDefaultTextEncodingName(String encoding);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001316
1317 /**
Steve Block4e584df2012-04-24 23:12:47 +01001318 * Gets the default text encoding name.
1319 *
1320 * @return the default text encoding name as a string
1321 * @see #setDefaultTextEncodingName
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001322 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001323 public abstract String getDefaultTextEncodingName();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001324
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001325 /**
Nate Fischer0a6140d2017-09-05 12:37:49 -07001326 * Sets the WebView's user-agent string. If the string is {@code null} or empty,
Steve Blockb0e0f332012-06-13 22:01:11 +01001327 * the system default value will be used.
Mikhail Naganov550f6212015-07-07 13:39:31 -07001328 *
1329 * Note that starting from {@link android.os.Build.VERSION_CODES#KITKAT} Android
1330 * version, changing the user-agent while loading a web page causes WebView
1331 * to initiate loading once again.
1332 *
1333 * @param ua new user-agent string
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001334 */
Nate Fischer3442c742017-09-08 17:02:00 -07001335 public abstract void setUserAgentString(@Nullable String ua);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001336
1337 /**
Steve Block4e584df2012-04-24 23:12:47 +01001338 * Gets the WebView's user-agent string.
Steve Blockb0e0f332012-06-13 22:01:11 +01001339 *
1340 * @return the WebView's user-agent string
1341 * @see #setUserAgentString
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001342 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001343 public abstract String getUserAgentString();
Shimeng (Simon) Wangc55886a2010-10-28 13:46:02 -07001344
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001345 /**
George Mount9f410c52012-08-10 15:29:30 -07001346 * Returns the default User-Agent used by a WebView.
1347 * An instance of WebView could use a different User-Agent if a call
Kristian Monsenf4912582012-08-16 15:26:24 -04001348 * is made to {@link WebSettings#setUserAgentString(String)}.
George Mount9f410c52012-08-10 15:29:30 -07001349 *
1350 * @param context a Context object used to access application assets
1351 */
1352 public static String getDefaultUserAgent(Context context) {
Jonathan Dixond1c4faa2012-08-20 16:37:15 -07001353 return WebViewFactory.getProvider().getStatics().getDefaultUserAgent(context);
George Mount9f410c52012-08-10 15:29:30 -07001354 }
1355
1356 /**
Steve Block4e584df2012-04-24 23:12:47 +01001357 * Tells the WebView whether it needs to set a node to have focus when
Steve Blockb0e0f332012-06-13 22:01:11 +01001358 * {@link WebView#requestFocus(int, android.graphics.Rect)} is called. The
Nate Fischer0a6140d2017-09-05 12:37:49 -07001359 * default value is {@code true}.
Michael Kolba172e7d2010-06-30 12:35:26 -07001360 *
Steve Block4e584df2012-04-24 23:12:47 +01001361 * @param flag whether the WebView needs to set a node
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001362 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001363 public abstract void setNeedInitialFocus(boolean flag);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001364
1365 /**
Steve Block4e584df2012-04-24 23:12:47 +01001366 * Sets the priority of the Render thread. Unlike the other settings, this
Steve Blockb0e0f332012-06-13 22:01:11 +01001367 * one only needs to be called once per process. The default value is
1368 * {@link RenderPriority#NORMAL}.
Mike Hearnadcd2ed2009-01-21 16:44:36 +01001369 *
Steve Blockb0e0f332012-06-13 22:01:11 +01001370 * @param priority the priority
Jonathan Dixon835b1fc2013-02-25 12:29:33 -08001371 * @deprecated It is not recommended to adjust thread priorities, and this will
1372 * not be supported in future versions.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001373 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -08001374 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001375 public abstract void setRenderPriority(RenderPriority priority);
Michael Kolba172e7d2010-06-30 12:35:26 -07001376
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001377 /**
Steve Block4e584df2012-04-24 23:12:47 +01001378 * Overrides the way the cache is used. The way the cache is used is based
Steve Blockb0e0f332012-06-13 22:01:11 +01001379 * on the navigation type. For a normal page load, the cache is checked
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001380 * and content is re-validated as needed. When navigating back, content is
Steve Blockb0e0f332012-06-13 22:01:11 +01001381 * not revalidated, instead the content is just retrieved from the cache.
1382 * This method allows the client to override this behavior by specifying
Mikhail Naganov56936a12012-07-25 13:07:18 +01001383 * one of {@link #LOAD_DEFAULT},
Steve Blockb0e0f332012-06-13 22:01:11 +01001384 * {@link #LOAD_CACHE_ELSE_NETWORK}, {@link #LOAD_NO_CACHE} or
1385 * {@link #LOAD_CACHE_ONLY}. The default value is {@link #LOAD_DEFAULT}.
Steve Block4e584df2012-04-24 23:12:47 +01001386 *
Steve Blockb0e0f332012-06-13 22:01:11 +01001387 * @param mode the mode to use
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001388 */
Tim Volodineb90f5382016-04-29 12:44:41 +01001389 public abstract void setCacheMode(@CacheMode int mode);
Michael Kolba172e7d2010-06-30 12:35:26 -07001390
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001391 /**
Steve Blockb0e0f332012-06-13 22:01:11 +01001392 * Gets the current setting for overriding the cache mode.
1393 *
1394 * @return the current setting for overriding the cache mode
1395 * @see #setCacheMode
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001396 */
Tim Volodineb90f5382016-04-29 12:44:41 +01001397 @CacheMode
Ignacio Solla451e3382014-11-10 10:35:54 +00001398 public abstract int getCacheMode();
Ben Murdochfe9fc3d2014-04-10 15:31:06 +01001399
1400 /**
1401 * Configures the WebView's behavior when a secure origin attempts to load a resource from an
1402 * insecure origin.
1403 *
1404 * By default, apps that target {@link android.os.Build.VERSION_CODES#KITKAT} or below default
1405 * to {@link #MIXED_CONTENT_ALWAYS_ALLOW}. Apps targeting
Dianne Hackborn955d8d62014-10-07 20:17:19 -07001406 * {@link android.os.Build.VERSION_CODES#LOLLIPOP} default to {@link #MIXED_CONTENT_NEVER_ALLOW}.
Ben Murdochfe9fc3d2014-04-10 15:31:06 +01001407 *
1408 * The preferred and most secure mode of operation for the WebView is
1409 * {@link #MIXED_CONTENT_NEVER_ALLOW} and use of {@link #MIXED_CONTENT_ALWAYS_ALLOW} is
1410 * strongly discouraged.
1411 *
1412 * @param mode The mixed content mode to use. One of {@link #MIXED_CONTENT_NEVER_ALLOW},
Torne (Richard Coles)2b666c92015-03-06 14:20:00 +00001413 * {@link #MIXED_CONTENT_ALWAYS_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}.
Ben Murdochfe9fc3d2014-04-10 15:31:06 +01001414 */
1415 public abstract void setMixedContentMode(int mode);
1416
1417 /**
1418 * Gets the current behavior of the WebView with regard to loading insecure content from a
1419 * secure origin.
1420 * @return The current setting, one of {@link #MIXED_CONTENT_NEVER_ALLOW},
Torne (Richard Coles)2b666c92015-03-06 14:20:00 +00001421 * {@link #MIXED_CONTENT_ALWAYS_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}.
Ben Murdochfe9fc3d2014-04-10 15:31:06 +01001422 */
1423 public abstract int getMixedContentMode();
Yuncheol Heo4d07c482014-05-07 17:29:35 +09001424
1425 /**
1426 * Sets whether to use a video overlay for embedded encrypted video.
Dianne Hackborn955d8d62014-10-07 20:17:19 -07001427 * In API levels prior to {@link android.os.Build.VERSION_CODES#LOLLIPOP}, encrypted video can
Yuncheol Heo4d07c482014-05-07 17:29:35 +09001428 * only be rendered directly on a secure video surface, so it had been a hard problem to play
1429 * encrypted video in HTML. When this flag is on, WebView can play encrypted video (MSE/EME)
1430 * by using a video overlay (aka hole-punching) for videos embedded using HTML &lt;video&gt;
1431 * tag.<br>
1432 * Caution: This setting is intended for use only in a narrow set of circumstances and apps
1433 * should only enable it if they require playback of encrypted video content. It will impose
1434 * the following limitations on the WebView:
1435 * <ul>
1436 * <li> Only one video overlay can be played at a time.
1437 * <li> Changes made to position or dimensions of a video element may be propagated to the
1438 * corresponding video overlay with a noticeable delay.
1439 * <li> The video overlay is not visible to web APIs and as such may not interact with
1440 * script or styling. For example, CSS styles applied to the &lt;video&gt; tag may be ignored.
1441 * </ul>
1442 * This is not an exhaustive set of constraints and it may vary with new versions of the
1443 * WebView.
1444 * @hide
1445 */
Yuncheol Heoeeba0252014-07-08 19:43:00 +09001446 @SystemApi
Yuncheol Heo4d07c482014-05-07 17:29:35 +09001447 public abstract void setVideoOverlayForEmbeddedEncryptedVideoEnabled(boolean flag);
1448
1449 /**
1450 * Gets whether a video overlay will be used for embedded encrypted video.
1451 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001452 * @return {@code true} if WebView uses a video overlay for embedded encrypted video.
Yuncheol Heo4d07c482014-05-07 17:29:35 +09001453 * @see #setVideoOverlayForEmbeddedEncryptedVideoEnabled
1454 * @hide
1455 */
Yuncheol Heoeeba0252014-07-08 19:43:00 +09001456 @SystemApi
Yuncheol Heo4d07c482014-05-07 17:29:35 +09001457 public abstract boolean getVideoOverlayForEmbeddedEncryptedVideoEnabled();
Hui Shub1ee70b2015-03-03 11:38:41 -08001458
1459 /**
1460 * Sets whether this WebView should raster tiles when it is
1461 * offscreen but attached to a window. Turning this on can avoid
1462 * rendering artifacts when animating an offscreen WebView on-screen.
1463 * Offscreen WebViews in this mode use more memory. The default value is
Hui Shud377c0f2015-05-13 12:01:42 -07001464 * false.<br>
Hui Shub1ee70b2015-03-03 11:38:41 -08001465 * Please follow these guidelines to limit memory usage:
Hui Shud377c0f2015-05-13 12:01:42 -07001466 * <ul>
1467 * <li> WebView size should be not be larger than the device screen size.
1468 * <li> Limit use of this mode to a small number of WebViews. Use it for
Hui Shub1ee70b2015-03-03 11:38:41 -08001469 * visible WebViews and WebViews about to be animated to visible.
Hui Shud377c0f2015-05-13 12:01:42 -07001470 * </ul>
Hui Shub1ee70b2015-03-03 11:38:41 -08001471 */
1472 public abstract void setOffscreenPreRaster(boolean enabled);
1473
1474 /**
1475 * Gets whether this WebView should raster tiles when it is
1476 * offscreen but attached to a window.
Nate Fischer0a6140d2017-09-05 12:37:49 -07001477 * @return {@code true} if this WebView will raster tiles when it is
Hui Shub1ee70b2015-03-03 11:38:41 -08001478 * offscreen but attached to a window.
1479 */
1480 public abstract boolean getOffscreenPreRaster();
Hui Shu227a8c12015-10-22 14:57:51 -07001481
Selim Gurunec0a1f22017-04-07 18:21:46 -07001482
1483 /**
Nate Fischerfb92ee12018-01-18 12:01:19 -08001484 * Sets whether Safe Browsing is enabled. Safe Browsing allows WebView to
Selim Gurunec0a1f22017-04-07 18:21:46 -07001485 * protect against malware and phishing attacks by verifying the links.
1486 *
Selim Gurunec0a1f22017-04-07 18:21:46 -07001487 * <p>
Nate Fischerfb92ee12018-01-18 12:01:19 -08001488 * Safe Browsing can be disabled for all WebViews using a manifest tag (read <a
1489 * href="{@docRoot}reference/android/webkit/WebView.html">general Safe Browsing info</a>). The
1490 * manifest tag has a lower precedence than this API.
Selim Gurunec0a1f22017-04-07 18:21:46 -07001491 *
Nate Fischer471891d2017-07-18 19:15:52 -07001492 * <p>
Nate Fischerfb92ee12018-01-18 12:01:19 -08001493 * Safe Browsing is enabled by default for devices which support it.
Selim Gurunec0a1f22017-04-07 18:21:46 -07001494 *
Nate Fischerfb92ee12018-01-18 12:01:19 -08001495 * @param enabled Whether Safe Browsing is enabled.
Selim Gurunec0a1f22017-04-07 18:21:46 -07001496 */
1497 public abstract void setSafeBrowsingEnabled(boolean enabled);
1498
1499 /**
Nate Fischerfb92ee12018-01-18 12:01:19 -08001500 * Gets whether Safe Browsing is enabled.
Selim Gurunec0a1f22017-04-07 18:21:46 -07001501 * See {@link #setSafeBrowsingEnabled}.
1502 *
Nate Fischerfb92ee12018-01-18 12:01:19 -08001503 * @return {@code true} if Safe Browsing is enabled and {@code false} otherwise.
Selim Gurunec0a1f22017-04-07 18:21:46 -07001504 */
1505 public abstract boolean getSafeBrowsingEnabled();
1506
1507
Hui Shu227a8c12015-10-22 14:57:51 -07001508 /**
Tobias Sargeantfec405a32018-12-06 15:22:18 +00001509 * Set the force dark mode for this WebView.
Tobias Sargeante1fc7912019-03-19 12:16:22 +00001510 *
1511 * @param forceDark the force dark mode to set.
Anna Malova7374ce12019-09-25 12:19:27 +01001512 * @see #getForceDark
Tobias Sargeantfec405a32018-12-06 15:22:18 +00001513 */
Tobias Sargeantbbb043a2019-03-11 10:14:28 +00001514 public void setForceDark(@ForceDark int forceDark) {
Tobias Sargeantfec405a32018-12-06 15:22:18 +00001515 // Stub implementation to satisfy Roboelectrc shadows that don't override this yet.
1516 }
1517
1518 /**
1519 * Get the force dark mode for this WebView.
Anna Malova7374ce12019-09-25 12:19:27 +01001520 * The default force dark mode is {@link #FORCE_DARK_AUTO}.
Tobias Sargeante1fc7912019-03-19 12:16:22 +00001521 *
Tobias Sargeantfec405a32018-12-06 15:22:18 +00001522 * @return the currently set force dark mode.
Anna Malova7374ce12019-09-25 12:19:27 +01001523 * @see #setForceDark
Tobias Sargeantfec405a32018-12-06 15:22:18 +00001524 */
Tobias Sargeantbbb043a2019-03-11 10:14:28 +00001525 public @ForceDark int getForceDark() {
Tobias Sargeantfec405a32018-12-06 15:22:18 +00001526 // Stub implementation to satisfy Roboelectrc shadows that don't override this yet.
1527 return FORCE_DARK_AUTO;
1528 }
1529
1530 /**
Hui Shu539b0772016-04-20 15:21:37 -07001531 * @hide
1532 */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07001533 @IntDef(flag = true, prefix = { "MENU_ITEM_" }, value = {
1534 MENU_ITEM_NONE,
1535 MENU_ITEM_SHARE,
1536 MENU_ITEM_WEB_SEARCH,
1537 MENU_ITEM_PROCESS_TEXT
1538 })
Hui Shu539b0772016-04-20 15:21:37 -07001539 @Retention(RetentionPolicy.SOURCE)
1540 @Target({ElementType.PARAMETER, ElementType.METHOD})
1541 private @interface MenuItemFlags {}
1542
1543 /**
Hui Shu227a8c12015-10-22 14:57:51 -07001544 * Disables the action mode menu items according to {@code menuItems} flag.
1545 * @param menuItems an integer field flag for the menu items to be disabled.
1546 */
Hui Shu539b0772016-04-20 15:21:37 -07001547 public abstract void setDisabledActionModeMenuItems(@MenuItemFlags int menuItems);
Hui Shu227a8c12015-10-22 14:57:51 -07001548
1549 /**
1550 * Gets the action mode menu items that are disabled, expressed in an integer field flag.
1551 * The default value is {@link #MENU_ITEM_NONE}
1552 *
Hui Shu539b0772016-04-20 15:21:37 -07001553 * @return all the disabled menu item flags combined with bitwise OR.
Hui Shu227a8c12015-10-22 14:57:51 -07001554 */
Hui Shu539b0772016-04-20 15:21:37 -07001555 public abstract @MenuItemFlags int getDisabledActionModeMenuItems();
Hui Shu227a8c12015-10-22 14:57:51 -07001556
1557 /**
Hui Shu227a8c12015-10-22 14:57:51 -07001558 * No menu items should be disabled.
Anna Malova7374ce12019-09-25 12:19:27 +01001559 *
1560 * @see #setDisabledActionModeMenuItems
Hui Shu227a8c12015-10-22 14:57:51 -07001561 */
1562 public static final int MENU_ITEM_NONE = 0;
1563
1564 /**
Hui Shu227a8c12015-10-22 14:57:51 -07001565 * Disable menu item "Share".
Anna Malova7374ce12019-09-25 12:19:27 +01001566 *
1567 * @see #setDisabledActionModeMenuItems
Hui Shu227a8c12015-10-22 14:57:51 -07001568 */
1569 public static final int MENU_ITEM_SHARE = 1 << 0;
1570
1571 /**
Hui Shu227a8c12015-10-22 14:57:51 -07001572 * Disable menu item "Web Search".
Anna Malova7374ce12019-09-25 12:19:27 +01001573 *
1574 * @see #setDisabledActionModeMenuItems
Hui Shu227a8c12015-10-22 14:57:51 -07001575 */
1576 public static final int MENU_ITEM_WEB_SEARCH = 1 << 1;
1577
1578 /**
Hui Shu227a8c12015-10-22 14:57:51 -07001579 * Disable all the action mode menu items for text processing.
1580 * By default WebView searches for activities that are able to handle
1581 * {@link android.content.Intent#ACTION_PROCESS_TEXT} and show them in the
1582 * action mode menu. If this flag is set via {@link
1583 * #setDisabledActionModeMenuItems}, these menu items will be disabled.
Anna Malova7374ce12019-09-25 12:19:27 +01001584 *
1585 * @see #setDisabledActionModeMenuItems
Hui Shu227a8c12015-10-22 14:57:51 -07001586 */
1587 public static final int MENU_ITEM_PROCESS_TEXT = 1 << 2;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001588}