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