The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.webkit; |
| 18 | |
Hui Shu | 539b077 | 2016-04-20 15:21:37 -0700 | [diff] [blame] | 19 | import android.annotation.IntDef; |
Nate Fischer | 3442c74 | 2017-09-08 17:02:00 -0700 | [diff] [blame] | 20 | import android.annotation.Nullable; |
Yuncheol Heo | eeba025 | 2014-07-08 19:43:00 +0900 | [diff] [blame] | 21 | import android.annotation.SystemApi; |
Artur Satayev | ad9254c | 2019-12-10 17:47:54 +0000 | [diff] [blame] | 22 | import android.compat.annotation.UnsupportedAppUsage; |
George Mount | 9f410c5 | 2012-08-10 15:29:30 -0700 | [diff] [blame] | 23 | import android.content.Context; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 24 | |
Hui Shu | 539b077 | 2016-04-20 15:21:37 -0700 | [diff] [blame] | 25 | import java.lang.annotation.ElementType; |
| 26 | import java.lang.annotation.Retention; |
| 27 | import java.lang.annotation.RetentionPolicy; |
| 28 | import java.lang.annotation.Target; |
| 29 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 30 | /** |
| 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 Fischer | 4ea9240 | 2017-11-17 18:48:13 -0800 | [diff] [blame] | 33 | * 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 Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 37 | */ |
Jonathan Dixon | d3101b1 | 2012-04-12 20:51:51 +0100 | [diff] [blame] | 38 | // This is an abstract base class: concrete WebViewProviders must |
Jonathan Dixon | 3c90952 | 2012-02-28 18:45:06 +0000 | [diff] [blame] | 39 | // create a class derived from this, and return an instance of it in the |
| 40 | // WebViewProvider.getWebSettingsProvider() method implementation. |
Selim Gurun | 0ea6dad | 2012-03-29 18:19:01 -0700 | [diff] [blame] | 41 | public abstract class WebSettings { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 42 | /** |
| 43 | * Enum for controlling the layout of html. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 44 | * <ul> |
Nate Fischer | 4ea9240 | 2017-11-17 18:48:13 -0800 | [diff] [blame] | 45 | * <li>{@code NORMAL} means no rendering changes. This is the recommended choice for maximum |
Jonathan Dixon | 5545d08 | 2013-08-31 22:43:11 -0700 | [diff] [blame] | 46 | * compatibility across different platforms and Android versions.</li> |
Nate Fischer | 4ea9240 | 2017-11-17 18:48:13 -0800 | [diff] [blame] | 47 | * <li>{@code SINGLE_COLUMN} moves all content into one column that is the width of the |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 48 | * view.</li> |
Nate Fischer | 4ea9240 | 2017-11-17 18:48:13 -0800 | [diff] [blame] | 49 | * <li>{@code NARROW_COLUMNS} makes all columns no wider than the screen if possible. Only use |
Jonathan Dixon | 5545d08 | 2013-08-31 22:43:11 -0700 | [diff] [blame] | 50 | * this for API levels prior to {@link android.os.Build.VERSION_CODES#KITKAT}.</li> |
Nate Fischer | 4ea9240 | 2017-11-17 18:48:13 -0800 | [diff] [blame] | 51 | * <li>{@code TEXT_AUTOSIZING} boosts font size of paragraphs based on heuristics to make |
Mikhail Naganov | 94e0bd3 | 2012-12-14 17:01:25 +0000 | [diff] [blame] | 52 | * 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 Dixon | 5545d08 | 2013-08-31 22:43:11 -0700 | [diff] [blame] | 54 | * using this mode. Supported from API level |
| 55 | * {@link android.os.Build.VERSION_CODES#KITKAT}</li> |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 56 | * </ul> |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 57 | */ |
| 58 | // XXX: These must match LayoutAlgorithm in Settings.h in WebCore. |
| 59 | public enum LayoutAlgorithm { |
| 60 | NORMAL, |
John Reck | 5a1ef413 | 2011-10-26 10:37:00 -0700 | [diff] [blame] | 61 | /** |
| 62 | * @deprecated This algorithm is now obsolete. |
| 63 | */ |
| 64 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 65 | SINGLE_COLUMN, |
Mikhail Naganov | 94e0bd3 | 2012-12-14 17:01:25 +0000 | [diff] [blame] | 66 | /** |
Jonathan Dixon | 5545d08 | 2013-08-31 22:43:11 -0700 | [diff] [blame] | 67 | * @deprecated This algorithm is now obsolete. |
Mikhail Naganov | 94e0bd3 | 2012-12-14 17:01:25 +0000 | [diff] [blame] | 68 | */ |
Jonathan Dixon | 5545d08 | 2013-08-31 22:43:11 -0700 | [diff] [blame] | 69 | @Deprecated |
| 70 | NARROW_COLUMNS, |
Mikhail Naganov | 94e0bd3 | 2012-12-14 17:01:25 +0000 | [diff] [blame] | 71 | TEXT_AUTOSIZING |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Enum for specifying the text size. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 76 | * <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 Reck | caeb120 | 2011-06-17 11:50:15 -0700 | [diff] [blame] | 84 | * @deprecated Use {@link WebSettings#setTextZoom(int)} and {@link WebSettings#getTextZoom()} instead. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 85 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 86 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 87 | 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 Inwood | 62d83fb | 2018-08-16 19:09:48 +0100 | [diff] [blame] | 96 | @UnsupportedAppUsage |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 97 | int value; |
| 98 | } |
Grace Kloba | 0d8b77c | 2009-06-25 11:20:51 -0700 | [diff] [blame] | 99 | |
| 100 | /** |
| 101 | * Enum for specifying the WebView's desired density. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 102 | * <ul> |
Nate Fischer | 4ea9240 | 2017-11-17 18:48:13 -0800 | [diff] [blame] | 103 | * <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 Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 106 | * </ul> |
Grace Kloba | 0d8b77c | 2009-06-25 11:20:51 -0700 | [diff] [blame] | 107 | */ |
| 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 Naganov | ce76ca5 | 2012-07-27 12:00:05 +0100 | [diff] [blame] | 115 | |
| 116 | /** |
| 117 | * @hide Only for use by WebViewProvider implementations |
| 118 | */ |
| 119 | public int getValue() { |
| 120 | return value; |
| 121 | } |
| 122 | |
Grace Kloba | 0d8b77c | 2009-06-25 11:20:51 -0700 | [diff] [blame] | 123 | int value; |
| 124 | } |
| 125 | |
Tim Volodine | b90f538 | 2016-04-29 12:44:41 +0100 | [diff] [blame] | 126 | /** @hide */ |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 127 | @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 Volodine | b90f538 | 2016-04-29 12:44:41 +0100 | [diff] [blame] | 134 | @Retention(RetentionPolicy.SOURCE) |
| 135 | public @interface CacheMode {} |
| 136 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 137 | /** |
Mikhail Naganov | 500b003 | 2012-07-25 13:06:14 +0100 | [diff] [blame] | 138 | * 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 Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 142 | */ |
| 143 | public static final int LOAD_DEFAULT = -1; |
| 144 | |
| 145 | /** |
Mikhail Naganov | 500b003 | 2012-07-25 13:06:14 +0100 | [diff] [blame] | 146 | * Normal cache usage mode. Use with {@link #setCacheMode}. |
Mikhail Naganov | 56936a1 | 2012-07-25 13:07:18 +0100 | [diff] [blame] | 147 | * |
| 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 Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 151 | */ |
Kristian Monsen | 5cc2351 | 2012-08-09 15:33:08 -0400 | [diff] [blame] | 152 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 153 | public static final int LOAD_NORMAL = 0; |
| 154 | |
| 155 | /** |
Mikhail Naganov | 500b003 | 2012-07-25 13:06:14 +0100 | [diff] [blame] | 156 | * Use cached resources when they are available, even if they have expired. |
| 157 | * Otherwise load resources from the network. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 158 | * Use with {@link #setCacheMode}. |
| 159 | */ |
| 160 | public static final int LOAD_CACHE_ELSE_NETWORK = 1; |
| 161 | |
| 162 | /** |
Mikhail Naganov | 500b003 | 2012-07-25 13:06:14 +0100 | [diff] [blame] | 163 | * Don't use the cache, load from the network. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 164 | * Use with {@link #setCacheMode}. |
| 165 | */ |
| 166 | public static final int LOAD_NO_CACHE = 2; |
Michael Kolb | a172e7d | 2010-06-30 12:35:26 -0700 | [diff] [blame] | 167 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 168 | /** |
Mikhail Naganov | 500b003 | 2012-07-25 13:06:14 +0100 | [diff] [blame] | 169 | * Don't use the network, load from the cache. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 170 | * 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 Scott | 300f2e9 | 2010-03-22 10:20:45 -0400 | [diff] [blame] | 180 | /** |
| 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 Murdoch | e9e3ccd | 2010-10-06 14:33:02 +0100 | [diff] [blame] | 195 | /** |
Ben Murdoch | fe9fc3d | 2014-04-10 15:31:06 +0100 | [diff] [blame] | 196 | * 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 Malova | 7374ce1 | 2019-09-25 12:19:27 +0100 | [diff] [blame] | 199 | * |
| 200 | * @see #setMixedContentMode |
Ben Murdoch | fe9fc3d | 2014-04-10 15:31:06 +0100 | [diff] [blame] | 201 | */ |
| 202 | public static final int MIXED_CONTENT_ALWAYS_ALLOW = 0; |
| 203 | |
| 204 | /** |
Ben Murdoch | fe9fc3d | 2014-04-10 15:31:06 +0100 | [diff] [blame] | 205 | * 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 Malova | 7374ce1 | 2019-09-25 12:19:27 +0100 | [diff] [blame] | 208 | * |
| 209 | * @see #setMixedContentMode |
Ben Murdoch | fe9fc3d | 2014-04-10 15:31:06 +0100 | [diff] [blame] | 210 | */ |
| 211 | public static final int MIXED_CONTENT_NEVER_ALLOW = 1; |
| 212 | |
| 213 | /** |
Ben Murdoch | fe9fc3d | 2014-04-10 15:31:06 +0100 | [diff] [blame] | 214 | * 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 Malova | 7374ce1 | 2019-09-25 12:19:27 +0100 | [diff] [blame] | 222 | * |
| 223 | * @see #setMixedContentMode |
Ben Murdoch | fe9fc3d | 2014-04-10 15:31:06 +0100 | [diff] [blame] | 224 | */ |
| 225 | public static final int MIXED_CONTENT_COMPATIBILITY_MODE = 2; |
| 226 | |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 227 | /** @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 Sargeant | bbb043a | 2019-03-11 10:14:28 +0000 | [diff] [blame] | 234 | public @interface ForceDark {} |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 235 | |
| 236 | /** |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 237 | * 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 Malova | 7374ce1 | 2019-09-25 12:19:27 +0100 | [diff] [blame] | 240 | * |
| 241 | * @see #setForceDark |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 242 | */ |
Tobias Sargeant | bbb043a | 2019-03-11 10:14:28 +0000 | [diff] [blame] | 243 | public static final int FORCE_DARK_OFF = 0; |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 244 | |
| 245 | /** |
Tobias Sargeant | e1fc791 | 2019-03-19 12:16:22 +0000 | [diff] [blame] | 246 | * 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 Malova | 7374ce1 | 2019-09-25 12:19:27 +0100 | [diff] [blame] | 251 | * |
| 252 | * @see #setForceDark |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 253 | */ |
Tobias Sargeant | bbb043a | 2019-03-11 10:14:28 +0000 | [diff] [blame] | 254 | public static final int FORCE_DARK_AUTO = 1; |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 255 | |
| 256 | /** |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 257 | * Unconditionally enable force dark. In this mode WebView content will always be rendered so |
| 258 | * as to emulate a dark theme. |
Anna Malova | 7374ce1 | 2019-09-25 12:19:27 +0100 | [diff] [blame] | 259 | * |
| 260 | * @see #setForceDark |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 261 | */ |
Tobias Sargeant | bbb043a | 2019-03-11 10:14:28 +0000 | [diff] [blame] | 262 | public static final int FORCE_DARK_ON = 2; |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 263 | |
Ben Murdoch | fe9fc3d | 2014-04-10 15:31:06 +0100 | [diff] [blame] | 264 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 265 | * Enables dumping the pages navigation cache to a text file. The default |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 266 | * is {@code false}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 267 | * |
Kristian Monsen | fc77165 | 2011-05-10 16:44:05 +0100 | [diff] [blame] | 268 | * @deprecated This method is now obsolete. |
Kristian Monsen | f491258 | 2012-08-16 15:26:24 -0400 | [diff] [blame] | 269 | * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 270 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 271 | @SystemApi |
Kristian Monsen | fc77165 | 2011-05-10 16:44:05 +0100 | [diff] [blame] | 272 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 273 | public abstract void setNavDump(boolean enabled); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 274 | |
| 275 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 276 | * Gets whether dumping the navigation cache is enabled. |
| 277 | * |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 278 | * @return whether dumping the navigation cache is enabled |
| 279 | * @see #setNavDump |
Kristian Monsen | fc77165 | 2011-05-10 16:44:05 +0100 | [diff] [blame] | 280 | * @deprecated This method is now obsolete. |
Kristian Monsen | f491258 | 2012-08-16 15:26:24 -0400 | [diff] [blame] | 281 | * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 282 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 283 | @SystemApi |
Kristian Monsen | fc77165 | 2011-05-10 16:44:05 +0100 | [diff] [blame] | 284 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 285 | public abstract boolean getNavDump(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 286 | |
| 287 | /** |
Mikhail Naganov | b533fb4 | 2012-04-05 14:50:02 +0100 | [diff] [blame] | 288 | * 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 Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 292 | * {@link WebView#zoomOut()} methods. The default is {@code true}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 293 | * |
| 294 | * @param support whether the WebView should support zoom |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 295 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 296 | public abstract void setSupportZoom(boolean support); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 297 | |
| 298 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 299 | * Gets whether the WebView supports zoom. |
| 300 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 301 | * @return {@code true} if the WebView supports zoom |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 302 | * @see #setSupportZoom |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 303 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 304 | public abstract boolean supportZoom(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 305 | |
| 306 | /** |
Teng-Hui Zhu | 0e5b160 | 2012-07-17 17:19:13 -0700 | [diff] [blame] | 307 | * Sets whether the WebView requires a user gesture to play media. |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 308 | * The default is {@code true}. |
Teng-Hui Zhu | 0e5b160 | 2012-07-17 17:19:13 -0700 | [diff] [blame] | 309 | * |
| 310 | * @param require whether the WebView requires a user gesture to play media |
| 311 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 312 | public abstract void setMediaPlaybackRequiresUserGesture(boolean require); |
Teng-Hui Zhu | 0e5b160 | 2012-07-17 17:19:13 -0700 | [diff] [blame] | 313 | |
| 314 | /** |
| 315 | * Gets whether the WebView requires a user gesture to play media. |
| 316 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 317 | * @return {@code true} if the WebView requires a user gesture to play media |
Teng-Hui Zhu | 0e5b160 | 2012-07-17 17:19:13 -0700 | [diff] [blame] | 318 | * @see #setMediaPlaybackRequiresUserGesture |
| 319 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 320 | public abstract boolean getMediaPlaybackRequiresUserGesture(); |
Teng-Hui Zhu | 0e5b160 | 2012-07-17 17:19:13 -0700 | [diff] [blame] | 321 | |
| 322 | /** |
Steve Block | 06d268e | 2012-04-16 14:10:54 +0100 | [diff] [blame] | 323 | * 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 Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 327 | * can be set with {@link #setDisplayZoomControls}. The default is {@code false}. |
Steve Block | 06d268e | 2012-04-16 14:10:54 +0100 | [diff] [blame] | 328 | * <p> |
| 329 | * The built-in mechanisms are the only currently supported zoom |
| 330 | * mechanisms, so it is recommended that this setting is always enabled. |
Torne (Richard Coles) | 41c6486 | 2019-10-25 16:38:30 -0400 | [diff] [blame] | 331 | * However, on-screen zoom controls are deprecated in Android (see |
| 332 | * {@link android.widget.ZoomButtonsController}) so it's recommended to |
| 333 | * disable {@link #setDisplayZoomControls}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 334 | * |
| 335 | * @param enabled whether the WebView should use its built-in zoom mechanisms |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 336 | */ |
Steve Block | 06d268e | 2012-04-16 14:10:54 +0100 | [diff] [blame] | 337 | // This method was intended to select between the built-in zoom mechanisms |
| 338 | // and the separate zoom controls. The latter were obtained using |
| 339 | // {@link WebView#getZoomControls}, which is now hidden. |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 340 | public abstract void setBuiltInZoomControls(boolean enabled); |
Michael Kolb | a172e7d | 2010-06-30 12:35:26 -0700 | [diff] [blame] | 341 | |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 342 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 343 | * Gets whether the zoom mechanisms built into WebView are being used. |
| 344 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 345 | * @return {@code true} if the zoom mechanisms built into WebView are being used |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 346 | * @see #setBuiltInZoomControls |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 347 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 348 | public abstract boolean getBuiltInZoomControls(); |
Michael Kolb | a172e7d | 2010-06-30 12:35:26 -0700 | [diff] [blame] | 349 | |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 350 | /** |
Mikhail Naganov | b533fb4 | 2012-04-05 14:50:02 +0100 | [diff] [blame] | 351 | * Sets whether the WebView should display on-screen zoom controls when |
| 352 | * using the built-in zoom mechanisms. See {@link #setBuiltInZoomControls}. |
Torne (Richard Coles) | 41c6486 | 2019-10-25 16:38:30 -0400 | [diff] [blame] | 353 | * The default is {@code true}. However, on-screen zoom controls are deprecated |
| 354 | * in Android (see {@link android.widget.ZoomButtonsController}) so it's |
| 355 | * recommended to set this to {@code false}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 356 | * |
| 357 | * @param enabled whether the WebView should display on-screen zoom controls |
Michael Kolb | 6fe3b42 | 2010-08-19 12:41:24 -0700 | [diff] [blame] | 358 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 359 | public abstract void setDisplayZoomControls(boolean enabled); |
Michael Kolb | 6fe3b42 | 2010-08-19 12:41:24 -0700 | [diff] [blame] | 360 | |
| 361 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 362 | * Gets whether the WebView displays on-screen zoom controls when using |
Mikhail Naganov | b533fb4 | 2012-04-05 14:50:02 +0100 | [diff] [blame] | 363 | * the built-in zoom mechanisms. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 364 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 365 | * @return {@code true} if the WebView displays on-screen zoom controls when using |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 366 | * the built-in zoom mechanisms |
| 367 | * @see #setDisplayZoomControls |
Michael Kolb | 6fe3b42 | 2010-08-19 12:41:24 -0700 | [diff] [blame] | 368 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 369 | public abstract boolean getDisplayZoomControls(); |
Michael Kolb | 6fe3b42 | 2010-08-19 12:41:24 -0700 | [diff] [blame] | 370 | |
| 371 | /** |
Hazem Ashmawy | ee824f0 | 2020-02-14 16:27:38 +0000 | [diff] [blame] | 372 | * Enables or disables file access within WebView. |
| 373 | * Note that this enables or disables file system access only. Assets and resources |
| 374 | * are still accessible using file:///android_asset and file:///android_res. |
| 375 | * <p class="note"> |
| 376 | * <b>Note:</b> Apps should not open {@code file://} URLs from any external source in |
| 377 | * WebView, don't enable this if your app accepts arbitrary URLs from external sources. |
| 378 | * It's recommended to always use |
| 379 | * <a href="{@docRoot}reference/androidx/webkit/WebViewAssetLoader"> |
| 380 | * androidx.webkit.WebViewAssetLoader</a> to access files including assets and resources over |
| 381 | * {@code http(s)://} schemes, instead of {@code file://} URLs. To prevent possible security |
| 382 | * issues targeting {@link android.os.Build.VERSION_CODES#Q} and earlier, you should explicitly |
| 383 | * set this value to {@code false}. |
| 384 | * <p> |
| 385 | * The default value is {@code true} for apps targeting |
| 386 | * {@link android.os.Build.VERSION_CODES#Q} and below, and {@code false} when targeting |
| 387 | * {@link android.os.Build.VERSION_CODES#R} and above. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 388 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 389 | public abstract void setAllowFileAccess(boolean allow); |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 390 | |
| 391 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 392 | * Gets whether this WebView supports file access. |
| 393 | * |
| 394 | * @see #setAllowFileAccess |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 395 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 396 | public abstract boolean getAllowFileAccess(); |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 397 | |
| 398 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 399 | * Enables or disables content URL access within WebView. Content URL |
| 400 | * access allows WebView to load content from a content provider installed |
| 401 | * in the system. The default is enabled. |
Patrick Scott | d1737ed | 2011-01-05 11:36:48 -0500 | [diff] [blame] | 402 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 403 | public abstract void setAllowContentAccess(boolean allow); |
Patrick Scott | d1737ed | 2011-01-05 11:36:48 -0500 | [diff] [blame] | 404 | |
| 405 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 406 | * Gets whether this WebView supports content URL access. |
| 407 | * |
| 408 | * @see #setAllowContentAccess |
Patrick Scott | d1737ed | 2011-01-05 11:36:48 -0500 | [diff] [blame] | 409 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 410 | public abstract boolean getAllowContentAccess(); |
Patrick Scott | d1737ed | 2011-01-05 11:36:48 -0500 | [diff] [blame] | 411 | |
| 412 | /** |
Mikhail Naganov | 0030336 | 2013-09-02 10:57:04 +0100 | [diff] [blame] | 413 | * Sets whether the WebView loads pages in overview mode, that is, |
| 414 | * zooms out the content to fit on screen by width. This setting is |
| 415 | * taken into account when the content width is greater than the width |
| 416 | * of the WebView control, for example, when {@link #getUseWideViewPort} |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 417 | * is enabled. The default is {@code false}. |
Grace Kloba | e397a88 | 2009-08-06 12:04:14 -0700 | [diff] [blame] | 418 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 419 | public abstract void setLoadWithOverviewMode(boolean overview); |
Grace Kloba | e397a88 | 2009-08-06 12:04:14 -0700 | [diff] [blame] | 420 | |
| 421 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 422 | * Gets whether this WebView loads pages in overview mode. |
| 423 | * |
| 424 | * @return whether this WebView loads pages in overview mode |
| 425 | * @see #setLoadWithOverviewMode |
Grace Kloba | e397a88 | 2009-08-06 12:04:14 -0700 | [diff] [blame] | 426 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 427 | public abstract boolean getLoadWithOverviewMode(); |
Grace Kloba | e397a88 | 2009-08-06 12:04:14 -0700 | [diff] [blame] | 428 | |
| 429 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 430 | * Sets whether the WebView will enable smooth transition while panning or |
Adam Powell | e00e8a78 | 2011-09-11 17:48:42 -0700 | [diff] [blame] | 431 | * zooming or while the window hosting the WebView does not have focus. |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 432 | * If it is {@code true}, WebView will choose a solution to maximize the performance. |
Adam Powell | e00e8a78 | 2011-09-11 17:48:42 -0700 | [diff] [blame] | 433 | * e.g. the WebView's content may not be updated during the transition. |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 434 | * If it is false, WebView will keep its fidelity. The default value is {@code false}. |
Kristian Monsen | 5cc2351 | 2012-08-09 15:33:08 -0400 | [diff] [blame] | 435 | * |
| 436 | * @deprecated This method is now obsolete, and will become a no-op in future. |
Grace Kloba | f9b731d | 2010-06-21 19:23:57 -0700 | [diff] [blame] | 437 | */ |
Kristian Monsen | 5cc2351 | 2012-08-09 15:33:08 -0400 | [diff] [blame] | 438 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 439 | public abstract void setEnableSmoothTransition(boolean enable); |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 440 | |
Grace Kloba | f9b731d | 2010-06-21 19:23:57 -0700 | [diff] [blame] | 441 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 442 | * Gets whether the WebView enables smooth transition while panning or |
Grace Kloba | f9b731d | 2010-06-21 19:23:57 -0700 | [diff] [blame] | 443 | * zooming. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 444 | * |
| 445 | * @see #setEnableSmoothTransition |
Kristian Monsen | 5cc2351 | 2012-08-09 15:33:08 -0400 | [diff] [blame] | 446 | * |
| 447 | * @deprecated This method is now obsolete, and will become a no-op in future. |
Grace Kloba | f9b731d | 2010-06-21 19:23:57 -0700 | [diff] [blame] | 448 | */ |
Kristian Monsen | 5cc2351 | 2012-08-09 15:33:08 -0400 | [diff] [blame] | 449 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 450 | public abstract boolean enableSmoothTransition(); |
Grace Kloba | f9b731d | 2010-06-21 19:23:57 -0700 | [diff] [blame] | 451 | |
| 452 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 453 | * Sets whether the WebView uses its background for over scroll background. |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 454 | * If {@code true}, it will use the WebView's background. If {@code false}, it will use an |
| 455 | * internal pattern. Default is {@code true}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 456 | * |
Kristian Monsen | fc77165 | 2011-05-10 16:44:05 +0100 | [diff] [blame] | 457 | * @deprecated This method is now obsolete. |
Kristian Monsen | d0b90d3 | 2012-09-24 12:30:45 -0400 | [diff] [blame] | 458 | * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 459 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 460 | @SystemApi |
Kristian Monsen | fc77165 | 2011-05-10 16:44:05 +0100 | [diff] [blame] | 461 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 462 | public abstract void setUseWebViewBackgroundForOverscrollBackground(boolean view); |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 463 | |
| 464 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 465 | * Gets whether this WebView uses WebView's background instead of |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 466 | * internal pattern for over scroll background. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 467 | * |
| 468 | * @see #setUseWebViewBackgroundForOverscrollBackground |
Kristian Monsen | fc77165 | 2011-05-10 16:44:05 +0100 | [diff] [blame] | 469 | * @deprecated This method is now obsolete. |
Kristian Monsen | f491258 | 2012-08-16 15:26:24 -0400 | [diff] [blame] | 470 | * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 471 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 472 | @SystemApi |
Kristian Monsen | fc77165 | 2011-05-10 16:44:05 +0100 | [diff] [blame] | 473 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 474 | public abstract boolean getUseWebViewBackgroundForOverscrollBackground(); |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 475 | |
| 476 | /** |
Selim Gurun | 13e5b0b | 2017-04-03 14:29:14 -0700 | [diff] [blame] | 477 | * Sets whether the WebView should save form data. In Android O, the |
| 478 | * platform has implemented a fully functional Autofill feature to store |
| 479 | * form data. Therefore, the Webview form data save feature is disabled. |
| 480 | * |
| 481 | * Note that the feature will continue to be supported on older versions of |
| 482 | * Android as before. |
| 483 | * |
Tao Bai | 990f9a9 | 2019-07-02 20:32:47 +0000 | [diff] [blame] | 484 | * @deprecated In Android O and afterwards, this function does not have |
| 485 | * any effect, the form data will be saved to platform's autofill service |
| 486 | * if applicable. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 487 | */ |
Selim Gurun | 13e5b0b | 2017-04-03 14:29:14 -0700 | [diff] [blame] | 488 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 489 | public abstract void setSaveFormData(boolean save); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 490 | |
| 491 | /** |
Selim Gurun | 5c11ef1 | 2013-01-04 14:58:36 -0800 | [diff] [blame] | 492 | * Gets whether the WebView saves form data. |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 493 | * |
| 494 | * @return whether the WebView saves form data |
| 495 | * @see #setSaveFormData |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 496 | */ |
Selim Gurun | 13e5b0b | 2017-04-03 14:29:14 -0700 | [diff] [blame] | 497 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 498 | public abstract boolean getSaveFormData(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 499 | |
| 500 | /** |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 501 | * Sets whether the WebView should save passwords. The default is {@code true}. |
Jonathan Dixon | 835b1fc | 2013-02-25 12:29:33 -0800 | [diff] [blame] | 502 | * @deprecated Saving passwords in WebView will not be supported in future versions. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 503 | */ |
Jonathan Dixon | 835b1fc | 2013-02-25 12:29:33 -0800 | [diff] [blame] | 504 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 505 | public abstract void setSavePassword(boolean save); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 506 | |
| 507 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 508 | * Gets whether the WebView saves passwords. |
| 509 | * |
| 510 | * @return whether the WebView saves passwords |
| 511 | * @see #setSavePassword |
Jonathan Dixon | 835b1fc | 2013-02-25 12:29:33 -0800 | [diff] [blame] | 512 | * @deprecated Saving passwords in WebView will not be supported in future versions. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 513 | */ |
Jonathan Dixon | 835b1fc | 2013-02-25 12:29:33 -0800 | [diff] [blame] | 514 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 515 | public abstract boolean getSavePassword(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 516 | |
| 517 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 518 | * Sets the text zoom of the page in percent. The default is 100. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 519 | * |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 520 | * @param textZoom the text zoom in percent |
John Reck | ff56bcd | 2011-06-16 17:12:08 -0700 | [diff] [blame] | 521 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 522 | public abstract void setTextZoom(int textZoom); |
John Reck | ff56bcd | 2011-06-16 17:12:08 -0700 | [diff] [blame] | 523 | |
| 524 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 525 | * Gets the text zoom of the page in percent. |
| 526 | * |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 527 | * @return the text zoom of the page in percent |
Mikhail Naganov | 1202d66 | 2012-08-07 18:26:52 +0100 | [diff] [blame] | 528 | * @see #setTextZoom |
John Reck | ff56bcd | 2011-06-16 17:12:08 -0700 | [diff] [blame] | 529 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 530 | public abstract int getTextZoom(); |
John Reck | ff56bcd | 2011-06-16 17:12:08 -0700 | [diff] [blame] | 531 | |
| 532 | /** |
Hector Dearman | fc9a27a | 2014-06-05 13:45:28 +0100 | [diff] [blame] | 533 | * Sets policy for third party cookies. |
| 534 | * Developers should access this via {@link CookieManager#setShouldAcceptThirdPartyCookies}. |
| 535 | * @hide Internal API. |
| 536 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 537 | @SystemApi |
| 538 | public abstract void setAcceptThirdPartyCookies(boolean accept); |
Hector Dearman | fc9a27a | 2014-06-05 13:45:28 +0100 | [diff] [blame] | 539 | |
| 540 | /** |
| 541 | * Gets policy for third party cookies. |
| 542 | * Developers should access this via {@link CookieManager#getShouldAcceptThirdPartyCookies}. |
| 543 | * @hide Internal API |
| 544 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 545 | @SystemApi |
| 546 | public abstract boolean getAcceptThirdPartyCookies(); |
Hector Dearman | fc9a27a | 2014-06-05 13:45:28 +0100 | [diff] [blame] | 547 | |
| 548 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 549 | * Sets the text size of the page. The default is {@link TextSize#NORMAL}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 550 | * |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 551 | * @param t the text size as a {@link TextSize} value |
| 552 | * @deprecated Use {@link #setTextZoom} instead. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 553 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 554 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 555 | public synchronized void setTextSize(TextSize t) { |
Mikhail Naganov | 1202d66 | 2012-08-07 18:26:52 +0100 | [diff] [blame] | 556 | setTextZoom(t.value); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 560 | * Gets the text size of the page. If the text size was previously specified |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 561 | * in percent using {@link #setTextZoom}, this will return the closest |
| 562 | * matching {@link TextSize}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 563 | * |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 564 | * @return the text size as a {@link TextSize} value |
| 565 | * @see #setTextSize |
| 566 | * @deprecated Use {@link #getTextZoom} instead. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 567 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 568 | @Deprecated |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 569 | public synchronized TextSize getTextSize() { |
Mikhail Naganov | 1202d66 | 2012-08-07 18:26:52 +0100 | [diff] [blame] | 570 | TextSize closestSize = null; |
| 571 | int smallestDelta = Integer.MAX_VALUE; |
| 572 | int textSize = getTextZoom(); |
| 573 | for (TextSize size : TextSize.values()) { |
| 574 | int delta = Math.abs(textSize - size.value); |
| 575 | if (delta == 0) { |
| 576 | return size; |
| 577 | } |
| 578 | if (delta < smallestDelta) { |
| 579 | smallestDelta = delta; |
| 580 | closestSize = size; |
| 581 | } |
| 582 | } |
| 583 | return closestSize != null ? closestSize : TextSize.NORMAL; |
Mangesh Ghiware | edb528e | 2011-10-12 14:25:41 -0700 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 587 | * Sets the default zoom density of the page. This must be called from the UI |
| 588 | * thread. The default is {@link ZoomDensity#MEDIUM}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 589 | * |
Mikhail Naganov | 8887b2b | 2013-05-28 10:34:43 +0100 | [diff] [blame] | 590 | * This setting is not recommended for use in new applications. If the WebView |
| 591 | * is utilized to display mobile-oriented pages, the desired effect can be achieved by |
| 592 | * adjusting 'width' and 'initial-scale' attributes of page's 'meta viewport' |
| 593 | * tag. For pages lacking the tag, {@link android.webkit.WebView#setInitialScale} |
| 594 | * and {@link #setUseWideViewPort} can be used. |
| 595 | * |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 596 | * @param zoom the zoom density |
Jonathan Dixon | 5545d08 | 2013-08-31 22:43:11 -0700 | [diff] [blame] | 597 | * @deprecated This method is no longer supported, see the function documentation for |
| 598 | * recommended alternatives. |
Grace Kloba | 0d8b77c | 2009-06-25 11:20:51 -0700 | [diff] [blame] | 599 | */ |
Jonathan Dixon | 5545d08 | 2013-08-31 22:43:11 -0700 | [diff] [blame] | 600 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 601 | public abstract void setDefaultZoom(ZoomDensity zoom); |
Grace Kloba | 0d8b77c | 2009-06-25 11:20:51 -0700 | [diff] [blame] | 602 | |
| 603 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 604 | * Gets the default zoom density of the page. This should be called from |
| 605 | * the UI thread. |
| 606 | * |
Mikhail Naganov | 8887b2b | 2013-05-28 10:34:43 +0100 | [diff] [blame] | 607 | * This setting is not recommended for use in new applications. |
| 608 | * |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 609 | * @return the zoom density |
| 610 | * @see #setDefaultZoom |
Jonathan Dixon | 5545d08 | 2013-08-31 22:43:11 -0700 | [diff] [blame] | 611 | * @deprecated Will only return the default value. |
Grace Kloba | 0d8b77c | 2009-06-25 11:20:51 -0700 | [diff] [blame] | 612 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 613 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 614 | public abstract ZoomDensity getDefaultZoom(); |
Grace Kloba | 0d8b77c | 2009-06-25 11:20:51 -0700 | [diff] [blame] | 615 | |
| 616 | /** |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 617 | * Enables using light touches to make a selection and activate mouseovers. |
Jonathan Dixon | 835b1fc | 2013-02-25 12:29:33 -0800 | [diff] [blame] | 618 | * @deprecated From {@link android.os.Build.VERSION_CODES#JELLY_BEAN} this |
| 619 | * setting is obsolete and has no effect. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 620 | */ |
Jonathan Dixon | 835b1fc | 2013-02-25 12:29:33 -0800 | [diff] [blame] | 621 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 622 | public abstract void setLightTouchEnabled(boolean enabled); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 623 | |
| 624 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 625 | * Gets whether light touches are enabled. |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 626 | * @see #setLightTouchEnabled |
Jonathan Dixon | 98fac17 | 2013-02-28 15:32:10 -0800 | [diff] [blame] | 627 | * @deprecated This setting is obsolete. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 628 | */ |
Jonathan Dixon | 835b1fc | 2013-02-25 12:29:33 -0800 | [diff] [blame] | 629 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 630 | public abstract boolean getLightTouchEnabled(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 631 | |
| 632 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 633 | * Controlled a rendering optimization that is no longer present. Setting |
| 634 | * it now has no effect. |
| 635 | * |
| 636 | * @deprecated This setting now has no effect. |
Kristian Monsen | f491258 | 2012-08-16 15:26:24 -0400 | [diff] [blame] | 637 | * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 638 | */ |
Mike Hearn | adcd2ed | 2009-01-21 16:44:36 +0100 | [diff] [blame] | 639 | @Deprecated |
Mathew Inwood | 62d83fb | 2018-08-16 19:09:48 +0100 | [diff] [blame] | 640 | @UnsupportedAppUsage |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 641 | public void setUseDoubleTree(boolean use) { |
Jonathan Dixon | 3c90952 | 2012-02-28 18:45:06 +0000 | [diff] [blame] | 642 | // Specified to do nothing, so no need for derived classes to override. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 646 | * Controlled a rendering optimization that is no longer present. Setting |
| 647 | * it now has no effect. |
| 648 | * |
| 649 | * @deprecated This setting now has no effect. |
Kristian Monsen | f491258 | 2012-08-16 15:26:24 -0400 | [diff] [blame] | 650 | * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 651 | */ |
Mike Hearn | adcd2ed | 2009-01-21 16:44:36 +0100 | [diff] [blame] | 652 | @Deprecated |
Mathew Inwood | 62d83fb | 2018-08-16 19:09:48 +0100 | [diff] [blame] | 653 | @UnsupportedAppUsage |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 654 | public boolean getUseDoubleTree() { |
Jonathan Dixon | 3c90952 | 2012-02-28 18:45:06 +0000 | [diff] [blame] | 655 | // Returns false unconditionally, so no need for derived classes to override. |
Mike Hearn | adcd2ed | 2009-01-21 16:44:36 +0100 | [diff] [blame] | 656 | return false; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 657 | } |
| 658 | |
| 659 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 660 | * Sets the user-agent string using an integer code. |
| 661 | * <ul> |
| 662 | * <li>0 means the WebView should use an Android user-agent string</li> |
| 663 | * <li>1 means the WebView should use a desktop user-agent string</li> |
| 664 | * </ul> |
| 665 | * Other values are ignored. The default is an Android user-agent string, |
| 666 | * i.e. code value 0. |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 667 | * |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 668 | * @param ua the integer code for the user-agent string |
| 669 | * @deprecated Please use {@link #setUserAgentString} instead. |
Kristian Monsen | f491258 | 2012-08-16 15:26:24 -0400 | [diff] [blame] | 670 | * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 671 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 672 | @SystemApi |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 673 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 674 | public abstract void setUserAgent(int ua); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 675 | |
| 676 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 677 | * Gets the user-agent as an integer code. |
| 678 | * <ul> |
| 679 | * <li>-1 means the WebView is using a custom user-agent string set with |
| 680 | * {@link #setUserAgentString}</li> |
| 681 | * <li>0 means the WebView should use an Android user-agent string</li> |
| 682 | * <li>1 means the WebView should use a desktop user-agent string</li> |
| 683 | * </ul> |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 684 | * |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 685 | * @return the integer code for the user-agent string |
| 686 | * @see #setUserAgent |
| 687 | * @deprecated Please use {@link #getUserAgentString} instead. |
Kristian Monsen | f491258 | 2012-08-16 15:26:24 -0400 | [diff] [blame] | 688 | * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 689 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 690 | @SystemApi |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 691 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 692 | public abstract int getUserAgent(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 693 | |
| 694 | /** |
Mikhail Naganov | cb000a6 | 2013-01-04 18:02:54 +0000 | [diff] [blame] | 695 | * Sets whether the WebView should enable support for the "viewport" |
| 696 | * HTML meta tag or should use a wide viewport. |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 697 | * When the value of the setting is {@code false}, the layout width is always set to the |
Mikhail Naganov | cb000a6 | 2013-01-04 18:02:54 +0000 | [diff] [blame] | 698 | * width of the WebView control in device-independent (CSS) pixels. |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 699 | * When the value is {@code true} and the page contains the viewport meta tag, the value |
Mikhail Naganov | cb000a6 | 2013-01-04 18:02:54 +0000 | [diff] [blame] | 700 | * of the width specified in the tag is used. If the page does not contain the tag or |
| 701 | * does not provide a width, then a wide viewport will be used. |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 702 | * |
Mikhail Naganov | cb000a6 | 2013-01-04 18:02:54 +0000 | [diff] [blame] | 703 | * @param use whether to enable support for the viewport meta tag |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 704 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 705 | public abstract void setUseWideViewPort(boolean use); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 706 | |
| 707 | /** |
Mikhail Naganov | cb000a6 | 2013-01-04 18:02:54 +0000 | [diff] [blame] | 708 | * Gets whether the WebView supports the "viewport" |
| 709 | * HTML meta tag or will use a wide viewport. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 710 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 711 | * @return {@code true} if the WebView supports the viewport meta tag |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 712 | * @see #setUseWideViewPort |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 713 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 714 | public abstract boolean getUseWideViewPort(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 715 | |
| 716 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 717 | * Sets whether the WebView whether supports multiple windows. If set to |
| 718 | * true, {@link WebChromeClient#onCreateWindow} must be implemented by the |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 719 | * host application. The default is {@code false}. |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 720 | * |
Nate Fischer | 4ea9240 | 2017-11-17 18:48:13 -0800 | [diff] [blame] | 721 | * @param support whether to support multiple windows |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 722 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 723 | public abstract void setSupportMultipleWindows(boolean support); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 724 | |
| 725 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 726 | * Gets whether the WebView supports multiple windows. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 727 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 728 | * @return {@code true} if the WebView supports multiple windows |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 729 | * @see #setSupportMultipleWindows |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 730 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 731 | public abstract boolean supportMultipleWindows(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 732 | |
| 733 | /** |
Nate Fischer | 4ea9240 | 2017-11-17 18:48:13 -0800 | [diff] [blame] | 734 | * Sets the underlying layout algorithm. This will cause a re-layout of the |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 735 | * WebView. The default is {@link LayoutAlgorithm#NARROW_COLUMNS}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 736 | * |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 737 | * @param l the layout algorithm to use, as a {@link LayoutAlgorithm} value |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 738 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 739 | public abstract void setLayoutAlgorithm(LayoutAlgorithm l); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 740 | |
| 741 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 742 | * Gets the current layout algorithm. |
| 743 | * |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 744 | * @return the layout algorithm in use, as a {@link LayoutAlgorithm} value |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 745 | * @see #setLayoutAlgorithm |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 746 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 747 | public abstract LayoutAlgorithm getLayoutAlgorithm(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 748 | |
| 749 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 750 | * Sets the standard font family name. The default is "sans-serif". |
| 751 | * |
| 752 | * @param font a font family name |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 753 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 754 | public abstract void setStandardFontFamily(String font); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 755 | |
| 756 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 757 | * Gets the standard font family name. |
| 758 | * |
| 759 | * @return the standard font family name as a string |
| 760 | * @see #setStandardFontFamily |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 761 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 762 | public abstract String getStandardFontFamily(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 763 | |
| 764 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 765 | * Sets the fixed font family name. The default is "monospace". |
| 766 | * |
| 767 | * @param font a font family name |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 768 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 769 | public abstract void setFixedFontFamily(String font); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 770 | |
| 771 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 772 | * Gets the fixed font family name. |
| 773 | * |
| 774 | * @return the fixed font family name as a string |
| 775 | * @see #setFixedFontFamily |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 776 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 777 | public abstract String getFixedFontFamily(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 778 | |
| 779 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 780 | * Sets the sans-serif font family name. The default is "sans-serif". |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 781 | * |
| 782 | * @param font a font family name |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 783 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 784 | public abstract void setSansSerifFontFamily(String font); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 785 | |
| 786 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 787 | * Gets the sans-serif font family name. |
| 788 | * |
| 789 | * @return the sans-serif font family name as a string |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 790 | * @see #setSansSerifFontFamily |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 791 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 792 | public abstract String getSansSerifFontFamily(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 793 | |
| 794 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 795 | * Sets the serif font family name. The default is "sans-serif". |
| 796 | * |
| 797 | * @param font a font family name |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 798 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 799 | public abstract void setSerifFontFamily(String font); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 800 | |
| 801 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 802 | * Gets the serif font family name. The default is "serif". |
| 803 | * |
| 804 | * @return the serif font family name as a string |
| 805 | * @see #setSerifFontFamily |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 806 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 807 | public abstract String getSerifFontFamily(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 808 | |
| 809 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 810 | * Sets the cursive font family name. The default is "cursive". |
| 811 | * |
| 812 | * @param font a font family name |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 813 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 814 | public abstract void setCursiveFontFamily(String font); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 815 | |
| 816 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 817 | * Gets the cursive font family name. |
| 818 | * |
| 819 | * @return the cursive font family name as a string |
| 820 | * @see #setCursiveFontFamily |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 821 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 822 | public abstract String getCursiveFontFamily(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 823 | |
| 824 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 825 | * Sets the fantasy font family name. The default is "fantasy". |
| 826 | * |
| 827 | * @param font a font family name |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 828 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 829 | public abstract void setFantasyFontFamily(String font); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 830 | |
| 831 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 832 | * Gets the fantasy font family name. |
| 833 | * |
| 834 | * @return the fantasy font family name as a string |
| 835 | * @see #setFantasyFontFamily |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 836 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 837 | public abstract String getFantasyFontFamily(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 838 | |
| 839 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 840 | * Sets the minimum font size. The default is 8. |
| 841 | * |
| 842 | * @param size a non-negative integer between 1 and 72. Any number outside |
| 843 | * the specified range will be pinned. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 844 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 845 | public abstract void setMinimumFontSize(int size); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 846 | |
| 847 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 848 | * Gets the minimum font size. |
| 849 | * |
| 850 | * @return a non-negative integer between 1 and 72 |
| 851 | * @see #setMinimumFontSize |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 852 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 853 | public abstract int getMinimumFontSize(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 854 | |
| 855 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 856 | * Sets the minimum logical font size. The default is 8. |
| 857 | * |
| 858 | * @param size a non-negative integer between 1 and 72. Any number outside |
| 859 | * the specified range will be pinned. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 860 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 861 | public abstract void setMinimumLogicalFontSize(int size); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 862 | |
| 863 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 864 | * Gets the minimum logical font size. |
| 865 | * |
| 866 | * @return a non-negative integer between 1 and 72 |
| 867 | * @see #setMinimumLogicalFontSize |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 868 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 869 | public abstract int getMinimumLogicalFontSize(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 870 | |
| 871 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 872 | * Sets the default font size. The default is 16. |
| 873 | * |
| 874 | * @param size a non-negative integer between 1 and 72. Any number outside |
| 875 | * the specified range will be pinned. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 876 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 877 | public abstract void setDefaultFontSize(int size); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 878 | |
| 879 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 880 | * Gets the default font size. |
| 881 | * |
| 882 | * @return a non-negative integer between 1 and 72 |
| 883 | * @see #setDefaultFontSize |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 884 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 885 | public abstract int getDefaultFontSize(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 886 | |
| 887 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 888 | * Sets the default fixed font size. The default is 16. |
| 889 | * |
| 890 | * @param size a non-negative integer between 1 and 72. Any number outside |
| 891 | * the specified range will be pinned. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 892 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 893 | public abstract void setDefaultFixedFontSize(int size); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 894 | |
| 895 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 896 | * Gets the default fixed font size. |
| 897 | * |
| 898 | * @return a non-negative integer between 1 and 72 |
| 899 | * @see #setDefaultFixedFontSize |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 900 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 901 | public abstract int getDefaultFixedFontSize(); |
Grace Kloba | 097b1e77 | 2009-11-24 14:23:18 -0800 | [diff] [blame] | 902 | |
| 903 | /** |
Mikhail Naganov | 605a491 | 2012-02-03 16:53:10 +0000 | [diff] [blame] | 904 | * Sets whether the WebView should load image resources. Note that this method |
| 905 | * controls loading of all images, including those embedded using the data |
| 906 | * URI scheme. Use {@link #setBlockNetworkImage} to control loading only |
| 907 | * of images specified using network URI schemes. Note that if the value of this |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 908 | * setting is changed from {@code false} to {@code true}, all images resources referenced |
Mikhail Naganov | 605a491 | 2012-02-03 16:53:10 +0000 | [diff] [blame] | 909 | * by content currently displayed by the WebView are loaded automatically. |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 910 | * The default is {@code true}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 911 | * |
| 912 | * @param flag whether the WebView should load image resources |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 913 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 914 | public abstract void setLoadsImagesAutomatically(boolean flag); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 915 | |
| 916 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 917 | * Gets whether the WebView loads image resources. This includes |
| 918 | * images embedded using the data URI scheme. |
| 919 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 920 | * @return {@code true} if the WebView loads image resources |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 921 | * @see #setLoadsImagesAutomatically |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 922 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 923 | public abstract boolean getLoadsImagesAutomatically(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 924 | |
| 925 | /** |
Mikhail Naganov | 605a491 | 2012-02-03 16:53:10 +0000 | [diff] [blame] | 926 | * Sets whether the WebView should not load image resources from the |
| 927 | * network (resources accessed via http and https URI schemes). Note |
| 928 | * that this method has no effect unless |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 929 | * {@link #getLoadsImagesAutomatically} returns {@code true}. Also note that |
Mikhail Naganov | 605a491 | 2012-02-03 16:53:10 +0000 | [diff] [blame] | 930 | * disabling all network loads using {@link #setBlockNetworkLoads} |
| 931 | * will also prevent network images from loading, even if this flag is set |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 932 | * to false. When the value of this setting is changed from {@code true} to {@code false}, |
Mikhail Naganov | 605a491 | 2012-02-03 16:53:10 +0000 | [diff] [blame] | 933 | * network images resources referenced by content currently displayed by |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 934 | * the WebView are fetched automatically. The default is {@code false}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 935 | * |
| 936 | * @param flag whether the WebView should not load image resources from the |
| 937 | * network |
Patrick Scott | f43113f | 2010-02-18 09:13:12 -0500 | [diff] [blame] | 938 | * @see #setBlockNetworkLoads |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 939 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 940 | public abstract void setBlockNetworkImage(boolean flag); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 941 | |
| 942 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 943 | * Gets whether the WebView does not load image resources from the network. |
| 944 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 945 | * @return {@code true} if the WebView does not load image resources from the network |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 946 | * @see #setBlockNetworkImage |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 947 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 948 | public abstract boolean getBlockNetworkImage(); |
Mike Hearn | adcd2ed | 2009-01-21 16:44:36 +0100 | [diff] [blame] | 949 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 950 | /** |
Mikhail Naganov | 605a491 | 2012-02-03 16:53:10 +0000 | [diff] [blame] | 951 | * Sets whether the WebView should not load resources from the network. |
| 952 | * Use {@link #setBlockNetworkImage} to only avoid loading |
| 953 | * image resources. Note that if the value of this setting is |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 954 | * changed from {@code true} to {@code false}, network resources referenced by content |
Mikhail Naganov | 605a491 | 2012-02-03 16:53:10 +0000 | [diff] [blame] | 955 | * currently displayed by the WebView are not fetched until |
| 956 | * {@link android.webkit.WebView#reload} is called. |
| 957 | * If the application does not have the |
| 958 | * {@link android.Manifest.permission#INTERNET} permission, attempts to set |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 959 | * a value of {@code false} will cause a {@link java.lang.SecurityException} |
| 960 | * to be thrown. The default value is {@code false} if the application has the |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 961 | * {@link android.Manifest.permission#INTERNET} permission, otherwise it is |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 962 | * {@code true}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 963 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 964 | * @param flag {@code true} means block network loads by the WebView |
Patrick Scott | f43113f | 2010-02-18 09:13:12 -0500 | [diff] [blame] | 965 | * @see android.webkit.WebView#reload |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 966 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 967 | public abstract void setBlockNetworkLoads(boolean flag); |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 968 | |
| 969 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 970 | * Gets whether the WebView does not load any resources from the network. |
| 971 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 972 | * @return {@code true} if the WebView does not load any resources from the network |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 973 | * @see #setBlockNetworkLoads |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 974 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 975 | public abstract boolean getBlockNetworkLoads(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 976 | |
| 977 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 978 | * Tells the WebView to enable JavaScript execution. |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 979 | * <b>The default is {@code false}.</b> |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 980 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 981 | * @param flag {@code true} if the WebView should execute JavaScript |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 982 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 983 | public abstract void setJavaScriptEnabled(boolean flag); |
Teng-Hui Zhu | da7378e | 2011-02-16 11:25:03 -0800 | [diff] [blame] | 984 | |
| 985 | /** |
Hazem Ashmawy | 7536c2b | 2020-02-20 19:39:27 +0000 | [diff] [blame] | 986 | * Sets whether cross-origin requests in the context of a file scheme URL should be allowed to |
| 987 | * access content from <i>any</i> origin. This includes access to content from other file |
| 988 | * scheme URLs or web contexts. Note that some access such as image HTML elements doesn't |
| 989 | * follow same-origin rules and isn't affected by this setting. |
| 990 | * <p> |
| 991 | * <b>Don't</b> enable this setting if you open files that may be created or altered by |
| 992 | * external sources. Enabling this setting allows malicious scripts loaded in a {@code file://} |
| 993 | * context to launch cross-site scripting attacks, either accessing arbitrary local files |
| 994 | * including WebView cookies, app private data or even credentials used on arbitrary web sites. |
| 995 | * <p class="note"> |
| 996 | * Loading content via {@code file://} URLs is generally discouraged. See the note in |
| 997 | * {@link #setAllowFileAccess}. |
Steve Block | ef16315 | 2012-04-23 18:08:06 +0100 | [diff] [blame] | 998 | * <p> |
Nate Fischer | 8cc1536 | 2018-01-23 16:51:30 -0800 | [diff] [blame] | 999 | * The default value is {@code true} for apps targeting |
Hazem Ashmawy | 7536c2b | 2020-02-20 19:39:27 +0000 | [diff] [blame] | 1000 | * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and below, and {@code false} |
| 1001 | * when targeting {@link android.os.Build.VERSION_CODES#JELLY_BEAN} and above. To prevent |
| 1002 | * possible violation of same domain policy when targeting |
| 1003 | * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and earlier, you should |
| 1004 | * explicitly set this value to {@code false}. |
Selim Gurun | 0ea6dad | 2012-03-29 18:19:01 -0700 | [diff] [blame] | 1005 | * |
Hazem Ashmawy | 7536c2b | 2020-02-20 19:39:27 +0000 | [diff] [blame] | 1006 | * @param flag whether JavaScript running in the context of a file scheme URL should be allowed |
| 1007 | * to access content from any origin |
| 1008 | * @deprecated This setting is not secure, please use |
| 1009 | * <a href="{@docRoot}reference/androidx/webkit/WebViewAssetLoader.html"> |
| 1010 | * androidx.webkit.WebViewAssetLoader</a> to load file content securely. |
Selim Gurun | 0ea6dad | 2012-03-29 18:19:01 -0700 | [diff] [blame] | 1011 | */ |
Hazem Ashmawy | 7536c2b | 2020-02-20 19:39:27 +0000 | [diff] [blame] | 1012 | @Deprecated |
Selim Gurun | 0ea6dad | 2012-03-29 18:19:01 -0700 | [diff] [blame] | 1013 | public abstract void setAllowUniversalAccessFromFileURLs(boolean flag); |
| 1014 | |
| 1015 | /** |
Hazem Ashmawy | 7536c2b | 2020-02-20 19:39:27 +0000 | [diff] [blame] | 1016 | * Sets whether cross-origin requests in the context of a file scheme URL should be allowed to |
| 1017 | * access content from other file scheme URLs. Note that some accesses such as image HTML |
| 1018 | * elements don't follow same-origin rules and aren't affected by this setting. |
Steve Block | ef16315 | 2012-04-23 18:08:06 +0100 | [diff] [blame] | 1019 | * <p> |
Hazem Ashmawy | 7536c2b | 2020-02-20 19:39:27 +0000 | [diff] [blame] | 1020 | * <b>Don't</b> enable this setting if you open files that may be created or altered by |
| 1021 | * external sources. Enabling this setting allows malicious scripts loaded in a {@code file://} |
| 1022 | * context to access arbitrary local files including WebView cookies and app private data. |
| 1023 | * <p class="note"> |
| 1024 | * Loading content via {@code file://} URLs is generally discouraged. See the note in |
| 1025 | * {@link #setAllowFileAccess}. |
| 1026 | * <p> |
| 1027 | * Note that the value of this setting is ignored if the value of |
| 1028 | * {@link #getAllowUniversalAccessFromFileURLs} is {@code true}. The default value is |
| 1029 | * {@code true} for apps targeting {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} |
| 1030 | * and below, and {@code false} when targeting {@link android.os.Build.VERSION_CODES#JELLY_BEAN} |
| 1031 | * and above. To prevent possible violation of same domain policy when targeting |
| 1032 | * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and earlier, you should |
| 1033 | * explicitly set this value to {@code false}. |
Selim Gurun | 0ea6dad | 2012-03-29 18:19:01 -0700 | [diff] [blame] | 1034 | * |
Steve Block | ef16315 | 2012-04-23 18:08:06 +0100 | [diff] [blame] | 1035 | * @param flag whether JavaScript running in the context of a file scheme |
| 1036 | * URL should be allowed to access content from other file |
| 1037 | * scheme URLs |
Hazem Ashmawy | 7536c2b | 2020-02-20 19:39:27 +0000 | [diff] [blame] | 1038 | * @deprecated This setting is not secure, please use |
| 1039 | * <a href="{@docRoot}reference/androidx/webkit/WebViewAssetLoader.html"> |
| 1040 | * androidx.webkit.WebViewAssetLoader</a> to load file content securely. |
Selim Gurun | 0ea6dad | 2012-03-29 18:19:01 -0700 | [diff] [blame] | 1041 | */ |
Hazem Ashmawy | 7536c2b | 2020-02-20 19:39:27 +0000 | [diff] [blame] | 1042 | @Deprecated |
Selim Gurun | 0ea6dad | 2012-03-29 18:19:01 -0700 | [diff] [blame] | 1043 | public abstract void setAllowFileAccessFromFileURLs(boolean flag); |
| 1044 | |
| 1045 | /** |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1046 | * Sets whether the WebView should enable plugins. The default is {@code false}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1047 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1048 | * @param flag {@code true} if plugins should be enabled |
Patrick Scott | 300f2e9 | 2010-03-22 10:20:45 -0400 | [diff] [blame] | 1049 | * @deprecated This method has been deprecated in favor of |
| 1050 | * {@link #setPluginState} |
Jonathan Dixon | 0bf4781 | 2013-03-07 17:20:08 -0800 | [diff] [blame] | 1051 | * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1052 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1053 | @SystemApi |
Michael Kolb | a172e7d | 2010-06-30 12:35:26 -0700 | [diff] [blame] | 1054 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1055 | public abstract void setPluginsEnabled(boolean flag); |
Patrick Scott | 300f2e9 | 2010-03-22 10:20:45 -0400 | [diff] [blame] | 1056 | |
| 1057 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1058 | * Tells the WebView to enable, disable, or have plugins on demand. On |
Patrick Scott | 300f2e9 | 2010-03-22 10:20:45 -0400 | [diff] [blame] | 1059 | * demand mode means that if a plugin exists that can handle the embedded |
| 1060 | * content, a placeholder icon will be shown instead of the plugin. When |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1061 | * the placeholder is clicked, the plugin will be enabled. The default is |
| 1062 | * {@link PluginState#OFF}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1063 | * |
| 1064 | * @param state a PluginState value |
Torne (Richard Coles) | 1676c95 | 2018-06-28 19:33:27 -0400 | [diff] [blame] | 1065 | * @deprecated Plugins are not supported in API level |
| 1066 | * {@link android.os.Build.VERSION_CODES#KITKAT} or later; |
| 1067 | * enabling plugins is a no-op. |
Patrick Scott | 300f2e9 | 2010-03-22 10:20:45 -0400 | [diff] [blame] | 1068 | */ |
Jonathan Dixon | 835b1fc | 2013-02-25 12:29:33 -0800 | [diff] [blame] | 1069 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1070 | public abstract void setPluginState(PluginState state); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1071 | |
| 1072 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1073 | * Sets a custom path to plugins used by the WebView. This method is |
Derek Sollenberger | fdbdeb3 | 2010-08-12 11:20:13 -0400 | [diff] [blame] | 1074 | * obsolete since each plugin is now loaded from its own package. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1075 | * |
| 1076 | * @param pluginsPath a String path to the directory containing plugins |
Derek Sollenberger | fdbdeb3 | 2010-08-12 11:20:13 -0400 | [diff] [blame] | 1077 | * @deprecated This method is no longer used as plugins are loaded from |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1078 | * their own APK via the system's package manager. |
Jonathan Dixon | 0bf4781 | 2013-03-07 17:20:08 -0800 | [diff] [blame] | 1079 | * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1080 | */ |
Jason Chen | 9dc2e75 | 2010-09-01 19:11:14 -0700 | [diff] [blame] | 1081 | @Deprecated |
Mathew Inwood | 62d83fb | 2018-08-16 19:09:48 +0100 | [diff] [blame] | 1082 | @UnsupportedAppUsage |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1083 | public void setPluginsPath(String pluginsPath) { |
Jonathan Dixon | 3c90952 | 2012-02-28 18:45:06 +0000 | [diff] [blame] | 1084 | // Specified to do nothing, so no need for derived classes to override. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1085 | } |
| 1086 | |
| 1087 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1088 | * Sets the path to where database storage API databases should be saved. |
Steve Block | 72ca7a4 | 2012-06-13 22:00:30 +0100 | [diff] [blame] | 1089 | * In order for the database storage API to function correctly, this method |
| 1090 | * must be called with a path to which the application can write. This |
| 1091 | * method should only be called once: repeated calls are ignored. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1092 | * |
Steve Block | 72ca7a4 | 2012-06-13 22:00:30 +0100 | [diff] [blame] | 1093 | * @param databasePath a path to the directory where databases should be |
| 1094 | * saved. |
Jonathan Dixon | 5545d08 | 2013-08-31 22:43:11 -0700 | [diff] [blame] | 1095 | * @deprecated Database paths are managed by the implementation and calling this method |
| 1096 | * will have no effect. |
Ben Murdoch | 7df1985 | 2009-04-22 13:07:58 +0100 | [diff] [blame] | 1097 | */ |
Jonathan Dixon | 5545d08 | 2013-08-31 22:43:11 -0700 | [diff] [blame] | 1098 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1099 | public abstract void setDatabasePath(String databasePath); |
Ben Murdoch | 7df1985 | 2009-04-22 13:07:58 +0100 | [diff] [blame] | 1100 | |
| 1101 | /** |
Steve Block | 72ca7a4 | 2012-06-13 22:00:30 +0100 | [diff] [blame] | 1102 | * Sets the path where the Geolocation databases should be saved. In order |
| 1103 | * for Geolocation permissions and cached positions to be persisted, this |
| 1104 | * method must be called with a path to which the application can write. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1105 | * |
Steve Block | 72ca7a4 | 2012-06-13 22:00:30 +0100 | [diff] [blame] | 1106 | * @param databasePath a path to the directory where databases should be |
| 1107 | * saved. |
Hui Shu | 89eb9b4 | 2016-01-07 11:32:23 -0800 | [diff] [blame] | 1108 | * @deprecated Geolocation database are managed by the implementation and calling this method |
| 1109 | * will have no effect. |
Steve Block | 9d3273f | 2009-08-21 13:16:27 +0100 | [diff] [blame] | 1110 | */ |
Hui Shu | 89eb9b4 | 2016-01-07 11:32:23 -0800 | [diff] [blame] | 1111 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1112 | public abstract void setGeolocationDatabasePath(String databasePath); |
Steve Block | 9d3273f | 2009-08-21 13:16:27 +0100 | [diff] [blame] | 1113 | |
| 1114 | /** |
Steve Block | 72ca7a4 | 2012-06-13 22:00:30 +0100 | [diff] [blame] | 1115 | * Sets whether the Application Caches API should be enabled. The default |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1116 | * is {@code false}. Note that in order for the Application Caches API to be |
Steve Block | 72ca7a4 | 2012-06-13 22:00:30 +0100 | [diff] [blame] | 1117 | * enabled, a valid database path must also be supplied to |
| 1118 | * {@link #setAppCachePath}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1119 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1120 | * @param flag {@code true} if the WebView should enable Application Caches |
Torne (Richard Coles) | 76752c8 | 2020-05-11 14:58:53 -0400 | [diff] [blame] | 1121 | * @deprecated The Application Cache API is deprecated and this method will |
| 1122 | * become a no-op on all Android versions once support is |
| 1123 | * removed in Chromium. Consider using Service Workers instead. |
Andrei Popescu | 60a9a7d | 2009-04-17 10:43:42 +0100 | [diff] [blame] | 1124 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1125 | public abstract void setAppCacheEnabled(boolean flag); |
Andrei Popescu | 60a9a7d | 2009-04-17 10:43:42 +0100 | [diff] [blame] | 1126 | |
| 1127 | /** |
Steve Block | 72ca7a4 | 2012-06-13 22:00:30 +0100 | [diff] [blame] | 1128 | * Sets the path to the Application Caches files. In order for the |
| 1129 | * Application Caches API to be enabled, this method must be called with a |
| 1130 | * path to which the application can write. This method should only be |
| 1131 | * called once: repeated calls are ignored. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1132 | * |
| 1133 | * @param appCachePath a String path to the directory containing |
Steve Block | 72ca7a4 | 2012-06-13 22:00:30 +0100 | [diff] [blame] | 1134 | * Application Caches files. |
Jonathan Dixon | 47aaba3 | 2012-11-30 16:32:17 -0800 | [diff] [blame] | 1135 | * @see #setAppCacheEnabled |
Torne (Richard Coles) | 76752c8 | 2020-05-11 14:58:53 -0400 | [diff] [blame] | 1136 | * @deprecated The Application Cache API is deprecated and this method will |
| 1137 | * become a no-op on all Android versions once support is |
| 1138 | * removed in Chromium. Consider using Service Workers instead. |
Andrei Popescu | 60a9a7d | 2009-04-17 10:43:42 +0100 | [diff] [blame] | 1139 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1140 | public abstract void setAppCachePath(String appCachePath); |
Andrei Popescu | 60a9a7d | 2009-04-17 10:43:42 +0100 | [diff] [blame] | 1141 | |
| 1142 | /** |
Selim Gurun | b632adf | 2012-06-28 11:21:05 -0700 | [diff] [blame] | 1143 | * Sets the maximum size for the Application Cache content. The passed size |
| 1144 | * will be rounded to the nearest value that the database can support, so |
| 1145 | * this should be viewed as a guide, not a hard limit. Setting the |
| 1146 | * size to a value less than current database size does not cause the |
Selim Gurun | f27ac09 | 2012-06-28 11:21:05 -0700 | [diff] [blame] | 1147 | * database to be trimmed. The default size is {@link Long#MAX_VALUE}. |
Jonathan Dixon | 835b1fc | 2013-02-25 12:29:33 -0800 | [diff] [blame] | 1148 | * It is recommended to leave the maximum size set to the default value. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1149 | * |
| 1150 | * @param appCacheMaxSize the maximum size in bytes |
Torne (Richard Coles) | 76752c8 | 2020-05-11 14:58:53 -0400 | [diff] [blame] | 1151 | * @deprecated Quota is managed automatically; this method is a no-op. |
Andrei Popescu | 1c82920 | 2009-07-22 16:47:52 +0100 | [diff] [blame] | 1152 | */ |
Jonathan Dixon | 835b1fc | 2013-02-25 12:29:33 -0800 | [diff] [blame] | 1153 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1154 | public abstract void setAppCacheMaxSize(long appCacheMaxSize); |
Andrei Popescu | 1c82920 | 2009-07-22 16:47:52 +0100 | [diff] [blame] | 1155 | |
| 1156 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1157 | * Sets whether the database storage API is enabled. The default value is |
| 1158 | * false. See also {@link #setDatabasePath} for how to correctly set up the |
| 1159 | * database storage API. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1160 | * |
Selim Gurun | 2bca22b | 2013-02-28 17:47:21 -0800 | [diff] [blame] | 1161 | * This setting is global in effect, across all WebView instances in a process. |
| 1162 | * Note you should only modify this setting prior to making <b>any</b> WebView |
| 1163 | * page load within a given process, as the WebView implementation may ignore |
| 1164 | * changes to this setting after that point. |
| 1165 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1166 | * @param flag {@code true} if the WebView should use the database storage API |
Ben Murdoch | 7df1985 | 2009-04-22 13:07:58 +0100 | [diff] [blame] | 1167 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1168 | public abstract void setDatabaseEnabled(boolean flag); |
Ben Murdoch | 7df1985 | 2009-04-22 13:07:58 +0100 | [diff] [blame] | 1169 | |
| 1170 | /** |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1171 | * Sets whether the DOM storage API is enabled. The default value is {@code false}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1172 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1173 | * @param flag {@code true} if the WebView should use the DOM storage API |
Ben Murdoch | 274680d | 2009-05-28 13:44:44 +0100 | [diff] [blame] | 1174 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1175 | public abstract void setDomStorageEnabled(boolean flag); |
Ben Murdoch | 274680d | 2009-05-28 13:44:44 +0100 | [diff] [blame] | 1176 | |
| 1177 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1178 | * Gets whether the DOM Storage APIs are enabled. |
| 1179 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1180 | * @return {@code true} if the DOM Storage APIs are enabled |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1181 | * @see #setDomStorageEnabled |
Ben Murdoch | 274680d | 2009-05-28 13:44:44 +0100 | [diff] [blame] | 1182 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1183 | public abstract boolean getDomStorageEnabled(); |
| 1184 | |
Ben Murdoch | 274680d | 2009-05-28 13:44:44 +0100 | [diff] [blame] | 1185 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1186 | * Gets the path to where database storage API databases are saved. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1187 | * |
| 1188 | * @return the String path to the database storage API databases |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1189 | * @see #setDatabasePath |
Jonathan Dixon | 5545d08 | 2013-08-31 22:43:11 -0700 | [diff] [blame] | 1190 | * @deprecated Database paths are managed by the implementation this method is obsolete. |
Ben Murdoch | 7df1985 | 2009-04-22 13:07:58 +0100 | [diff] [blame] | 1191 | */ |
Jonathan Dixon | 5545d08 | 2013-08-31 22:43:11 -0700 | [diff] [blame] | 1192 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1193 | public abstract String getDatabasePath(); |
Ben Murdoch | 7df1985 | 2009-04-22 13:07:58 +0100 | [diff] [blame] | 1194 | |
| 1195 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1196 | * Gets whether the database storage API is enabled. |
| 1197 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1198 | * @return {@code true} if the database storage API is enabled |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1199 | * @see #setDatabaseEnabled |
Ben Murdoch | 7df1985 | 2009-04-22 13:07:58 +0100 | [diff] [blame] | 1200 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1201 | public abstract boolean getDatabaseEnabled(); |
Andrei Popescu | c27a9ac | 2009-08-03 15:59:24 +0100 | [diff] [blame] | 1202 | |
| 1203 | /** |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1204 | * Sets whether Geolocation is enabled. The default is {@code true}. |
Mikhail Naganov | 6cb296a | 2012-08-28 16:57:24 +0100 | [diff] [blame] | 1205 | * <p> |
| 1206 | * Please note that in order for the Geolocation API to be usable |
| 1207 | * by a page in the WebView, the following requirements must be met: |
| 1208 | * <ul> |
| 1209 | * <li>an application must have permission to access the device location, |
| 1210 | * see {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}, |
| 1211 | * {@link android.Manifest.permission#ACCESS_FINE_LOCATION}; |
| 1212 | * <li>an application must provide an implementation of the |
| 1213 | * {@link WebChromeClient#onGeolocationPermissionsShowPrompt} callback |
| 1214 | * to receive notifications that a page is requesting access to location |
| 1215 | * via the JavaScript Geolocation API. |
| 1216 | * </ul> |
| 1217 | * <p> |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1218 | * |
| 1219 | * @param flag whether Geolocation should be enabled |
Steve Block | 06cd751 | 2009-08-21 10:26:37 +0100 | [diff] [blame] | 1220 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1221 | public abstract void setGeolocationEnabled(boolean flag); |
Elliott Slaughter | 5dc0c82 | 2010-06-22 11:31:54 -0700 | [diff] [blame] | 1222 | |
| 1223 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1224 | * Gets whether JavaScript is enabled. |
| 1225 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1226 | * @return {@code true} if JavaScript is enabled |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1227 | * @see #setJavaScriptEnabled |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1228 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1229 | public abstract boolean getJavaScriptEnabled(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1230 | |
| 1231 | /** |
Steve Block | ef16315 | 2012-04-23 18:08:06 +0100 | [diff] [blame] | 1232 | * Gets whether JavaScript running in the context of a file scheme URL can |
| 1233 | * access content from any origin. This includes access to content from |
| 1234 | * other file scheme URLs. |
Selim Gurun | 0ea6dad | 2012-03-29 18:19:01 -0700 | [diff] [blame] | 1235 | * |
Steve Block | ef16315 | 2012-04-23 18:08:06 +0100 | [diff] [blame] | 1236 | * @return whether JavaScript running in the context of a file scheme URL |
| 1237 | * can access content from any origin |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1238 | * @see #setAllowUniversalAccessFromFileURLs |
Selim Gurun | 0ea6dad | 2012-03-29 18:19:01 -0700 | [diff] [blame] | 1239 | */ |
| 1240 | public abstract boolean getAllowUniversalAccessFromFileURLs(); |
| 1241 | |
| 1242 | /** |
Steve Block | ef16315 | 2012-04-23 18:08:06 +0100 | [diff] [blame] | 1243 | * Gets whether JavaScript running in the context of a file scheme URL can |
| 1244 | * access content from other file scheme URLs. |
Selim Gurun | 0ea6dad | 2012-03-29 18:19:01 -0700 | [diff] [blame] | 1245 | * |
Steve Block | ef16315 | 2012-04-23 18:08:06 +0100 | [diff] [blame] | 1246 | * @return whether JavaScript running in the context of a file scheme URL |
| 1247 | * can access content from other file scheme URLs |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1248 | * @see #setAllowFileAccessFromFileURLs |
Selim Gurun | 0ea6dad | 2012-03-29 18:19:01 -0700 | [diff] [blame] | 1249 | */ |
| 1250 | public abstract boolean getAllowFileAccessFromFileURLs(); |
| 1251 | |
| 1252 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1253 | * Gets whether plugins are enabled. |
| 1254 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1255 | * @return {@code true} if plugins are enabled |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1256 | * @see #setPluginsEnabled |
Patrick Scott | 300f2e9 | 2010-03-22 10:20:45 -0400 | [diff] [blame] | 1257 | * @deprecated This method has been replaced by {@link #getPluginState} |
Jonathan Dixon | 0bf4781 | 2013-03-07 17:20:08 -0800 | [diff] [blame] | 1258 | * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1259 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1260 | @SystemApi |
Michael Kolb | a172e7d | 2010-06-30 12:35:26 -0700 | [diff] [blame] | 1261 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1262 | public abstract boolean getPluginsEnabled(); |
Patrick Scott | 300f2e9 | 2010-03-22 10:20:45 -0400 | [diff] [blame] | 1263 | |
| 1264 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1265 | * Gets the current state regarding whether plugins are enabled. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1266 | * |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1267 | * @return the plugin state as a {@link PluginState} value |
| 1268 | * @see #setPluginState |
Torne (Richard Coles) | 1676c95 | 2018-06-28 19:33:27 -0400 | [diff] [blame] | 1269 | * @deprecated Plugins are not supported in API level |
| 1270 | * {@link android.os.Build.VERSION_CODES#KITKAT} or later; |
| 1271 | * enabling plugins is a no-op. |
Patrick Scott | 300f2e9 | 2010-03-22 10:20:45 -0400 | [diff] [blame] | 1272 | */ |
Jonathan Dixon | 835b1fc | 2013-02-25 12:29:33 -0800 | [diff] [blame] | 1273 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1274 | public abstract PluginState getPluginState(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1275 | |
| 1276 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1277 | * Gets the directory that contains the plugin libraries. This method is |
Derek Sollenberger | fdbdeb3 | 2010-08-12 11:20:13 -0400 | [diff] [blame] | 1278 | * obsolete since each plugin is now loaded from its own package. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1279 | * |
| 1280 | * @return an empty string |
Derek Sollenberger | fdbdeb3 | 2010-08-12 11:20:13 -0400 | [diff] [blame] | 1281 | * @deprecated This method is no longer used as plugins are loaded from |
| 1282 | * their own APK via the system's package manager. |
Jonathan Dixon | 0bf4781 | 2013-03-07 17:20:08 -0800 | [diff] [blame] | 1283 | * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2} |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1284 | */ |
Jason Chen | 9dc2e75 | 2010-09-01 19:11:14 -0700 | [diff] [blame] | 1285 | @Deprecated |
Mathew Inwood | 62d83fb | 2018-08-16 19:09:48 +0100 | [diff] [blame] | 1286 | @UnsupportedAppUsage |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1287 | public String getPluginsPath() { |
Jonathan Dixon | 3c90952 | 2012-02-28 18:45:06 +0000 | [diff] [blame] | 1288 | // Unconditionally returns empty string, so no need for derived classes to override. |
Grace Kloba | 658ab7d | 2009-05-14 14:45:26 -0700 | [diff] [blame] | 1289 | return ""; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1290 | } |
| 1291 | |
| 1292 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1293 | * Tells JavaScript to open windows automatically. This applies to the |
Nate Fischer | 4ea9240 | 2017-11-17 18:48:13 -0800 | [diff] [blame] | 1294 | * JavaScript function {@code window.open()}. The default is {@code false}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1295 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1296 | * @param flag {@code true} if JavaScript can open windows automatically |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1297 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1298 | public abstract void setJavaScriptCanOpenWindowsAutomatically(boolean flag); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1299 | |
| 1300 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1301 | * Gets whether JavaScript can open windows automatically. |
| 1302 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1303 | * @return {@code true} if JavaScript can open windows automatically during |
Nate Fischer | 4ea9240 | 2017-11-17 18:48:13 -0800 | [diff] [blame] | 1304 | * {@code window.open()} |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1305 | * @see #setJavaScriptCanOpenWindowsAutomatically |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1306 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1307 | public abstract boolean getJavaScriptCanOpenWindowsAutomatically(); |
Marcin Kosiba | fd1ac83 | 2014-10-10 17:12:49 +0100 | [diff] [blame] | 1308 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1309 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1310 | * Sets the default text encoding name to use when decoding html pages. |
Marcin Kosiba | fd1ac83 | 2014-10-10 17:12:49 +0100 | [diff] [blame] | 1311 | * The default is "UTF-8". |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1312 | * |
| 1313 | * @param encoding the text encoding name |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1314 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1315 | public abstract void setDefaultTextEncodingName(String encoding); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1316 | |
| 1317 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1318 | * Gets the default text encoding name. |
| 1319 | * |
| 1320 | * @return the default text encoding name as a string |
| 1321 | * @see #setDefaultTextEncodingName |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1322 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1323 | public abstract String getDefaultTextEncodingName(); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1324 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 1325 | /** |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1326 | * Sets the WebView's user-agent string. If the string is {@code null} or empty, |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1327 | * the system default value will be used. |
Mikhail Naganov | 550f621 | 2015-07-07 13:39:31 -0700 | [diff] [blame] | 1328 | * |
| 1329 | * Note that starting from {@link android.os.Build.VERSION_CODES#KITKAT} Android |
| 1330 | * version, changing the user-agent while loading a web page causes WebView |
| 1331 | * to initiate loading once again. |
| 1332 | * |
| 1333 | * @param ua new user-agent string |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 1334 | */ |
Nate Fischer | 3442c74 | 2017-09-08 17:02:00 -0700 | [diff] [blame] | 1335 | public abstract void setUserAgentString(@Nullable String ua); |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 1336 | |
| 1337 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1338 | * Gets the WebView's user-agent string. |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1339 | * |
| 1340 | * @return the WebView's user-agent string |
| 1341 | * @see #setUserAgentString |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 1342 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1343 | public abstract String getUserAgentString(); |
Shimeng (Simon) Wang | c55886a | 2010-10-28 13:46:02 -0700 | [diff] [blame] | 1344 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1345 | /** |
George Mount | 9f410c5 | 2012-08-10 15:29:30 -0700 | [diff] [blame] | 1346 | * Returns the default User-Agent used by a WebView. |
| 1347 | * An instance of WebView could use a different User-Agent if a call |
Kristian Monsen | f491258 | 2012-08-16 15:26:24 -0400 | [diff] [blame] | 1348 | * is made to {@link WebSettings#setUserAgentString(String)}. |
George Mount | 9f410c5 | 2012-08-10 15:29:30 -0700 | [diff] [blame] | 1349 | * |
| 1350 | * @param context a Context object used to access application assets |
| 1351 | */ |
| 1352 | public static String getDefaultUserAgent(Context context) { |
Jonathan Dixon | d1c4faa | 2012-08-20 16:37:15 -0700 | [diff] [blame] | 1353 | return WebViewFactory.getProvider().getStatics().getDefaultUserAgent(context); |
George Mount | 9f410c5 | 2012-08-10 15:29:30 -0700 | [diff] [blame] | 1354 | } |
| 1355 | |
| 1356 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1357 | * Tells the WebView whether it needs to set a node to have focus when |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1358 | * {@link WebView#requestFocus(int, android.graphics.Rect)} is called. The |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1359 | * default value is {@code true}. |
Michael Kolb | a172e7d | 2010-06-30 12:35:26 -0700 | [diff] [blame] | 1360 | * |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1361 | * @param flag whether the WebView needs to set a node |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1362 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1363 | public abstract void setNeedInitialFocus(boolean flag); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1364 | |
| 1365 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1366 | * Sets the priority of the Render thread. Unlike the other settings, this |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1367 | * one only needs to be called once per process. The default value is |
| 1368 | * {@link RenderPriority#NORMAL}. |
Mike Hearn | adcd2ed | 2009-01-21 16:44:36 +0100 | [diff] [blame] | 1369 | * |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1370 | * @param priority the priority |
Jonathan Dixon | 835b1fc | 2013-02-25 12:29:33 -0800 | [diff] [blame] | 1371 | * @deprecated It is not recommended to adjust thread priorities, and this will |
| 1372 | * not be supported in future versions. |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1373 | */ |
Jonathan Dixon | 835b1fc | 2013-02-25 12:29:33 -0800 | [diff] [blame] | 1374 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1375 | public abstract void setRenderPriority(RenderPriority priority); |
Michael Kolb | a172e7d | 2010-06-30 12:35:26 -0700 | [diff] [blame] | 1376 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1377 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1378 | * Overrides the way the cache is used. The way the cache is used is based |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1379 | * on the navigation type. For a normal page load, the cache is checked |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1380 | * and content is re-validated as needed. When navigating back, content is |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1381 | * not revalidated, instead the content is just retrieved from the cache. |
| 1382 | * This method allows the client to override this behavior by specifying |
Mikhail Naganov | 56936a1 | 2012-07-25 13:07:18 +0100 | [diff] [blame] | 1383 | * one of {@link #LOAD_DEFAULT}, |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1384 | * {@link #LOAD_CACHE_ELSE_NETWORK}, {@link #LOAD_NO_CACHE} or |
| 1385 | * {@link #LOAD_CACHE_ONLY}. The default value is {@link #LOAD_DEFAULT}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 1386 | * |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1387 | * @param mode the mode to use |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1388 | */ |
Tim Volodine | b90f538 | 2016-04-29 12:44:41 +0100 | [diff] [blame] | 1389 | public abstract void setCacheMode(@CacheMode int mode); |
Michael Kolb | a172e7d | 2010-06-30 12:35:26 -0700 | [diff] [blame] | 1390 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1391 | /** |
Steve Block | b0e0f33 | 2012-06-13 22:01:11 +0100 | [diff] [blame] | 1392 | * Gets the current setting for overriding the cache mode. |
| 1393 | * |
| 1394 | * @return the current setting for overriding the cache mode |
| 1395 | * @see #setCacheMode |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1396 | */ |
Tim Volodine | b90f538 | 2016-04-29 12:44:41 +0100 | [diff] [blame] | 1397 | @CacheMode |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 1398 | public abstract int getCacheMode(); |
Ben Murdoch | fe9fc3d | 2014-04-10 15:31:06 +0100 | [diff] [blame] | 1399 | |
| 1400 | /** |
| 1401 | * Configures the WebView's behavior when a secure origin attempts to load a resource from an |
| 1402 | * insecure origin. |
| 1403 | * |
| 1404 | * By default, apps that target {@link android.os.Build.VERSION_CODES#KITKAT} or below default |
| 1405 | * to {@link #MIXED_CONTENT_ALWAYS_ALLOW}. Apps targeting |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 1406 | * {@link android.os.Build.VERSION_CODES#LOLLIPOP} default to {@link #MIXED_CONTENT_NEVER_ALLOW}. |
Ben Murdoch | fe9fc3d | 2014-04-10 15:31:06 +0100 | [diff] [blame] | 1407 | * |
| 1408 | * The preferred and most secure mode of operation for the WebView is |
| 1409 | * {@link #MIXED_CONTENT_NEVER_ALLOW} and use of {@link #MIXED_CONTENT_ALWAYS_ALLOW} is |
| 1410 | * strongly discouraged. |
| 1411 | * |
| 1412 | * @param mode The mixed content mode to use. One of {@link #MIXED_CONTENT_NEVER_ALLOW}, |
Torne (Richard Coles) | 2b666c9 | 2015-03-06 14:20:00 +0000 | [diff] [blame] | 1413 | * {@link #MIXED_CONTENT_ALWAYS_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}. |
Ben Murdoch | fe9fc3d | 2014-04-10 15:31:06 +0100 | [diff] [blame] | 1414 | */ |
| 1415 | public abstract void setMixedContentMode(int mode); |
| 1416 | |
| 1417 | /** |
| 1418 | * Gets the current behavior of the WebView with regard to loading insecure content from a |
| 1419 | * secure origin. |
| 1420 | * @return The current setting, one of {@link #MIXED_CONTENT_NEVER_ALLOW}, |
Torne (Richard Coles) | 2b666c9 | 2015-03-06 14:20:00 +0000 | [diff] [blame] | 1421 | * {@link #MIXED_CONTENT_ALWAYS_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}. |
Ben Murdoch | fe9fc3d | 2014-04-10 15:31:06 +0100 | [diff] [blame] | 1422 | */ |
| 1423 | public abstract int getMixedContentMode(); |
Yuncheol Heo | 4d07c48 | 2014-05-07 17:29:35 +0900 | [diff] [blame] | 1424 | |
| 1425 | /** |
| 1426 | * Sets whether to use a video overlay for embedded encrypted video. |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 1427 | * In API levels prior to {@link android.os.Build.VERSION_CODES#LOLLIPOP}, encrypted video can |
Yuncheol Heo | 4d07c48 | 2014-05-07 17:29:35 +0900 | [diff] [blame] | 1428 | * only be rendered directly on a secure video surface, so it had been a hard problem to play |
| 1429 | * encrypted video in HTML. When this flag is on, WebView can play encrypted video (MSE/EME) |
| 1430 | * by using a video overlay (aka hole-punching) for videos embedded using HTML <video> |
| 1431 | * tag.<br> |
| 1432 | * Caution: This setting is intended for use only in a narrow set of circumstances and apps |
| 1433 | * should only enable it if they require playback of encrypted video content. It will impose |
| 1434 | * the following limitations on the WebView: |
| 1435 | * <ul> |
| 1436 | * <li> Only one video overlay can be played at a time. |
| 1437 | * <li> Changes made to position or dimensions of a video element may be propagated to the |
| 1438 | * corresponding video overlay with a noticeable delay. |
| 1439 | * <li> The video overlay is not visible to web APIs and as such may not interact with |
| 1440 | * script or styling. For example, CSS styles applied to the <video> tag may be ignored. |
| 1441 | * </ul> |
| 1442 | * This is not an exhaustive set of constraints and it may vary with new versions of the |
| 1443 | * WebView. |
| 1444 | * @hide |
| 1445 | */ |
Yuncheol Heo | eeba025 | 2014-07-08 19:43:00 +0900 | [diff] [blame] | 1446 | @SystemApi |
Yuncheol Heo | 4d07c48 | 2014-05-07 17:29:35 +0900 | [diff] [blame] | 1447 | public abstract void setVideoOverlayForEmbeddedEncryptedVideoEnabled(boolean flag); |
| 1448 | |
| 1449 | /** |
| 1450 | * Gets whether a video overlay will be used for embedded encrypted video. |
| 1451 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1452 | * @return {@code true} if WebView uses a video overlay for embedded encrypted video. |
Yuncheol Heo | 4d07c48 | 2014-05-07 17:29:35 +0900 | [diff] [blame] | 1453 | * @see #setVideoOverlayForEmbeddedEncryptedVideoEnabled |
| 1454 | * @hide |
| 1455 | */ |
Yuncheol Heo | eeba025 | 2014-07-08 19:43:00 +0900 | [diff] [blame] | 1456 | @SystemApi |
Yuncheol Heo | 4d07c48 | 2014-05-07 17:29:35 +0900 | [diff] [blame] | 1457 | public abstract boolean getVideoOverlayForEmbeddedEncryptedVideoEnabled(); |
Hui Shu | b1ee70b | 2015-03-03 11:38:41 -0800 | [diff] [blame] | 1458 | |
| 1459 | /** |
| 1460 | * Sets whether this WebView should raster tiles when it is |
| 1461 | * offscreen but attached to a window. Turning this on can avoid |
| 1462 | * rendering artifacts when animating an offscreen WebView on-screen. |
| 1463 | * Offscreen WebViews in this mode use more memory. The default value is |
Hui Shu | d377c0f | 2015-05-13 12:01:42 -0700 | [diff] [blame] | 1464 | * false.<br> |
Hui Shu | b1ee70b | 2015-03-03 11:38:41 -0800 | [diff] [blame] | 1465 | * Please follow these guidelines to limit memory usage: |
Hui Shu | d377c0f | 2015-05-13 12:01:42 -0700 | [diff] [blame] | 1466 | * <ul> |
| 1467 | * <li> WebView size should be not be larger than the device screen size. |
| 1468 | * <li> Limit use of this mode to a small number of WebViews. Use it for |
Hui Shu | b1ee70b | 2015-03-03 11:38:41 -0800 | [diff] [blame] | 1469 | * visible WebViews and WebViews about to be animated to visible. |
Hui Shu | d377c0f | 2015-05-13 12:01:42 -0700 | [diff] [blame] | 1470 | * </ul> |
Hui Shu | b1ee70b | 2015-03-03 11:38:41 -0800 | [diff] [blame] | 1471 | */ |
| 1472 | public abstract void setOffscreenPreRaster(boolean enabled); |
| 1473 | |
| 1474 | /** |
| 1475 | * Gets whether this WebView should raster tiles when it is |
| 1476 | * offscreen but attached to a window. |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 1477 | * @return {@code true} if this WebView will raster tiles when it is |
Hui Shu | b1ee70b | 2015-03-03 11:38:41 -0800 | [diff] [blame] | 1478 | * offscreen but attached to a window. |
| 1479 | */ |
| 1480 | public abstract boolean getOffscreenPreRaster(); |
Hui Shu | 227a8c1 | 2015-10-22 14:57:51 -0700 | [diff] [blame] | 1481 | |
Selim Gurun | ec0a1f2 | 2017-04-07 18:21:46 -0700 | [diff] [blame] | 1482 | |
| 1483 | /** |
Nate Fischer | fb92ee1 | 2018-01-18 12:01:19 -0800 | [diff] [blame] | 1484 | * Sets whether Safe Browsing is enabled. Safe Browsing allows WebView to |
Selim Gurun | ec0a1f2 | 2017-04-07 18:21:46 -0700 | [diff] [blame] | 1485 | * protect against malware and phishing attacks by verifying the links. |
| 1486 | * |
Selim Gurun | ec0a1f2 | 2017-04-07 18:21:46 -0700 | [diff] [blame] | 1487 | * <p> |
Nate Fischer | fb92ee1 | 2018-01-18 12:01:19 -0800 | [diff] [blame] | 1488 | * Safe Browsing can be disabled for all WebViews using a manifest tag (read <a |
| 1489 | * href="{@docRoot}reference/android/webkit/WebView.html">general Safe Browsing info</a>). The |
| 1490 | * manifest tag has a lower precedence than this API. |
Selim Gurun | ec0a1f2 | 2017-04-07 18:21:46 -0700 | [diff] [blame] | 1491 | * |
Nate Fischer | 471891d | 2017-07-18 19:15:52 -0700 | [diff] [blame] | 1492 | * <p> |
Nate Fischer | fb92ee1 | 2018-01-18 12:01:19 -0800 | [diff] [blame] | 1493 | * Safe Browsing is enabled by default for devices which support it. |
Selim Gurun | ec0a1f2 | 2017-04-07 18:21:46 -0700 | [diff] [blame] | 1494 | * |
Nate Fischer | fb92ee1 | 2018-01-18 12:01:19 -0800 | [diff] [blame] | 1495 | * @param enabled Whether Safe Browsing is enabled. |
Selim Gurun | ec0a1f2 | 2017-04-07 18:21:46 -0700 | [diff] [blame] | 1496 | */ |
| 1497 | public abstract void setSafeBrowsingEnabled(boolean enabled); |
| 1498 | |
| 1499 | /** |
Nate Fischer | fb92ee1 | 2018-01-18 12:01:19 -0800 | [diff] [blame] | 1500 | * Gets whether Safe Browsing is enabled. |
Selim Gurun | ec0a1f2 | 2017-04-07 18:21:46 -0700 | [diff] [blame] | 1501 | * See {@link #setSafeBrowsingEnabled}. |
| 1502 | * |
Nate Fischer | fb92ee1 | 2018-01-18 12:01:19 -0800 | [diff] [blame] | 1503 | * @return {@code true} if Safe Browsing is enabled and {@code false} otherwise. |
Selim Gurun | ec0a1f2 | 2017-04-07 18:21:46 -0700 | [diff] [blame] | 1504 | */ |
| 1505 | public abstract boolean getSafeBrowsingEnabled(); |
| 1506 | |
| 1507 | |
Hui Shu | 227a8c1 | 2015-10-22 14:57:51 -0700 | [diff] [blame] | 1508 | /** |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 1509 | * Set the force dark mode for this WebView. |
Tobias Sargeant | e1fc791 | 2019-03-19 12:16:22 +0000 | [diff] [blame] | 1510 | * |
| 1511 | * @param forceDark the force dark mode to set. |
Anna Malova | 7374ce1 | 2019-09-25 12:19:27 +0100 | [diff] [blame] | 1512 | * @see #getForceDark |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 1513 | */ |
Tobias Sargeant | bbb043a | 2019-03-11 10:14:28 +0000 | [diff] [blame] | 1514 | public void setForceDark(@ForceDark int forceDark) { |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 1515 | // Stub implementation to satisfy Roboelectrc shadows that don't override this yet. |
| 1516 | } |
| 1517 | |
| 1518 | /** |
| 1519 | * Get the force dark mode for this WebView. |
Anna Malova | 7374ce1 | 2019-09-25 12:19:27 +0100 | [diff] [blame] | 1520 | * The default force dark mode is {@link #FORCE_DARK_AUTO}. |
Tobias Sargeant | e1fc791 | 2019-03-19 12:16:22 +0000 | [diff] [blame] | 1521 | * |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 1522 | * @return the currently set force dark mode. |
Anna Malova | 7374ce1 | 2019-09-25 12:19:27 +0100 | [diff] [blame] | 1523 | * @see #setForceDark |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 1524 | */ |
Tobias Sargeant | bbb043a | 2019-03-11 10:14:28 +0000 | [diff] [blame] | 1525 | public @ForceDark int getForceDark() { |
Tobias Sargeant | fec405a3 | 2018-12-06 15:22:18 +0000 | [diff] [blame] | 1526 | // Stub implementation to satisfy Roboelectrc shadows that don't override this yet. |
| 1527 | return FORCE_DARK_AUTO; |
| 1528 | } |
| 1529 | |
| 1530 | /** |
Hui Shu | 539b077 | 2016-04-20 15:21:37 -0700 | [diff] [blame] | 1531 | * @hide |
| 1532 | */ |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 1533 | @IntDef(flag = true, prefix = { "MENU_ITEM_" }, value = { |
| 1534 | MENU_ITEM_NONE, |
| 1535 | MENU_ITEM_SHARE, |
| 1536 | MENU_ITEM_WEB_SEARCH, |
| 1537 | MENU_ITEM_PROCESS_TEXT |
| 1538 | }) |
Hui Shu | 539b077 | 2016-04-20 15:21:37 -0700 | [diff] [blame] | 1539 | @Retention(RetentionPolicy.SOURCE) |
| 1540 | @Target({ElementType.PARAMETER, ElementType.METHOD}) |
| 1541 | private @interface MenuItemFlags {} |
| 1542 | |
| 1543 | /** |
Hui Shu | 227a8c1 | 2015-10-22 14:57:51 -0700 | [diff] [blame] | 1544 | * Disables the action mode menu items according to {@code menuItems} flag. |
| 1545 | * @param menuItems an integer field flag for the menu items to be disabled. |
| 1546 | */ |
Hui Shu | 539b077 | 2016-04-20 15:21:37 -0700 | [diff] [blame] | 1547 | public abstract void setDisabledActionModeMenuItems(@MenuItemFlags int menuItems); |
Hui Shu | 227a8c1 | 2015-10-22 14:57:51 -0700 | [diff] [blame] | 1548 | |
| 1549 | /** |
| 1550 | * Gets the action mode menu items that are disabled, expressed in an integer field flag. |
| 1551 | * The default value is {@link #MENU_ITEM_NONE} |
| 1552 | * |
Hui Shu | 539b077 | 2016-04-20 15:21:37 -0700 | [diff] [blame] | 1553 | * @return all the disabled menu item flags combined with bitwise OR. |
Hui Shu | 227a8c1 | 2015-10-22 14:57:51 -0700 | [diff] [blame] | 1554 | */ |
Hui Shu | 539b077 | 2016-04-20 15:21:37 -0700 | [diff] [blame] | 1555 | public abstract @MenuItemFlags int getDisabledActionModeMenuItems(); |
Hui Shu | 227a8c1 | 2015-10-22 14:57:51 -0700 | [diff] [blame] | 1556 | |
| 1557 | /** |
Hui Shu | 227a8c1 | 2015-10-22 14:57:51 -0700 | [diff] [blame] | 1558 | * No menu items should be disabled. |
Anna Malova | 7374ce1 | 2019-09-25 12:19:27 +0100 | [diff] [blame] | 1559 | * |
| 1560 | * @see #setDisabledActionModeMenuItems |
Hui Shu | 227a8c1 | 2015-10-22 14:57:51 -0700 | [diff] [blame] | 1561 | */ |
| 1562 | public static final int MENU_ITEM_NONE = 0; |
| 1563 | |
| 1564 | /** |
Hui Shu | 227a8c1 | 2015-10-22 14:57:51 -0700 | [diff] [blame] | 1565 | * Disable menu item "Share". |
Anna Malova | 7374ce1 | 2019-09-25 12:19:27 +0100 | [diff] [blame] | 1566 | * |
| 1567 | * @see #setDisabledActionModeMenuItems |
Hui Shu | 227a8c1 | 2015-10-22 14:57:51 -0700 | [diff] [blame] | 1568 | */ |
| 1569 | public static final int MENU_ITEM_SHARE = 1 << 0; |
| 1570 | |
| 1571 | /** |
Hui Shu | 227a8c1 | 2015-10-22 14:57:51 -0700 | [diff] [blame] | 1572 | * Disable menu item "Web Search". |
Anna Malova | 7374ce1 | 2019-09-25 12:19:27 +0100 | [diff] [blame] | 1573 | * |
| 1574 | * @see #setDisabledActionModeMenuItems |
Hui Shu | 227a8c1 | 2015-10-22 14:57:51 -0700 | [diff] [blame] | 1575 | */ |
| 1576 | public static final int MENU_ITEM_WEB_SEARCH = 1 << 1; |
| 1577 | |
| 1578 | /** |
Hui Shu | 227a8c1 | 2015-10-22 14:57:51 -0700 | [diff] [blame] | 1579 | * Disable all the action mode menu items for text processing. |
| 1580 | * By default WebView searches for activities that are able to handle |
| 1581 | * {@link android.content.Intent#ACTION_PROCESS_TEXT} and show them in the |
| 1582 | * action mode menu. If this flag is set via {@link |
| 1583 | * #setDisabledActionModeMenuItems}, these menu items will be disabled. |
Anna Malova | 7374ce1 | 2019-09-25 12:19:27 +0100 | [diff] [blame] | 1584 | * |
| 1585 | * @see #setDisabledActionModeMenuItems |
Hui Shu | 227a8c1 | 2015-10-22 14:57:51 -0700 | [diff] [blame] | 1586 | */ |
| 1587 | public static final int MENU_ITEM_PROCESS_TEXT = 1 << 2; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1588 | } |