blob: 7282008f7e3a7861de0b4ed1eec0822a7480158c [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;
Mathew Inwood62d83fb2018-08-16 19:09:48 +010022import android.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.
Steve Block4e584df2012-04-24 23:12:47 +0100331 *
332 * @param enabled whether the WebView should use its built-in zoom mechanisms
The Android Open Source Project10592532009-03-18 17:39:46 -0700333 */
Steve Block06d268e2012-04-16 14:10:54 +0100334 // This method was intended to select between the built-in zoom mechanisms
335 // and the separate zoom controls. The latter were obtained using
336 // {@link WebView#getZoomControls}, which is now hidden.
Ignacio Solla451e3382014-11-10 10:35:54 +0000337 public abstract void setBuiltInZoomControls(boolean enabled);
Michael Kolba172e7d2010-06-30 12:35:26 -0700338
The Android Open Source Project10592532009-03-18 17:39:46 -0700339 /**
Steve Block4e584df2012-04-24 23:12:47 +0100340 * Gets whether the zoom mechanisms built into WebView are being used.
341 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700342 * @return {@code true} if the zoom mechanisms built into WebView are being used
Steve Block4e584df2012-04-24 23:12:47 +0100343 * @see #setBuiltInZoomControls
The Android Open Source Project10592532009-03-18 17:39:46 -0700344 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000345 public abstract boolean getBuiltInZoomControls();
Michael Kolba172e7d2010-06-30 12:35:26 -0700346
The Android Open Source Project10592532009-03-18 17:39:46 -0700347 /**
Mikhail Naganovb533fb42012-04-05 14:50:02 +0100348 * Sets whether the WebView should display on-screen zoom controls when
349 * using the built-in zoom mechanisms. See {@link #setBuiltInZoomControls}.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700350 * The default is {@code true}.
Steve Block4e584df2012-04-24 23:12:47 +0100351 *
352 * @param enabled whether the WebView should display on-screen zoom controls
Michael Kolb6fe3b422010-08-19 12:41:24 -0700353 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000354 public abstract void setDisplayZoomControls(boolean enabled);
Michael Kolb6fe3b422010-08-19 12:41:24 -0700355
356 /**
Steve Block4e584df2012-04-24 23:12:47 +0100357 * Gets whether the WebView displays on-screen zoom controls when using
Mikhail Naganovb533fb42012-04-05 14:50:02 +0100358 * the built-in zoom mechanisms.
Steve Block4e584df2012-04-24 23:12:47 +0100359 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700360 * @return {@code true} if the WebView displays on-screen zoom controls when using
Steve Block4e584df2012-04-24 23:12:47 +0100361 * the built-in zoom mechanisms
362 * @see #setDisplayZoomControls
Michael Kolb6fe3b422010-08-19 12:41:24 -0700363 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000364 public abstract boolean getDisplayZoomControls();
Michael Kolb6fe3b422010-08-19 12:41:24 -0700365
366 /**
Steve Block4e584df2012-04-24 23:12:47 +0100367 * Enables or disables file access within WebView. File access is enabled by
Patrick Scottd1737ed2011-01-05 11:36:48 -0500368 * default. Note that this enables or disables file system access only.
369 * Assets and resources are still accessible using file:///android_asset and
370 * file:///android_res.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800371 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000372 public abstract void setAllowFileAccess(boolean allow);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800373
374 /**
Steve Block4e584df2012-04-24 23:12:47 +0100375 * Gets whether this WebView supports file access.
376 *
377 * @see #setAllowFileAccess
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800378 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000379 public abstract boolean getAllowFileAccess();
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800380
381 /**
Steve Block4e584df2012-04-24 23:12:47 +0100382 * Enables or disables content URL access within WebView. Content URL
383 * access allows WebView to load content from a content provider installed
384 * in the system. The default is enabled.
Patrick Scottd1737ed2011-01-05 11:36:48 -0500385 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000386 public abstract void setAllowContentAccess(boolean allow);
Patrick Scottd1737ed2011-01-05 11:36:48 -0500387
388 /**
Steve Block4e584df2012-04-24 23:12:47 +0100389 * Gets whether this WebView supports content URL access.
390 *
391 * @see #setAllowContentAccess
Patrick Scottd1737ed2011-01-05 11:36:48 -0500392 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000393 public abstract boolean getAllowContentAccess();
Patrick Scottd1737ed2011-01-05 11:36:48 -0500394
395 /**
Mikhail Naganov00303362013-09-02 10:57:04 +0100396 * Sets whether the WebView loads pages in overview mode, that is,
397 * zooms out the content to fit on screen by width. This setting is
398 * taken into account when the content width is greater than the width
399 * of the WebView control, for example, when {@link #getUseWideViewPort}
Nate Fischer0a6140d2017-09-05 12:37:49 -0700400 * is enabled. The default is {@code false}.
Grace Klobae397a882009-08-06 12:04:14 -0700401 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000402 public abstract void setLoadWithOverviewMode(boolean overview);
Grace Klobae397a882009-08-06 12:04:14 -0700403
404 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100405 * Gets whether this WebView loads pages in overview mode.
406 *
407 * @return whether this WebView loads pages in overview mode
408 * @see #setLoadWithOverviewMode
Grace Klobae397a882009-08-06 12:04:14 -0700409 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000410 public abstract boolean getLoadWithOverviewMode();
Grace Klobae397a882009-08-06 12:04:14 -0700411
412 /**
Steve Block4e584df2012-04-24 23:12:47 +0100413 * Sets whether the WebView will enable smooth transition while panning or
Adam Powelle00e8a782011-09-11 17:48:42 -0700414 * zooming or while the window hosting the WebView does not have focus.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700415 * If it is {@code true}, WebView will choose a solution to maximize the performance.
Adam Powelle00e8a782011-09-11 17:48:42 -0700416 * e.g. the WebView's content may not be updated during the transition.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700417 * If it is false, WebView will keep its fidelity. The default value is {@code false}.
Kristian Monsen5cc23512012-08-09 15:33:08 -0400418 *
419 * @deprecated This method is now obsolete, and will become a no-op in future.
Grace Klobaf9b731d2010-06-21 19:23:57 -0700420 */
Kristian Monsen5cc23512012-08-09 15:33:08 -0400421 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000422 public abstract void setEnableSmoothTransition(boolean enable);
Steve Block4e584df2012-04-24 23:12:47 +0100423
Grace Klobaf9b731d2010-06-21 19:23:57 -0700424 /**
Steve Block4e584df2012-04-24 23:12:47 +0100425 * Gets whether the WebView enables smooth transition while panning or
Grace Klobaf9b731d2010-06-21 19:23:57 -0700426 * zooming.
Steve Block4e584df2012-04-24 23:12:47 +0100427 *
428 * @see #setEnableSmoothTransition
Kristian Monsen5cc23512012-08-09 15:33:08 -0400429 *
430 * @deprecated This method is now obsolete, and will become a no-op in future.
Grace Klobaf9b731d2010-06-21 19:23:57 -0700431 */
Kristian Monsen5cc23512012-08-09 15:33:08 -0400432 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000433 public abstract boolean enableSmoothTransition();
Grace Klobaf9b731d2010-06-21 19:23:57 -0700434
435 /**
Steve Block4e584df2012-04-24 23:12:47 +0100436 * Sets whether the WebView uses its background for over scroll background.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700437 * If {@code true}, it will use the WebView's background. If {@code false}, it will use an
438 * internal pattern. Default is {@code true}.
Steve Block4e584df2012-04-24 23:12:47 +0100439 *
Kristian Monsenfc771652011-05-10 16:44:05 +0100440 * @deprecated This method is now obsolete.
Kristian Monsend0b90d32012-09-24 12:30:45 -0400441 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
Adam Powell637d3372010-08-25 14:37:03 -0700442 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000443 @SystemApi
Kristian Monsenfc771652011-05-10 16:44:05 +0100444 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000445 public abstract void setUseWebViewBackgroundForOverscrollBackground(boolean view);
Adam Powell637d3372010-08-25 14:37:03 -0700446
447 /**
Steve Block4e584df2012-04-24 23:12:47 +0100448 * Gets whether this WebView uses WebView's background instead of
Adam Powell637d3372010-08-25 14:37:03 -0700449 * internal pattern for over scroll background.
Steve Block4e584df2012-04-24 23:12:47 +0100450 *
451 * @see #setUseWebViewBackgroundForOverscrollBackground
Kristian Monsenfc771652011-05-10 16:44:05 +0100452 * @deprecated This method is now obsolete.
Kristian Monsenf4912582012-08-16 15:26:24 -0400453 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
Adam Powell637d3372010-08-25 14:37:03 -0700454 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000455 @SystemApi
Kristian Monsenfc771652011-05-10 16:44:05 +0100456 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000457 public abstract boolean getUseWebViewBackgroundForOverscrollBackground();
Adam Powell637d3372010-08-25 14:37:03 -0700458
459 /**
Selim Gurun13e5b0b2017-04-03 14:29:14 -0700460 * Sets whether the WebView should save form data. In Android O, the
461 * platform has implemented a fully functional Autofill feature to store
462 * form data. Therefore, the Webview form data save feature is disabled.
463 *
464 * Note that the feature will continue to be supported on older versions of
465 * Android as before.
466 *
Tao Bai990f9a92019-07-02 20:32:47 +0000467 * @deprecated In Android O and afterwards, this function does not have
468 * any effect, the form data will be saved to platform's autofill service
469 * if applicable.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700470 */
Selim Gurun13e5b0b2017-04-03 14:29:14 -0700471 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000472 public abstract void setSaveFormData(boolean save);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700473
474 /**
Selim Gurun5c11ef12013-01-04 14:58:36 -0800475 * Gets whether the WebView saves form data.
Steve Blockb0e0f332012-06-13 22:01:11 +0100476 *
477 * @return whether the WebView saves form data
478 * @see #setSaveFormData
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700479 */
Selim Gurun13e5b0b2017-04-03 14:29:14 -0700480 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000481 public abstract boolean getSaveFormData();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700482
483 /**
Nate Fischer0a6140d2017-09-05 12:37:49 -0700484 * Sets whether the WebView should save passwords. The default is {@code true}.
Jonathan Dixon835b1fc2013-02-25 12:29:33 -0800485 * @deprecated Saving passwords in WebView will not be supported in future versions.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700486 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -0800487 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000488 public abstract void setSavePassword(boolean save);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700489
490 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100491 * Gets whether the WebView saves passwords.
492 *
493 * @return whether the WebView saves passwords
494 * @see #setSavePassword
Jonathan Dixon835b1fc2013-02-25 12:29:33 -0800495 * @deprecated Saving passwords in WebView will not be supported in future versions.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700496 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -0800497 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000498 public abstract boolean getSavePassword();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700499
500 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100501 * Sets the text zoom of the page in percent. The default is 100.
Steve Block4e584df2012-04-24 23:12:47 +0100502 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100503 * @param textZoom the text zoom in percent
John Reckff56bcd2011-06-16 17:12:08 -0700504 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000505 public abstract void setTextZoom(int textZoom);
John Reckff56bcd2011-06-16 17:12:08 -0700506
507 /**
Steve Block4e584df2012-04-24 23:12:47 +0100508 * Gets the text zoom of the page in percent.
509 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100510 * @return the text zoom of the page in percent
Mikhail Naganov1202d662012-08-07 18:26:52 +0100511 * @see #setTextZoom
John Reckff56bcd2011-06-16 17:12:08 -0700512 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000513 public abstract int getTextZoom();
John Reckff56bcd2011-06-16 17:12:08 -0700514
515 /**
Hector Dearmanfc9a27a2014-06-05 13:45:28 +0100516 * Sets policy for third party cookies.
517 * Developers should access this via {@link CookieManager#setShouldAcceptThirdPartyCookies}.
518 * @hide Internal API.
519 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000520 @SystemApi
521 public abstract void setAcceptThirdPartyCookies(boolean accept);
Hector Dearmanfc9a27a2014-06-05 13:45:28 +0100522
523 /**
524 * Gets policy for third party cookies.
525 * Developers should access this via {@link CookieManager#getShouldAcceptThirdPartyCookies}.
526 * @hide Internal API
527 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000528 @SystemApi
529 public abstract boolean getAcceptThirdPartyCookies();
Hector Dearmanfc9a27a2014-06-05 13:45:28 +0100530
531 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100532 * Sets the text size of the page. The default is {@link TextSize#NORMAL}.
Steve Block4e584df2012-04-24 23:12:47 +0100533 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100534 * @param t the text size as a {@link TextSize} value
535 * @deprecated Use {@link #setTextZoom} instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700536 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -0700537 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700538 public synchronized void setTextSize(TextSize t) {
Mikhail Naganov1202d662012-08-07 18:26:52 +0100539 setTextZoom(t.value);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700540 }
541
542 /**
Steve Block4e584df2012-04-24 23:12:47 +0100543 * Gets the text size of the page. If the text size was previously specified
Steve Blockb0e0f332012-06-13 22:01:11 +0100544 * in percent using {@link #setTextZoom}, this will return the closest
545 * matching {@link TextSize}.
Steve Block4e584df2012-04-24 23:12:47 +0100546 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100547 * @return the text size as a {@link TextSize} value
548 * @see #setTextSize
549 * @deprecated Use {@link #getTextZoom} instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700550 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -0700551 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700552 public synchronized TextSize getTextSize() {
Mikhail Naganov1202d662012-08-07 18:26:52 +0100553 TextSize closestSize = null;
554 int smallestDelta = Integer.MAX_VALUE;
555 int textSize = getTextZoom();
556 for (TextSize size : TextSize.values()) {
557 int delta = Math.abs(textSize - size.value);
558 if (delta == 0) {
559 return size;
560 }
561 if (delta < smallestDelta) {
562 smallestDelta = delta;
563 closestSize = size;
564 }
565 }
566 return closestSize != null ? closestSize : TextSize.NORMAL;
Mangesh Ghiwareedb528e2011-10-12 14:25:41 -0700567 }
568
569 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100570 * Sets the default zoom density of the page. This must be called from the UI
571 * thread. The default is {@link ZoomDensity#MEDIUM}.
Steve Block4e584df2012-04-24 23:12:47 +0100572 *
Mikhail Naganov8887b2b2013-05-28 10:34:43 +0100573 * This setting is not recommended for use in new applications. If the WebView
574 * is utilized to display mobile-oriented pages, the desired effect can be achieved by
575 * adjusting 'width' and 'initial-scale' attributes of page's 'meta viewport'
576 * tag. For pages lacking the tag, {@link android.webkit.WebView#setInitialScale}
577 * and {@link #setUseWideViewPort} can be used.
578 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100579 * @param zoom the zoom density
Jonathan Dixon5545d082013-08-31 22:43:11 -0700580 * @deprecated This method is no longer supported, see the function documentation for
581 * recommended alternatives.
Grace Kloba0d8b77c2009-06-25 11:20:51 -0700582 */
Jonathan Dixon5545d082013-08-31 22:43:11 -0700583 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000584 public abstract void setDefaultZoom(ZoomDensity zoom);
Grace Kloba0d8b77c2009-06-25 11:20:51 -0700585
586 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100587 * Gets the default zoom density of the page. This should be called from
588 * the UI thread.
589 *
Mikhail Naganov8887b2b2013-05-28 10:34:43 +0100590 * This setting is not recommended for use in new applications.
591 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100592 * @return the zoom density
593 * @see #setDefaultZoom
Jonathan Dixon5545d082013-08-31 22:43:11 -0700594 * @deprecated Will only return the default value.
Grace Kloba0d8b77c2009-06-25 11:20:51 -0700595 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -0700596 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000597 public abstract ZoomDensity getDefaultZoom();
Grace Kloba0d8b77c2009-06-25 11:20:51 -0700598
599 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700600 * Enables using light touches to make a selection and activate mouseovers.
Jonathan Dixon835b1fc2013-02-25 12:29:33 -0800601 * @deprecated From {@link android.os.Build.VERSION_CODES#JELLY_BEAN} this
602 * setting is obsolete and has no effect.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700603 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -0800604 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000605 public abstract void setLightTouchEnabled(boolean enabled);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700606
607 /**
Steve Block4e584df2012-04-24 23:12:47 +0100608 * Gets whether light touches are enabled.
Steve Blockb0e0f332012-06-13 22:01:11 +0100609 * @see #setLightTouchEnabled
Jonathan Dixon98fac172013-02-28 15:32:10 -0800610 * @deprecated This setting is obsolete.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700611 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -0800612 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000613 public abstract boolean getLightTouchEnabled();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700614
615 /**
Steve Block4e584df2012-04-24 23:12:47 +0100616 * Controlled a rendering optimization that is no longer present. Setting
617 * it now has no effect.
618 *
619 * @deprecated This setting now has no effect.
Kristian Monsenf4912582012-08-16 15:26:24 -0400620 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700621 */
Mike Hearnadcd2ed2009-01-21 16:44:36 +0100622 @Deprecated
Mathew Inwood62d83fb2018-08-16 19:09:48 +0100623 @UnsupportedAppUsage
Ignacio Solla451e3382014-11-10 10:35:54 +0000624 public void setUseDoubleTree(boolean use) {
Jonathan Dixon3c909522012-02-28 18:45:06 +0000625 // Specified to do nothing, so no need for derived classes to override.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700626 }
627
628 /**
Steve Block4e584df2012-04-24 23:12:47 +0100629 * Controlled a rendering optimization that is no longer present. Setting
630 * it now has no effect.
631 *
632 * @deprecated This setting now has no effect.
Kristian Monsenf4912582012-08-16 15:26:24 -0400633 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700634 */
Mike Hearnadcd2ed2009-01-21 16:44:36 +0100635 @Deprecated
Mathew Inwood62d83fb2018-08-16 19:09:48 +0100636 @UnsupportedAppUsage
Ignacio Solla451e3382014-11-10 10:35:54 +0000637 public boolean getUseDoubleTree() {
Jonathan Dixon3c909522012-02-28 18:45:06 +0000638 // Returns false unconditionally, so no need for derived classes to override.
Mike Hearnadcd2ed2009-01-21 16:44:36 +0100639 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700640 }
641
642 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100643 * Sets the user-agent string using an integer code.
644 * <ul>
645 * <li>0 means the WebView should use an Android user-agent string</li>
646 * <li>1 means the WebView should use a desktop user-agent string</li>
647 * </ul>
648 * Other values are ignored. The default is an Android user-agent string,
649 * i.e. code value 0.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800650 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100651 * @param ua the integer code for the user-agent string
652 * @deprecated Please use {@link #setUserAgentString} instead.
Kristian Monsenf4912582012-08-16 15:26:24 -0400653 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700654 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000655 @SystemApi
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800656 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000657 public abstract void setUserAgent(int ua);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700658
659 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100660 * Gets the user-agent as an integer code.
661 * <ul>
662 * <li>-1 means the WebView is using a custom user-agent string set with
663 * {@link #setUserAgentString}</li>
664 * <li>0 means the WebView should use an Android user-agent string</li>
665 * <li>1 means the WebView should use a desktop user-agent string</li>
666 * </ul>
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800667 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100668 * @return the integer code for the user-agent string
669 * @see #setUserAgent
670 * @deprecated Please use {@link #getUserAgentString} instead.
Kristian Monsenf4912582012-08-16 15:26:24 -0400671 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700672 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000673 @SystemApi
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800674 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +0000675 public abstract int getUserAgent();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700676
677 /**
Mikhail Naganovcb000a62013-01-04 18:02:54 +0000678 * Sets whether the WebView should enable support for the &quot;viewport&quot;
679 * HTML meta tag or should use a wide viewport.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700680 * When the value of the setting is {@code false}, the layout width is always set to the
Mikhail Naganovcb000a62013-01-04 18:02:54 +0000681 * width of the WebView control in device-independent (CSS) pixels.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700682 * When the value is {@code true} and the page contains the viewport meta tag, the value
Mikhail Naganovcb000a62013-01-04 18:02:54 +0000683 * of the width specified in the tag is used. If the page does not contain the tag or
684 * does not provide a width, then a wide viewport will be used.
Steve Blockb0e0f332012-06-13 22:01:11 +0100685 *
Mikhail Naganovcb000a62013-01-04 18:02:54 +0000686 * @param use whether to enable support for the viewport meta tag
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700687 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000688 public abstract void setUseWideViewPort(boolean use);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700689
690 /**
Mikhail Naganovcb000a62013-01-04 18:02:54 +0000691 * Gets whether the WebView supports the &quot;viewport&quot;
692 * HTML meta tag or will use a wide viewport.
Steve Block4e584df2012-04-24 23:12:47 +0100693 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700694 * @return {@code true} if the WebView supports the viewport meta tag
Steve Blockb0e0f332012-06-13 22:01:11 +0100695 * @see #setUseWideViewPort
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700696 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000697 public abstract boolean getUseWideViewPort();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700698
699 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100700 * Sets whether the WebView whether supports multiple windows. If set to
701 * true, {@link WebChromeClient#onCreateWindow} must be implemented by the
Nate Fischer0a6140d2017-09-05 12:37:49 -0700702 * host application. The default is {@code false}.
Steve Blockb0e0f332012-06-13 22:01:11 +0100703 *
Nate Fischer4ea92402017-11-17 18:48:13 -0800704 * @param support whether to support multiple windows
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700705 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000706 public abstract void setSupportMultipleWindows(boolean support);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700707
708 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100709 * Gets whether the WebView supports multiple windows.
Steve Block4e584df2012-04-24 23:12:47 +0100710 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700711 * @return {@code true} if the WebView supports multiple windows
Steve Blockb0e0f332012-06-13 22:01:11 +0100712 * @see #setSupportMultipleWindows
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700713 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000714 public abstract boolean supportMultipleWindows();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700715
716 /**
Nate Fischer4ea92402017-11-17 18:48:13 -0800717 * Sets the underlying layout algorithm. This will cause a re-layout of the
Steve Blockb0e0f332012-06-13 22:01:11 +0100718 * WebView. The default is {@link LayoutAlgorithm#NARROW_COLUMNS}.
Steve Block4e584df2012-04-24 23:12:47 +0100719 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100720 * @param l the layout algorithm to use, as a {@link LayoutAlgorithm} value
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700721 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000722 public abstract void setLayoutAlgorithm(LayoutAlgorithm l);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700723
724 /**
Steve Block4e584df2012-04-24 23:12:47 +0100725 * Gets the current layout algorithm.
726 *
Steve Blockb0e0f332012-06-13 22:01:11 +0100727 * @return the layout algorithm in use, as a {@link LayoutAlgorithm} value
Steve Block4e584df2012-04-24 23:12:47 +0100728 * @see #setLayoutAlgorithm
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700729 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000730 public abstract LayoutAlgorithm getLayoutAlgorithm();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700731
732 /**
Steve Block4e584df2012-04-24 23:12:47 +0100733 * Sets the standard font family name. The default is "sans-serif".
734 *
735 * @param font a font family name
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700736 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000737 public abstract void setStandardFontFamily(String font);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700738
739 /**
Steve Block4e584df2012-04-24 23:12:47 +0100740 * Gets the standard font family name.
741 *
742 * @return the standard font family name as a string
743 * @see #setStandardFontFamily
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700744 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000745 public abstract String getStandardFontFamily();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700746
747 /**
Steve Block4e584df2012-04-24 23:12:47 +0100748 * Sets the fixed font family name. The default is "monospace".
749 *
750 * @param font a font family name
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700751 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000752 public abstract void setFixedFontFamily(String font);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700753
754 /**
Steve Block4e584df2012-04-24 23:12:47 +0100755 * Gets the fixed font family name.
756 *
757 * @return the fixed font family name as a string
758 * @see #setFixedFontFamily
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700759 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000760 public abstract String getFixedFontFamily();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700761
762 /**
Steve Blockb0e0f332012-06-13 22:01:11 +0100763 * Sets the sans-serif font family name. The default is "sans-serif".
Steve Block4e584df2012-04-24 23:12:47 +0100764 *
765 * @param font a font family name
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700766 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000767 public abstract void setSansSerifFontFamily(String font);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700768
769 /**
Steve Block4e584df2012-04-24 23:12:47 +0100770 * Gets the sans-serif font family name.
771 *
772 * @return the sans-serif font family name as a string
Steve Blockb0e0f332012-06-13 22:01:11 +0100773 * @see #setSansSerifFontFamily
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700774 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000775 public abstract String getSansSerifFontFamily();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700776
777 /**
Steve Block4e584df2012-04-24 23:12:47 +0100778 * Sets the serif font family name. The default is "sans-serif".
779 *
780 * @param font a font family name
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700781 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000782 public abstract void setSerifFontFamily(String font);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700783
784 /**
Steve Block4e584df2012-04-24 23:12:47 +0100785 * Gets the serif font family name. The default is "serif".
786 *
787 * @return the serif font family name as a string
788 * @see #setSerifFontFamily
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700789 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000790 public abstract String getSerifFontFamily();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700791
792 /**
Steve Block4e584df2012-04-24 23:12:47 +0100793 * Sets the cursive font family name. The default is "cursive".
794 *
795 * @param font a font family name
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700796 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000797 public abstract void setCursiveFontFamily(String font);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700798
799 /**
Steve Block4e584df2012-04-24 23:12:47 +0100800 * Gets the cursive font family name.
801 *
802 * @return the cursive font family name as a string
803 * @see #setCursiveFontFamily
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700804 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000805 public abstract String getCursiveFontFamily();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700806
807 /**
Steve Block4e584df2012-04-24 23:12:47 +0100808 * Sets the fantasy font family name. The default is "fantasy".
809 *
810 * @param font a font family name
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700811 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000812 public abstract void setFantasyFontFamily(String font);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700813
814 /**
Steve Block4e584df2012-04-24 23:12:47 +0100815 * Gets the fantasy font family name.
816 *
817 * @return the fantasy font family name as a string
818 * @see #setFantasyFontFamily
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700819 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000820 public abstract String getFantasyFontFamily();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700821
822 /**
Steve Block4e584df2012-04-24 23:12:47 +0100823 * Sets the minimum font size. The default is 8.
824 *
825 * @param size a non-negative integer between 1 and 72. Any number outside
826 * the specified range will be pinned.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700827 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000828 public abstract void setMinimumFontSize(int size);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700829
830 /**
Steve Block4e584df2012-04-24 23:12:47 +0100831 * Gets the minimum font size.
832 *
833 * @return a non-negative integer between 1 and 72
834 * @see #setMinimumFontSize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700835 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000836 public abstract int getMinimumFontSize();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700837
838 /**
Steve Block4e584df2012-04-24 23:12:47 +0100839 * Sets the minimum logical font size. The default is 8.
840 *
841 * @param size a non-negative integer between 1 and 72. Any number outside
842 * the specified range will be pinned.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700843 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000844 public abstract void setMinimumLogicalFontSize(int size);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700845
846 /**
Steve Block4e584df2012-04-24 23:12:47 +0100847 * Gets the minimum logical font size.
848 *
849 * @return a non-negative integer between 1 and 72
850 * @see #setMinimumLogicalFontSize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700851 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000852 public abstract int getMinimumLogicalFontSize();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700853
854 /**
Steve Block4e584df2012-04-24 23:12:47 +0100855 * Sets the default font size. The default is 16.
856 *
857 * @param size a non-negative integer between 1 and 72. Any number outside
858 * the specified range will be pinned.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700859 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000860 public abstract void setDefaultFontSize(int size);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700861
862 /**
Steve Block4e584df2012-04-24 23:12:47 +0100863 * Gets the default font size.
864 *
865 * @return a non-negative integer between 1 and 72
866 * @see #setDefaultFontSize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700867 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000868 public abstract int getDefaultFontSize();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700869
870 /**
Steve Block4e584df2012-04-24 23:12:47 +0100871 * Sets the default fixed font size. The default is 16.
872 *
873 * @param size a non-negative integer between 1 and 72. Any number outside
874 * the specified range will be pinned.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700875 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000876 public abstract void setDefaultFixedFontSize(int size);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700877
878 /**
Steve Block4e584df2012-04-24 23:12:47 +0100879 * Gets the default fixed font size.
880 *
881 * @return a non-negative integer between 1 and 72
882 * @see #setDefaultFixedFontSize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700883 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000884 public abstract int getDefaultFixedFontSize();
Grace Kloba097b1e772009-11-24 14:23:18 -0800885
886 /**
Mikhail Naganov605a4912012-02-03 16:53:10 +0000887 * Sets whether the WebView should load image resources. Note that this method
888 * controls loading of all images, including those embedded using the data
889 * URI scheme. Use {@link #setBlockNetworkImage} to control loading only
890 * of images specified using network URI schemes. Note that if the value of this
Nate Fischer0a6140d2017-09-05 12:37:49 -0700891 * setting is changed from {@code false} to {@code true}, all images resources referenced
Mikhail Naganov605a4912012-02-03 16:53:10 +0000892 * by content currently displayed by the WebView are loaded automatically.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700893 * The default is {@code true}.
Steve Block4e584df2012-04-24 23:12:47 +0100894 *
895 * @param flag whether the WebView should load image resources
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700896 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000897 public abstract void setLoadsImagesAutomatically(boolean flag);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700898
899 /**
Steve Block4e584df2012-04-24 23:12:47 +0100900 * Gets whether the WebView loads image resources. This includes
901 * images embedded using the data URI scheme.
902 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700903 * @return {@code true} if the WebView loads image resources
Steve Block4e584df2012-04-24 23:12:47 +0100904 * @see #setLoadsImagesAutomatically
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700905 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000906 public abstract boolean getLoadsImagesAutomatically();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700907
908 /**
Mikhail Naganov605a4912012-02-03 16:53:10 +0000909 * Sets whether the WebView should not load image resources from the
910 * network (resources accessed via http and https URI schemes). Note
911 * that this method has no effect unless
Nate Fischer0a6140d2017-09-05 12:37:49 -0700912 * {@link #getLoadsImagesAutomatically} returns {@code true}. Also note that
Mikhail Naganov605a4912012-02-03 16:53:10 +0000913 * disabling all network loads using {@link #setBlockNetworkLoads}
914 * will also prevent network images from loading, even if this flag is set
Nate Fischer0a6140d2017-09-05 12:37:49 -0700915 * to false. When the value of this setting is changed from {@code true} to {@code false},
Mikhail Naganov605a4912012-02-03 16:53:10 +0000916 * network images resources referenced by content currently displayed by
Nate Fischer0a6140d2017-09-05 12:37:49 -0700917 * the WebView are fetched automatically. The default is {@code false}.
Steve Block4e584df2012-04-24 23:12:47 +0100918 *
919 * @param flag whether the WebView should not load image resources from the
920 * network
Patrick Scottf43113f2010-02-18 09:13:12 -0500921 * @see #setBlockNetworkLoads
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700922 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000923 public abstract void setBlockNetworkImage(boolean flag);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700924
925 /**
Steve Block4e584df2012-04-24 23:12:47 +0100926 * Gets whether the WebView does not load image resources from the network.
927 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700928 * @return {@code true} if the WebView does not load image resources from the network
Steve Block4e584df2012-04-24 23:12:47 +0100929 * @see #setBlockNetworkImage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700930 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000931 public abstract boolean getBlockNetworkImage();
Mike Hearnadcd2ed2009-01-21 16:44:36 +0100932
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800933 /**
Mikhail Naganov605a4912012-02-03 16:53:10 +0000934 * Sets whether the WebView should not load resources from the network.
935 * Use {@link #setBlockNetworkImage} to only avoid loading
936 * image resources. Note that if the value of this setting is
Nate Fischer0a6140d2017-09-05 12:37:49 -0700937 * changed from {@code true} to {@code false}, network resources referenced by content
Mikhail Naganov605a4912012-02-03 16:53:10 +0000938 * currently displayed by the WebView are not fetched until
939 * {@link android.webkit.WebView#reload} is called.
940 * If the application does not have the
941 * {@link android.Manifest.permission#INTERNET} permission, attempts to set
Nate Fischer0a6140d2017-09-05 12:37:49 -0700942 * a value of {@code false} will cause a {@link java.lang.SecurityException}
943 * to be thrown. The default value is {@code false} if the application has the
Steve Block4e584df2012-04-24 23:12:47 +0100944 * {@link android.Manifest.permission#INTERNET} permission, otherwise it is
Nate Fischer0a6140d2017-09-05 12:37:49 -0700945 * {@code true}.
Steve Block4e584df2012-04-24 23:12:47 +0100946 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700947 * @param flag {@code true} means block network loads by the WebView
Patrick Scottf43113f2010-02-18 09:13:12 -0500948 * @see android.webkit.WebView#reload
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800949 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000950 public abstract void setBlockNetworkLoads(boolean flag);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800951
952 /**
Steve Block4e584df2012-04-24 23:12:47 +0100953 * Gets whether the WebView does not load any resources from the network.
954 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700955 * @return {@code true} if the WebView does not load any resources from the network
Steve Block4e584df2012-04-24 23:12:47 +0100956 * @see #setBlockNetworkLoads
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800957 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000958 public abstract boolean getBlockNetworkLoads();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700959
960 /**
Steve Block4e584df2012-04-24 23:12:47 +0100961 * Tells the WebView to enable JavaScript execution.
Nate Fischer0a6140d2017-09-05 12:37:49 -0700962 * <b>The default is {@code false}.</b>
Steve Block4e584df2012-04-24 23:12:47 +0100963 *
Nate Fischer0a6140d2017-09-05 12:37:49 -0700964 * @param flag {@code true} if the WebView should execute JavaScript
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700965 */
Ignacio Solla451e3382014-11-10 10:35:54 +0000966 public abstract void setJavaScriptEnabled(boolean flag);
Teng-Hui Zhuda7378e2011-02-16 11:25:03 -0800967
968 /**
Steve Blockef163152012-04-23 18:08:06 +0100969 * Sets whether JavaScript running in the context of a file scheme URL
970 * should be allowed to access content from any origin. This includes
971 * access to content from other file scheme URLs. See
972 * {@link #setAllowFileAccessFromFileURLs}. To enable the most restrictive,
973 * and therefore secure policy, this setting should be disabled.
Mikhail Naganov65e7ace2012-08-07 13:57:42 +0100974 * Note that this setting affects only JavaScript access to file scheme
975 * resources. Other access to such resources, for example, from image HTML
Joe Fernandez22b5ba82015-04-22 17:29:12 -0700976 * elements, is unaffected. To prevent possible violation of same domain policy
Nate Fischer8cc15362018-01-23 16:51:30 -0800977 * when targeting {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and earlier,
978 * you should explicitly set this value to {@code false}.
Steve Blockef163152012-04-23 18:08:06 +0100979 * <p>
Nate Fischer8cc15362018-01-23 16:51:30 -0800980 * The default value is {@code true} for apps targeting
Steve Blockef163152012-04-23 18:08:06 +0100981 * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and below,
Nate Fischer8cc15362018-01-23 16:51:30 -0800982 * and {@code false} when targeting {@link android.os.Build.VERSION_CODES#JELLY_BEAN}
Steve Blockef163152012-04-23 18:08:06 +0100983 * and above.
Selim Gurun0ea6dad2012-03-29 18:19:01 -0700984 *
Steve Blockef163152012-04-23 18:08:06 +0100985 * @param flag whether JavaScript running in the context of a file scheme
986 * URL should be allowed to access content from any origin
Selim Gurun0ea6dad2012-03-29 18:19:01 -0700987 */
988 public abstract void setAllowUniversalAccessFromFileURLs(boolean flag);
989
990 /**
Steve Blockef163152012-04-23 18:08:06 +0100991 * Sets whether JavaScript running in the context of a file scheme URL
992 * should be allowed to access content from other file scheme URLs. To
Nate Fischer8cc15362018-01-23 16:51:30 -0800993 * enable the most restrictive, and therefore secure, policy this setting
Steve Blockef163152012-04-23 18:08:06 +0100994 * should be disabled. Note that the value of this setting is ignored if
Nate Fischer0a6140d2017-09-05 12:37:49 -0700995 * the value of {@link #getAllowUniversalAccessFromFileURLs} is {@code true}.
Mikhail Naganov65e7ace2012-08-07 13:57:42 +0100996 * Note too, that this setting affects only JavaScript access to file scheme
997 * resources. Other access to such resources, for example, from image HTML
Joe Fernandez22b5ba82015-04-22 17:29:12 -0700998 * elements, is unaffected. To prevent possible violation of same domain policy
Nate Fischer8cc15362018-01-23 16:51:30 -0800999 * when targeting {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and earlier,
1000 * you should explicitly set this value to {@code false}.
Steve Blockef163152012-04-23 18:08:06 +01001001 * <p>
Nate Fischer8cc15362018-01-23 16:51:30 -08001002 * The default value is {@code true} for apps targeting
Steve Blockef163152012-04-23 18:08:06 +01001003 * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and below,
Nate Fischer8cc15362018-01-23 16:51:30 -08001004 * and {@code false} when targeting {@link android.os.Build.VERSION_CODES#JELLY_BEAN}
Steve Blockef163152012-04-23 18:08:06 +01001005 * and above.
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001006 *
Steve Blockef163152012-04-23 18:08:06 +01001007 * @param flag whether JavaScript running in the context of a file scheme
1008 * URL should be allowed to access content from other file
1009 * scheme URLs
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001010 */
1011 public abstract void setAllowFileAccessFromFileURLs(boolean flag);
1012
1013 /**
Nate Fischer0a6140d2017-09-05 12:37:49 -07001014 * Sets whether the WebView should enable plugins. The default is {@code false}.
Steve Block4e584df2012-04-24 23:12:47 +01001015 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001016 * @param flag {@code true} if plugins should be enabled
Patrick Scott300f2e92010-03-22 10:20:45 -04001017 * @deprecated This method has been deprecated in favor of
1018 * {@link #setPluginState}
Jonathan Dixon0bf47812013-03-07 17:20:08 -08001019 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001020 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001021 @SystemApi
Michael Kolba172e7d2010-06-30 12:35:26 -07001022 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001023 public abstract void setPluginsEnabled(boolean flag);
Patrick Scott300f2e92010-03-22 10:20:45 -04001024
1025 /**
Steve Block4e584df2012-04-24 23:12:47 +01001026 * Tells the WebView to enable, disable, or have plugins on demand. On
Patrick Scott300f2e92010-03-22 10:20:45 -04001027 * demand mode means that if a plugin exists that can handle the embedded
1028 * content, a placeholder icon will be shown instead of the plugin. When
Steve Blockb0e0f332012-06-13 22:01:11 +01001029 * the placeholder is clicked, the plugin will be enabled. The default is
1030 * {@link PluginState#OFF}.
Steve Block4e584df2012-04-24 23:12:47 +01001031 *
1032 * @param state a PluginState value
Torne (Richard Coles)1676c952018-06-28 19:33:27 -04001033 * @deprecated Plugins are not supported in API level
1034 * {@link android.os.Build.VERSION_CODES#KITKAT} or later;
1035 * enabling plugins is a no-op.
Patrick Scott300f2e92010-03-22 10:20:45 -04001036 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -08001037 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001038 public abstract void setPluginState(PluginState state);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001039
1040 /**
Steve Block4e584df2012-04-24 23:12:47 +01001041 * Sets a custom path to plugins used by the WebView. This method is
Derek Sollenbergerfdbdeb32010-08-12 11:20:13 -04001042 * obsolete since each plugin is now loaded from its own package.
Steve Block4e584df2012-04-24 23:12:47 +01001043 *
1044 * @param pluginsPath a String path to the directory containing plugins
Derek Sollenbergerfdbdeb32010-08-12 11:20:13 -04001045 * @deprecated This method is no longer used as plugins are loaded from
Steve Block4e584df2012-04-24 23:12:47 +01001046 * their own APK via the system's package manager.
Jonathan Dixon0bf47812013-03-07 17:20:08 -08001047 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001048 */
Jason Chen9dc2e752010-09-01 19:11:14 -07001049 @Deprecated
Mathew Inwood62d83fb2018-08-16 19:09:48 +01001050 @UnsupportedAppUsage
Ignacio Solla451e3382014-11-10 10:35:54 +00001051 public void setPluginsPath(String pluginsPath) {
Jonathan Dixon3c909522012-02-28 18:45:06 +00001052 // Specified to do nothing, so no need for derived classes to override.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001053 }
1054
1055 /**
Steve Block4e584df2012-04-24 23:12:47 +01001056 * Sets the path to where database storage API databases should be saved.
Steve Block72ca7a42012-06-13 22:00:30 +01001057 * In order for the database storage API to function correctly, this method
1058 * must be called with a path to which the application can write. This
1059 * method should only be called once: repeated calls are ignored.
Steve Block4e584df2012-04-24 23:12:47 +01001060 *
Steve Block72ca7a42012-06-13 22:00:30 +01001061 * @param databasePath a path to the directory where databases should be
1062 * saved.
Jonathan Dixon5545d082013-08-31 22:43:11 -07001063 * @deprecated Database paths are managed by the implementation and calling this method
1064 * will have no effect.
Ben Murdoch7df19852009-04-22 13:07:58 +01001065 */
Jonathan Dixon5545d082013-08-31 22:43:11 -07001066 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001067 public abstract void setDatabasePath(String databasePath);
Ben Murdoch7df19852009-04-22 13:07:58 +01001068
1069 /**
Steve Block72ca7a42012-06-13 22:00:30 +01001070 * Sets the path where the Geolocation databases should be saved. In order
1071 * for Geolocation permissions and cached positions to be persisted, this
1072 * method must be called with a path to which the application can write.
Steve Block4e584df2012-04-24 23:12:47 +01001073 *
Steve Block72ca7a42012-06-13 22:00:30 +01001074 * @param databasePath a path to the directory where databases should be
1075 * saved.
Hui Shu89eb9b42016-01-07 11:32:23 -08001076 * @deprecated Geolocation database are managed by the implementation and calling this method
1077 * will have no effect.
Steve Block9d3273f2009-08-21 13:16:27 +01001078 */
Hui Shu89eb9b42016-01-07 11:32:23 -08001079 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001080 public abstract void setGeolocationDatabasePath(String databasePath);
Steve Block9d3273f2009-08-21 13:16:27 +01001081
1082 /**
Steve Block72ca7a42012-06-13 22:00:30 +01001083 * Sets whether the Application Caches API should be enabled. The default
Nate Fischer0a6140d2017-09-05 12:37:49 -07001084 * is {@code false}. Note that in order for the Application Caches API to be
Steve Block72ca7a42012-06-13 22:00:30 +01001085 * enabled, a valid database path must also be supplied to
1086 * {@link #setAppCachePath}.
Steve Block4e584df2012-04-24 23:12:47 +01001087 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001088 * @param flag {@code true} if the WebView should enable Application Caches
Andrei Popescu60a9a7d2009-04-17 10:43:42 +01001089 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001090 public abstract void setAppCacheEnabled(boolean flag);
Andrei Popescu60a9a7d2009-04-17 10:43:42 +01001091
1092 /**
Steve Block72ca7a42012-06-13 22:00:30 +01001093 * Sets the path to the Application Caches files. In order for the
1094 * Application Caches API to be enabled, this method must be called with a
1095 * path to which the application can write. This method should only be
1096 * called once: repeated calls are ignored.
Steve Block4e584df2012-04-24 23:12:47 +01001097 *
1098 * @param appCachePath a String path to the directory containing
Steve Block72ca7a42012-06-13 22:00:30 +01001099 * Application Caches files.
Jonathan Dixon47aaba32012-11-30 16:32:17 -08001100 * @see #setAppCacheEnabled
Andrei Popescu60a9a7d2009-04-17 10:43:42 +01001101 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001102 public abstract void setAppCachePath(String appCachePath);
Andrei Popescu60a9a7d2009-04-17 10:43:42 +01001103
1104 /**
Selim Gurunb632adf2012-06-28 11:21:05 -07001105 * Sets the maximum size for the Application Cache content. The passed size
1106 * will be rounded to the nearest value that the database can support, so
1107 * this should be viewed as a guide, not a hard limit. Setting the
1108 * size to a value less than current database size does not cause the
Selim Gurunf27ac092012-06-28 11:21:05 -07001109 * database to be trimmed. The default size is {@link Long#MAX_VALUE}.
Jonathan Dixon835b1fc2013-02-25 12:29:33 -08001110 * It is recommended to leave the maximum size set to the default value.
Steve Block4e584df2012-04-24 23:12:47 +01001111 *
1112 * @param appCacheMaxSize the maximum size in bytes
Jonathan Dixon835b1fc2013-02-25 12:29:33 -08001113 * @deprecated In future quota will be managed automatically.
Andrei Popescu1c829202009-07-22 16:47:52 +01001114 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -08001115 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001116 public abstract void setAppCacheMaxSize(long appCacheMaxSize);
Andrei Popescu1c829202009-07-22 16:47:52 +01001117
1118 /**
Steve Blockb0e0f332012-06-13 22:01:11 +01001119 * Sets whether the database storage API is enabled. The default value is
1120 * false. See also {@link #setDatabasePath} for how to correctly set up the
1121 * database storage API.
Steve Block4e584df2012-04-24 23:12:47 +01001122 *
Selim Gurun2bca22b2013-02-28 17:47:21 -08001123 * This setting is global in effect, across all WebView instances in a process.
1124 * Note you should only modify this setting prior to making <b>any</b> WebView
1125 * page load within a given process, as the WebView implementation may ignore
1126 * changes to this setting after that point.
1127 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001128 * @param flag {@code true} if the WebView should use the database storage API
Ben Murdoch7df19852009-04-22 13:07:58 +01001129 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001130 public abstract void setDatabaseEnabled(boolean flag);
Ben Murdoch7df19852009-04-22 13:07:58 +01001131
1132 /**
Nate Fischer0a6140d2017-09-05 12:37:49 -07001133 * Sets whether the DOM storage API is enabled. The default value is {@code false}.
Steve Block4e584df2012-04-24 23:12:47 +01001134 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001135 * @param flag {@code true} if the WebView should use the DOM storage API
Ben Murdoch274680d2009-05-28 13:44:44 +01001136 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001137 public abstract void setDomStorageEnabled(boolean flag);
Ben Murdoch274680d2009-05-28 13:44:44 +01001138
1139 /**
Steve Block4e584df2012-04-24 23:12:47 +01001140 * Gets whether the DOM Storage APIs are enabled.
1141 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001142 * @return {@code true} if the DOM Storage APIs are enabled
Steve Blockb0e0f332012-06-13 22:01:11 +01001143 * @see #setDomStorageEnabled
Ben Murdoch274680d2009-05-28 13:44:44 +01001144 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001145 public abstract boolean getDomStorageEnabled();
1146
Ben Murdoch274680d2009-05-28 13:44:44 +01001147 /**
Steve Blockb0e0f332012-06-13 22:01:11 +01001148 * Gets the path to where database storage API databases are saved.
Steve Block4e584df2012-04-24 23:12:47 +01001149 *
1150 * @return the String path to the database storage API databases
Steve Blockb0e0f332012-06-13 22:01:11 +01001151 * @see #setDatabasePath
Jonathan Dixon5545d082013-08-31 22:43:11 -07001152 * @deprecated Database paths are managed by the implementation this method is obsolete.
Ben Murdoch7df19852009-04-22 13:07:58 +01001153 */
Jonathan Dixon5545d082013-08-31 22:43:11 -07001154 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001155 public abstract String getDatabasePath();
Ben Murdoch7df19852009-04-22 13:07:58 +01001156
1157 /**
Steve Block4e584df2012-04-24 23:12:47 +01001158 * Gets whether the database storage API is enabled.
1159 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001160 * @return {@code true} if the database storage API is enabled
Steve Blockb0e0f332012-06-13 22:01:11 +01001161 * @see #setDatabaseEnabled
Ben Murdoch7df19852009-04-22 13:07:58 +01001162 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001163 public abstract boolean getDatabaseEnabled();
Andrei Popescuc27a9ac2009-08-03 15:59:24 +01001164
1165 /**
Nate Fischer0a6140d2017-09-05 12:37:49 -07001166 * Sets whether Geolocation is enabled. The default is {@code true}.
Mikhail Naganov6cb296a2012-08-28 16:57:24 +01001167 * <p>
1168 * Please note that in order for the Geolocation API to be usable
1169 * by a page in the WebView, the following requirements must be met:
1170 * <ul>
1171 * <li>an application must have permission to access the device location,
1172 * see {@link android.Manifest.permission#ACCESS_COARSE_LOCATION},
1173 * {@link android.Manifest.permission#ACCESS_FINE_LOCATION};
1174 * <li>an application must provide an implementation of the
1175 * {@link WebChromeClient#onGeolocationPermissionsShowPrompt} callback
1176 * to receive notifications that a page is requesting access to location
1177 * via the JavaScript Geolocation API.
1178 * </ul>
1179 * <p>
Steve Block4e584df2012-04-24 23:12:47 +01001180 *
1181 * @param flag whether Geolocation should be enabled
Steve Block06cd7512009-08-21 10:26:37 +01001182 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001183 public abstract void setGeolocationEnabled(boolean flag);
Elliott Slaughter5dc0c822010-06-22 11:31:54 -07001184
1185 /**
Steve Block4e584df2012-04-24 23:12:47 +01001186 * Gets whether JavaScript is enabled.
1187 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001188 * @return {@code true} if JavaScript is enabled
Steve Block4e584df2012-04-24 23:12:47 +01001189 * @see #setJavaScriptEnabled
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001190 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001191 public abstract boolean getJavaScriptEnabled();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001192
1193 /**
Steve Blockef163152012-04-23 18:08:06 +01001194 * Gets whether JavaScript running in the context of a file scheme URL can
1195 * access content from any origin. This includes access to content from
1196 * other file scheme URLs.
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001197 *
Steve Blockef163152012-04-23 18:08:06 +01001198 * @return whether JavaScript running in the context of a file scheme URL
1199 * can access content from any origin
Steve Block4e584df2012-04-24 23:12:47 +01001200 * @see #setAllowUniversalAccessFromFileURLs
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001201 */
1202 public abstract boolean getAllowUniversalAccessFromFileURLs();
1203
1204 /**
Steve Blockef163152012-04-23 18:08:06 +01001205 * Gets whether JavaScript running in the context of a file scheme URL can
1206 * access content from other file scheme URLs.
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001207 *
Steve Blockef163152012-04-23 18:08:06 +01001208 * @return whether JavaScript running in the context of a file scheme URL
1209 * can access content from other file scheme URLs
Steve Block4e584df2012-04-24 23:12:47 +01001210 * @see #setAllowFileAccessFromFileURLs
Selim Gurun0ea6dad2012-03-29 18:19:01 -07001211 */
1212 public abstract boolean getAllowFileAccessFromFileURLs();
1213
1214 /**
Steve Block4e584df2012-04-24 23:12:47 +01001215 * Gets whether plugins are enabled.
1216 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001217 * @return {@code true} if plugins are enabled
Steve Blockb0e0f332012-06-13 22:01:11 +01001218 * @see #setPluginsEnabled
Patrick Scott300f2e92010-03-22 10:20:45 -04001219 * @deprecated This method has been replaced by {@link #getPluginState}
Jonathan Dixon0bf47812013-03-07 17:20:08 -08001220 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001221 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001222 @SystemApi
Michael Kolba172e7d2010-06-30 12:35:26 -07001223 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001224 public abstract boolean getPluginsEnabled();
Patrick Scott300f2e92010-03-22 10:20:45 -04001225
1226 /**
Steve Blockb0e0f332012-06-13 22:01:11 +01001227 * Gets the current state regarding whether plugins are enabled.
Steve Block4e584df2012-04-24 23:12:47 +01001228 *
Steve Blockb0e0f332012-06-13 22:01:11 +01001229 * @return the plugin state as a {@link PluginState} value
1230 * @see #setPluginState
Torne (Richard Coles)1676c952018-06-28 19:33:27 -04001231 * @deprecated Plugins are not supported in API level
1232 * {@link android.os.Build.VERSION_CODES#KITKAT} or later;
1233 * enabling plugins is a no-op.
Patrick Scott300f2e92010-03-22 10:20:45 -04001234 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -08001235 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001236 public abstract PluginState getPluginState();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001237
1238 /**
Steve Block4e584df2012-04-24 23:12:47 +01001239 * Gets the directory that contains the plugin libraries. This method is
Derek Sollenbergerfdbdeb32010-08-12 11:20:13 -04001240 * obsolete since each plugin is now loaded from its own package.
Steve Block4e584df2012-04-24 23:12:47 +01001241 *
1242 * @return an empty string
Derek Sollenbergerfdbdeb32010-08-12 11:20:13 -04001243 * @deprecated This method is no longer used as plugins are loaded from
1244 * their own APK via the system's package manager.
Jonathan Dixon0bf47812013-03-07 17:20:08 -08001245 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001246 */
Jason Chen9dc2e752010-09-01 19:11:14 -07001247 @Deprecated
Mathew Inwood62d83fb2018-08-16 19:09:48 +01001248 @UnsupportedAppUsage
Ignacio Solla451e3382014-11-10 10:35:54 +00001249 public String getPluginsPath() {
Jonathan Dixon3c909522012-02-28 18:45:06 +00001250 // Unconditionally returns empty string, so no need for derived classes to override.
Grace Kloba658ab7d2009-05-14 14:45:26 -07001251 return "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001252 }
1253
1254 /**
Steve Block4e584df2012-04-24 23:12:47 +01001255 * Tells JavaScript to open windows automatically. This applies to the
Nate Fischer4ea92402017-11-17 18:48:13 -08001256 * JavaScript function {@code window.open()}. The default is {@code false}.
Steve Block4e584df2012-04-24 23:12:47 +01001257 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001258 * @param flag {@code true} if JavaScript can open windows automatically
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001259 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001260 public abstract void setJavaScriptCanOpenWindowsAutomatically(boolean flag);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001261
1262 /**
Steve Block4e584df2012-04-24 23:12:47 +01001263 * Gets whether JavaScript can open windows automatically.
1264 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001265 * @return {@code true} if JavaScript can open windows automatically during
Nate Fischer4ea92402017-11-17 18:48:13 -08001266 * {@code window.open()}
Steve Block4e584df2012-04-24 23:12:47 +01001267 * @see #setJavaScriptCanOpenWindowsAutomatically
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001268 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001269 public abstract boolean getJavaScriptCanOpenWindowsAutomatically();
Marcin Kosibafd1ac832014-10-10 17:12:49 +01001270
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001271 /**
Steve Block4e584df2012-04-24 23:12:47 +01001272 * Sets the default text encoding name to use when decoding html pages.
Marcin Kosibafd1ac832014-10-10 17:12:49 +01001273 * The default is "UTF-8".
Steve Block4e584df2012-04-24 23:12:47 +01001274 *
1275 * @param encoding the text encoding name
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001276 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001277 public abstract void setDefaultTextEncodingName(String encoding);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001278
1279 /**
Steve Block4e584df2012-04-24 23:12:47 +01001280 * Gets the default text encoding name.
1281 *
1282 * @return the default text encoding name as a string
1283 * @see #setDefaultTextEncodingName
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001284 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001285 public abstract String getDefaultTextEncodingName();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001286
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001287 /**
Nate Fischer0a6140d2017-09-05 12:37:49 -07001288 * Sets the WebView's user-agent string. If the string is {@code null} or empty,
Steve Blockb0e0f332012-06-13 22:01:11 +01001289 * the system default value will be used.
Mikhail Naganov550f6212015-07-07 13:39:31 -07001290 *
1291 * Note that starting from {@link android.os.Build.VERSION_CODES#KITKAT} Android
1292 * version, changing the user-agent while loading a web page causes WebView
1293 * to initiate loading once again.
1294 *
1295 * @param ua new user-agent string
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001296 */
Nate Fischer3442c742017-09-08 17:02:00 -07001297 public abstract void setUserAgentString(@Nullable String ua);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001298
1299 /**
Steve Block4e584df2012-04-24 23:12:47 +01001300 * Gets the WebView's user-agent string.
Steve Blockb0e0f332012-06-13 22:01:11 +01001301 *
1302 * @return the WebView's user-agent string
1303 * @see #setUserAgentString
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001304 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001305 public abstract String getUserAgentString();
Shimeng (Simon) Wangc55886a2010-10-28 13:46:02 -07001306
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001307 /**
George Mount9f410c52012-08-10 15:29:30 -07001308 * Returns the default User-Agent used by a WebView.
1309 * An instance of WebView could use a different User-Agent if a call
Kristian Monsenf4912582012-08-16 15:26:24 -04001310 * is made to {@link WebSettings#setUserAgentString(String)}.
George Mount9f410c52012-08-10 15:29:30 -07001311 *
1312 * @param context a Context object used to access application assets
1313 */
1314 public static String getDefaultUserAgent(Context context) {
Jonathan Dixond1c4faa2012-08-20 16:37:15 -07001315 return WebViewFactory.getProvider().getStatics().getDefaultUserAgent(context);
George Mount9f410c52012-08-10 15:29:30 -07001316 }
1317
1318 /**
Steve Block4e584df2012-04-24 23:12:47 +01001319 * Tells the WebView whether it needs to set a node to have focus when
Steve Blockb0e0f332012-06-13 22:01:11 +01001320 * {@link WebView#requestFocus(int, android.graphics.Rect)} is called. The
Nate Fischer0a6140d2017-09-05 12:37:49 -07001321 * default value is {@code true}.
Michael Kolba172e7d2010-06-30 12:35:26 -07001322 *
Steve Block4e584df2012-04-24 23:12:47 +01001323 * @param flag whether the WebView needs to set a node
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001324 */
Ignacio Solla451e3382014-11-10 10:35:54 +00001325 public abstract void setNeedInitialFocus(boolean flag);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001326
1327 /**
Steve Block4e584df2012-04-24 23:12:47 +01001328 * Sets the priority of the Render thread. Unlike the other settings, this
Steve Blockb0e0f332012-06-13 22:01:11 +01001329 * one only needs to be called once per process. The default value is
1330 * {@link RenderPriority#NORMAL}.
Mike Hearnadcd2ed2009-01-21 16:44:36 +01001331 *
Steve Blockb0e0f332012-06-13 22:01:11 +01001332 * @param priority the priority
Jonathan Dixon835b1fc2013-02-25 12:29:33 -08001333 * @deprecated It is not recommended to adjust thread priorities, and this will
1334 * not be supported in future versions.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001335 */
Jonathan Dixon835b1fc2013-02-25 12:29:33 -08001336 @Deprecated
Ignacio Solla451e3382014-11-10 10:35:54 +00001337 public abstract void setRenderPriority(RenderPriority priority);
Michael Kolba172e7d2010-06-30 12:35:26 -07001338
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001339 /**
Steve Block4e584df2012-04-24 23:12:47 +01001340 * Overrides the way the cache is used. The way the cache is used is based
Steve Blockb0e0f332012-06-13 22:01:11 +01001341 * on the navigation type. For a normal page load, the cache is checked
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001342 * and content is re-validated as needed. When navigating back, content is
Steve Blockb0e0f332012-06-13 22:01:11 +01001343 * not revalidated, instead the content is just retrieved from the cache.
1344 * This method allows the client to override this behavior by specifying
Mikhail Naganov56936a12012-07-25 13:07:18 +01001345 * one of {@link #LOAD_DEFAULT},
Steve Blockb0e0f332012-06-13 22:01:11 +01001346 * {@link #LOAD_CACHE_ELSE_NETWORK}, {@link #LOAD_NO_CACHE} or
1347 * {@link #LOAD_CACHE_ONLY}. The default value is {@link #LOAD_DEFAULT}.
Steve Block4e584df2012-04-24 23:12:47 +01001348 *
Steve Blockb0e0f332012-06-13 22:01:11 +01001349 * @param mode the mode to use
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001350 */
Tim Volodineb90f5382016-04-29 12:44:41 +01001351 public abstract void setCacheMode(@CacheMode int mode);
Michael Kolba172e7d2010-06-30 12:35:26 -07001352
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001353 /**
Steve Blockb0e0f332012-06-13 22:01:11 +01001354 * Gets the current setting for overriding the cache mode.
1355 *
1356 * @return the current setting for overriding the cache mode
1357 * @see #setCacheMode
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001358 */
Tim Volodineb90f5382016-04-29 12:44:41 +01001359 @CacheMode
Ignacio Solla451e3382014-11-10 10:35:54 +00001360 public abstract int getCacheMode();
Ben Murdochfe9fc3d2014-04-10 15:31:06 +01001361
1362 /**
1363 * Configures the WebView's behavior when a secure origin attempts to load a resource from an
1364 * insecure origin.
1365 *
1366 * By default, apps that target {@link android.os.Build.VERSION_CODES#KITKAT} or below default
1367 * to {@link #MIXED_CONTENT_ALWAYS_ALLOW}. Apps targeting
Dianne Hackborn955d8d62014-10-07 20:17:19 -07001368 * {@link android.os.Build.VERSION_CODES#LOLLIPOP} default to {@link #MIXED_CONTENT_NEVER_ALLOW}.
Ben Murdochfe9fc3d2014-04-10 15:31:06 +01001369 *
1370 * The preferred and most secure mode of operation for the WebView is
1371 * {@link #MIXED_CONTENT_NEVER_ALLOW} and use of {@link #MIXED_CONTENT_ALWAYS_ALLOW} is
1372 * strongly discouraged.
1373 *
1374 * @param mode The mixed content mode to use. One of {@link #MIXED_CONTENT_NEVER_ALLOW},
Torne (Richard Coles)2b666c92015-03-06 14:20:00 +00001375 * {@link #MIXED_CONTENT_ALWAYS_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}.
Ben Murdochfe9fc3d2014-04-10 15:31:06 +01001376 */
1377 public abstract void setMixedContentMode(int mode);
1378
1379 /**
1380 * Gets the current behavior of the WebView with regard to loading insecure content from a
1381 * secure origin.
1382 * @return The current setting, one of {@link #MIXED_CONTENT_NEVER_ALLOW},
Torne (Richard Coles)2b666c92015-03-06 14:20:00 +00001383 * {@link #MIXED_CONTENT_ALWAYS_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}.
Ben Murdochfe9fc3d2014-04-10 15:31:06 +01001384 */
1385 public abstract int getMixedContentMode();
Yuncheol Heo4d07c482014-05-07 17:29:35 +09001386
1387 /**
1388 * Sets whether to use a video overlay for embedded encrypted video.
Dianne Hackborn955d8d62014-10-07 20:17:19 -07001389 * In API levels prior to {@link android.os.Build.VERSION_CODES#LOLLIPOP}, encrypted video can
Yuncheol Heo4d07c482014-05-07 17:29:35 +09001390 * only be rendered directly on a secure video surface, so it had been a hard problem to play
1391 * encrypted video in HTML. When this flag is on, WebView can play encrypted video (MSE/EME)
1392 * by using a video overlay (aka hole-punching) for videos embedded using HTML &lt;video&gt;
1393 * tag.<br>
1394 * Caution: This setting is intended for use only in a narrow set of circumstances and apps
1395 * should only enable it if they require playback of encrypted video content. It will impose
1396 * the following limitations on the WebView:
1397 * <ul>
1398 * <li> Only one video overlay can be played at a time.
1399 * <li> Changes made to position or dimensions of a video element may be propagated to the
1400 * corresponding video overlay with a noticeable delay.
1401 * <li> The video overlay is not visible to web APIs and as such may not interact with
1402 * script or styling. For example, CSS styles applied to the &lt;video&gt; tag may be ignored.
1403 * </ul>
1404 * This is not an exhaustive set of constraints and it may vary with new versions of the
1405 * WebView.
1406 * @hide
1407 */
Yuncheol Heoeeba0252014-07-08 19:43:00 +09001408 @SystemApi
Yuncheol Heo4d07c482014-05-07 17:29:35 +09001409 public abstract void setVideoOverlayForEmbeddedEncryptedVideoEnabled(boolean flag);
1410
1411 /**
1412 * Gets whether a video overlay will be used for embedded encrypted video.
1413 *
Nate Fischer0a6140d2017-09-05 12:37:49 -07001414 * @return {@code true} if WebView uses a video overlay for embedded encrypted video.
Yuncheol Heo4d07c482014-05-07 17:29:35 +09001415 * @see #setVideoOverlayForEmbeddedEncryptedVideoEnabled
1416 * @hide
1417 */
Yuncheol Heoeeba0252014-07-08 19:43:00 +09001418 @SystemApi
Yuncheol Heo4d07c482014-05-07 17:29:35 +09001419 public abstract boolean getVideoOverlayForEmbeddedEncryptedVideoEnabled();
Hui Shub1ee70b2015-03-03 11:38:41 -08001420
1421 /**
1422 * Sets whether this WebView should raster tiles when it is
1423 * offscreen but attached to a window. Turning this on can avoid
1424 * rendering artifacts when animating an offscreen WebView on-screen.
1425 * Offscreen WebViews in this mode use more memory. The default value is
Hui Shud377c0f2015-05-13 12:01:42 -07001426 * false.<br>
Hui Shub1ee70b2015-03-03 11:38:41 -08001427 * Please follow these guidelines to limit memory usage:
Hui Shud377c0f2015-05-13 12:01:42 -07001428 * <ul>
1429 * <li> WebView size should be not be larger than the device screen size.
1430 * <li> Limit use of this mode to a small number of WebViews. Use it for
Hui Shub1ee70b2015-03-03 11:38:41 -08001431 * visible WebViews and WebViews about to be animated to visible.
Hui Shud377c0f2015-05-13 12:01:42 -07001432 * </ul>
Hui Shub1ee70b2015-03-03 11:38:41 -08001433 */
1434 public abstract void setOffscreenPreRaster(boolean enabled);
1435
1436 /**
1437 * Gets whether this WebView should raster tiles when it is
1438 * offscreen but attached to a window.
Nate Fischer0a6140d2017-09-05 12:37:49 -07001439 * @return {@code true} if this WebView will raster tiles when it is
Hui Shub1ee70b2015-03-03 11:38:41 -08001440 * offscreen but attached to a window.
1441 */
1442 public abstract boolean getOffscreenPreRaster();
Hui Shu227a8c12015-10-22 14:57:51 -07001443
Selim Gurunec0a1f22017-04-07 18:21:46 -07001444
1445 /**
Nate Fischerfb92ee12018-01-18 12:01:19 -08001446 * Sets whether Safe Browsing is enabled. Safe Browsing allows WebView to
Selim Gurunec0a1f22017-04-07 18:21:46 -07001447 * protect against malware and phishing attacks by verifying the links.
1448 *
Selim Gurunec0a1f22017-04-07 18:21:46 -07001449 * <p>
Nate Fischerfb92ee12018-01-18 12:01:19 -08001450 * Safe Browsing can be disabled for all WebViews using a manifest tag (read <a
1451 * href="{@docRoot}reference/android/webkit/WebView.html">general Safe Browsing info</a>). The
1452 * manifest tag has a lower precedence than this API.
Selim Gurunec0a1f22017-04-07 18:21:46 -07001453 *
Nate Fischer471891d2017-07-18 19:15:52 -07001454 * <p>
Nate Fischerfb92ee12018-01-18 12:01:19 -08001455 * Safe Browsing is enabled by default for devices which support it.
Selim Gurunec0a1f22017-04-07 18:21:46 -07001456 *
Nate Fischerfb92ee12018-01-18 12:01:19 -08001457 * @param enabled Whether Safe Browsing is enabled.
Selim Gurunec0a1f22017-04-07 18:21:46 -07001458 */
1459 public abstract void setSafeBrowsingEnabled(boolean enabled);
1460
1461 /**
Nate Fischerfb92ee12018-01-18 12:01:19 -08001462 * Gets whether Safe Browsing is enabled.
Selim Gurunec0a1f22017-04-07 18:21:46 -07001463 * See {@link #setSafeBrowsingEnabled}.
1464 *
Nate Fischerfb92ee12018-01-18 12:01:19 -08001465 * @return {@code true} if Safe Browsing is enabled and {@code false} otherwise.
Selim Gurunec0a1f22017-04-07 18:21:46 -07001466 */
1467 public abstract boolean getSafeBrowsingEnabled();
1468
1469
Hui Shu227a8c12015-10-22 14:57:51 -07001470 /**
Tobias Sargeantfec405a32018-12-06 15:22:18 +00001471 * Set the force dark mode for this WebView.
Tobias Sargeante1fc7912019-03-19 12:16:22 +00001472 *
1473 * @param forceDark the force dark mode to set.
Anna Malova7374ce12019-09-25 12:19:27 +01001474 * @see #getForceDark
Tobias Sargeantfec405a32018-12-06 15:22:18 +00001475 */
Tobias Sargeantbbb043a2019-03-11 10:14:28 +00001476 public void setForceDark(@ForceDark int forceDark) {
Tobias Sargeantfec405a32018-12-06 15:22:18 +00001477 // Stub implementation to satisfy Roboelectrc shadows that don't override this yet.
1478 }
1479
1480 /**
1481 * Get the force dark mode for this WebView.
Anna Malova7374ce12019-09-25 12:19:27 +01001482 * The default force dark mode is {@link #FORCE_DARK_AUTO}.
Tobias Sargeante1fc7912019-03-19 12:16:22 +00001483 *
Tobias Sargeantfec405a32018-12-06 15:22:18 +00001484 * @return the currently set force dark mode.
Anna Malova7374ce12019-09-25 12:19:27 +01001485 * @see #setForceDark
Tobias Sargeantfec405a32018-12-06 15:22:18 +00001486 */
Tobias Sargeantbbb043a2019-03-11 10:14:28 +00001487 public @ForceDark int getForceDark() {
Tobias Sargeantfec405a32018-12-06 15:22:18 +00001488 // Stub implementation to satisfy Roboelectrc shadows that don't override this yet.
1489 return FORCE_DARK_AUTO;
1490 }
1491
1492 /**
Hui Shu539b0772016-04-20 15:21:37 -07001493 * @hide
1494 */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07001495 @IntDef(flag = true, prefix = { "MENU_ITEM_" }, value = {
1496 MENU_ITEM_NONE,
1497 MENU_ITEM_SHARE,
1498 MENU_ITEM_WEB_SEARCH,
1499 MENU_ITEM_PROCESS_TEXT
1500 })
Hui Shu539b0772016-04-20 15:21:37 -07001501 @Retention(RetentionPolicy.SOURCE)
1502 @Target({ElementType.PARAMETER, ElementType.METHOD})
1503 private @interface MenuItemFlags {}
1504
1505 /**
Hui Shu227a8c12015-10-22 14:57:51 -07001506 * Disables the action mode menu items according to {@code menuItems} flag.
1507 * @param menuItems an integer field flag for the menu items to be disabled.
1508 */
Hui Shu539b0772016-04-20 15:21:37 -07001509 public abstract void setDisabledActionModeMenuItems(@MenuItemFlags int menuItems);
Hui Shu227a8c12015-10-22 14:57:51 -07001510
1511 /**
1512 * Gets the action mode menu items that are disabled, expressed in an integer field flag.
1513 * The default value is {@link #MENU_ITEM_NONE}
1514 *
Hui Shu539b0772016-04-20 15:21:37 -07001515 * @return all the disabled menu item flags combined with bitwise OR.
Hui Shu227a8c12015-10-22 14:57:51 -07001516 */
Hui Shu539b0772016-04-20 15:21:37 -07001517 public abstract @MenuItemFlags int getDisabledActionModeMenuItems();
Hui Shu227a8c12015-10-22 14:57:51 -07001518
1519 /**
Hui Shu227a8c12015-10-22 14:57:51 -07001520 * No menu items should be disabled.
Anna Malova7374ce12019-09-25 12:19:27 +01001521 *
1522 * @see #setDisabledActionModeMenuItems
Hui Shu227a8c12015-10-22 14:57:51 -07001523 */
1524 public static final int MENU_ITEM_NONE = 0;
1525
1526 /**
Hui Shu227a8c12015-10-22 14:57:51 -07001527 * Disable menu item "Share".
Anna Malova7374ce12019-09-25 12:19:27 +01001528 *
1529 * @see #setDisabledActionModeMenuItems
Hui Shu227a8c12015-10-22 14:57:51 -07001530 */
1531 public static final int MENU_ITEM_SHARE = 1 << 0;
1532
1533 /**
Hui Shu227a8c12015-10-22 14:57:51 -07001534 * Disable menu item "Web Search".
Anna Malova7374ce12019-09-25 12:19:27 +01001535 *
1536 * @see #setDisabledActionModeMenuItems
Hui Shu227a8c12015-10-22 14:57:51 -07001537 */
1538 public static final int MENU_ITEM_WEB_SEARCH = 1 << 1;
1539
1540 /**
Hui Shu227a8c12015-10-22 14:57:51 -07001541 * Disable all the action mode menu items for text processing.
1542 * By default WebView searches for activities that are able to handle
1543 * {@link android.content.Intent#ACTION_PROCESS_TEXT} and show them in the
1544 * action mode menu. If this flag is set via {@link
1545 * #setDisabledActionModeMenuItems}, these menu items will be disabled.
Anna Malova7374ce12019-09-25 12:19:27 +01001546 *
1547 * @see #setDisabledActionModeMenuItems
Hui Shu227a8c12015-10-22 14:57:51 -07001548 */
1549 public static final int MENU_ITEM_PROCESS_TEXT = 1 << 2;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001550}