Bug 1596090 - use staticprefs for flash enabled state pref, r=mconley
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 13 Nov 2019 21:17:12 +0000
changeset 502304 df333402f12666918a136e961c4f0bb0c6ffc40a
parent 502303 131bd5b63a028f04fc488bf9ed7f2c6d6b038810
child 502305 74ac84aa60fd048101ff962b8441334a3770116a
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1596090
milestone72.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
Bug 1596090 - use staticprefs for flash enabled state pref, r=mconley Differential Revision: https://phabricator.services.mozilla.com/D52845
browser/app/profile/firefox.js
dom/plugins/base/nsPluginTags.cpp
modules/libpref/init/StaticPrefList.yaml
modules/libpref/moz.build
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -727,26 +727,16 @@ pref("plugins.testmode", false);
 pref("plugins.show_infobar", false);
 
 #if defined(_ARM64_) && defined(XP_WIN)
   pref("plugin.default.state", 0);
 #else
   pref("plugin.default.state", 1);
 #endif
 
-// Plugins bundled in XPIs are enabled by default.
-pref("plugin.defaultXpi.state", 2);
-
-// Flash is Click-to-Activate by default on all channels. Disabled for ARM builds.
-#if defined(_ARM64_) && defined(XP_WIN)
-  pref("plugin.state.flash", 0);
-#else
-  pref("plugin.state.flash", 1);
-#endif
-
 // Enables the download and use of the flash blocklists.
 pref("plugins.flashBlock.enabled", true);
 
 // Prefer HTML5 video over Flash content, and don't
 // load plugin instances with no src declared.
 // These prefs are documented in details on all.js.
 // With the "follow-ctp" setting, this will only
 // apply to users that have plugin.state.flash = 1.
--- a/dom/plugins/base/nsPluginTags.cpp
+++ b/dom/plugins/base/nsPluginTags.cpp
@@ -15,16 +15,17 @@
 #include "nsNPAPIPlugin.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Unused.h"
 #include "nsNetUtil.h"
 #include <cctype>
 #include "mozilla/Encoding.h"
 #include "mozilla/dom/FakePluginTagInitBinding.h"
+#include "mozilla/StaticPrefs_plugin.h"
 
 #if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
 #  include "mozilla/SandboxSettings.h"
 #  include "nsCocoaFeatures.h"
 #endif
 
 using mozilla::dom::FakePluginTagInit;
 using namespace mozilla;
@@ -36,17 +37,16 @@ using namespace mozilla;
 // pluginreg.dat
 #define NS_PLUGIN_FLAG_FROMCACHE \
   0x0004  // this plugintag info was loaded from cache
 // no longer used                   0x0008    // reuse only if regenerating
 // pluginreg.dat
 #define NS_PLUGIN_FLAG_CLICKTOPLAY 0x0020  // this is a click-to-play plugin
 
 static const char kPrefDefaultEnabledState[] = "plugin.default.state";
-static const char kPrefDefaultEnabledStateXpi[] = "plugin.defaultXpi.state";
 
 // The defaults here will be read from prefs and overwritten
 #if defined(MOZ_SANDBOX)
 #  if defined(XP_WIN) || defined(XP_MACOSX)
 static int32_t sFlashSandboxLevel = 3;
 static int32_t sDefaultSandboxLevel = 0;
 #  endif
 #  if defined(XP_MACOSX)
@@ -468,27 +468,34 @@ NS_IMETHODIMP
 nsPluginTag::GetClicktoplay(bool* aClicktoplay) {
   *aClicktoplay = IsClicktoplay();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPluginTag::GetEnabledState(uint32_t* aEnabledState) {
   int32_t enabledState;
-  nsresult rv =
-      Preferences::GetInt(GetStatePrefNameForPlugin(this).get(), &enabledState);
-  if (enabledState == nsIPluginTag::STATE_ENABLED && mIsFlashPlugin) {
-    enabledState = nsIPluginTag::STATE_CLICKTOPLAY;
+  nsresult rv = NS_OK;
+  if (mIsFlashPlugin) {
+    enabledState = StaticPrefs::plugin_state_flash();
+    if (enabledState == nsIPluginTag::STATE_ENABLED) {
+      enabledState = nsIPluginTag::STATE_CLICKTOPLAY;
+    }
+  } else {
+    rv = Preferences::GetInt(GetStatePrefNameForPlugin(this).get(),
+                             &enabledState);
   }
   if (NS_SUCCEEDED(rv) && enabledState >= nsIPluginTag::STATE_DISABLED &&
       enabledState <= nsIPluginTag::STATE_ENABLED) {
     *aEnabledState = (uint32_t)enabledState;
     return rv;
   }
 
+  // Something went wrong fetching the plugin's state (e.g. it wasn't flash
+  // and the preference was not present) - use the default state:
   enabledState = Preferences::GetInt(kPrefDefaultEnabledState,
                                      nsIPluginTag::STATE_ENABLED);
   if (enabledState == nsIPluginTag::STATE_ENABLED && mIsFlashPlugin) {
     enabledState = nsIPluginTag::STATE_CLICKTOPLAY;
   }
   if (enabledState >= nsIPluginTag::STATE_DISABLED &&
       enabledState <= nsIPluginTag::STATE_ENABLED) {
     *aEnabledState = (uint32_t)enabledState;
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -6915,16 +6915,30 @@
 
 # When false, text in plaintext documents does not wrap long lines.
 - name: plain_text.wrap_long_lines
   type: bool
   value: true
   mirror: always
 
 #---------------------------------------------------------------------------
+# Prefs starting with "plugin."
+#---------------------------------------------------------------------------
+
+- name: plugin.state.flash
+  type: uint32_t
+  # Flash is Click-to-Activate by default on all channels. Disabled for ARM builds.
+#if defined(_ARM64_) && defined(XP_WIN)
+  value: 0
+#else
+  value: 1
+#endif
+  mirror: always
+
+#---------------------------------------------------------------------------
 # Prefs starting with "plugins."
 #---------------------------------------------------------------------------
 
 - name: plugins.flashBlock.enabled
   type: bool
   value: false
   mirror: always
 
--- a/modules/libpref/moz.build
+++ b/modules/libpref/moz.build
@@ -59,16 +59,17 @@ pref_groups = [
     'mathml',
     'media',
     'mousewheel',
     'network',
     'nglayout',
     'page_load',
     'permissions',
     'plain_text',
+    'plugin',
     'plugins',
     'preferences',
     'print',
     'privacy',
     'security',
     'slider',
     'svg',
     'telemetry',