OSDN Git Service

Add the on-demand setting for plugins.
authorPatrick Scott <phanna@android.com>
Mon, 22 Mar 2010 14:19:32 +0000 (10:19 -0400)
committerPatrick Scott <phanna@android.com>
Tue, 23 Mar 2010 18:32:56 +0000 (14:32 -0400)
Requires a change to webkit and the framework.

Bug: 2411524
Change-Id: I874e4e2139eedf4bc9332947fe6513b027e660d9

res/values/strings.xml
res/xml/browser_preferences.xml
src/com/android/browser/BrowserSettings.java

index 1b02aac..3e9a7be 100644 (file)
     <string name="pref_content_open_in_background">Open in background</string>
     <!-- Settings label -->
     <string name="pref_content_plugins">Enable plug-ins</string>
+    <!-- Plugin options -->
+    <string-array name="pref_content_plugins_choices">
+        <item>Always on</item>
+        <item>On demand</item>
+        <item>Off</item>
+    </string-array>
+    <string-array name="pref_content_plugins_values">
+        <item>ON</item>
+        <item>ON_DEMAND</item>
+        <item>OFF</item>
+    </string-array>
     <!-- Settings summary -->
     <string name="pref_content_open_in_background_summary">Open new windows behind the current one</string>
     <!-- Settings label -->
index 04c0ebe..ee1b306 100644 (file)
                 android:defaultValue="true"
                 android:title="@string/pref_content_javascript" />     
 
-        <CheckBoxPreference
-                android:key="enable_plugins"
-                android:defaultValue="true"
-                android:title="@string/pref_content_plugins" />
+        <ListPreference
+                android:key="plugin_state"
+                android:title="@string/pref_content_plugins"
+                android:defaultValue="ON"
+                android:entries="@array/pref_content_plugins_choices"
+                android:entryValues="@array/pref_content_plugins_values"
+                android:dialogTitle="@string/pref_content_plugins" />
 
         <CheckBoxPreference
                 android:key="open_in_background"
index f58478f..39c2f1e 100644 (file)
@@ -63,7 +63,7 @@ class BrowserSettings extends Observable {
     // Note: boolean variables are set inside reset function.
     private boolean loadsImagesAutomatically;
     private boolean javaScriptEnabled;
-    private boolean pluginsEnabled;
+    private WebSettings.PluginState pluginState;
     private boolean javaScriptCanOpenWindowsAutomatically;
     private boolean showSecurityWarnings;
     private boolean rememberPasswords;
@@ -186,7 +186,7 @@ class BrowserSettings extends Observable {
             s.setUseWideViewPort(b.useWideViewPort);
             s.setLoadsImagesAutomatically(b.loadsImagesAutomatically);
             s.setJavaScriptEnabled(b.javaScriptEnabled);
-            s.setPluginsEnabled(b.pluginsEnabled);
+            s.setPluginState(b.pluginState);
             s.setJavaScriptCanOpenWindowsAutomatically(
                     b.javaScriptCanOpenWindowsAutomatically);
             s.setDefaultTextEncodingName(b.defaultTextEncodingName);
@@ -285,8 +285,8 @@ class BrowserSettings extends Observable {
                 loadsImagesAutomatically);
         javaScriptEnabled = p.getBoolean("enable_javascript",
                 javaScriptEnabled);
-        pluginsEnabled = p.getBoolean("enable_plugins",
-                pluginsEnabled);
+        pluginState = WebSettings.PluginState.valueOf(
+                p.getString("plugin_state", pluginState.name()));
         javaScriptCanOpenWindowsAutomatically = !p.getBoolean(
             "block_popup_windows",
             !javaScriptCanOpenWindowsAutomatically);
@@ -591,7 +591,7 @@ class BrowserSettings extends Observable {
         // is improved.
         loadsImagesAutomatically = true;
         javaScriptEnabled = true;
-        pluginsEnabled = true;
+        pluginState = WebSettings.PluginState.ON;
         javaScriptCanOpenWindowsAutomatically = false;
         showSecurityWarnings = true;
         rememberPasswords = true;