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 541349 67b5cc66a182b7e8e0ab458ccb832e8d1ded0c8d
parent 541348 65ccf4163c2615a8d6340ac9a26d9f00900c78ea
child 541350 e699e0db71f7b4d17c55f298f7a268ac5d6592ab
push id11580
push userarchaeopteryx@coole-files.de
push dateMon, 15 Jul 2019 14:32:23 +0000
treeherdermozilla-beta@e699e0db71f7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersVladBaicu, RyanVM
bugs1561844
milestone69.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
@@ -225,16 +225,22 @@ ChromeUtils.defineModuleGetter(
 );
 
 ChromeUtils.defineModuleGetter(
   this,
   "ContentBlockingAllowList",
   "resource://gre/modules/ContentBlockingAllowList.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"],
@@ -674,16 +680,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
       );
@@ -843,16 +851,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) {