Add on-demand setting for plugins.

Deprecate the old apis for enabling plugins in favor of the multi-state plugin
flag. Add the assets for WebView to display the plugin placeholder for on-demand
plugins.

Bug: 2411524
Change-Id: I5a35cc6d0afced1489f54d4dcb8bb92d36de52d8
This commit is contained in:
Patrick Scott
2010-03-22 10:20:45 -04:00
parent 7e6ee51359
commit 300f2e95a4
4 changed files with 100 additions and 6 deletions

View File

@@ -193673,6 +193673,17 @@
visibility="public"
>
</method>
<method name="getPluginState"
return="android.webkit.WebSettings.PluginState"
abstract="false"
native="false"
synchronized="true"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="getPluginsEnabled"
return="boolean"
abstract="false"
@@ -193680,7 +193691,7 @@
synchronized="true"
static="false"
final="false"
deprecated="not deprecated"
deprecated="deprecated"
visibility="public"
>
</method>
@@ -194206,7 +194217,7 @@
<parameter name="flag" type="boolean">
</parameter>
</method>
<method name="setPluginsEnabled"
<method name="setPluginState"
return="void"
abstract="false"
native="false"
@@ -194216,6 +194227,19 @@
deprecated="not deprecated"
visibility="public"
>
<parameter name="state" type="android.webkit.WebSettings.PluginState">
</parameter>
</method>
<method name="setPluginsEnabled"
return="void"
abstract="false"
native="false"
synchronized="true"
static="false"
final="false"
deprecated="deprecated"
visibility="public"
>
<parameter name="flag" type="boolean">
</parameter>
</method>
@@ -194525,6 +194549,39 @@
>
</method>
</class>
<class name="WebSettings.PluginState"
extends="java.lang.Enum"
abstract="false"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
<method name="valueOf"
return="android.webkit.WebSettings.PluginState"
abstract="false"
native="false"
synchronized="false"
static="true"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="name" type="java.lang.String">
</parameter>
</method>
<method name="values"
return="android.webkit.WebSettings.PluginState[]"
abstract="false"
native="false"
synchronized="false"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</method>
</class>
<class name="WebSettings.RenderPriority"
extends="java.lang.Enum"
abstract="false"

View File

@@ -120,6 +120,21 @@ public class WebSettings {
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
}
// WebView associated with this WebSettings.
private WebView mWebView;
// BrowserFrame used to access the native frame pointer.
@@ -157,7 +172,7 @@ public class WebSettings {
private boolean mBlockNetworkImage = false;
private boolean mBlockNetworkLoads;
private boolean mJavaScriptEnabled = false;
private boolean mPluginsEnabled = false;
private PluginState mPluginState = PluginState.OFF;
private boolean mJavaScriptCanOpenWindowsAutomatically = false;
private boolean mUseDoubleTree = false;
private boolean mUseWideViewport = false;
@@ -1011,10 +1026,23 @@ public class WebSettings {
/**
* Tell the WebView to enable plugins.
* @param flag True if the WebView should load plugins.
* @deprecated This method has been deprecated in favor of
* {@link #setPluginState}
*/
public synchronized void setPluginsEnabled(boolean flag) {
if (mPluginsEnabled != flag) {
mPluginsEnabled = flag;
setPluginState(PluginState.ON);
}
/**
* Tell the WebView to enable, disable, or have plugins on demand. On
* demand mode means that if a plugin exists that can handle the embedded
* content, a placeholder icon will be shown instead of the plugin. When
* the placeholder is clicked, the plugin will be enabled.
* @param state One of the PluginState values.
*/
public synchronized void setPluginState(PluginState state) {
if (mPluginState != state) {
mPluginState = state;
postSync();
}
}
@@ -1176,9 +1204,18 @@ public class WebSettings {
/**
* Return true if plugins are enabled.
* @return True if plugins are enabled.
* @deprecated This method has been replaced by {@link #getPluginState}
*/
public synchronized boolean getPluginsEnabled() {
return mPluginsEnabled;
return mPluginState == PluginState.ON;
}
/**
* Return the current plugin state.
* @return A value corresponding to the enum PluginState.
*/
public synchronized PluginState getPluginState() {
return mPluginState;
}
/**

Binary file not shown.

After

Width:  |  Height:  |  Size: 1009 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B