/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.webkit;
import android.annotation.SystemApi;
import android.content.Context;
/**
* Manages settings state for a WebView. When a WebView is first created, it
* obtains a set of default settings. These default settings will be returned
* from any getter call. A WebSettings object obtained from
* WebView.getSettings() is tied to the life of the WebView. If a WebView has
* been destroyed, any method call on WebSettings will throw an
* IllegalStateException.
*/
// This is an abstract base class: concrete WebViewProviders must
// create a class derived from this, and return an instance of it in the
// WebViewProvider.getWebSettingsProvider() method implementation.
public abstract class WebSettings {
/**
* Enum for controlling the layout of html.
* <ul>
* <li>NORMAL means no rendering changes. This is the recommended choice for maximum
* compatibility across different platforms and Android versions.</li>
* <li>SINGLE_COLUMN moves all content into one column that is the width of the
* view.</li>
* <li>NARROW_COLUMNS makes all columns no wider than the screen if possible. Only use
* this for API levels prior to {@link android.os.Build.VERSION_CODES#KITKAT}.</li>
* <li>TEXT_AUTOSIZING boosts font size of paragraphs based on heuristics to make
* the text readable when viewing a wide-viewport layout in the overview mode.
* It is recommended to enable zoom support {@link #setSupportZoom} when
* using this mode. Supported from API level
* {@link android.os.Build.VERSION_CODES#KITKAT}</li>
* </ul>
*/
// XXX: These must match LayoutAlgorithm in Settings.h in WebCore.
public enum LayoutAlgorithm {
NORMAL,
/**
* @deprecated This algorithm is now obsolete.
*/
@Deprecated
SINGLE_COLUMN,
/**
* @deprecated This algorithm is now obsolete.
*/
@Deprecated
NARROW_COLUMNS,
TEXT_AUTOSIZING
}
/**
* Enum for specifying the text size.
* <ul>
* <li>SMALLEST is 50%</li>
* <li>SMALLER is 75%</li>
* <li>NORMAL is 100%</li>
* <li>LARGER is 150%</li>
* <li>LARGEST is 200%</li>
* </ul>
*
* @deprecated Use {@link WebSettings#setTextZoom(int)} and {@link WebSettings#getTextZoom()} instead.
*/
public enum TextSize {
SMALLEST(50),
SMALLER(75),
NORMAL(100),
LARGER(150),
LARGEST(200);
TextSize(int size) {
value = size;
}
int value;
}
/**
* Enum for specifying the WebView's desired density.
* <ul>
* <li>FAR makes 100% looking like in 240dpi</li>
* <li>MEDIUM makes 100% looking like in 160dpi</li>
* <li>CLOSE makes 100% looking like in 120dpi</li>
* </ul>
*/
public enum ZoomDensity {
FAR(150), // 240dpi
MEDIUM(100), // 160dpi
CLOSE(75); // 120dpi
ZoomDensity(int size) {
value = size;
}
/**
* @hide Only for use by WebViewProvider implementations
*/
public int getValue() {
return value;
}
int value;
}
/**
* Default cache usage mode. If the navigation type doesn't impose any
* specific behavior, use cached resources when they are available
* and not expired, otherwise load resources from the network.
* Use with {@link #setCacheMode}.
*/
public static final int LOAD_DEFAULT = -1;
/**
* Normal cache usage mode. Use with {@link #setCacheMode}.
*
* @deprecated This value is obsolete, as from API level
* {@link android.os.Build.VERSION_CODES#HONEYCOMB} and onwards it has the
* same effect as {@link #LOAD_DEFAULT}.
*/
@Deprecated
public static final int LOAD_NORMAL = 0;
/**
* Use cached resources when they are available, even if they have expired.
* Otherwise load resources from the network.
* Use with {@link #setCacheMode}.
*/
public static final int LOAD_CACHE_ELSE_NETWORK = 1;
/**
* Don't use the cache, load from the network.
* Use with {@link #setCacheMode}.
*/
public static final int LOAD_NO_CACHE = 2;
/**
* Don't use the network, load from the cache.
* Use with {@link #setCacheMode}.
*/
public static final int LOAD_CACHE_ONLY = 3;
public enum RenderPriority {
NORMAL,
HIGH,
LOW
}
/**
* The plugin state effects how plugins are treated on a page. ON means
* that any object will be loaded even if a plugin does not exist to handle
* the content. ON_DEMAND means that if there is a plugin installed that
* can handle the content, a placeholder is shown until the user clicks on
* the placeholder. Once clicked, the plugin will be enabled on the page.
* OFF means that all plugins will be turned off and any fallback content
* will be used.
*/
public enum PluginState {
ON,
ON_DEMAND,
OFF
}
/**
* Used with {@link #setMixedContentMode}
*
* In this mode, the WebView will allow a secure origin to load content from any other origin,
* even if that origin is insecure. This is the least secure mode of operation for the WebView,
* and where possible apps should not set this mode.
*/
public static final int MIXED_CONTENT_ALWAYS_ALLOW = 0;
/**
* Used with {@link #setMixedContentMode}
*
* In this mode, the WebView will not allow a secure origin to load content from an insecure
* origin. This is the preferred and most secure mode of operation for the WebView and apps are
* strongly advised to use this mode.
*/
public static final int MIXED_CONTENT_NEVER_ALLOW = 1;
/**
* Used with {@link #setMixedContentMode}
*
* In this mode, the WebView will attempt to be compatible with the approach of a modern web
* browser with regard to mixed content. Some insecure content may be allowed to be loaded by
* a secure origin and other types of content will be blocked. The types of content are allowed
* or blocked may change release to release and are not explicitly defined.
*
* This mode is intended to be used by apps that are not in control of the content that they
* render but desire to operate in a reasonably secure environment. For highest security, apps
* are recommended to use {@link #MIXED_CONTENT_NEVER_ALLOW}.
*/
public static final int MIXED_CONTENT_COMPATIBILITY_MODE = 2;
/**
* Enables dumping the pages navigation cache to a text file. The default
* is false.
*
* @deprecated This method is now obsolete.
* @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
*/
@SystemApi
@Deprecated
public abstract void setNavDump(boolean enabled);
/**
* Gets whether dumping the navigation cache is enabled.
*
* @return whether dumping the navigation cache is enabled
* @see #setNavDump
* @deprecated This method is now obsolete.
* @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}
*/
@SystemApi
@Deprecated
评论0