Bug 1561844 Remove OpenH264 plugin from about:addons r=VladBaicu a=RyanVM
authorAndrei Lazar <andrei.a.lazar@softvision.ro>
Mon, 08 Jul 2019 17:03:25 +0300
changeset 522903 b08cd190d83dadd249ff438c8c99fce1a7cc524f
parent 522902 7f7f77e35e3ed610c16ef1a7fea576c8b7193161
child 522904 a8da73ce90a4110e14caaba3e93d8a086b3a0669
push id69
push userryanvm@gmail.com
push dateMon, 15 Jul 2019 17:53:58 +0000
treeherdermozilla-esr68@a8da73ce90a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersVladBaicu, RyanVM
bugs1561844
milestone68.1.0
Bug 1561844 Remove OpenH264 plugin from about:addons r=VladBaicu a=RyanVM Removed OpenH264 plugin from addons list for users that doesn't have it installed. Differential Revision: https://phabricator.services.mozilla.com/D37237
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -107,16 +107,22 @@ XPCOMUtils.defineLazyServiceGetter(this,
 
 ChromeUtils.defineModuleGetter(this, "E10SUtils", "resource://gre/modules/E10SUtils.jsm");
 
 ChromeUtils.defineModuleGetter(this, "FormLikeFactory",
                                "resource://gre/modules/FormLikeFactory.jsm");
 ChromeUtils.defineModuleGetter(this, "GeckoViewAutoFill",
                                "resource://gre/modules/GeckoViewAutoFill.jsm");
 
+ChromeUtils.defineModuleGetter(
+  this,
+  "GMPInstallManager",
+  "resource://gre/modules/GMPInstallManager.jsm"
+);
+
 var GlobalEventDispatcher = EventDispatcher.instance;
 var WindowEventDispatcher = EventDispatcher.for(window);
 
 var lazilyLoadedBrowserScripts = [
   ["MasterPassword", "chrome://browser/content/MasterPassword.js"],
   ["OfflineApps", "chrome://browser/content/OfflineApps.js"],
   ["Linkifier", "chrome://browser/content/Linkify.js"],
   ["CastingApps", "chrome://browser/content/CastingApps.js"],
@@ -470,16 +476,18 @@ var BrowserApp = {
       Services.prefs.setIntPref("extensions.autoDisableScopes", 1);
       Services.prefs.setBoolPref("xpinstall.enabled", false);
     } else if (ParentalControls.parentalControlsEnabled) {
       Services.prefs.clearUserPref("extensions.enabledScopes");
       Services.prefs.clearUserPref("extensions.autoDisableScopes");
       Services.prefs.setBoolPref("xpinstall.enabled", true);
     }
 
+    this.hideH264AddonIfNeeded();
+
     if (ParentalControls.parentalControlsEnabled) {
         let isBlockListEnabled = ParentalControls.isAllowed(ParentalControls.BLOCK_LIST);
         Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", !isBlockListEnabled);
 
         let isTelemetryEnabled = ParentalControls.isAllowed(ParentalControls.TELEMETRY);
         Services.prefs.setBoolPref("toolkit.telemetry.enabled", isTelemetryEnabled);
 
         let isHealthReportEnabled = ParentalControls.isAllowed(ParentalControls.HEALTH_REPORT);
@@ -587,16 +595,33 @@ var BrowserApp = {
 
   /**
    * Pass this a locale string, such as "fr" or "es_ES".
    */
   setLocale: function(locale) {
     WindowEventDispatcher.sendRequest({ type: "Locale:Set", locale: locale });
   },
 
+  hideH264AddonIfNeeded: function() {
+    let installManager = new GMPInstallManager();
+    installManager.checkForAddons().then(
+      ({ usedFallback, gmpAddons }) => {
+        gmpAddons.forEach(addon => {
+          if (addon && addon.id === "gmp-gmpopenh264" && !addon.isInstalled) {
+            Services.prefs.setBoolPref("media.gmp-gmpopenh264.visible", false);
+            Services.prefs.setBoolPref("media.gmp-gmpopenh264.enabled", false);
+          }
+        });
+      },
+      err => {
+        console.log(`Checking for addons failed with:${err}`);
+      }
+    );
+  },
+
   initContextMenu: function() {
     // We pass a thunk in place of a raw label string. This allows the
     // context menu to automatically accommodate locale changes without
     // having to be rebuilt.
     let stringGetter = name => () => Strings.browser.GetStringFromName(name);
 
     function videoClassifier(aTarget) {
       if (aTarget.readyState == aTarget.HAVE_NOTHING) {