2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.webkit;
19 import android.content.Context;
22 * Manages settings state for a WebView. When a WebView is first created, it
23 * obtains a set of default settings. These default settings will be returned
24 * from any getter call. A WebSettings object obtained from
25 * WebView.getSettings() is tied to the life of the WebView. If a WebView has
26 * been destroyed, any method call on WebSettings will throw an
27 * IllegalStateException.
29 // This is an abstract base class: concrete WebViewProviders must
30 // create a class derived from this, and return an instance of it in the
31 // WebViewProvider.getWebSettingsProvider() method implementation.
32 public abstract class WebSettings {
34 * Enum for controlling the layout of html.
36 * <li>NORMAL means no rendering changes.</li>
37 * <li>SINGLE_COLUMN moves all content into one column that is the width of the
39 * <li>NARROW_COLUMNS makes all columns no wider than the screen if possible.</li>
42 // XXX: These must match LayoutAlgorithm in Settings.h in WebCore.
43 public enum LayoutAlgorithm {
46 * @deprecated This algorithm is now obsolete.
54 * Enum for specifying the text size.
56 * <li>SMALLEST is 50%</li>
57 * <li>SMALLER is 75%</li>
58 * <li>NORMAL is 100%</li>
59 * <li>LARGER is 150%</li>
60 * <li>LARGEST is 200%</li>
63 * @deprecated Use {@link WebSettings#setTextZoom(int)} and {@link WebSettings#getTextZoom()} instead.
65 public enum TextSize {
76 * @hide Only for use by WebViewProvider implementations
78 public int getValue() {
86 * Enum for specifying the WebView's desired density.
88 * <li>FAR makes 100% looking like in 240dpi</li>
89 * <li>MEDIUM makes 100% looking like in 160dpi</li>
90 * <li>CLOSE makes 100% looking like in 120dpi</li>
93 public enum ZoomDensity {
95 MEDIUM(100), // 160dpi
97 ZoomDensity(int size) {
102 * @hide Only for use by WebViewProvider implementations
104 public int getValue() {
112 * Default cache usage mode. If the navigation type doesn't impose any
113 * specific behavior, use cached resources when they are available
114 * and not expired, otherwise load resources from the network.
115 * Use with {@link #setCacheMode}.
117 public static final int LOAD_DEFAULT = -1;
120 * Normal cache usage mode. Use with {@link #setCacheMode}.
122 * @deprecated This value is obsolete, as from API level
123 * {@link android.os.Build.VERSION_CODES#HONEYCOMB} and onwards it has the
124 * same effect as {@link #LOAD_DEFAULT}.
127 public static final int LOAD_NORMAL = 0;
130 * Use cached resources when they are available, even if they have expired.
131 * Otherwise load resources from the network.
132 * Use with {@link #setCacheMode}.
134 public static final int LOAD_CACHE_ELSE_NETWORK = 1;
137 * Don't use the cache, load from the network.
138 * Use with {@link #setCacheMode}.
140 public static final int LOAD_NO_CACHE = 2;
143 * Don't use the network, load from the cache.
144 * Use with {@link #setCacheMode}.
146 public static final int LOAD_CACHE_ONLY = 3;
148 public enum RenderPriority {
155 * The plugin state effects how plugins are treated on a page. ON means
156 * that any object will be loaded even if a plugin does not exist to handle
157 * the content. ON_DEMAND means that if there is a plugin installed that
158 * can handle the content, a placeholder is shown until the user clicks on
159 * the placeholder. Once clicked, the plugin will be enabled on the page.
160 * OFF means that all plugins will be turned off and any fallback content
163 public enum PluginState {
170 * Hidden constructor to prevent clients from creating a new settings
171 * instance or deriving the class.
175 protected WebSettings() {
179 * Enables dumping the pages navigation cache to a text file. The default
182 * @deprecated This method is now obsolete.
183 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
186 public void setNavDump(boolean enabled) {
187 throw new MustOverrideException();
191 * Gets whether dumping the navigation cache is enabled.
193 * @return whether dumping the navigation cache is enabled
195 * @deprecated This method is now obsolete.
196 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
199 public boolean getNavDump() {
200 throw new MustOverrideException();
204 * Sets whether the WebView should support zooming using its on-screen zoom
205 * controls and gestures. The particular zoom mechanisms that should be used
206 * can be set with {@link #setBuiltInZoomControls}. This setting does not
207 * affect zooming performed using the {@link WebView#zoomIn()} and
208 * {@link WebView#zoomOut()} methods. The default is true.
210 * @param support whether the WebView should support zoom
212 public void setSupportZoom(boolean support) {
213 throw new MustOverrideException();
217 * Gets whether the WebView supports zoom.
219 * @return true if the WebView supports zoom
220 * @see #setSupportZoom
222 public boolean supportZoom() {
223 throw new MustOverrideException();
227 * Sets whether the WebView requires a user gesture to play media.
228 * The default is true.
230 * @param require whether the WebView requires a user gesture to play media
232 public void setMediaPlaybackRequiresUserGesture(boolean require) {
233 throw new MustOverrideException();
237 * Gets whether the WebView requires a user gesture to play media.
239 * @return true if the WebView requires a user gesture to play media
240 * @see #setMediaPlaybackRequiresUserGesture
242 public boolean getMediaPlaybackRequiresUserGesture() {
243 throw new MustOverrideException();
247 * Sets whether the WebView should use its built-in zoom mechanisms. The
248 * built-in zoom mechanisms comprise on-screen zoom controls, which are
249 * displayed over the WebView's content, and the use of a pinch gesture to
250 * control zooming. Whether or not these on-screen controls are displayed
251 * can be set with {@link #setDisplayZoomControls}. The default is false.
253 * The built-in mechanisms are the only currently supported zoom
254 * mechanisms, so it is recommended that this setting is always enabled.
256 * @param enabled whether the WebView should use its built-in zoom mechanisms
258 // This method was intended to select between the built-in zoom mechanisms
259 // and the separate zoom controls. The latter were obtained using
260 // {@link WebView#getZoomControls}, which is now hidden.
261 public void setBuiltInZoomControls(boolean enabled) {
262 throw new MustOverrideException();
266 * Gets whether the zoom mechanisms built into WebView are being used.
268 * @return true if the zoom mechanisms built into WebView are being used
269 * @see #setBuiltInZoomControls
271 public boolean getBuiltInZoomControls() {
272 throw new MustOverrideException();
276 * Sets whether the WebView should display on-screen zoom controls when
277 * using the built-in zoom mechanisms. See {@link #setBuiltInZoomControls}.
278 * The default is true.
280 * @param enabled whether the WebView should display on-screen zoom controls
282 public void setDisplayZoomControls(boolean enabled) {
283 throw new MustOverrideException();
287 * Gets whether the WebView displays on-screen zoom controls when using
288 * the built-in zoom mechanisms.
290 * @return true if the WebView displays on-screen zoom controls when using
291 * the built-in zoom mechanisms
292 * @see #setDisplayZoomControls
294 public boolean getDisplayZoomControls() {
295 throw new MustOverrideException();
299 * Enables or disables file access within WebView. File access is enabled by
300 * default. Note that this enables or disables file system access only.
301 * Assets and resources are still accessible using file:///android_asset and
302 * file:///android_res.
304 public void setAllowFileAccess(boolean allow) {
305 throw new MustOverrideException();
309 * Gets whether this WebView supports file access.
311 * @see #setAllowFileAccess
313 public boolean getAllowFileAccess() {
314 throw new MustOverrideException();
318 * Enables or disables content URL access within WebView. Content URL
319 * access allows WebView to load content from a content provider installed
320 * in the system. The default is enabled.
322 public void setAllowContentAccess(boolean allow) {
323 throw new MustOverrideException();
327 * Gets whether this WebView supports content URL access.
329 * @see #setAllowContentAccess
331 public boolean getAllowContentAccess() {
332 throw new MustOverrideException();
336 * Sets whether the WebView loads pages in overview mode. The default is
339 public void setLoadWithOverviewMode(boolean overview) {
340 throw new MustOverrideException();
344 * Gets whether this WebView loads pages in overview mode.
346 * @return whether this WebView loads pages in overview mode
347 * @see #setLoadWithOverviewMode
349 public boolean getLoadWithOverviewMode() {
350 throw new MustOverrideException();
354 * Sets whether the WebView will enable smooth transition while panning or
355 * zooming or while the window hosting the WebView does not have focus.
356 * If it is true, WebView will choose a solution to maximize the performance.
357 * e.g. the WebView's content may not be updated during the transition.
358 * If it is false, WebView will keep its fidelity. The default value is false.
360 * @deprecated This method is now obsolete, and will become a no-op in future.
363 public void setEnableSmoothTransition(boolean enable) {
364 throw new MustOverrideException();
368 * Gets whether the WebView enables smooth transition while panning or
371 * @see #setEnableSmoothTransition
373 * @deprecated This method is now obsolete, and will become a no-op in future.
376 public boolean enableSmoothTransition() {
377 throw new MustOverrideException();
381 * Sets whether the WebView uses its background for over scroll background.
382 * If true, it will use the WebView's background. If false, it will use an
383 * internal pattern. Default is true.
385 * @deprecated This method is now obsolete.
386 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
389 public void setUseWebViewBackgroundForOverscrollBackground(boolean view) {
390 throw new MustOverrideException();
394 * Gets whether this WebView uses WebView's background instead of
395 * internal pattern for over scroll background.
397 * @see #setUseWebViewBackgroundForOverscrollBackground
398 * @deprecated This method is now obsolete.
399 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
402 public boolean getUseWebViewBackgroundForOverscrollBackground() {
403 throw new MustOverrideException();
407 * Sets whether the WebView should save form data. The default is true,
408 * unless in private browsing mode, when the value is always false.
410 public void setSaveFormData(boolean save) {
411 throw new MustOverrideException();
415 * Gets whether the WebView saves form data. Always false in private
418 * @return whether the WebView saves form data
419 * @see #setSaveFormData
421 public boolean getSaveFormData() {
422 throw new MustOverrideException();
426 * Sets whether the WebView should save passwords. The default is true.
428 public void setSavePassword(boolean save) {
429 throw new MustOverrideException();
433 * Gets whether the WebView saves passwords.
435 * @return whether the WebView saves passwords
436 * @see #setSavePassword
438 public boolean getSavePassword() {
439 throw new MustOverrideException();
443 * Sets the text zoom of the page in percent. The default is 100.
445 * @param textZoom the text zoom in percent
447 public synchronized void setTextZoom(int textZoom) {
448 throw new MustOverrideException();
452 * Gets the text zoom of the page in percent.
454 * @return the text zoom of the page in percent
457 public synchronized int getTextZoom() {
458 throw new MustOverrideException();
462 * Sets the text size of the page. The default is {@link TextSize#NORMAL}.
464 * @param t the text size as a {@link TextSize} value
465 * @deprecated Use {@link #setTextZoom} instead.
467 public synchronized void setTextSize(TextSize t) {
468 setTextZoom(t.value);
472 * Gets the text size of the page. If the text size was previously specified
473 * in percent using {@link #setTextZoom}, this will return the closest
474 * matching {@link TextSize}.
476 * @return the text size as a {@link TextSize} value
478 * @deprecated Use {@link #getTextZoom} instead.
480 public synchronized TextSize getTextSize() {
481 TextSize closestSize = null;
482 int smallestDelta = Integer.MAX_VALUE;
483 int textSize = getTextZoom();
484 for (TextSize size : TextSize.values()) {
485 int delta = Math.abs(textSize - size.value);
489 if (delta < smallestDelta) {
490 smallestDelta = delta;
494 return closestSize != null ? closestSize : TextSize.NORMAL;
498 * Sets the default zoom density of the page. This must be called from the UI
499 * thread. The default is {@link ZoomDensity#MEDIUM}.
501 * @param zoom the zoom density
503 public void setDefaultZoom(ZoomDensity zoom) {
504 throw new MustOverrideException();
508 * Gets the default zoom density of the page. This should be called from
511 * @return the zoom density
512 * @see #setDefaultZoom
514 public ZoomDensity getDefaultZoom() {
515 throw new MustOverrideException();
519 * Enables using light touches to make a selection and activate mouseovers.
520 * The default is false.
522 public void setLightTouchEnabled(boolean enabled) {
523 throw new MustOverrideException();
527 * Gets whether light touches are enabled.
529 * @return whether light touches are enabled
530 * @see #setLightTouchEnabled
532 public boolean getLightTouchEnabled() {
533 throw new MustOverrideException();
537 * Controlled a rendering optimization that is no longer present. Setting
538 * it now has no effect.
540 * @deprecated This setting now has no effect.
541 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
544 public synchronized void setUseDoubleTree(boolean use) {
545 // Specified to do nothing, so no need for derived classes to override.
549 * Controlled a rendering optimization that is no longer present. Setting
550 * it now has no effect.
552 * @deprecated This setting now has no effect.
553 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
556 public synchronized boolean getUseDoubleTree() {
557 // Returns false unconditionally, so no need for derived classes to override.
562 * Sets the user-agent string using an integer code.
564 * <li>0 means the WebView should use an Android user-agent string</li>
565 * <li>1 means the WebView should use a desktop user-agent string</li>
567 * Other values are ignored. The default is an Android user-agent string,
570 * @param ua the integer code for the user-agent string
571 * @deprecated Please use {@link #setUserAgentString} instead.
572 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
575 public synchronized void setUserAgent(int ua) {
576 throw new MustOverrideException();
580 * Gets the user-agent as an integer code.
582 * <li>-1 means the WebView is using a custom user-agent string set with
583 * {@link #setUserAgentString}</li>
584 * <li>0 means the WebView should use an Android user-agent string</li>
585 * <li>1 means the WebView should use a desktop user-agent string</li>
588 * @return the integer code for the user-agent string
590 * @deprecated Please use {@link #getUserAgentString} instead.
591 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
594 public synchronized int getUserAgent() {
595 throw new MustOverrideException();
599 * Tells the WebView to use a wide viewport. The default is false.
601 * @param use whether to use a wide viewport
603 public synchronized void setUseWideViewPort(boolean use) {
604 throw new MustOverrideException();
608 * Gets whether the WebView is using a wide viewport.
610 * @return true if the WebView is using a wide viewport
611 * @see #setUseWideViewPort
613 public synchronized boolean getUseWideViewPort() {
614 throw new MustOverrideException();
618 * Sets whether the WebView whether supports multiple windows. If set to
619 * true, {@link WebChromeClient#onCreateWindow} must be implemented by the
620 * host application. The default is false.
622 * @param support whether to suport multiple windows
624 public synchronized void setSupportMultipleWindows(boolean support) {
625 throw new MustOverrideException();
629 * Gets whether the WebView supports multiple windows.
631 * @return true if the WebView supports multiple windows
632 * @see #setSupportMultipleWindows
634 public synchronized boolean supportMultipleWindows() {
635 throw new MustOverrideException();
639 * Sets the underlying layout algorithm. This will cause a relayout of the
640 * WebView. The default is {@link LayoutAlgorithm#NARROW_COLUMNS}.
642 * @param l the layout algorithm to use, as a {@link LayoutAlgorithm} value
644 public synchronized void setLayoutAlgorithm(LayoutAlgorithm l) {
645 throw new MustOverrideException();
649 * Gets the current layout algorithm.
651 * @return the layout algorithm in use, as a {@link LayoutAlgorithm} value
652 * @see #setLayoutAlgorithm
654 public synchronized LayoutAlgorithm getLayoutAlgorithm() {
655 throw new MustOverrideException();
659 * Sets the standard font family name. The default is "sans-serif".
661 * @param font a font family name
663 public synchronized void setStandardFontFamily(String font) {
664 throw new MustOverrideException();
668 * Gets the standard font family name.
670 * @return the standard font family name as a string
671 * @see #setStandardFontFamily
673 public synchronized String getStandardFontFamily() {
674 throw new MustOverrideException();
678 * Sets the fixed font family name. The default is "monospace".
680 * @param font a font family name
682 public synchronized void setFixedFontFamily(String font) {
683 throw new MustOverrideException();
687 * Gets the fixed font family name.
689 * @return the fixed font family name as a string
690 * @see #setFixedFontFamily
692 public synchronized String getFixedFontFamily() {
693 throw new MustOverrideException();
697 * Sets the sans-serif font family name. The default is "sans-serif".
699 * @param font a font family name
701 public synchronized void setSansSerifFontFamily(String font) {
702 throw new MustOverrideException();
706 * Gets the sans-serif font family name.
708 * @return the sans-serif font family name as a string
709 * @see #setSansSerifFontFamily
711 public synchronized String getSansSerifFontFamily() {
712 throw new MustOverrideException();
716 * Sets the serif font family name. The default is "sans-serif".
718 * @param font a font family name
720 public synchronized void setSerifFontFamily(String font) {
721 throw new MustOverrideException();
725 * Gets the serif font family name. The default is "serif".
727 * @return the serif font family name as a string
728 * @see #setSerifFontFamily
730 public synchronized String getSerifFontFamily() {
731 throw new MustOverrideException();
735 * Sets the cursive font family name. The default is "cursive".
737 * @param font a font family name
739 public synchronized void setCursiveFontFamily(String font) {
740 throw new MustOverrideException();
744 * Gets the cursive font family name.
746 * @return the cursive font family name as a string
747 * @see #setCursiveFontFamily
749 public synchronized String getCursiveFontFamily() {
750 throw new MustOverrideException();
754 * Sets the fantasy font family name. The default is "fantasy".
756 * @param font a font family name
758 public synchronized void setFantasyFontFamily(String font) {
759 throw new MustOverrideException();
763 * Gets the fantasy font family name.
765 * @return the fantasy font family name as a string
766 * @see #setFantasyFontFamily
768 public synchronized String getFantasyFontFamily() {
769 throw new MustOverrideException();
773 * Sets the minimum font size. The default is 8.
775 * @param size a non-negative integer between 1 and 72. Any number outside
776 * the specified range will be pinned.
778 public synchronized void setMinimumFontSize(int size) {
779 throw new MustOverrideException();
783 * Gets the minimum font size.
785 * @return a non-negative integer between 1 and 72
786 * @see #setMinimumFontSize
788 public synchronized int getMinimumFontSize() {
789 throw new MustOverrideException();
793 * Sets the minimum logical font size. The default is 8.
795 * @param size a non-negative integer between 1 and 72. Any number outside
796 * the specified range will be pinned.
798 public synchronized void setMinimumLogicalFontSize(int size) {
799 throw new MustOverrideException();
803 * Gets the minimum logical font size.
805 * @return a non-negative integer between 1 and 72
806 * @see #setMinimumLogicalFontSize
808 public synchronized int getMinimumLogicalFontSize() {
809 throw new MustOverrideException();
813 * Sets the default font size. The default is 16.
815 * @param size a non-negative integer between 1 and 72. Any number outside
816 * the specified range will be pinned.
818 public synchronized void setDefaultFontSize(int size) {
819 throw new MustOverrideException();
823 * Gets the default font size.
825 * @return a non-negative integer between 1 and 72
826 * @see #setDefaultFontSize
828 public synchronized int getDefaultFontSize() {
829 throw new MustOverrideException();
833 * Sets the default fixed font size. The default is 16.
835 * @param size a non-negative integer between 1 and 72. Any number outside
836 * the specified range will be pinned.
838 public synchronized void setDefaultFixedFontSize(int size) {
839 throw new MustOverrideException();
843 * Gets the default fixed font size.
845 * @return a non-negative integer between 1 and 72
846 * @see #setDefaultFixedFontSize
848 public synchronized int getDefaultFixedFontSize() {
849 throw new MustOverrideException();
853 * Sets whether the WebView should load image resources. Note that this method
854 * controls loading of all images, including those embedded using the data
855 * URI scheme. Use {@link #setBlockNetworkImage} to control loading only
856 * of images specified using network URI schemes. Note that if the value of this
857 * setting is changed from false to true, all images resources referenced
858 * by content currently displayed by the WebView are loaded automatically.
859 * The default is true.
861 * @param flag whether the WebView should load image resources
863 public synchronized void setLoadsImagesAutomatically(boolean flag) {
864 throw new MustOverrideException();
868 * Gets whether the WebView loads image resources. This includes
869 * images embedded using the data URI scheme.
871 * @return true if the WebView loads image resources
872 * @see #setLoadsImagesAutomatically
874 public synchronized boolean getLoadsImagesAutomatically() {
875 throw new MustOverrideException();
879 * Sets whether the WebView should not load image resources from the
880 * network (resources accessed via http and https URI schemes). Note
881 * that this method has no effect unless
882 * {@link #getLoadsImagesAutomatically} returns true. Also note that
883 * disabling all network loads using {@link #setBlockNetworkLoads}
884 * will also prevent network images from loading, even if this flag is set
885 * to false. When the value of this setting is changed from true to false,
886 * network images resources referenced by content currently displayed by
887 * the WebView are fetched automatically. The default is false.
889 * @param flag whether the WebView should not load image resources from the
891 * @see #setBlockNetworkLoads
893 public synchronized void setBlockNetworkImage(boolean flag) {
894 throw new MustOverrideException();
898 * Gets whether the WebView does not load image resources from the network.
900 * @return true if the WebView does not load image resources from the network
901 * @see #setBlockNetworkImage
903 public synchronized boolean getBlockNetworkImage() {
904 throw new MustOverrideException();
908 * Sets whether the WebView should not load resources from the network.
909 * Use {@link #setBlockNetworkImage} to only avoid loading
910 * image resources. Note that if the value of this setting is
911 * changed from true to false, network resources referenced by content
912 * currently displayed by the WebView are not fetched until
913 * {@link android.webkit.WebView#reload} is called.
914 * If the application does not have the
915 * {@link android.Manifest.permission#INTERNET} permission, attempts to set
916 * a value of false will cause a {@link java.lang.SecurityException}
917 * to be thrown. The default value is false if the application has the
918 * {@link android.Manifest.permission#INTERNET} permission, otherwise it is
921 * @param flag whether the WebView should not load any resources from the
923 * @see android.webkit.WebView#reload
925 public synchronized void setBlockNetworkLoads(boolean flag) {
926 throw new MustOverrideException();
930 * Gets whether the WebView does not load any resources from the network.
932 * @return true if the WebView does not load any resources from the network
933 * @see #setBlockNetworkLoads
935 public synchronized boolean getBlockNetworkLoads() {
936 throw new MustOverrideException();
940 * Tells the WebView to enable JavaScript execution.
941 * <b>The default is false.</b>
943 * @param flag true if the WebView should execute JavaScript
945 public synchronized void setJavaScriptEnabled(boolean flag) {
946 throw new MustOverrideException();
950 * Sets whether JavaScript running in the context of a file scheme URL
951 * should be allowed to access content from any origin. This includes
952 * access to content from other file scheme URLs. See
953 * {@link #setAllowFileAccessFromFileURLs}. To enable the most restrictive,
954 * and therefore secure policy, this setting should be disabled.
956 * The default value is true for API level
957 * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and below,
958 * and false for API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN}
961 * @param flag whether JavaScript running in the context of a file scheme
962 * URL should be allowed to access content from any origin
964 public abstract void setAllowUniversalAccessFromFileURLs(boolean flag);
967 * Sets whether JavaScript running in the context of a file scheme URL
968 * should be allowed to access content from other file scheme URLs. To
969 * enable the most restrictive, and therefore secure policy, this setting
970 * should be disabled. Note that the value of this setting is ignored if
971 * the value of {@link #getAllowUniversalAccessFromFileURLs} is true.
973 * The default value is true for API level
974 * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and below,
975 * and false for API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN}
978 * @param flag whether JavaScript running in the context of a file scheme
979 * URL should be allowed to access content from other file
982 public abstract void setAllowFileAccessFromFileURLs(boolean flag);
985 * Sets whether the WebView should enable plugins. The default is false.
987 * @param flag true if plugins should be enabled
988 * @deprecated This method has been deprecated in favor of
989 * {@link #setPluginState}
992 public synchronized void setPluginsEnabled(boolean flag) {
993 throw new MustOverrideException();
997 * Tells the WebView to enable, disable, or have plugins on demand. On
998 * demand mode means that if a plugin exists that can handle the embedded
999 * content, a placeholder icon will be shown instead of the plugin. When
1000 * the placeholder is clicked, the plugin will be enabled. The default is
1001 * {@link PluginState#OFF}.
1003 * @param state a PluginState value
1005 public synchronized void setPluginState(PluginState state) {
1006 throw new MustOverrideException();
1010 * Sets a custom path to plugins used by the WebView. This method is
1011 * obsolete since each plugin is now loaded from its own package.
1013 * @param pluginsPath a String path to the directory containing plugins
1014 * @deprecated This method is no longer used as plugins are loaded from
1015 * their own APK via the system's package manager.
1018 public synchronized void setPluginsPath(String pluginsPath) {
1019 // Specified to do nothing, so no need for derived classes to override.
1023 * Sets the path to where database storage API databases should be saved.
1024 * In order for the database storage API to function correctly, this method
1025 * must be called with a path to which the application can write. This
1026 * method should only be called once: repeated calls are ignored.
1028 * @param databasePath a path to the directory where databases should be
1031 // This will update WebCore when the Sync runs in the C++ side.
1032 // Note that the WebCore Database Tracker only allows the path to be set
1034 public synchronized void setDatabasePath(String databasePath) {
1035 throw new MustOverrideException();
1039 * Sets the path where the Geolocation databases should be saved. In order
1040 * for Geolocation permissions and cached positions to be persisted, this
1041 * method must be called with a path to which the application can write.
1043 * @param databasePath a path to the directory where databases should be
1046 // This will update WebCore when the Sync runs in the C++ side.
1047 public synchronized void setGeolocationDatabasePath(String databasePath) {
1048 throw new MustOverrideException();
1052 * Sets whether the Application Caches API should be enabled. The default
1053 * is false. Note that in order for the Application Caches API to be
1054 * enabled, a valid database path must also be supplied to
1055 * {@link #setAppCachePath}.
1057 * @param flag true if the WebView should enable Application Caches
1059 public synchronized void setAppCacheEnabled(boolean flag) {
1060 throw new MustOverrideException();
1064 * Sets the path to the Application Caches files. In order for the
1065 * Application Caches API to be enabled, this method must be called with a
1066 * path to which the application can write. This method should only be
1067 * called once: repeated calls are ignored.
1069 * @param appCachePath a String path to the directory containing
1070 * Application Caches files.
1071 * @see setAppCacheEnabled
1073 public synchronized void setAppCachePath(String appCachePath) {
1074 throw new MustOverrideException();
1078 * Sets the maximum size for the Application Cache content. The passed size
1079 * will be rounded to the nearest value that the database can support, so
1080 * this should be viewed as a guide, not a hard limit. Setting the
1081 * size to a value less than current database size does not cause the
1082 * database to be trimmed. The default size is {@link Long#MAX_VALUE}.
1084 * @param appCacheMaxSize the maximum size in bytes
1086 public synchronized void setAppCacheMaxSize(long appCacheMaxSize) {
1087 throw new MustOverrideException();
1091 * Sets whether the database storage API is enabled. The default value is
1092 * false. See also {@link #setDatabasePath} for how to correctly set up the
1093 * database storage API.
1095 * @param flag true if the WebView should use the database storage API
1097 public synchronized void setDatabaseEnabled(boolean flag) {
1098 throw new MustOverrideException();
1102 * Sets whether the DOM storage API is enabled. The default value is false.
1104 * @param flag true if the WebView should use the DOM storage API
1106 public synchronized void setDomStorageEnabled(boolean flag) {
1107 throw new MustOverrideException();
1111 * Gets whether the DOM Storage APIs are enabled.
1113 * @return true if the DOM Storage APIs are enabled
1114 * @see #setDomStorageEnabled
1116 public synchronized boolean getDomStorageEnabled() {
1117 throw new MustOverrideException();
1120 * Gets the path to where database storage API databases are saved.
1122 * @return the String path to the database storage API databases
1123 * @see #setDatabasePath
1125 public synchronized String getDatabasePath() {
1126 throw new MustOverrideException();
1130 * Gets whether the database storage API is enabled.
1132 * @return true if the database storage API is enabled
1133 * @see #setDatabaseEnabled
1135 public synchronized boolean getDatabaseEnabled() {
1136 throw new MustOverrideException();
1140 * Sets whether Geolocation is enabled. The default is true. See also
1141 * {@link #setGeolocationDatabasePath} for how to correctly set up
1144 * @param flag whether Geolocation should be enabled
1146 public synchronized void setGeolocationEnabled(boolean flag) {
1147 throw new MustOverrideException();
1151 * Gets whether JavaScript is enabled.
1153 * @return true if JavaScript is enabled
1154 * @see #setJavaScriptEnabled
1156 public synchronized boolean getJavaScriptEnabled() {
1157 throw new MustOverrideException();
1161 * Gets whether JavaScript running in the context of a file scheme URL can
1162 * access content from any origin. This includes access to content from
1163 * other file scheme URLs.
1165 * @return whether JavaScript running in the context of a file scheme URL
1166 * can access content from any origin
1167 * @see #setAllowUniversalAccessFromFileURLs
1169 public abstract boolean getAllowUniversalAccessFromFileURLs();
1172 * Gets whether JavaScript running in the context of a file scheme URL can
1173 * access content from other file scheme URLs.
1175 * @return whether JavaScript running in the context of a file scheme URL
1176 * can access content from other file scheme URLs
1177 * @see #setAllowFileAccessFromFileURLs
1179 public abstract boolean getAllowFileAccessFromFileURLs();
1182 * Gets whether plugins are enabled.
1184 * @return true if plugins are enabled
1185 * @see #setPluginsEnabled
1186 * @deprecated This method has been replaced by {@link #getPluginState}
1189 public synchronized boolean getPluginsEnabled() {
1190 throw new MustOverrideException();
1194 * Gets the current state regarding whether plugins are enabled.
1196 * @return the plugin state as a {@link PluginState} value
1197 * @see #setPluginState
1199 public synchronized PluginState getPluginState() {
1200 throw new MustOverrideException();
1204 * Gets the directory that contains the plugin libraries. This method is
1205 * obsolete since each plugin is now loaded from its own package.
1207 * @return an empty string
1208 * @deprecated This method is no longer used as plugins are loaded from
1209 * their own APK via the system's package manager.
1212 public synchronized String getPluginsPath() {
1213 // Unconditionally returns empty string, so no need for derived classes to override.
1218 * Tells JavaScript to open windows automatically. This applies to the
1219 * JavaScript function window.open(). The default is false.
1221 * @param flag true if JavaScript can open windows automatically
1223 public synchronized void setJavaScriptCanOpenWindowsAutomatically(boolean flag) {
1224 throw new MustOverrideException();
1228 * Gets whether JavaScript can open windows automatically.
1230 * @return true if JavaScript can open windows automatically during
1232 * @see #setJavaScriptCanOpenWindowsAutomatically
1234 public synchronized boolean getJavaScriptCanOpenWindowsAutomatically() {
1235 throw new MustOverrideException();
1238 * Sets the default text encoding name to use when decoding html pages.
1239 * The default is "Latin-1".
1241 * @param encoding the text encoding name
1243 public synchronized void setDefaultTextEncodingName(String encoding) {
1244 throw new MustOverrideException();
1248 * Gets the default text encoding name.
1250 * @return the default text encoding name as a string
1251 * @see #setDefaultTextEncodingName
1253 public synchronized String getDefaultTextEncodingName() {
1254 throw new MustOverrideException();
1258 * Sets the WebView's user-agent string. If the string is null or empty,
1259 * the system default value will be used.
1261 public synchronized void setUserAgentString(String ua) {
1262 throw new MustOverrideException();
1266 * Gets the WebView's user-agent string.
1268 * @return the WebView's user-agent string
1269 * @see #setUserAgentString
1271 public synchronized String getUserAgentString() {
1272 throw new MustOverrideException();
1276 * Returns the default User-Agent used by a WebView.
1277 * An instance of WebView could use a different User-Agent if a call
1278 * is made to {@link WebSettings#setUserAgentString(String)}.
1280 * @param context a Context object used to access application assets
1282 public static String getDefaultUserAgent(Context context) {
1283 return WebViewFactory.getProvider().getStatics().getDefaultUserAgent(context);
1287 * Tells the WebView whether it needs to set a node to have focus when
1288 * {@link WebView#requestFocus(int, android.graphics.Rect)} is called. The
1289 * default value is true.
1291 * @param flag whether the WebView needs to set a node
1293 public void setNeedInitialFocus(boolean flag) {
1294 throw new MustOverrideException();
1298 * Sets the priority of the Render thread. Unlike the other settings, this
1299 * one only needs to be called once per process. The default value is
1300 * {@link RenderPriority#NORMAL}.
1302 * @param priority the priority
1304 public synchronized void setRenderPriority(RenderPriority priority) {
1305 throw new MustOverrideException();
1309 * Overrides the way the cache is used. The way the cache is used is based
1310 * on the navigation type. For a normal page load, the cache is checked
1311 * and content is re-validated as needed. When navigating back, content is
1312 * not revalidated, instead the content is just retrieved from the cache.
1313 * This method allows the client to override this behavior by specifying
1314 * one of {@link #LOAD_DEFAULT},
1315 * {@link #LOAD_CACHE_ELSE_NETWORK}, {@link #LOAD_NO_CACHE} or
1316 * {@link #LOAD_CACHE_ONLY}. The default value is {@link #LOAD_DEFAULT}.
1318 * @param mode the mode to use
1320 public void setCacheMode(int mode) {
1321 throw new MustOverrideException();
1325 * Gets the current setting for overriding the cache mode.
1327 * @return the current setting for overriding the cache mode
1328 * @see #setCacheMode
1330 public int getCacheMode() {
1331 throw new MustOverrideException();