Home | History | Annotate | Download | only in webkit
      1 /*
      2  * Copyright (C) 2007 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.webkit;
     18 
     19 import android.annotation.IntDef;
     20 import android.annotation.SystemApi;
     21 import android.content.Context;
     22 
     23 import java.lang.annotation.ElementType;
     24 import java.lang.annotation.Retention;
     25 import java.lang.annotation.RetentionPolicy;
     26 import java.lang.annotation.Target;
     27 
     28 /**
     29  * Manages settings state for a WebView. When a WebView is first created, it
     30  * obtains a set of default settings. These default settings will be returned
     31  * from any getter call. A WebSettings object obtained from
     32  * WebView.getSettings() is tied to the life of the WebView. If a WebView has
     33  * been destroyed, any method call on WebSettings will throw an
     34  * IllegalStateException.
     35  */
     36 // This is an abstract base class: concrete WebViewProviders must
     37 // create a class derived from this, and return an instance of it in the
     38 // WebViewProvider.getWebSettingsProvider() method implementation.
     39 public abstract class WebSettings {
     40     /**
     41      * Enum for controlling the layout of html.
     42      * <ul>
     43      *   <li>NORMAL means no rendering changes. This is the recommended choice for maximum
     44      *       compatibility across different platforms and Android versions.</li>
     45      *   <li>SINGLE_COLUMN moves all content into one column that is the width of the
     46      *       view.</li>
     47      *   <li>NARROW_COLUMNS makes all columns no wider than the screen if possible. Only use
     48      *       this for API levels prior to {@link android.os.Build.VERSION_CODES#KITKAT}.</li>
     49      *   <li>TEXT_AUTOSIZING boosts font size of paragraphs based on heuristics to make
     50      *       the text readable when viewing a wide-viewport layout in the overview mode.
     51      *       It is recommended to enable zoom support {@link #setSupportZoom} when
     52      *       using this mode. Supported from API level
     53      *       {@link android.os.Build.VERSION_CODES#KITKAT}</li>
     54      * </ul>
     55      */
     56     // XXX: These must match LayoutAlgorithm in Settings.h in WebCore.
     57     public enum LayoutAlgorithm {
     58         NORMAL,
     59         /**
     60          * @deprecated This algorithm is now obsolete.
     61          */
     62         @Deprecated
     63         SINGLE_COLUMN,
     64         /**
     65          * @deprecated This algorithm is now obsolete.
     66          */
     67         @Deprecated
     68         NARROW_COLUMNS,
     69         TEXT_AUTOSIZING
     70     }
     71 
     72     /**
     73      * Enum for specifying the text size.
     74      * <ul>
     75      *   <li>SMALLEST is 50%</li>
     76      *   <li>SMALLER is 75%</li>
     77      *   <li>NORMAL is 100%</li>
     78      *   <li>LARGER is 150%</li>
     79      *   <li>LARGEST is 200%</li>
     80      * </ul>
     81      *
     82      * @deprecated Use {@link WebSettings#setTextZoom(int)} and {@link WebSettings#getTextZoom()} instead.
     83      */
     84     public enum TextSize {
     85         SMALLEST(50),
     86         SMALLER(75),
     87         NORMAL(100),
     88         LARGER(150),
     89         LARGEST(200);
     90         TextSize(int size) {
     91             value = size;
     92         }
     93         int value;
     94     }
     95 
     96     /**
     97      * Enum for specifying the WebView's desired density.
     98      * <ul>
     99      *   <li>FAR makes 100% looking like in 240dpi</li>
    100      *   <li>MEDIUM makes 100% looking like in 160dpi</li>
    101      *   <li>CLOSE makes 100% looking like in 120dpi</li>
    102      * </ul>
    103      */
    104     public enum ZoomDensity {
    105         FAR(150),      // 240dpi
    106         MEDIUM(100),    // 160dpi
    107         CLOSE(75);     // 120dpi
    108         ZoomDensity(int size) {
    109             value = size;
    110         }
    111 
    112         /**
    113          * @hide Only for use by WebViewProvider implementations
    114          */
    115         public int getValue() {
    116             return value;
    117         }
    118 
    119         int value;
    120     }
    121 
    122     /** @hide */
    123     @IntDef({LOAD_DEFAULT, LOAD_NORMAL, LOAD_CACHE_ELSE_NETWORK, LOAD_NO_CACHE, LOAD_CACHE_ONLY})
    124     @Retention(RetentionPolicy.SOURCE)
    125     public @interface CacheMode {}
    126 
    127     /**
    128      * Default cache usage mode. If the navigation type doesn't impose any
    129      * specific behavior, use cached resources when they are available
    130      * and not expired, otherwise load resources from the network.
    131      * Use with {@link #setCacheMode}.
    132      */
    133     public static final int LOAD_DEFAULT = -1;
    134 
    135     /**
    136      * Normal cache usage mode. Use with {@link #setCacheMode}.
    137      *
    138      * @deprecated This value is obsolete, as from API level
    139      * {@link android.os.Build.VERSION_CODES#HONEYCOMB} and onwards it has the
    140      * same effect as {@link #LOAD_DEFAULT}.
    141      */
    142     @Deprecated
    143     public static final int LOAD_NORMAL = 0;
    144 
    145     /**
    146      * Use cached resources when they are available, even if they have expired.
    147      * Otherwise load resources from the network.
    148      * Use with {@link #setCacheMode}.
    149      */
    150     public static final int LOAD_CACHE_ELSE_NETWORK = 1;
    151 
    152     /**
    153      * Don't use the cache, load from the network.
    154      * Use with {@link #setCacheMode}.
    155      */
    156     public static final int LOAD_NO_CACHE = 2;
    157 
    158     /**
    159      * Don't use the network, load from the cache.
    160      * Use with {@link #setCacheMode}.
    161      */
    162     public static final int LOAD_CACHE_ONLY = 3;
    163 
    164     public enum RenderPriority {
    165         NORMAL,
    166         HIGH,
    167         LOW
    168     }
    169 
    170     /**
    171      * The plugin state effects how plugins are treated on a page. ON means
    172      * that any object will be loaded even if a plugin does not exist to handle
    173      * the content. ON_DEMAND means that if there is a plugin installed that
    174      * can handle the content, a placeholder is shown until the user clicks on
    175      * the placeholder. Once clicked, the plugin will be enabled on the page.
    176      * OFF means that all plugins will be turned off and any fallback content
    177      * will be used.
    178      */
    179     public enum PluginState {
    180         ON,
    181         ON_DEMAND,
    182         OFF
    183     }
    184 
    185     /**
    186      * Used with {@link #setMixedContentMode}
    187      *
    188      * In this mode, the WebView will allow a secure origin to load content from any other origin,
    189      * even if that origin is insecure. This is the least secure mode of operation for the WebView,
    190      * and where possible apps should not set this mode.
    191      */
    192     public static final int MIXED_CONTENT_ALWAYS_ALLOW = 0;
    193 
    194     /**
    195      * Used with {@link #setMixedContentMode}
    196      *
    197      * In this mode, the WebView will not allow a secure origin to load content from an insecure
    198      * origin. This is the preferred and most secure mode of operation for the WebView and apps are
    199      * strongly advised to use this mode.
    200      */
    201     public static final int MIXED_CONTENT_NEVER_ALLOW = 1;
    202 
    203     /**
    204      * Used with {@link #setMixedContentMode}
    205      *
    206      * In this mode, the WebView will attempt to be compatible with the approach of a modern web
    207      * browser with regard to mixed content. Some insecure content may be allowed to be loaded by
    208      * a secure origin and other types of content will be blocked. The types of content are allowed
    209      * or blocked may change release to release and are not explicitly defined.
    210      *
    211      * This mode is intended to be used by apps that are not in control of the content that they
    212      * render but desire to operate in a reasonably secure environment. For highest security, apps
    213      * are recommended to use {@link #MIXED_CONTENT_NEVER_ALLOW}.
    214      */
    215     public static final int MIXED_CONTENT_COMPATIBILITY_MODE = 2;
    216 
    217     /**
    218      * Enables dumping the pages navigation cache to a text file. The default
    219      * is false.
    220      *
    221      * @deprecated This method is now obsolete.
    222      * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
    223      */
    224     @SystemApi
    225     @Deprecated
    226     public abstract void setNavDump(boolean enabled);
    227 
    228     /**
    229      * Gets whether dumping the navigation cache is enabled.
    230      *
    231      * @return whether dumping the navigation cache is enabled
    232      * @see #setNavDump
    233      * @deprecated This method is now obsolete.
    234      * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
    235      */
    236     @SystemApi
    237     @Deprecated
    238     public abstract boolean getNavDump();
    239 
    240     /**
    241      * Sets whether the WebView should support zooming using its on-screen zoom
    242      * controls and gestures. The particular zoom mechanisms that should be used
    243      * can be set with {@link #setBuiltInZoomControls}. This setting does not
    244      * affect zooming performed using the {@link WebView#zoomIn()} and
    245      * {@link WebView#zoomOut()} methods. The default is true.
    246      *
    247      * @param support whether the WebView should support zoom
    248      */
    249     public abstract void setSupportZoom(boolean support);
    250 
    251     /**
    252      * Gets whether the WebView supports zoom.
    253      *
    254      * @return true if the WebView supports zoom
    255      * @see #setSupportZoom
    256      */
    257     public abstract boolean supportZoom();
    258 
    259     /**
    260      * Sets whether the WebView requires a user gesture to play media.
    261      * The default is true.
    262      *
    263      * @param require whether the WebView requires a user gesture to play media
    264      */
    265     public abstract void setMediaPlaybackRequiresUserGesture(boolean require);
    266 
    267     /**
    268      * Gets whether the WebView requires a user gesture to play media.
    269      *
    270      * @return true if the WebView requires a user gesture to play media
    271      * @see #setMediaPlaybackRequiresUserGesture
    272      */
    273     public abstract boolean getMediaPlaybackRequiresUserGesture();
    274 
    275     /**
    276      * Sets whether the WebView should use its built-in zoom mechanisms. The
    277      * built-in zoom mechanisms comprise on-screen zoom controls, which are
    278      * displayed over the WebView's content, and the use of a pinch gesture to
    279      * control zooming. Whether or not these on-screen controls are displayed
    280      * can be set with {@link #setDisplayZoomControls}. The default is false.
    281      * <p>
    282      * The built-in mechanisms are the only currently supported zoom
    283      * mechanisms, so it is recommended that this setting is always enabled.
    284      *
    285      * @param enabled whether the WebView should use its built-in zoom mechanisms
    286      */
    287     // This method was intended to select between the built-in zoom mechanisms
    288     // and the separate zoom controls. The latter were obtained using
    289     // {@link WebView#getZoomControls}, which is now hidden.
    290     public abstract void setBuiltInZoomControls(boolean enabled);
    291 
    292     /**
    293      * Gets whether the zoom mechanisms built into WebView are being used.
    294      *
    295      * @return true if the zoom mechanisms built into WebView are being used
    296      * @see #setBuiltInZoomControls
    297      */
    298     public abstract boolean getBuiltInZoomControls();
    299 
    300     /**
    301      * Sets whether the WebView should display on-screen zoom controls when
    302      * using the built-in zoom mechanisms. See {@link #setBuiltInZoomControls}.
    303      * The default is true.
    304      *
    305      * @param enabled whether the WebView should display on-screen zoom controls
    306      */
    307     public abstract void setDisplayZoomControls(boolean enabled);
    308 
    309     /**
    310      * Gets whether the WebView displays on-screen zoom controls when using
    311      * the built-in zoom mechanisms.
    312      *
    313      * @return true if the WebView displays on-screen zoom controls when using
    314      *         the built-in zoom mechanisms
    315      * @see #setDisplayZoomControls
    316      */
    317     public abstract boolean getDisplayZoomControls();
    318 
    319     /**
    320      * Enables or disables file access within WebView. File access is enabled by
    321      * default.  Note that this enables or disables file system access only.
    322      * Assets and resources are still accessible using file:///android_asset and
    323      * file:///android_res.
    324      */
    325     public abstract void setAllowFileAccess(boolean allow);
    326 
    327     /**
    328      * Gets whether this WebView supports file access.
    329      *
    330      * @see #setAllowFileAccess
    331      */
    332     public abstract boolean getAllowFileAccess();
    333 
    334     /**
    335      * Enables or disables content URL access within WebView.  Content URL
    336      * access allows WebView to load content from a content provider installed
    337      * in the system. The default is enabled.
    338      */
    339     public abstract void setAllowContentAccess(boolean allow);
    340 
    341     /**
    342      * Gets whether this WebView supports content URL access.
    343      *
    344      * @see #setAllowContentAccess
    345      */
    346     public abstract boolean getAllowContentAccess();
    347 
    348     /**
    349      * Sets whether the WebView loads pages in overview mode, that is,
    350      * zooms out the content to fit on screen by width. This setting is
    351      * taken into account when the content width is greater than the width
    352      * of the WebView control, for example, when {@link #getUseWideViewPort}
    353      * is enabled. The default is false.
    354      */
    355     public abstract void setLoadWithOverviewMode(boolean overview);
    356 
    357     /**
    358      * Gets whether this WebView loads pages in overview mode.
    359      *
    360      * @return whether this WebView loads pages in overview mode
    361      * @see #setLoadWithOverviewMode
    362      */
    363     public abstract boolean getLoadWithOverviewMode();
    364 
    365     /**
    366      * Sets whether the WebView will enable smooth transition while panning or
    367      * zooming or while the window hosting the WebView does not have focus.
    368      * If it is true, WebView will choose a solution to maximize the performance.
    369      * e.g. the WebView's content may not be updated during the transition.
    370      * If it is false, WebView will keep its fidelity. The default value is false.
    371      *
    372      * @deprecated This method is now obsolete, and will become a no-op in future.
    373      */
    374     @Deprecated
    375     public abstract void setEnableSmoothTransition(boolean enable);
    376 
    377     /**
    378      * Gets whether the WebView enables smooth transition while panning or
    379      * zooming.
    380      *
    381      * @see #setEnableSmoothTransition
    382      *
    383      * @deprecated This method is now obsolete, and will become a no-op in future.
    384      */
    385     @Deprecated
    386     public abstract  boolean enableSmoothTransition();
    387 
    388     /**
    389      * Sets whether the WebView uses its background for over scroll background.
    390      * If true, it will use the WebView's background. If false, it will use an
    391      * internal pattern. Default is true.
    392      *
    393      * @deprecated This method is now obsolete.
    394      * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
    395      */
    396     @SystemApi
    397     @Deprecated
    398     public abstract  void setUseWebViewBackgroundForOverscrollBackground(boolean view);
    399 
    400     /**
    401      * Gets whether this WebView uses WebView's background instead of
    402      * internal pattern for over scroll background.
    403      *
    404      * @see #setUseWebViewBackgroundForOverscrollBackground
    405      * @deprecated This method is now obsolete.
    406      * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
    407      */
    408     @SystemApi
    409     @Deprecated
    410     public abstract  boolean getUseWebViewBackgroundForOverscrollBackground();
    411 
    412     /**
    413      * Sets whether the WebView should save form data. The default is true.
    414      */
    415     public abstract  void setSaveFormData(boolean save);
    416 
    417     /**
    418      * Gets whether the WebView saves form data.
    419      *
    420      * @return whether the WebView saves form data
    421      * @see #setSaveFormData
    422      */
    423     public abstract boolean getSaveFormData();
    424 
    425     /**
    426      * Sets whether the WebView should save passwords. The default is true.
    427      * @deprecated Saving passwords in WebView will not be supported in future versions.
    428      */
    429     @Deprecated
    430     public abstract void setSavePassword(boolean save);
    431 
    432     /**
    433      * Gets whether the WebView saves passwords.
    434      *
    435      * @return whether the WebView saves passwords
    436      * @see #setSavePassword
    437      * @deprecated Saving passwords in WebView will not be supported in future versions.
    438      */
    439     @Deprecated
    440     public abstract boolean getSavePassword();
    441 
    442     /**
    443      * Sets the text zoom of the page in percent. The default is 100.
    444      *
    445      * @param textZoom the text zoom in percent
    446      */
    447     public abstract void setTextZoom(int textZoom);
    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 abstract int getTextZoom();
    456 
    457     /**
    458      * Sets policy for third party cookies.
    459      * Developers should access this via {@link CookieManager#setShouldAcceptThirdPartyCookies}.
    460      * @hide Internal API.
    461      */
    462     @SystemApi
    463     public abstract void setAcceptThirdPartyCookies(boolean accept);
    464 
    465     /**
    466      * Gets policy for third party cookies.
    467      * Developers should access this via {@link CookieManager#getShouldAcceptThirdPartyCookies}.
    468      * @hide Internal API
    469      */
    470     @SystemApi
    471     public abstract boolean getAcceptThirdPartyCookies();
    472 
    473     /**
    474      * Sets the text size of the page. The default is {@link TextSize#NORMAL}.
    475      *
    476      * @param t the text size as a {@link TextSize} value
    477      * @deprecated Use {@link #setTextZoom} instead.
    478      */
    479     public synchronized void setTextSize(TextSize t) {
    480         setTextZoom(t.value);
    481     }
    482 
    483     /**
    484      * Gets the text size of the page. If the text size was previously specified
    485      * in percent using {@link #setTextZoom}, this will return the closest
    486      * matching {@link TextSize}.
    487      *
    488      * @return the text size as a {@link TextSize} value
    489      * @see #setTextSize
    490      * @deprecated Use {@link #getTextZoom} instead.
    491      */
    492     public synchronized TextSize getTextSize() {
    493         TextSize closestSize = null;
    494         int smallestDelta = Integer.MAX_VALUE;
    495         int textSize = getTextZoom();
    496         for (TextSize size : TextSize.values()) {
    497             int delta = Math.abs(textSize - size.value);
    498             if (delta == 0) {
    499                 return size;
    500             }
    501             if (delta < smallestDelta) {
    502                 smallestDelta = delta;
    503                 closestSize = size;
    504             }
    505         }
    506         return closestSize != null ? closestSize : TextSize.NORMAL;
    507     }
    508 
    509     /**
    510      * Sets the default zoom density of the page. This must be called from the UI
    511      * thread. The default is {@link ZoomDensity#MEDIUM}.
    512      *
    513      * This setting is not recommended for use in new applications.  If the WebView
    514      * is utilized to display mobile-oriented pages, the desired effect can be achieved by
    515      * adjusting 'width' and 'initial-scale' attributes of page's 'meta viewport'
    516      * tag. For pages lacking the tag, {@link android.webkit.WebView#setInitialScale}
    517      * and {@link #setUseWideViewPort} can be used.
    518      *
    519      * @param zoom the zoom density
    520      * @deprecated This method is no longer supported, see the function documentation for
    521      *             recommended alternatives.
    522      */
    523     @Deprecated
    524     public abstract void setDefaultZoom(ZoomDensity zoom);
    525 
    526     /**
    527      * Gets the default zoom density of the page. This should be called from
    528      * the UI thread.
    529      *
    530      * This setting is not recommended for use in new applications.
    531      *
    532      * @return the zoom density
    533      * @see #setDefaultZoom
    534      * @deprecated Will only return the default value.
    535      */
    536     public abstract ZoomDensity getDefaultZoom();
    537 
    538     /**
    539      * Enables using light touches to make a selection and activate mouseovers.
    540      * @deprecated From {@link android.os.Build.VERSION_CODES#JELLY_BEAN} this
    541      *             setting is obsolete and has no effect.
    542      */
    543     @Deprecated
    544     public abstract void setLightTouchEnabled(boolean enabled);
    545 
    546     /**
    547      * Gets whether light touches are enabled.
    548      * @see #setLightTouchEnabled
    549      * @deprecated This setting is obsolete.
    550      */
    551     @Deprecated
    552     public abstract boolean getLightTouchEnabled();
    553 
    554     /**
    555      * Controlled a rendering optimization that is no longer present. Setting
    556      * it now has no effect.
    557      *
    558      * @deprecated This setting now has no effect.
    559      * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
    560      */
    561     @Deprecated
    562     public void setUseDoubleTree(boolean use) {
    563         // Specified to do nothing, so no need for derived classes to override.
    564     }
    565 
    566     /**
    567      * Controlled a rendering optimization that is no longer present. Setting
    568      * it now has no effect.
    569      *
    570      * @deprecated This setting now has no effect.
    571      * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
    572      */
    573     @Deprecated
    574     public boolean getUseDoubleTree() {
    575         // Returns false unconditionally, so no need for derived classes to override.
    576         return false;
    577     }
    578 
    579     /**
    580      * Sets the user-agent string using an integer code.
    581      * <ul>
    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      * Other values are ignored. The default is an Android user-agent string,
    586      * i.e. code value 0.
    587      *
    588      * @param ua the integer code for the user-agent string
    589      * @deprecated Please use {@link #setUserAgentString} instead.
    590      * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
    591      */
    592     @SystemApi
    593     @Deprecated
    594     public abstract void setUserAgent(int ua);
    595 
    596     /**
    597      * Gets the user-agent as an integer code.
    598      * <ul>
    599      *   <li>-1 means the WebView is using a custom user-agent string set with
    600      *   {@link #setUserAgentString}</li>
    601      *   <li>0 means the WebView should use an Android user-agent string</li>
    602      *   <li>1 means the WebView should use a desktop user-agent string</li>
    603      * </ul>
    604      *
    605      * @return the integer code for the user-agent string
    606      * @see #setUserAgent
    607      * @deprecated Please use {@link #getUserAgentString} instead.
    608      * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
    609      */
    610     @SystemApi
    611     @Deprecated
    612     public abstract int getUserAgent();
    613 
    614     /**
    615      * Sets whether the WebView should enable support for the &quot;viewport&quot;
    616      * HTML meta tag or should use a wide viewport.
    617      * When the value of the setting is false, the layout width is always set to the
    618      * width of the WebView control in device-independent (CSS) pixels.
    619      * When the value is true and the page contains the viewport meta tag, the value
    620      * of the width specified in the tag is used. If the page does not contain the tag or
    621      * does not provide a width, then a wide viewport will be used.
    622      *
    623      * @param use whether to enable support for the viewport meta tag
    624      */
    625     public abstract void setUseWideViewPort(boolean use);
    626 
    627     /**
    628      * Gets whether the WebView supports the &quot;viewport&quot;
    629      * HTML meta tag or will use a wide viewport.
    630      *
    631      * @return true if the WebView supports the viewport meta tag
    632      * @see #setUseWideViewPort
    633      */
    634     public abstract boolean getUseWideViewPort();
    635 
    636     /**
    637      * Sets whether the WebView whether supports multiple windows. If set to
    638      * true, {@link WebChromeClient#onCreateWindow} must be implemented by the
    639      * host application. The default is false.
    640      *
    641      * @param support whether to suport multiple windows
    642      */
    643     public abstract void setSupportMultipleWindows(boolean support);
    644 
    645     /**
    646      * Gets whether the WebView supports multiple windows.
    647      *
    648      * @return true if the WebView supports multiple windows
    649      * @see #setSupportMultipleWindows
    650      */
    651     public abstract boolean supportMultipleWindows();
    652 
    653     /**
    654      * Sets the underlying layout algorithm. This will cause a relayout of the
    655      * WebView. The default is {@link LayoutAlgorithm#NARROW_COLUMNS}.
    656      *
    657      * @param l the layout algorithm to use, as a {@link LayoutAlgorithm} value
    658      */
    659     public abstract void setLayoutAlgorithm(LayoutAlgorithm l);
    660 
    661     /**
    662      * Gets the current layout algorithm.
    663      *
    664      * @return the layout algorithm in use, as a {@link LayoutAlgorithm} value
    665      * @see #setLayoutAlgorithm
    666      */
    667     public abstract LayoutAlgorithm getLayoutAlgorithm();
    668 
    669     /**
    670      * Sets the standard font family name. The default is "sans-serif".
    671      *
    672      * @param font a font family name
    673      */
    674     public abstract void setStandardFontFamily(String font);
    675 
    676     /**
    677      * Gets the standard font family name.
    678      *
    679      * @return the standard font family name as a string
    680      * @see #setStandardFontFamily
    681      */
    682     public abstract String getStandardFontFamily();
    683 
    684     /**
    685      * Sets the fixed font family name. The default is "monospace".
    686      *
    687      * @param font a font family name
    688      */
    689     public abstract void setFixedFontFamily(String font);
    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 abstract String getFixedFontFamily();
    698 
    699     /**
    700      * Sets the sans-serif font family name. The default is "sans-serif".
    701      *
    702      * @param font a font family name
    703      */
    704     public abstract void setSansSerifFontFamily(String font);
    705 
    706     /**
    707      * Gets the sans-serif font family name.
    708      *
    709      * @return the sans-serif font family name as a string
    710      * @see #setSansSerifFontFamily
    711      */
    712     public abstract String getSansSerifFontFamily();
    713 
    714     /**
    715      * Sets the serif font family name. The default is "sans-serif".
    716      *
    717      * @param font a font family name
    718      */
    719     public abstract void setSerifFontFamily(String font);
    720 
    721     /**
    722      * Gets the serif font family name. The default is "serif".
    723      *
    724      * @return the serif font family name as a string
    725      * @see #setSerifFontFamily
    726      */
    727     public abstract String getSerifFontFamily();
    728 
    729     /**
    730      * Sets the cursive font family name. The default is "cursive".
    731      *
    732      * @param font a font family name
    733      */
    734     public abstract void setCursiveFontFamily(String font);
    735 
    736     /**
    737      * Gets the cursive font family name.
    738      *
    739      * @return the cursive font family name as a string
    740      * @see #setCursiveFontFamily
    741      */
    742     public abstract String getCursiveFontFamily();
    743 
    744     /**
    745      * Sets the fantasy font family name. The default is "fantasy".
    746      *
    747      * @param font a font family name
    748      */
    749     public abstract void setFantasyFontFamily(String font);
    750 
    751     /**
    752      * Gets the fantasy font family name.
    753      *
    754      * @return the fantasy font family name as a string
    755      * @see #setFantasyFontFamily
    756      */
    757     public abstract String getFantasyFontFamily();
    758 
    759     /**
    760      * Sets the minimum font size. The default is 8.
    761      *
    762      * @param size a non-negative integer between 1 and 72. Any number outside
    763      *             the specified range will be pinned.
    764      */
    765     public abstract void setMinimumFontSize(int size);
    766 
    767     /**
    768      * Gets the minimum font size.
    769      *
    770      * @return a non-negative integer between 1 and 72
    771      * @see #setMinimumFontSize
    772      */
    773     public abstract int getMinimumFontSize();
    774 
    775     /**
    776      * Sets the minimum logical font size. The default is 8.
    777      *
    778      * @param size a non-negative integer between 1 and 72. Any number outside
    779      *             the specified range will be pinned.
    780      */
    781     public abstract void setMinimumLogicalFontSize(int size);
    782 
    783     /**
    784      * Gets the minimum logical font size.
    785      *
    786      * @return a non-negative integer between 1 and 72
    787      * @see #setMinimumLogicalFontSize
    788      */
    789     public abstract int getMinimumLogicalFontSize();
    790 
    791     /**
    792      * Sets the default font size. The default is 16.
    793      *
    794      * @param size a non-negative integer between 1 and 72. Any number outside
    795      *             the specified range will be pinned.
    796      */
    797     public abstract void setDefaultFontSize(int size);
    798 
    799     /**
    800      * Gets the default font size.
    801      *
    802      * @return a non-negative integer between 1 and 72
    803      * @see #setDefaultFontSize
    804      */
    805     public abstract int getDefaultFontSize();
    806 
    807     /**
    808      * Sets the default fixed font size. The default is 16.
    809      *
    810      * @param size a non-negative integer between 1 and 72. Any number outside
    811      *             the specified range will be pinned.
    812      */
    813     public abstract void setDefaultFixedFontSize(int size);
    814 
    815     /**
    816      * Gets the default fixed font size.
    817      *
    818      * @return a non-negative integer between 1 and 72
    819      * @see #setDefaultFixedFontSize
    820      */
    821     public abstract int getDefaultFixedFontSize();
    822 
    823     /**
    824      * Sets whether the WebView should load image resources. Note that this method
    825      * controls loading of all images, including those embedded using the data
    826      * URI scheme. Use {@link #setBlockNetworkImage} to control loading only
    827      * of images specified using network URI schemes. Note that if the value of this
    828      * setting is changed from false to true, all images resources referenced
    829      * by content currently displayed by the WebView are loaded automatically.
    830      * The default is true.
    831      *
    832      * @param flag whether the WebView should load image resources
    833      */
    834     public abstract void setLoadsImagesAutomatically(boolean flag);
    835 
    836     /**
    837      * Gets whether the WebView loads image resources. This includes
    838      * images embedded using the data URI scheme.
    839      *
    840      * @return true if the WebView loads image resources
    841      * @see #setLoadsImagesAutomatically
    842      */
    843     public abstract boolean getLoadsImagesAutomatically();
    844 
    845     /**
    846      * Sets whether the WebView should not load image resources from the
    847      * network (resources accessed via http and https URI schemes).  Note
    848      * that this method has no effect unless
    849      * {@link #getLoadsImagesAutomatically} returns true. Also note that
    850      * disabling all network loads using {@link #setBlockNetworkLoads}
    851      * will also prevent network images from loading, even if this flag is set
    852      * to false. When the value of this setting is changed from true to false,
    853      * network images resources referenced by content currently displayed by
    854      * the WebView are fetched automatically. The default is false.
    855      *
    856      * @param flag whether the WebView should not load image resources from the
    857      *             network
    858      * @see #setBlockNetworkLoads
    859      */
    860     public abstract void setBlockNetworkImage(boolean flag);
    861 
    862     /**
    863      * Gets whether the WebView does not load image resources from the network.
    864      *
    865      * @return true if the WebView does not load image resources from the network
    866      * @see #setBlockNetworkImage
    867      */
    868     public abstract boolean getBlockNetworkImage();
    869 
    870     /**
    871      * Sets whether the WebView should not load resources from the network.
    872      * Use {@link #setBlockNetworkImage} to only avoid loading
    873      * image resources. Note that if the value of this setting is
    874      * changed from true to false, network resources referenced by content
    875      * currently displayed by the WebView are not fetched until
    876      * {@link android.webkit.WebView#reload} is called.
    877      * If the application does not have the
    878      * {@link android.Manifest.permission#INTERNET} permission, attempts to set
    879      * a value of false will cause a {@link java.lang.SecurityException}
    880      * to be thrown. The default value is false if the application has the
    881      * {@link android.Manifest.permission#INTERNET} permission, otherwise it is
    882      * true.
    883      *
    884      * @param flag true means block network loads by the WebView
    885      * @see android.webkit.WebView#reload
    886      */
    887     public abstract void setBlockNetworkLoads(boolean flag);
    888 
    889     /**
    890      * Gets whether the WebView does not load any resources from the network.
    891      *
    892      * @return true if the WebView does not load any resources from the network
    893      * @see #setBlockNetworkLoads
    894      */
    895     public abstract boolean getBlockNetworkLoads();
    896 
    897     /**
    898      * Tells the WebView to enable JavaScript execution.
    899      * <b>The default is false.</b>
    900      *
    901      * @param flag true if the WebView should execute JavaScript
    902      */
    903     public abstract void setJavaScriptEnabled(boolean flag);
    904 
    905     /**
    906      * Sets whether JavaScript running in the context of a file scheme URL
    907      * should be allowed to access content from any origin. This includes
    908      * access to content from other file scheme URLs. See
    909      * {@link #setAllowFileAccessFromFileURLs}. To enable the most restrictive,
    910      * and therefore secure policy, this setting should be disabled.
    911      * Note that this setting affects only JavaScript access to file scheme
    912      * resources. Other access to such resources, for example, from image HTML
    913      * elements, is unaffected. To prevent possible violation of same domain policy
    914      * on {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH} and earlier
    915      * devices, you should explicitly set this value to {@code false}.
    916      * <p>
    917      * The default value is true for API level
    918      * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and below,
    919      * and false for API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN}
    920      * and above.
    921      *
    922      * @param flag whether JavaScript running in the context of a file scheme
    923      *             URL should be allowed to access content from any origin
    924      */
    925     public abstract void setAllowUniversalAccessFromFileURLs(boolean flag);
    926 
    927     /**
    928      * Sets whether JavaScript running in the context of a file scheme URL
    929      * should be allowed to access content from other file scheme URLs. To
    930      * enable the most restrictive, and therefore secure policy, this setting
    931      * should be disabled. Note that the value of this setting is ignored if
    932      * the value of {@link #getAllowUniversalAccessFromFileURLs} is true.
    933      * Note too, that this setting affects only JavaScript access to file scheme
    934      * resources. Other access to such resources, for example, from image HTML
    935      * elements, is unaffected. To prevent possible violation of same domain policy
    936      * on {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH} and earlier
    937      * devices, you should explicitly set this value to {@code false}.
    938      * <p>
    939      * The default value is true for API level
    940      * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and below,
    941      * and false for API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN}
    942      * and above.
    943      *
    944      * @param flag whether JavaScript running in the context of a file scheme
    945      *             URL should be allowed to access content from other file
    946      *             scheme URLs
    947      */
    948     public abstract void setAllowFileAccessFromFileURLs(boolean flag);
    949 
    950     /**
    951      * Sets whether the WebView should enable plugins. The default is false.
    952      *
    953      * @param flag true if plugins should be enabled
    954      * @deprecated This method has been deprecated in favor of
    955      *             {@link #setPluginState}
    956      * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
    957      */
    958     @SystemApi
    959     @Deprecated
    960     public abstract void setPluginsEnabled(boolean flag);
    961 
    962     /**
    963      * Tells the WebView to enable, disable, or have plugins on demand. On
    964      * demand mode means that if a plugin exists that can handle the embedded
    965      * content, a placeholder icon will be shown instead of the plugin. When
    966      * the placeholder is clicked, the plugin will be enabled. The default is
    967      * {@link PluginState#OFF}.
    968      *
    969      * @param state a PluginState value
    970      * @deprecated Plugins will not be supported in future, and should not be used.
    971      */
    972     @Deprecated
    973     public abstract void setPluginState(PluginState state);
    974 
    975     /**
    976      * Sets a custom path to plugins used by the WebView. This method is
    977      * obsolete since each plugin is now loaded from its own package.
    978      *
    979      * @param pluginsPath a String path to the directory containing plugins
    980      * @deprecated This method is no longer used as plugins are loaded from
    981      *             their own APK via the system's package manager.
    982      * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
    983      */
    984     @Deprecated
    985     public void setPluginsPath(String pluginsPath) {
    986         // Specified to do nothing, so no need for derived classes to override.
    987     }
    988 
    989     /**
    990      * Sets the path to where database storage API databases should be saved.
    991      * In order for the database storage API to function correctly, this method
    992      * must be called with a path to which the application can write. This
    993      * method should only be called once: repeated calls are ignored.
    994      *
    995      * @param databasePath a path to the directory where databases should be
    996      *                     saved.
    997      * @deprecated Database paths are managed by the implementation and calling this method
    998      *             will have no effect.
    999      */
   1000     @Deprecated
   1001     public abstract void setDatabasePath(String databasePath);
   1002 
   1003     /**
   1004      * Sets the path where the Geolocation databases should be saved. In order
   1005      * for Geolocation permissions and cached positions to be persisted, this
   1006      * method must be called with a path to which the application can write.
   1007      *
   1008      * @param databasePath a path to the directory where databases should be
   1009      *                     saved.
   1010      * @deprecated Geolocation database are managed by the implementation and calling this method
   1011      *             will have no effect.
   1012      */
   1013     @Deprecated
   1014     public abstract void setGeolocationDatabasePath(String databasePath);
   1015 
   1016     /**
   1017      * Sets whether the Application Caches API should be enabled. The default
   1018      * is false. Note that in order for the Application Caches API to be
   1019      * enabled, a valid database path must also be supplied to
   1020      * {@link #setAppCachePath}.
   1021      *
   1022      * @param flag true if the WebView should enable Application Caches
   1023      */
   1024     public abstract void setAppCacheEnabled(boolean flag);
   1025 
   1026     /**
   1027      * Sets the path to the Application Caches files. In order for the
   1028      * Application Caches API to be enabled, this method must be called with a
   1029      * path to which the application can write. This method should only be
   1030      * called once: repeated calls are ignored.
   1031      *
   1032      * @param appCachePath a String path to the directory containing
   1033      *                     Application Caches files.
   1034      * @see #setAppCacheEnabled
   1035      */
   1036     public abstract void setAppCachePath(String appCachePath);
   1037 
   1038     /**
   1039      * Sets the maximum size for the Application Cache content. The passed size
   1040      * will be rounded to the nearest value that the database can support, so
   1041      * this should be viewed as a guide, not a hard limit. Setting the
   1042      * size to a value less than current database size does not cause the
   1043      * database to be trimmed. The default size is {@link Long#MAX_VALUE}.
   1044      * It is recommended to leave the maximum size set to the default value.
   1045      *
   1046      * @param appCacheMaxSize the maximum size in bytes
   1047      * @deprecated In future quota will be managed automatically.
   1048      */
   1049     @Deprecated
   1050     public abstract void setAppCacheMaxSize(long appCacheMaxSize);
   1051 
   1052     /**
   1053      * Sets whether the database storage API is enabled. The default value is
   1054      * false. See also {@link #setDatabasePath} for how to correctly set up the
   1055      * database storage API.
   1056      *
   1057      * This setting is global in effect, across all WebView instances in a process.
   1058      * Note you should only modify this setting prior to making <b>any</b> WebView
   1059      * page load within a given process, as the WebView implementation may ignore
   1060      * changes to this setting after that point.
   1061      *
   1062      * @param flag true if the WebView should use the database storage API
   1063      */
   1064     public abstract void setDatabaseEnabled(boolean flag);
   1065 
   1066     /**
   1067      * Sets whether the DOM storage API is enabled. The default value is false.
   1068      *
   1069      * @param flag true if the WebView should use the DOM storage API
   1070      */
   1071     public abstract void setDomStorageEnabled(boolean flag);
   1072 
   1073     /**
   1074      * Gets whether the DOM Storage APIs are enabled.
   1075      *
   1076      * @return true if the DOM Storage APIs are enabled
   1077      * @see #setDomStorageEnabled
   1078      */
   1079     public abstract boolean getDomStorageEnabled();
   1080 
   1081     /**
   1082      * Gets the path to where database storage API databases are saved.
   1083      *
   1084      * @return the String path to the database storage API databases
   1085      * @see #setDatabasePath
   1086      * @deprecated Database paths are managed by the implementation this method is obsolete.
   1087      */
   1088     @Deprecated
   1089     public abstract String getDatabasePath();
   1090 
   1091     /**
   1092      * Gets whether the database storage API is enabled.
   1093      *
   1094      * @return true if the database storage API is enabled
   1095      * @see #setDatabaseEnabled
   1096      */
   1097     public abstract boolean getDatabaseEnabled();
   1098 
   1099     /**
   1100      * Sets whether Geolocation is enabled. The default is true.
   1101      * <p>
   1102      * Please note that in order for the Geolocation API to be usable
   1103      * by a page in the WebView, the following requirements must be met:
   1104      * <ul>
   1105      *   <li>an application must have permission to access the device location,
   1106      *   see {@link android.Manifest.permission#ACCESS_COARSE_LOCATION},
   1107      *   {@link android.Manifest.permission#ACCESS_FINE_LOCATION};
   1108      *   <li>an application must provide an implementation of the
   1109      *   {@link WebChromeClient#onGeolocationPermissionsShowPrompt} callback
   1110      *   to receive notifications that a page is requesting access to location
   1111      *   via the JavaScript Geolocation API.
   1112      * </ul>
   1113      * <p>
   1114      *
   1115      * @param flag whether Geolocation should be enabled
   1116      */
   1117     public abstract void setGeolocationEnabled(boolean flag);
   1118 
   1119     /**
   1120      * Gets whether JavaScript is enabled.
   1121      *
   1122      * @return true if JavaScript is enabled
   1123      * @see #setJavaScriptEnabled
   1124      */
   1125     public abstract boolean getJavaScriptEnabled();
   1126 
   1127     /**
   1128      * Gets whether JavaScript running in the context of a file scheme URL can
   1129      * access content from any origin. This includes access to content from
   1130      * other file scheme URLs.
   1131      *
   1132      * @return whether JavaScript running in the context of a file scheme URL
   1133      *         can access content from any origin
   1134      * @see #setAllowUniversalAccessFromFileURLs
   1135      */
   1136     public abstract boolean getAllowUniversalAccessFromFileURLs();
   1137 
   1138     /**
   1139      * Gets whether JavaScript running in the context of a file scheme URL can
   1140      * access content from other file scheme URLs.
   1141      *
   1142      * @return whether JavaScript running in the context of a file scheme URL
   1143      *         can access content from other file scheme URLs
   1144      * @see #setAllowFileAccessFromFileURLs
   1145      */
   1146     public abstract boolean getAllowFileAccessFromFileURLs();
   1147 
   1148     /**
   1149      * Gets whether plugins are enabled.
   1150      *
   1151      * @return true if plugins are enabled
   1152      * @see #setPluginsEnabled
   1153      * @deprecated This method has been replaced by {@link #getPluginState}
   1154      * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
   1155      */
   1156     @SystemApi
   1157     @Deprecated
   1158     public abstract boolean getPluginsEnabled();
   1159 
   1160     /**
   1161      * Gets the current state regarding whether plugins are enabled.
   1162      *
   1163      * @return the plugin state as a {@link PluginState} value
   1164      * @see #setPluginState
   1165      * @deprecated Plugins will not be supported in future, and should not be used.
   1166      */
   1167     @Deprecated
   1168     public abstract PluginState getPluginState();
   1169 
   1170     /**
   1171      * Gets the directory that contains the plugin libraries. This method is
   1172      * obsolete since each plugin is now loaded from its own package.
   1173      *
   1174      * @return an empty string
   1175      * @deprecated This method is no longer used as plugins are loaded from
   1176      * their own APK via the system's package manager.
   1177      * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
   1178      */
   1179     @Deprecated
   1180     public String getPluginsPath() {
   1181         // Unconditionally returns empty string, so no need for derived classes to override.
   1182         return "";
   1183     }
   1184 
   1185     /**
   1186      * Tells JavaScript to open windows automatically. This applies to the
   1187      * JavaScript function window.open(). The default is false.
   1188      *
   1189      * @param flag true if JavaScript can open windows automatically
   1190      */
   1191     public abstract void setJavaScriptCanOpenWindowsAutomatically(boolean flag);
   1192 
   1193     /**
   1194      * Gets whether JavaScript can open windows automatically.
   1195      *
   1196      * @return true if JavaScript can open windows automatically during
   1197      *         window.open()
   1198      * @see #setJavaScriptCanOpenWindowsAutomatically
   1199      */
   1200     public abstract boolean getJavaScriptCanOpenWindowsAutomatically();
   1201 
   1202     /**
   1203      * Sets the default text encoding name to use when decoding html pages.
   1204      * The default is "UTF-8".
   1205      *
   1206      * @param encoding the text encoding name
   1207      */
   1208     public abstract void setDefaultTextEncodingName(String encoding);
   1209 
   1210     /**
   1211      * Gets the default text encoding name.
   1212      *
   1213      * @return the default text encoding name as a string
   1214      * @see #setDefaultTextEncodingName
   1215      */
   1216     public abstract String getDefaultTextEncodingName();
   1217 
   1218     /**
   1219      * Sets the WebView's user-agent string. If the string is null or empty,
   1220      * the system default value will be used.
   1221      *
   1222      * Note that starting from {@link android.os.Build.VERSION_CODES#KITKAT} Android
   1223      * version, changing the user-agent while loading a web page causes WebView
   1224      * to initiate loading once again.
   1225      *
   1226      * @param ua new user-agent string
   1227      */
   1228     public abstract void setUserAgentString(String ua);
   1229 
   1230     /**
   1231      * Gets the WebView's user-agent string.
   1232      *
   1233      * @return the WebView's user-agent string
   1234      * @see #setUserAgentString
   1235      */
   1236     public abstract String getUserAgentString();
   1237 
   1238     /**
   1239      * Returns the default User-Agent used by a WebView.
   1240      * An instance of WebView could use a different User-Agent if a call
   1241      * is made to {@link WebSettings#setUserAgentString(String)}.
   1242      *
   1243      * @param context a Context object used to access application assets
   1244      */
   1245     public static String getDefaultUserAgent(Context context) {
   1246         return WebViewFactory.getProvider().getStatics().getDefaultUserAgent(context);
   1247     }
   1248 
   1249     /**
   1250      * Tells the WebView whether it needs to set a node to have focus when
   1251      * {@link WebView#requestFocus(int, android.graphics.Rect)} is called. The
   1252      * default value is true.
   1253      *
   1254      * @param flag whether the WebView needs to set a node
   1255      */
   1256     public abstract void setNeedInitialFocus(boolean flag);
   1257 
   1258     /**
   1259      * Sets the priority of the Render thread. Unlike the other settings, this
   1260      * one only needs to be called once per process. The default value is
   1261      * {@link RenderPriority#NORMAL}.
   1262      *
   1263      * @param priority the priority
   1264      * @deprecated It is not recommended to adjust thread priorities, and this will
   1265      *             not be supported in future versions.
   1266      */
   1267     @Deprecated
   1268     public abstract void setRenderPriority(RenderPriority priority);
   1269 
   1270     /**
   1271      * Overrides the way the cache is used. The way the cache is used is based
   1272      * on the navigation type. For a normal page load, the cache is checked
   1273      * and content is re-validated as needed. When navigating back, content is
   1274      * not revalidated, instead the content is just retrieved from the cache.
   1275      * This method allows the client to override this behavior by specifying
   1276      * one of {@link #LOAD_DEFAULT},
   1277      * {@link #LOAD_CACHE_ELSE_NETWORK}, {@link #LOAD_NO_CACHE} or
   1278      * {@link #LOAD_CACHE_ONLY}. The default value is {@link #LOAD_DEFAULT}.
   1279      *
   1280      * @param mode the mode to use
   1281      */
   1282     public abstract void setCacheMode(@CacheMode int mode);
   1283 
   1284     /**
   1285      * Gets the current setting for overriding the cache mode.
   1286      *
   1287      * @return the current setting for overriding the cache mode
   1288      * @see #setCacheMode
   1289      */
   1290     @CacheMode
   1291     public abstract int getCacheMode();
   1292 
   1293     /**
   1294      * Configures the WebView's behavior when a secure origin attempts to load a resource from an
   1295      * insecure origin.
   1296      *
   1297      * By default, apps that target {@link android.os.Build.VERSION_CODES#KITKAT} or below default
   1298      * to {@link #MIXED_CONTENT_ALWAYS_ALLOW}. Apps targeting
   1299      * {@link android.os.Build.VERSION_CODES#LOLLIPOP} default to {@link #MIXED_CONTENT_NEVER_ALLOW}.
   1300      *
   1301      * The preferred and most secure mode of operation for the WebView is
   1302      * {@link #MIXED_CONTENT_NEVER_ALLOW} and use of {@link #MIXED_CONTENT_ALWAYS_ALLOW} is
   1303      * strongly discouraged.
   1304      *
   1305      * @param mode The mixed content mode to use. One of {@link #MIXED_CONTENT_NEVER_ALLOW},
   1306      *     {@link #MIXED_CONTENT_ALWAYS_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}.
   1307      */
   1308     public abstract void setMixedContentMode(int mode);
   1309 
   1310     /**
   1311      * Gets the current behavior of the WebView with regard to loading insecure content from a
   1312      * secure origin.
   1313      * @return The current setting, one of {@link #MIXED_CONTENT_NEVER_ALLOW},
   1314      *     {@link #MIXED_CONTENT_ALWAYS_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}.
   1315      */
   1316     public abstract int getMixedContentMode();
   1317 
   1318     /**
   1319      * Sets whether to use a video overlay for embedded encrypted video.
   1320      * In API levels prior to {@link android.os.Build.VERSION_CODES#LOLLIPOP}, encrypted video can
   1321      * only be rendered directly on a secure video surface, so it had been a hard problem to play
   1322      * encrypted video in HTML.  When this flag is on, WebView can play encrypted video (MSE/EME)
   1323      * by using a video overlay (aka hole-punching) for videos embedded using HTML &lt;video&gt;
   1324      * tag.<br>
   1325      * Caution: This setting is intended for use only in a narrow set of circumstances and apps
   1326      * should only enable it if they require playback of encrypted video content. It will impose
   1327      * the following limitations on the WebView:
   1328      * <ul>
   1329      * <li> Only one video overlay can be played at a time.
   1330      * <li> Changes made to position or dimensions of a video element may be propagated to the
   1331      * corresponding video overlay with a noticeable delay.
   1332      * <li> The video overlay is not visible to web APIs and as such may not interact with
   1333      * script or styling. For example, CSS styles applied to the &lt;video&gt; tag may be ignored.
   1334      * </ul>
   1335      * This is not an exhaustive set of constraints and it may vary with new versions of the
   1336      * WebView.
   1337      * @hide
   1338      */
   1339     @SystemApi
   1340     public abstract void setVideoOverlayForEmbeddedEncryptedVideoEnabled(boolean flag);
   1341 
   1342     /**
   1343      * Gets whether a video overlay will be used for embedded encrypted video.
   1344      *
   1345      * @return true if WebView uses a video overlay for embedded encrypted video.
   1346      * @see #setVideoOverlayForEmbeddedEncryptedVideoEnabled
   1347      * @hide
   1348      */
   1349     @SystemApi
   1350     public abstract boolean getVideoOverlayForEmbeddedEncryptedVideoEnabled();
   1351 
   1352     /**
   1353      * Sets whether this WebView should raster tiles when it is
   1354      * offscreen but attached to a window. Turning this on can avoid
   1355      * rendering artifacts when animating an offscreen WebView on-screen.
   1356      * Offscreen WebViews in this mode use more memory. The default value is
   1357      * false.<br>
   1358      * Please follow these guidelines to limit memory usage:
   1359      * <ul>
   1360      * <li> WebView size should be not be larger than the device screen size.
   1361      * <li> Limit use of this mode to a small number of WebViews. Use it for
   1362      *   visible WebViews and WebViews about to be animated to visible.
   1363      * </ul>
   1364      */
   1365     public abstract void setOffscreenPreRaster(boolean enabled);
   1366 
   1367     /**
   1368      * Gets whether this WebView should raster tiles when it is
   1369      * offscreen but attached to a window.
   1370      * @return true if this WebView will raster tiles when it is
   1371      * offscreen but attached to a window.
   1372      */
   1373     public abstract boolean getOffscreenPreRaster();
   1374 
   1375     /**
   1376      * @hide
   1377      */
   1378     @IntDef(flag = true,
   1379             value = {
   1380                     MENU_ITEM_NONE,
   1381                     MENU_ITEM_SHARE,
   1382                     MENU_ITEM_WEB_SEARCH,
   1383                     MENU_ITEM_PROCESS_TEXT
   1384             })
   1385     @Retention(RetentionPolicy.SOURCE)
   1386     @Target({ElementType.PARAMETER, ElementType.METHOD})
   1387     private @interface MenuItemFlags {}
   1388 
   1389     /**
   1390      * Disables the action mode menu items according to {@code menuItems} flag.
   1391      * @param menuItems an integer field flag for the menu items to be disabled.
   1392      */
   1393     public abstract void setDisabledActionModeMenuItems(@MenuItemFlags int menuItems);
   1394 
   1395     /**
   1396      * Gets the action mode menu items that are disabled, expressed in an integer field flag.
   1397      * The default value is {@link #MENU_ITEM_NONE}
   1398      *
   1399      * @return all the disabled menu item flags combined with bitwise OR.
   1400      */
   1401     public abstract @MenuItemFlags int getDisabledActionModeMenuItems();
   1402 
   1403     /**
   1404      * Used with {@link #setDisabledActionModeMenuItems}.
   1405      *
   1406      * No menu items should be disabled.
   1407      */
   1408     public static final int MENU_ITEM_NONE = 0;
   1409 
   1410     /**
   1411      * Used with {@link #setDisabledActionModeMenuItems}.
   1412      *
   1413      * Disable menu item "Share".
   1414      */
   1415     public static final int MENU_ITEM_SHARE = 1 << 0;
   1416 
   1417     /**
   1418      * Used with {@link #setDisabledActionModeMenuItems}.
   1419      *
   1420      * Disable menu item "Web Search".
   1421      */
   1422     public static final int MENU_ITEM_WEB_SEARCH = 1 << 1;
   1423 
   1424     /**
   1425      * Used with {@link #setDisabledActionModeMenuItems}.
   1426      *
   1427      * Disable all the action mode menu items for text processing.
   1428      * By default WebView searches for activities that are able to handle
   1429      * {@link android.content.Intent#ACTION_PROCESS_TEXT} and show them in the
   1430      * action mode menu. If this flag is set via {@link
   1431      * #setDisabledActionModeMenuItems}, these menu items will be disabled.
   1432      */
   1433     public static final int MENU_ITEM_PROCESS_TEXT = 1 << 2;
   1434 }
   1435