author | Margaret Leibovic <margaret.leibovic@gmail.com> |
Tue, 13 Dec 2011 14:28:45 -0800 | |
changeset 84166 | 41ceaff2e5f11916534b58bf99f72429f00e91cd |
parent 84165 | 21e55816051dbbeb70a9e5ce58c1660c18cd6189 |
child 84167 | a9337c4d018c8260b913aeb8184f84cd43f08854 |
push id | 519 |
push user | akeybl@mozilla.com |
push date | Wed, 01 Feb 2012 00:38:35 +0000 |
treeherder | mozilla-beta@788ea1ef610b [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mfinkle, no-cpp |
bugs | 702653 |
milestone | 11.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/mobile/android/base/GeckoPreferences.java +++ b/mobile/android/base/GeckoPreferences.java @@ -33,16 +33,17 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ package org.mozilla.gecko; +import java.lang.CharSequence; import java.util.ArrayList; import android.os.Build; import android.os.Bundle; import android.content.res.Resources; import android.content.Context; import android.preference.*; import android.preference.Preference.*; @@ -126,18 +127,22 @@ public class GeckoPreferences return super.onOptionsItemSelected(item); } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { String prefName = preference.getKey(); setPreference(prefName, newValue); - if (preference instanceof ListPreference) - ((ListPreference)preference).setSummary((String)newValue); + if (preference instanceof ListPreference) { + // We need to find the entry for the new value + int newIndex = ((ListPreference)preference).findIndexOfValue((String) newValue); + CharSequence newEntry = ((ListPreference)preference).getEntries()[newIndex]; + ((ListPreference)preference).setSummary(newEntry); + } if (preference instanceof LinkPreference) finish(); return true; } private void refresh(JSONArray jsonPrefs) { // enable all preferences once we have them from gecko GeckoAppShell.getMainHandler().post(new Runnable() { @@ -172,16 +177,19 @@ public class GeckoPreferences ((EditTextPreference)pref).setText(value); } }); } else if (pref instanceof ListPreference && "string".equals(prefType)) { final String value = jPref.getString("value"); GeckoAppShell.getMainHandler().post(new Runnable() { public void run() { ((ListPreference)pref).setValue(value); + // Set the summary string to the current entry + CharSequence selectedEntry = ((ListPreference)pref).getEntry(); + ((ListPreference)pref).setSummary(selectedEntry); } }); } } } catch (JSONException e) { Log.e(LOGTAG, "Problem parsing preferences response: ", e); } }
--- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -201,16 +201,17 @@ RES_LAYOUT = \ RES_LAYOUT_V11 = \ res/layout-v11/awesomebar_search.xml \ res/layout-v11/gecko_app.xml \ res/layout-v11/gecko_app_actionbar.xml \ $(NULL) RES_VALUES = \ res/values/defaults.xml \ + res/values/arrays.xml \ res/values/colors.xml \ res/values/styles.xml \ res/values/themes.xml \ $(NULL) RES_VALUES_V11 = \ res/values-v11/styles.xml \ res/values-v11/themes.xml \ @@ -448,16 +449,17 @@ RES_DRAWABLE = $(addprefix res/drawable/ $(RES_LAYOUT_V11): $(subst res/,$(srcdir)/resources/,$(RES_LAYOUT_V11)) $(NSINSTALL) -D res/layout-v11 $(NSINSTALL) $(srcdir)/resources/layout-v11/* res/layout-v11/ $(RES_VALUES): \ $(srcdir)/resources/values/colors.xml \ $(srcdir)/resources/values/styles.xml \ $(srcdir)/resources/values/themes.xml \ + $(srcdir)/resources/values/arrays.xml \ $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/res/values/defaults.xml $(NSINSTALL) -D res/values $(NSINSTALL) $^ res/values $(RES_VALUES_V11): $(subst res/,$(srcdir)/resources/,$(RES_VALUES_V11)) $(NSINSTALL) -D res/values-v11 $(NSINSTALL) $(srcdir)/resources/values-v11/* res/values-v11
--- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -57,16 +57,20 @@ <!ENTITY pref_homepage_current "Current page"> <!ENTITY pref_remember_signons "Remember passwords"> <!ENTITY pref_cookies "Enable cookies"> <!ENTITY pref_char_encoding "Show character encoding"> <!ENTITY pref_clear_history "Clear history"> <!ENTITY pref_clear_history_confirm "Browsing history will be deleted"> <!ENTITY pref_clear_private_data "Clear private data"> <!ENTITY pref_clear_private_data_confirm "Browsing settings, including passwords and cookies, will be deleted"> +<!ENTITY pref_enable_flash "Enable Flash"> +<!ENTITY pref_enable_flash_yes "Yes"> +<!ENTITY pref_enable_flash_tap_to_play "Tap To Play"> +<!ENTITY pref_enable_flash_no "No"> <!ENTITY quit "Quit"> <!ENTITY addons "Add-ons"> <!ENTITY share "Share"> <!ENTITY save_as_pdf "Save as PDF"> <!ENTITY agent_request_desktop "Request Desktop Site">
new file mode 100644 --- /dev/null +++ b/mobile/android/base/resources/values/arrays.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> + +<resources> + <string-array name="pref_enable_flash_entries"> + <item>@string/pref_enable_flash_yes</item> + <item>@string/pref_enable_flash_tap_to_play</item> + <item>@string/pref_enable_flash_no</item> + </string-array> + <string-array name="pref_enable_flash_values"> + <item>1</item> + <item>2</item> + <item>0</item> + </string-array> +</resources>
--- a/mobile/android/base/resources/xml/preferences.xml +++ b/mobile/android/base/resources/xml/preferences.xml @@ -14,16 +14,22 @@ </PreferenceCategory> <PreferenceCategory android:title="@string/pref_category_content"> <CheckBoxPreference android:key="browser.menu.showCharacterEncoding" android:title="@string/pref_char_encoding" android:persistent="false" /> + <ListPreference android:key="plugin.enable" + android:title="@string/pref_enable_flash" + android:entries="@array/pref_enable_flash_entries" + android:entryValues="@array/pref_enable_flash_values" + android:persistent="false" /> + </PreferenceCategory> <PreferenceCategory android:title="@string/pref_category_privacy"> <org.mozilla.gecko.ConfirmPreference android:title="@string/pref_clear_history" android:dialogMessage="@string/pref_clear_history_confirm" android:positiveButtonText="@android:string/yes" android:negativeButtonText="@android:string/no"
--- a/mobile/android/base/strings.xml.in +++ b/mobile/android/base/strings.xml.in @@ -63,14 +63,18 @@ <string name="pref_homepage_current">&pref_homepage_current;</string> <string name="pref_remember_signons">&pref_remember_signons;</string> <string name="pref_cookies">&pref_cookies;</string> <string name="pref_char_encoding">&pref_char_encoding;</string> <string name="pref_clear_history">&pref_clear_history;</string> <string name="pref_clear_history_confirm">&pref_clear_history_confirm;</string> <string name="pref_clear_private_data">&pref_clear_private_data;</string> <string name="pref_clear_private_data_confirm">&pref_clear_private_data_confirm;</string> + <string name="pref_enable_flash">&pref_enable_flash;</string> + <string name="pref_enable_flash_yes">&pref_enable_flash_yes;</string> + <string name="pref_enable_flash_tap_to_play">&pref_enable_flash_tap_to_play;</string> + <string name="pref_enable_flash_no">&pref_enable_flash_no;</string> <string name="reload">&reload;</string> <string name="forward">&forward;</string> <string name="new_tab">&new_tab;</string> <string name="addons">&addons;</string> </resources>
--- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -430,16 +430,26 @@ var BrowserApp = { let json = JSON.parse(aPrefNames); let prefs = []; for each (let prefName in json) { let pref = { name: prefName }; + // The plugin pref is actually two separate prefs, so + // we need to handle it differently + if (prefName == "plugin.enable") { + // Use a string type for java's ListPreference + pref.type = "string"; + pref.value = PluginHelper.getPluginPreference(); + prefs.push(pref); + continue; + } + try { switch (Services.prefs.getPrefType(prefName)) { case Ci.nsIPrefBranch.PREF_BOOL: pref.type = "bool"; pref.value = Services.prefs.getBoolPref(prefName); break; case Ci.nsIPrefBranch.PREF_INT: pref.type = "int"; @@ -485,16 +495,23 @@ var BrowserApp = { } }); } catch (e) {} }, setPreferences: function setPreferences(aPref) { let json = JSON.parse(aPref); + // The plugin pref is actually two separate prefs, so + // we need to handle it differently + if (json.name == "plugin.enable") { + PluginHelper.setPluginPreference(json.value); + return; + } + // when sending to java, we normalized special preferences that use // integers and strings to represent booleans. here, we convert them back // to their actual types so we can store them. switch (json.name) { case "network.cookie.cookieBehavior": json.type = "int"; json.value = (json.value ? 0 : 2); break; @@ -2921,16 +2938,42 @@ var PluginHelper = { playAllPlugins: function(aTab) { let plugins = aTab._pluginsToPlay; for (let i = 0; i < plugins.length; i++) { let objLoadingContent = plugins[i].QueryInterface(Ci.nsIObjectLoadingContent); objLoadingContent.playPlugin(); } }, + getPluginPreference: function getPluginPreference() { + let pluginDisable = Services.prefs.getBoolPref("plugin.disable"); + if (pluginDisable) + return "0"; + + let clickToPlay = Services.prefs.getBoolPref("plugins.click_to_play"); + return clickToPlay ? "2" : "1"; + }, + + setPluginPreference: function setPluginPreference(aValue) { + switch (aValue) { + case "0": // Enable Plugins = No + Services.prefs.setBoolPref("plugin.disable", true); + Services.prefs.clearUserPref("plugins.click_to_play"); + break; + case "1": // Enable Plugins = Yes + Services.prefs.clearUserPref("plugin.disable"); + Services.prefs.setBoolPref("plugins.click_to_play", false); + break; + case "2": // Enable Plugins = Tap to Play (default) + Services.prefs.clearUserPref("plugin.disable"); + Services.prefs.clearUserPref("plugins.click_to_play"); + break; + } + }, + // Mostly copied from /browser/base/content/browser.js addPluginClickCallback: function (plugin, callbackName /*callbackArgs...*/) { // XXX just doing (callback)(arg) was giving a same-origin error. bug? let self = this; let callbackArgs = Array.prototype.slice.call(arguments).slice(2); plugin.addEventListener("click", function(evt) { if (!evt.isTrusted) return;