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