WebSettings.java revision 9f410c540ad593dd83e34266ccffd70867a600ab
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
17package android.webkit;
18
19import android.content.Context;
20import android.os.Message;
21import android.os.Build;
22
23/**
24 * Manages settings state for a WebView. When a WebView is first created, it
25 * obtains a set of default settings. These default settings will be returned
26 * from any getter call. A WebSettings object obtained from
27 * WebView.getSettings() is tied to the life of the WebView. If a WebView has
28 * been destroyed, any method call on WebSettings will throw an
29 * IllegalStateException.
30 */
31// This is an abstract base class: concrete WebViewProviders must
32// create a class derived from this, and return an instance of it in the
33// WebViewProvider.getWebSettingsProvider() method implementation.
34public abstract class WebSettings {
35    /**
36     * Enum for controlling the layout of html.
37     * <ul>
38     *   <li>NORMAL means no rendering changes.</li>
39     *   <li>SINGLE_COLUMN moves all content into one column that is the width of the
40     *       view.</li>
41     *   <li>NARROW_COLUMNS makes all columns no wider than the screen if possible.</li>
42     * </ul>
43     */
44    // XXX: These must match LayoutAlgorithm in Settings.h in WebCore.
45    public enum LayoutAlgorithm {
46        NORMAL,
47        /**
48         * @deprecated This algorithm is now obsolete.
49         */
50        @Deprecated
51        SINGLE_COLUMN,
52        NARROW_COLUMNS
53    }
54
55    /**
56     * Enum for specifying the text size.
57     * <ul>
58     *   <li>SMALLEST is 50%</li>
59     *   <li>SMALLER is 75%</li>
60     *   <li>NORMAL is 100%</li>
61     *   <li>LARGER is 150%</li>
62     *   <li>LARGEST is 200%</li>
63     * </ul>
64     *
65     * @deprecated Use {@link WebSettings#setTextZoom(int)} and {@link WebSettings#getTextZoom()} instead.
66     */
67    public enum TextSize {
68        SMALLEST(50),
69        SMALLER(75),
70        NORMAL(100),
71        LARGER(150),
72        LARGEST(200);
73        TextSize(int size) {
74            value = size;
75        }
76        int value;
77    }
78
79    /**
80     * Enum for specifying the WebView's desired density.
81     * <ul>
82     *   <li>FAR makes 100% looking like in 240dpi</li>
83     *   <li>MEDIUM makes 100% looking like in 160dpi</li>
84     *   <li>CLOSE makes 100% looking like in 120dpi</li>
85     * </ul>
86     */
87    public enum ZoomDensity {
88        FAR(150),      // 240dpi
89        MEDIUM(100),    // 160dpi
90        CLOSE(75);     // 120dpi
91        ZoomDensity(int size) {
92            value = size;
93        }
94        int value;
95    }
96
97    /**
98     * Default cache usage mode. If the navigation type doesn't impose any
99     * specific behavior, use cached resources when they are available
100     * and not expired, otherwise load resources from the network.
101     * Use with {@link #setCacheMode}.
102     */
103    public static final int LOAD_DEFAULT = -1;
104
105    /**
106     * Normal cache usage mode. Use with {@link #setCacheMode}.
107     */
108    public static final int LOAD_NORMAL = 0;
109
110    /**
111     * Use cached resources when they are available, even if they have expired.
112     * Otherwise load resources from the network.
113     * Use with {@link #setCacheMode}.
114     */
115    public static final int LOAD_CACHE_ELSE_NETWORK = 1;
116
117    /**
118     * Don't use the cache, load from the network.
119     * Use with {@link #setCacheMode}.
120     */
121    public static final int LOAD_NO_CACHE = 2;
122
123    /**
124     * Don't use the network, load from the cache.
125     * Use with {@link #setCacheMode}.
126     */
127    public static final int LOAD_CACHE_ONLY = 3;
128
129    public enum RenderPriority {
130        NORMAL,
131        HIGH,
132        LOW
133    }
134
135    /**
136     * The plugin state effects how plugins are treated on a page. ON means
137     * that any object will be loaded even if a plugin does not exist to handle
138     * the content. ON_DEMAND means that if there is a plugin installed that
139     * can handle the content, a placeholder is shown until the user clicks on
140     * the placeholder. Once clicked, the plugin will be enabled on the page.
141     * OFF means that all plugins will be turned off and any fallback content
142     * will be used.
143     */
144    public enum PluginState {
145        ON,
146        ON_DEMAND,
147        OFF
148    }
149
150    /**
151     * Hidden constructor to prevent clients from creating a new settings
152     * instance or deriving the class.
153     *
154     * @hide
155     */
156    protected WebSettings() {
157    }
158
159    /**
160     * Enables dumping the pages navigation cache to a text file. The default
161     * is false.
162     *
163     * @deprecated This method is now obsolete.
164     */
165    @Deprecated
166    public void setNavDump(boolean enabled) {
167        throw new MustOverrideException();
168    }
169
170    /**
171     * Gets whether dumping the navigation cache is enabled.
172     *
173     * @return whether dumping the navigation cache is enabled
174     * @see #setNavDump
175     * @deprecated This method is now obsolete.
176     */
177    @Deprecated
178    public boolean getNavDump() {
179        throw new MustOverrideException();
180    }
181
182    /**
183     * Sets whether the WebView should support zooming using its on-screen zoom
184     * controls and gestures. The particular zoom mechanisms that should be used
185     * can be set with {@link #setBuiltInZoomControls}. This setting does not
186     * affect zooming performed using the {@link WebView#zoomIn()} and
187     * {@link WebView#zoomOut()} methods. The default is true.
188     *
189     * @param support whether the WebView should support zoom
190     */
191    public void setSupportZoom(boolean support) {
192        throw new MustOverrideException();
193    }
194
195    /**
196     * Gets whether the WebView supports zoom.
197     *
198     * @return true if the WebView supports zoom
199     * @see #setSupportZoom
200     */
201    public boolean supportZoom() {
202        throw new MustOverrideException();
203    }
204
205    /**
206     * Sets whether the WebView requires a user gesture to play media.
207     * The default is true.
208     *
209     * @param require whether the WebView requires a user gesture to play media
210     */
211    public void setMediaPlaybackRequiresUserGesture(boolean require) {
212        throw new MustOverrideException();
213    }
214
215    /**
216     * Gets whether the WebView requires a user gesture to play media.
217     *
218     * @return true if the WebView requires a user gesture to play media
219     * @see #setMediaPlaybackRequiresUserGesture
220     */
221    public boolean getMediaPlaybackRequiresUserGesture() {
222        throw new MustOverrideException();
223    }
224
225    /**
226     * Sets whether the WebView should use its built-in zoom mechanisms. The
227     * built-in zoom mechanisms comprise on-screen zoom controls, which are
228     * displayed over the WebView's content, and the use of a pinch gesture to
229     * control zooming. Whether or not these on-screen controls are displayed
230     * can be set with {@link #setDisplayZoomControls}. The default is false.
231     * <p>
232     * The built-in mechanisms are the only currently supported zoom
233     * mechanisms, so it is recommended that this setting is always enabled.
234     *
235     * @param enabled whether the WebView should use its built-in zoom mechanisms
236     */
237    // This method was intended to select between the built-in zoom mechanisms
238    // and the separate zoom controls. The latter were obtained using
239    // {@link WebView#getZoomControls}, which is now hidden.
240    public void setBuiltInZoomControls(boolean enabled) {
241        throw new MustOverrideException();
242    }
243
244    /**
245     * Gets whether the zoom mechanisms built into WebView are being used.
246     *
247     * @return true if the zoom mechanisms built into WebView are being used
248     * @see #setBuiltInZoomControls
249     */
250    public boolean getBuiltInZoomControls() {
251        throw new MustOverrideException();
252    }
253
254    /**
255     * Sets whether the WebView should display on-screen zoom controls when
256     * using the built-in zoom mechanisms. See {@link #setBuiltInZoomControls}.
257     * The default is true.
258     *
259     * @param enabled whether the WebView should display on-screen zoom controls
260     */
261    public void setDisplayZoomControls(boolean enabled) {
262        throw new MustOverrideException();
263    }
264
265    /**
266     * Gets whether the WebView displays on-screen zoom controls when using
267     * the built-in zoom mechanisms.
268     *
269     * @return true if the WebView displays on-screen zoom controls when using
270     *         the built-in zoom mechanisms
271     * @see #setDisplayZoomControls
272     */
273    public boolean getDisplayZoomControls() {
274        throw new MustOverrideException();
275    }
276
277    /**
278     * Enables or disables file access within WebView. File access is enabled by
279     * default.  Note that this enables or disables file system access only.
280     * Assets and resources are still accessible using file:///android_asset and
281     * file:///android_res.
282     */
283    public void setAllowFileAccess(boolean allow) {
284        throw new MustOverrideException();
285    }
286
287    /**
288     * Gets whether this WebView supports file access.
289     *
290     * @see #setAllowFileAccess
291     */
292    public boolean getAllowFileAccess() {
293        throw new MustOverrideException();
294    }
295
296    /**
297     * Enables or disables content URL access within WebView.  Content URL
298     * access allows WebView to load content from a content provider installed
299     * in the system. The default is enabled.
300     */
301    public void setAllowContentAccess(boolean allow) {
302        throw new MustOverrideException();
303    }
304
305    /**
306     * Gets whether this WebView supports content URL access.
307     *
308     * @see #setAllowContentAccess
309     */
310    public boolean getAllowContentAccess() {
311        throw new MustOverrideException();
312    }
313
314    /**
315     * Sets whether the WebView loads pages in overview mode. The default is
316     * false.
317     */
318    public void setLoadWithOverviewMode(boolean overview) {
319        throw new MustOverrideException();
320    }
321
322    /**
323     * Gets whether this WebView loads pages in overview mode.
324     *
325     * @return whether this WebView loads pages in overview mode
326     * @see #setLoadWithOverviewMode
327     */
328    public boolean getLoadWithOverviewMode() {
329        throw new MustOverrideException();
330    }
331
332    /**
333     * Sets whether the WebView will enable smooth transition while panning or
334     * zooming or while the window hosting the WebView does not have focus.
335     * If it is true, WebView will choose a solution to maximize the performance.
336     * e.g. the WebView's content may not be updated during the transition.
337     * If it is false, WebView will keep its fidelity. The default value is false.
338     */
339    public void setEnableSmoothTransition(boolean enable) {
340        throw new MustOverrideException();
341    }
342
343    /**
344     * Gets whether the WebView enables smooth transition while panning or
345     * zooming.
346     *
347     * @see #setEnableSmoothTransition
348     */
349    public boolean enableSmoothTransition() {
350        throw new MustOverrideException();
351    }
352
353    /**
354     * Sets whether the WebView uses its background for over scroll background.
355     * If true, it will use the WebView's background. If false, it will use an
356     * internal pattern. Default is true.
357     *
358     * @deprecated This method is now obsolete.
359     */
360    @Deprecated
361    public void setUseWebViewBackgroundForOverscrollBackground(boolean view) {
362        throw new MustOverrideException();
363    }
364
365    /**
366     * Gets whether this WebView uses WebView's background instead of
367     * internal pattern for over scroll background.
368     *
369     * @see #setUseWebViewBackgroundForOverscrollBackground
370     * @deprecated This method is now obsolete.
371     */
372    @Deprecated
373    public boolean getUseWebViewBackgroundForOverscrollBackground() {
374        throw new MustOverrideException();
375    }
376
377    /**
378     * Sets whether the WebView should save form data. The default is true,
379     * unless in private browsing mode, when the value is always false.
380     */
381    public void setSaveFormData(boolean save) {
382        throw new MustOverrideException();
383    }
384
385    /**
386     * Gets whether the WebView saves form data. Always false in private
387     * browsing mode.
388     *
389     * @return whether the WebView saves form data
390     * @see #setSaveFormData
391     */
392    public boolean getSaveFormData() {
393        throw new MustOverrideException();
394    }
395
396    /**
397     * Sets whether the WebView should save passwords. The default is true.
398     */
399    public void setSavePassword(boolean save) {
400        throw new MustOverrideException();
401    }
402
403    /**
404     * Gets whether the WebView saves passwords.
405     *
406     * @return whether the WebView saves passwords
407     * @see #setSavePassword
408     */
409    public boolean getSavePassword() {
410        throw new MustOverrideException();
411    }
412
413    /**
414     * Sets the text zoom of the page in percent. The default is 100.
415     *
416     * @param textZoom the text zoom in percent
417     */
418    public synchronized void setTextZoom(int textZoom) {
419        throw new MustOverrideException();
420    }
421
422    /**
423     * Gets the text zoom of the page in percent.
424     *
425     * @return the text zoom of the page in percent
426     * @see #setTextSizeZoom
427     */
428    public synchronized int getTextZoom() {
429        throw new MustOverrideException();
430    }
431
432    /**
433     * Sets the text size of the page. The default is {@link TextSize#NORMAL}.
434     *
435     * @param t the text size as a {@link TextSize} value
436     * @deprecated Use {@link #setTextZoom} instead.
437     */
438    public synchronized void setTextSize(TextSize t) {
439        throw new MustOverrideException();
440    }
441
442    /**
443     * Gets the text size of the page. If the text size was previously specified
444     * in percent using {@link #setTextZoom}, this will return the closest
445     * matching {@link TextSize}.
446     *
447     * @return the text size as a {@link TextSize} value
448     * @see #setTextSize
449     * @deprecated Use {@link #getTextZoom} instead.
450     */
451    public synchronized TextSize getTextSize() {
452        throw new MustOverrideException();
453    }
454
455    /**
456     * Sets the default zoom density of the page. This must be called from the UI
457     * thread. The default is {@link ZoomDensity#MEDIUM}.
458     *
459     * @param zoom the zoom density
460     */
461    public void setDefaultZoom(ZoomDensity zoom) {
462        throw new MustOverrideException();
463    }
464
465    /**
466     * Gets the default zoom density of the page. This should be called from
467     * the UI thread.
468     *
469     * @return the zoom density
470     * @see #setDefaultZoom
471     */
472    public ZoomDensity getDefaultZoom() {
473        throw new MustOverrideException();
474    }
475
476    /**
477     * Enables using light touches to make a selection and activate mouseovers.
478     * The default is false.
479     */
480    public void setLightTouchEnabled(boolean enabled) {
481        throw new MustOverrideException();
482    }
483
484    /**
485     * Gets whether light touches are enabled.
486     *
487     * @return whether light touches are enabled
488     * @see #setLightTouchEnabled
489     */
490    public boolean getLightTouchEnabled() {
491        throw new MustOverrideException();
492    }
493
494    /**
495     * Controlled a rendering optimization that is no longer present. Setting
496     * it now has no effect.
497     *
498     * @deprecated This setting now has no effect.
499     */
500    @Deprecated
501    public synchronized void setUseDoubleTree(boolean use) {
502        // Specified to do nothing, so no need for derived classes to override.
503    }
504
505    /**
506     * Controlled a rendering optimization that is no longer present. Setting
507     * it now has no effect.
508     *
509     * @deprecated This setting now has no effect.
510     */
511    @Deprecated
512    public synchronized boolean getUseDoubleTree() {
513        // Returns false unconditionally, so no need for derived classes to override.
514        return false;
515    }
516
517    /**
518     * Sets the user-agent string using an integer code.
519     * <ul>
520     *   <li>0 means the WebView should use an Android user-agent string</li>
521     *   <li>1 means the WebView should use a desktop user-agent string</li>
522     * </ul>
523     * Other values are ignored. The default is an Android user-agent string,
524     * i.e. code value 0.
525     *
526     * @param ua the integer code for the user-agent string
527     * @deprecated Please use {@link #setUserAgentString} instead.
528     */
529    @Deprecated
530    public synchronized void setUserAgent(int ua) {
531        throw new MustOverrideException();
532    }
533
534    /**
535     * Gets the user-agent as an integer code.
536     * <ul>
537     *   <li>-1 means the WebView is using a custom user-agent string set with
538     *   {@link #setUserAgentString}</li>
539     *   <li>0 means the WebView should use an Android user-agent string</li>
540     *   <li>1 means the WebView should use a desktop user-agent string</li>
541     * </ul>
542     *
543     * @return the integer code for the user-agent string
544     * @see #setUserAgent
545     * @deprecated Please use {@link #getUserAgentString} instead.
546     */
547    @Deprecated
548    public synchronized int getUserAgent() {
549        throw new MustOverrideException();
550    }
551
552    /**
553     * Tells the WebView to use a wide viewport. The default is false.
554     *
555     * @param use whether to use a wide viewport
556     */
557    public synchronized void setUseWideViewPort(boolean use) {
558        throw new MustOverrideException();
559    }
560
561    /**
562     * Gets whether the WebView is using a wide viewport.
563     *
564     * @return true if the WebView is using a wide viewport
565     * @see #setUseWideViewPort
566     */
567    public synchronized boolean getUseWideViewPort() {
568        throw new MustOverrideException();
569    }
570
571    /**
572     * Sets whether the WebView whether supports multiple windows. If set to
573     * true, {@link WebChromeClient#onCreateWindow} must be implemented by the
574     * host application. The default is false.
575     *
576     * @param support whether to suport multiple windows
577     */
578    public synchronized void setSupportMultipleWindows(boolean support) {
579        throw new MustOverrideException();
580    }
581
582    /**
583     * Gets whether the WebView supports multiple windows.
584     *
585     * @return true if the WebView supports multiple windows
586     * @see #setSupportMultipleWindows
587     */
588    public synchronized boolean supportMultipleWindows() {
589        throw new MustOverrideException();
590    }
591
592    /**
593     * Sets the underlying layout algorithm. This will cause a relayout of the
594     * WebView. The default is {@link LayoutAlgorithm#NARROW_COLUMNS}.
595     *
596     * @param l the layout algorithm to use, as a {@link LayoutAlgorithm} value
597     */
598    public synchronized void setLayoutAlgorithm(LayoutAlgorithm l) {
599        throw new MustOverrideException();
600    }
601
602    /**
603     * Gets the current layout algorithm.
604     *
605     * @return the layout algorithm in use, as a {@link LayoutAlgorithm} value
606     * @see #setLayoutAlgorithm
607     */
608    public synchronized LayoutAlgorithm getLayoutAlgorithm() {
609        throw new MustOverrideException();
610    }
611
612    /**
613     * Sets the standard font family name. The default is "sans-serif".
614     *
615     * @param font a font family name
616     */
617    public synchronized void setStandardFontFamily(String font) {
618        throw new MustOverrideException();
619    }
620
621    /**
622     * Gets the standard font family name.
623     *
624     * @return the standard font family name as a string
625     * @see #setStandardFontFamily
626     */
627    public synchronized String getStandardFontFamily() {
628        throw new MustOverrideException();
629    }
630
631    /**
632     * Sets the fixed font family name. The default is "monospace".
633     *
634     * @param font a font family name
635     */
636    public synchronized void setFixedFontFamily(String font) {
637        throw new MustOverrideException();
638    }
639
640    /**
641     * Gets the fixed font family name.
642     *
643     * @return the fixed font family name as a string
644     * @see #setFixedFontFamily
645     */
646    public synchronized String getFixedFontFamily() {
647        throw new MustOverrideException();
648    }
649
650    /**
651     * Sets the sans-serif font family name. The default is "sans-serif".
652     *
653     * @param font a font family name
654     */
655    public synchronized void setSansSerifFontFamily(String font) {
656        throw new MustOverrideException();
657    }
658
659    /**
660     * Gets the sans-serif font family name.
661     *
662     * @return the sans-serif font family name as a string
663     * @see #setSansSerifFontFamily
664     */
665    public synchronized String getSansSerifFontFamily() {
666        throw new MustOverrideException();
667    }
668
669    /**
670     * Sets the serif font family name. The default is "sans-serif".
671     *
672     * @param font a font family name
673     */
674    public synchronized void setSerifFontFamily(String font) {
675        throw new MustOverrideException();
676    }
677
678    /**
679     * Gets the serif font family name. The default is "serif".
680     *
681     * @return the serif font family name as a string
682     * @see #setSerifFontFamily
683     */
684    public synchronized String getSerifFontFamily() {
685        throw new MustOverrideException();
686    }
687
688    /**
689     * Sets the cursive font family name. The default is "cursive".
690     *
691     * @param font a font family name
692     */
693    public synchronized void setCursiveFontFamily(String font) {
694        throw new MustOverrideException();
695    }
696
697    /**
698     * Gets the cursive font family name.
699     *
700     * @return the cursive font family name as a string
701     * @see #setCursiveFontFamily
702     */
703    public synchronized String getCursiveFontFamily() {
704        throw new MustOverrideException();
705    }
706
707    /**
708     * Sets the fantasy font family name. The default is "fantasy".
709     *
710     * @param font a font family name
711     */
712    public synchronized void setFantasyFontFamily(String font) {
713        throw new MustOverrideException();
714    }
715
716    /**
717     * Gets the fantasy font family name.
718     *
719     * @return the fantasy font family name as a string
720     * @see #setFantasyFontFamily
721     */
722    public synchronized String getFantasyFontFamily() {
723        throw new MustOverrideException();
724    }
725
726    /**
727     * Sets the minimum font size. The default is 8.
728     *
729     * @param size a non-negative integer between 1 and 72. Any number outside
730     *             the specified range will be pinned.
731     */
732    public synchronized void setMinimumFontSize(int size) {
733        throw new MustOverrideException();
734    }
735
736    /**
737     * Gets the minimum font size.
738     *
739     * @return a non-negative integer between 1 and 72
740     * @see #setMinimumFontSize
741     */
742    public synchronized int getMinimumFontSize() {
743        throw new MustOverrideException();
744    }
745
746    /**
747     * Sets the minimum logical font size. The default is 8.
748     *
749     * @param size a non-negative integer between 1 and 72. Any number outside
750     *             the specified range will be pinned.
751     */
752    public synchronized void setMinimumLogicalFontSize(int size) {
753        throw new MustOverrideException();
754    }
755
756    /**
757     * Gets the minimum logical font size.
758     *
759     * @return a non-negative integer between 1 and 72
760     * @see #setMinimumLogicalFontSize
761     */
762    public synchronized int getMinimumLogicalFontSize() {
763        throw new MustOverrideException();
764    }
765
766    /**
767     * Sets the default font size. The default is 16.
768     *
769     * @param size a non-negative integer between 1 and 72. Any number outside
770     *             the specified range will be pinned.
771     */
772    public synchronized void setDefaultFontSize(int size) {
773        throw new MustOverrideException();
774    }
775
776    /**
777     * Gets the default font size.
778     *
779     * @return a non-negative integer between 1 and 72
780     * @see #setDefaultFontSize
781     */
782    public synchronized int getDefaultFontSize() {
783        throw new MustOverrideException();
784    }
785
786    /**
787     * Sets the default fixed font size. The default is 16.
788     *
789     * @param size a non-negative integer between 1 and 72. Any number outside
790     *             the specified range will be pinned.
791     */
792    public synchronized void setDefaultFixedFontSize(int size) {
793        throw new MustOverrideException();
794    }
795
796    /**
797     * Gets the default fixed font size.
798     *
799     * @return a non-negative integer between 1 and 72
800     * @see #setDefaultFixedFontSize
801     */
802    public synchronized int getDefaultFixedFontSize() {
803        throw new MustOverrideException();
804    }
805
806    /**
807     * Sets whether the WebView should load image resources. Note that this method
808     * controls loading of all images, including those embedded using the data
809     * URI scheme. Use {@link #setBlockNetworkImage} to control loading only
810     * of images specified using network URI schemes. Note that if the value of this
811     * setting is changed from false to true, all images resources referenced
812     * by content currently displayed by the WebView are loaded automatically.
813     * The default is true.
814     *
815     * @param flag whether the WebView should load image resources
816     */
817    public synchronized void setLoadsImagesAutomatically(boolean flag) {
818        throw new MustOverrideException();
819    }
820
821    /**
822     * Gets whether the WebView loads image resources. This includes
823     * images embedded using the data URI scheme.
824     *
825     * @return true if the WebView loads image resources
826     * @see #setLoadsImagesAutomatically
827     */
828    public synchronized boolean getLoadsImagesAutomatically() {
829        throw new MustOverrideException();
830    }
831
832    /**
833     * Sets whether the WebView should not load image resources from the
834     * network (resources accessed via http and https URI schemes).  Note
835     * that this method has no effect unless
836     * {@link #getLoadsImagesAutomatically} returns true. Also note that
837     * disabling all network loads using {@link #setBlockNetworkLoads}
838     * will also prevent network images from loading, even if this flag is set
839     * to false. When the value of this setting is changed from true to false,
840     * network images resources referenced by content currently displayed by
841     * the WebView are fetched automatically. The default is false.
842     *
843     * @param flag whether the WebView should not load image resources from the
844     *             network
845     * @see #setBlockNetworkLoads
846     */
847    public synchronized void setBlockNetworkImage(boolean flag) {
848        throw new MustOverrideException();
849    }
850
851    /**
852     * Gets whether the WebView does not load image resources from the network.
853     *
854     * @return true if the WebView does not load image resources from the network
855     * @see #setBlockNetworkImage
856     */
857    public synchronized boolean getBlockNetworkImage() {
858        throw new MustOverrideException();
859    }
860
861    /**
862     * Sets whether the WebView should not load resources from the network.
863     * Use {@link #setBlockNetworkImage} to only avoid loading
864     * image resources. Note that if the value of this setting is
865     * changed from true to false, network resources referenced by content
866     * currently displayed by the WebView are not fetched until
867     * {@link android.webkit.WebView#reload} is called.
868     * If the application does not have the
869     * {@link android.Manifest.permission#INTERNET} permission, attempts to set
870     * a value of false will cause a {@link java.lang.SecurityException}
871     * to be thrown. The default value is false if the application has the
872     * {@link android.Manifest.permission#INTERNET} permission, otherwise it is
873     * true.
874     *
875     * @param flag whether the WebView should not load any resources from the
876     *             network
877     * @see android.webkit.WebView#reload
878     */
879    public synchronized void setBlockNetworkLoads(boolean flag) {
880        throw new MustOverrideException();
881    }
882
883    /**
884     * Gets whether the WebView does not load any resources from the network.
885     *
886     * @return true if the WebView does not load any resources from the network
887     * @see #setBlockNetworkLoads
888     */
889    public synchronized boolean getBlockNetworkLoads() {
890        throw new MustOverrideException();
891    }
892
893    /**
894     * Tells the WebView to enable JavaScript execution.
895     * <b>The default is false.</b>
896     *
897     * @param flag true if the WebView should execute JavaScript
898     */
899    public synchronized void setJavaScriptEnabled(boolean flag) {
900        throw new MustOverrideException();
901    }
902
903    /**
904     * Sets whether JavaScript running in the context of a file scheme URL
905     * should be allowed to access content from any origin. This includes
906     * access to content from other file scheme URLs. See
907     * {@link #setAllowFileAccessFromFileURLs}. To enable the most restrictive,
908     * and therefore secure policy, this setting should be disabled.
909     * <p>
910     * The default value is true for API level
911     * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and below,
912     * and false for API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN}
913     * and above.
914     *
915     * @param flag whether JavaScript running in the context of a file scheme
916     *             URL should be allowed to access content from any origin
917     */
918    public abstract void setAllowUniversalAccessFromFileURLs(boolean flag);
919
920    /**
921     * Sets whether JavaScript running in the context of a file scheme URL
922     * should be allowed to access content from other file scheme URLs. To
923     * enable the most restrictive, and therefore secure policy, this setting
924     * should be disabled. Note that the value of this setting is ignored if
925     * the value of {@link #getAllowUniversalAccessFromFileURLs} is true.
926     * <p>
927     * The default value is true for API level
928     * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and below,
929     * and false for API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN}
930     * and above.
931     *
932     * @param flag whether JavaScript running in the context of a file scheme
933     *             URL should be allowed to access content from other file
934     *             scheme URLs
935     */
936    public abstract void setAllowFileAccessFromFileURLs(boolean flag);
937
938    /**
939     * Sets whether the WebView should enable plugins. The default is false.
940     *
941     * @param flag true if plugins should be enabled
942     * @deprecated This method has been deprecated in favor of
943     *             {@link #setPluginState}
944     */
945    @Deprecated
946    public synchronized void setPluginsEnabled(boolean flag) {
947        throw new MustOverrideException();
948    }
949
950    /**
951     * Tells the WebView to enable, disable, or have plugins on demand. On
952     * demand mode means that if a plugin exists that can handle the embedded
953     * content, a placeholder icon will be shown instead of the plugin. When
954     * the placeholder is clicked, the plugin will be enabled. The default is
955     * {@link PluginState#OFF}.
956     *
957     * @param state a PluginState value
958     */
959    public synchronized void setPluginState(PluginState state) {
960        throw new MustOverrideException();
961    }
962
963    /**
964     * Sets a custom path to plugins used by the WebView. This method is
965     * obsolete since each plugin is now loaded from its own package.
966     *
967     * @param pluginsPath a String path to the directory containing plugins
968     * @deprecated This method is no longer used as plugins are loaded from
969     *             their own APK via the system's package manager.
970     */
971    @Deprecated
972    public synchronized void setPluginsPath(String pluginsPath) {
973        // Specified to do nothing, so no need for derived classes to override.
974    }
975
976    /**
977     * Sets the path to where database storage API databases should be saved.
978     * In order for the database storage API to function correctly, this method
979     * must be called with a path to which the application can write. This
980     * method should only be called once: repeated calls are ignored.
981     *
982     * @param databasePath a path to the directory where databases should be
983     *                     saved.
984     */
985    // This will update WebCore when the Sync runs in the C++ side.
986    // Note that the WebCore Database Tracker only allows the path to be set
987    // once.
988    public synchronized void setDatabasePath(String databasePath) {
989        throw new MustOverrideException();
990    }
991
992    /**
993     * Sets the path where the Geolocation databases should be saved. In order
994     * for Geolocation permissions and cached positions to be persisted, this
995     * method must be called with a path to which the application can write.
996     *
997     * @param databasePath a path to the directory where databases should be
998     *                     saved.
999     */
1000    // This will update WebCore when the Sync runs in the C++ side.
1001    public synchronized void setGeolocationDatabasePath(String databasePath) {
1002        throw new MustOverrideException();
1003    }
1004
1005    /**
1006     * Sets whether the Application Caches API should be enabled. The default
1007     * is false. Note that in order for the Application Caches API to be
1008     * enabled, a valid database path must also be supplied to
1009     * {@link #setAppCachePath}.
1010     *
1011     * @param flag true if the WebView should enable Application Caches
1012     */
1013    public synchronized void setAppCacheEnabled(boolean flag) {
1014        throw new MustOverrideException();
1015    }
1016
1017    /**
1018     * Sets the path to the Application Caches files. In order for the
1019     * Application Caches API to be enabled, this method must be called with a
1020     * path to which the application can write. This method should only be
1021     * called once: repeated calls are ignored.
1022     *
1023     * @param appCachePath a String path to the directory containing
1024     *                     Application Caches files.
1025     * @see setAppCacheEnabled
1026     */
1027    public synchronized void setAppCachePath(String appCachePath) {
1028        throw new MustOverrideException();
1029    }
1030
1031    /**
1032     * Sets the maximum size for the Application Cache content. The passed size
1033     * will be rounded to the nearest value that the database can support, so
1034     * this should be viewed as a guide, not a hard limit. Setting the
1035     * size to a value less than current database size does not cause the
1036     * database to be trimmed. The default size is {@link Long#MAX_VALUE}.
1037     *
1038     * @param appCacheMaxSize the maximum size in bytes
1039     */
1040    public synchronized void setAppCacheMaxSize(long appCacheMaxSize) {
1041        throw new MustOverrideException();
1042    }
1043
1044    /**
1045     * Sets whether the database storage API is enabled. The default value is
1046     * false. See also {@link #setDatabasePath} for how to correctly set up the
1047     * database storage API.
1048     *
1049     * @param flag true if the WebView should use the database storage API
1050     */
1051    public synchronized void setDatabaseEnabled(boolean flag) {
1052        throw new MustOverrideException();
1053    }
1054
1055    /**
1056     * Sets whether the DOM storage API is enabled. The default value is false.
1057     *
1058     * @param flag true if the WebView should use the DOM storage API
1059     */
1060    public synchronized void setDomStorageEnabled(boolean flag) {
1061        throw new MustOverrideException();
1062    }
1063
1064    /**
1065     * Gets whether the DOM Storage APIs are enabled.
1066     *
1067     * @return true if the DOM Storage APIs are enabled
1068     * @see #setDomStorageEnabled
1069     */
1070    public synchronized boolean getDomStorageEnabled() {
1071        throw new MustOverrideException();
1072    }
1073    /**
1074     * Gets the path to where database storage API databases are saved.
1075     *
1076     * @return the String path to the database storage API databases
1077     * @see #setDatabasePath
1078     */
1079    public synchronized String getDatabasePath() {
1080        throw new MustOverrideException();
1081    }
1082
1083    /**
1084     * Gets whether the database storage API is enabled.
1085     *
1086     * @return true if the database storage API is enabled
1087     * @see #setDatabaseEnabled
1088     */
1089    public synchronized boolean getDatabaseEnabled() {
1090        throw new MustOverrideException();
1091    }
1092
1093    /**
1094     * Sets whether Geolocation is enabled. The default is true. See also
1095     * {@link #setGeolocationDatabasePath} for how to correctly set up
1096     * Geolocation.
1097     *
1098     * @param flag whether Geolocation should be enabled
1099     */
1100    public synchronized void setGeolocationEnabled(boolean flag) {
1101        throw new MustOverrideException();
1102    }
1103
1104    /**
1105     * Gets whether JavaScript is enabled.
1106     *
1107     * @return true if JavaScript is enabled
1108     * @see #setJavaScriptEnabled
1109     */
1110    public synchronized boolean getJavaScriptEnabled() {
1111        throw new MustOverrideException();
1112    }
1113
1114    /**
1115     * Gets whether JavaScript running in the context of a file scheme URL can
1116     * access content from any origin. This includes access to content from
1117     * other file scheme URLs.
1118     *
1119     * @return whether JavaScript running in the context of a file scheme URL
1120     *         can access content from any origin
1121     * @see #setAllowUniversalAccessFromFileURLs
1122     */
1123    public abstract boolean getAllowUniversalAccessFromFileURLs();
1124
1125    /**
1126     * Gets whether JavaScript running in the context of a file scheme URL can
1127     * access content from other file scheme URLs.
1128     *
1129     * @return whether JavaScript running in the context of a file scheme URL
1130     *         can access content from other file scheme URLs
1131     * @see #setAllowFileAccessFromFileURLs
1132     */
1133    public abstract boolean getAllowFileAccessFromFileURLs();
1134
1135    /**
1136     * Gets whether plugins are enabled.
1137     *
1138     * @return true if plugins are enabled
1139     * @see #setPluginsEnabled
1140     * @deprecated This method has been replaced by {@link #getPluginState}
1141     */
1142    @Deprecated
1143    public synchronized boolean getPluginsEnabled() {
1144        throw new MustOverrideException();
1145    }
1146
1147    /**
1148     * Gets the current state regarding whether plugins are enabled.
1149     *
1150     * @return the plugin state as a {@link PluginState} value
1151     * @see #setPluginState
1152     */
1153    public synchronized PluginState getPluginState() {
1154        throw new MustOverrideException();
1155    }
1156
1157    /**
1158     * Gets the directory that contains the plugin libraries. This method is
1159     * obsolete since each plugin is now loaded from its own package.
1160     *
1161     * @return an empty string
1162     * @deprecated This method is no longer used as plugins are loaded from
1163     * their own APK via the system's package manager.
1164     */
1165    @Deprecated
1166    public synchronized String getPluginsPath() {
1167        // Unconditionally returns empty string, so no need for derived classes to override.
1168        return "";
1169    }
1170
1171    /**
1172     * Tells JavaScript to open windows automatically. This applies to the
1173     * JavaScript function window.open(). The default is false.
1174     *
1175     * @param flag true if JavaScript can open windows automatically
1176     */
1177    public synchronized void setJavaScriptCanOpenWindowsAutomatically(boolean flag) {
1178        throw new MustOverrideException();
1179    }
1180
1181    /**
1182     * Gets whether JavaScript can open windows automatically.
1183     *
1184     * @return true if JavaScript can open windows automatically during
1185     *         window.open()
1186     * @see #setJavaScriptCanOpenWindowsAutomatically
1187     */
1188    public synchronized boolean getJavaScriptCanOpenWindowsAutomatically() {
1189        throw new MustOverrideException();
1190    }
1191    /**
1192     * Sets the default text encoding name to use when decoding html pages.
1193     * The default is "Latin-1".
1194     *
1195     * @param encoding the text encoding name
1196     */
1197    public synchronized void setDefaultTextEncodingName(String encoding) {
1198        throw new MustOverrideException();
1199    }
1200
1201    /**
1202     * Gets the default text encoding name.
1203     *
1204     * @return the default text encoding name as a string
1205     * @see #setDefaultTextEncodingName
1206     */
1207    public synchronized String getDefaultTextEncodingName() {
1208        throw new MustOverrideException();
1209    }
1210
1211    /**
1212     * Sets the WebView's user-agent string. If the string is null or empty,
1213     * the system default value will be used.
1214     */
1215    public synchronized void setUserAgentString(String ua) {
1216        throw new MustOverrideException();
1217    }
1218
1219    /**
1220     * Gets the WebView's user-agent string.
1221     *
1222     * @return the WebView's user-agent string
1223     * @see #setUserAgentString
1224     */
1225    public synchronized String getUserAgentString() {
1226        throw new MustOverrideException();
1227    }
1228
1229    /**
1230     * Returns the default User-Agent used by a WebView.
1231     * An instance of WebView could use a different User-Agent if a call
1232     * is made to {@link WebSettings#setUserAgent(int)} or
1233     * {@link WebSettings#setUserAgentString(String)}.
1234     *
1235     * @param context a Context object used to access application assets
1236     */
1237    public static String getDefaultUserAgent(Context context) {
1238        return WebView.getFactory().getDefaultUserAgent(context);
1239    }
1240
1241    /**
1242     * Tells the WebView whether it needs to set a node to have focus when
1243     * {@link WebView#requestFocus(int, android.graphics.Rect)} is called. The
1244     * default value is true.
1245     *
1246     * @param flag whether the WebView needs to set a node
1247     */
1248    public void setNeedInitialFocus(boolean flag) {
1249        throw new MustOverrideException();
1250    }
1251
1252    /**
1253     * Sets the priority of the Render thread. Unlike the other settings, this
1254     * one only needs to be called once per process. The default value is
1255     * {@link RenderPriority#NORMAL}.
1256     *
1257     * @param priority the priority
1258     */
1259    public synchronized void setRenderPriority(RenderPriority priority) {
1260        throw new MustOverrideException();
1261    }
1262
1263    /**
1264     * Overrides the way the cache is used. The way the cache is used is based
1265     * on the navigation type. For a normal page load, the cache is checked
1266     * and content is re-validated as needed. When navigating back, content is
1267     * not revalidated, instead the content is just retrieved from the cache.
1268     * This method allows the client to override this behavior by specifying
1269     * one of {@link #LOAD_DEFAULT}, {@link #LOAD_NORMAL},
1270     * {@link #LOAD_CACHE_ELSE_NETWORK}, {@link #LOAD_NO_CACHE} or
1271     * {@link #LOAD_CACHE_ONLY}. The default value is {@link #LOAD_DEFAULT}.
1272     *
1273     * @param mode the mode to use
1274     */
1275    public void setCacheMode(int mode) {
1276        throw new MustOverrideException();
1277    }
1278
1279    /**
1280     * Gets the current setting for overriding the cache mode.
1281     *
1282     * @return the current setting for overriding the cache mode
1283     * @see #setCacheMode
1284     */
1285    public int getCacheMode() {
1286        throw new MustOverrideException();
1287    }
1288}
1289