Bug 1414406: Switch plugins to use inline browser options. r=aswan
authorDave Townsend <dtownsend@oxymoronical.com>
Mon, 13 Nov 2017 15:08:34 -0800
changeset 443541 a44297e0db42f272df3a176ba01603db8ecc9dee
parent 443540 bf0e4dd83b3bf933d40fe16629d489c7599c347b
child 443542 36cb0ea658920eae775aa8ac9b72ae9f80835d63
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1414406
milestone59.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 1414406: Switch plugins to use inline browser options. r=aswan MozReview-Commit-ID: 2hE7lYny6li
toolkit/mozapps/extensions/content/pluginPrefs.js
toolkit/mozapps/extensions/content/pluginPrefs.xul
toolkit/mozapps/extensions/internal/PluginProvider.jsm
toolkit/mozapps/extensions/jar.mn
toolkit/mozapps/extensions/test/browser/browser_pluginprefs.js
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/content/pluginPrefs.js
@@ -0,0 +1,26 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const { utils: Cu } = Components;
+
+const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
+
+const PREFS = {
+  "pluginFlashBlockingCheckbox": "plugins.flashBlock.enabled",
+  "pluginEnableProtectedModeCheckbox": "dom.ipc.plugins.flash.disable-protected-mode",
+};
+
+function init() {
+  for (let id of Object.keys(PREFS)) {
+    let checkbox = document.getElementById(id);
+    checkbox.checked = Services.prefs.getBoolPref(PREFS[id]);
+    checkbox.addEventListener("command", () => {
+      Services.prefs.setBoolPref(PREFS[id], checkbox.checked);
+    });
+  }
+}
+
+window.addEventListener("load", init, { once: true });
--- a/toolkit/mozapps/extensions/content/pluginPrefs.xul
+++ b/toolkit/mozapps/extensions/content/pluginPrefs.xul
@@ -1,24 +1,57 @@
 <?xml version="1.0"?>
 
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this file,
    - You can obtain one at http://mozilla.org/MPL/2.0/.  -->
 
-<!DOCTYPE window SYSTEM "chrome://pluginproblem/locale/pluginproblem.dtd">
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://mozapps/content/extensions/extensions.css"?>
+<?xml-stylesheet href="chrome://mozapps/skin/extensions/extensions.css"?>
+
+<!DOCTYPE window [
+<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
+%brandDTD;
+<!ENTITY % pluginsDTD SYSTEM "chrome://pluginproblem/locale/pluginproblem.dtd">
+%pluginsDTD;
+<!ENTITY % extensionsDTD SYSTEM "chrome://mozapps/locale/extensions/extensions.dtd">
+%extensionsDTD;
+]>
+
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+  <script type="application/javascript"
+          src="chrome://mozapps/content/extensions/pluginPrefs.js"/>
 
-<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-  <setting type="control" title="&plugin.file;">
-    <label class="text-list" id="pluginLibraries"/>
-  </setting>
-  <setting type="control" title="&plugin.mimeTypes;">
-    <label class="text-list" id="pluginMimeTypes"/>
-  </setting>
-  <setting type="bool" pref="plugins.flashBlock.enabled"
-           id="pluginFlashBlocking"
-           title="&plugin.enableBlocklists.label;"
-           learnmore="https://support.mozilla.org/kb/flash-blocklists" />
-  <setting type="bool" pref="dom.ipc.plugins.flash.disable-protected-mode"
-           inverted="true" title="&plugin.flashProtectedMode.label;"
-           id="pluginEnableProtectedMode"
-           learnmore="https://support.mozilla.org/kb/flash-protected-mode-settings" />
-</vbox>
+  <vbox class="detail-view-container">
+    <grid id="detail-grid">
+      <columns>
+          <column flex="1"/>
+          <column flex="2"/>
+      </columns>
+      <rows id="detail-rows">
+        <row class="detail-row-complex">
+          <label>&plugin.file;</label>
+          <label class="text-list" id="pluginLibraries"/>
+        </row>
+        <row class="detail-row-complex">
+          <label>&plugin.mimeTypes;</label>
+          <label class="text-list" id="pluginMimeTypes"/>
+        </row>
+        <row id="pluginFlashBlocking" class="detail-row-complex">
+          <vbox>
+            <label>&plugin.enableBlocklists.label;</label>
+            <label class="preferences-learnmore text-link">&setting.learnmore;</label>
+          </vbox>
+          <checkbox id="pluginFlashBlockingCheckbox"/>
+        </row>
+        <row id="pluginEnableProtectedMode" class="detail-row-complex">
+          <vbox>
+            <label>&plugin.flashProtectedMode.label;</label>
+            <label class="preferences-learnmore text-link">&setting.learnmore;</label>
+          </vbox>
+          <checkbox id="pluginEnableProtectedModeCheckbox"/>
+        </row>
+      </rows>
+    </grid>
+  </vbox>
+</window>
--- a/toolkit/mozapps/extensions/internal/PluginProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/PluginProvider.jsm
@@ -52,28 +52,30 @@ var PluginProvider = {
 
   observe(aSubject, aTopic, aData) {
     switch (aTopic) {
     case AddonManager.OPTIONS_NOTIFICATION_DISPLAYED:
       this.getAddonByID(aData, function(plugin) {
         if (!plugin)
           return;
 
-        let libLabel = aSubject.getElementById("pluginLibraries");
+        let document = aSubject.getElementById("addon-options").contentDocument;
+
+        let libLabel = document.getElementById("pluginLibraries");
         libLabel.textContent = plugin.pluginLibraries.join(", ");
 
-        let typeLabel = aSubject.getElementById("pluginMimeTypes"), types = [];
+        let typeLabel = document.getElementById("pluginMimeTypes"), types = [];
         for (let type of plugin.pluginMimeTypes) {
           let extras = [type.description.trim(), type.suffixes].
                        filter(x => x).join(": ");
           types.push(type.type + (extras ? " (" + extras + ")" : ""));
         }
         typeLabel.textContent = types.join(",\n");
         let showProtectedModePref = canDisableFlashProtectedMode(plugin);
-        aSubject.getElementById("pluginEnableProtectedMode")
+        document.getElementById("pluginEnableProtectedMode")
           .setAttribute("collapsed", showProtectedModePref ? "" : "true");
       });
       break;
     case LIST_UPDATED_TOPIC:
       if (this.plugins)
         this.updatePluginList();
       break;
     }
@@ -520,17 +522,17 @@ PluginWrapper.prototype = {
       if (this.userDisabled !== false && !isCTPBlocklisted) {
         permissions |= AddonManager.PERM_CAN_ENABLE;
       }
     }
     return permissions;
   },
 
   get optionsType() {
-    return AddonManager.OPTIONS_TYPE_INLINE;
+    return AddonManager.OPTIONS_TYPE_INLINE_BROWSER;
   },
 
   get optionsURL() {
     return "chrome://mozapps/content/extensions/pluginPrefs.xul";
   },
 
   get updateDate() {
     return this.installDate;
--- a/toolkit/mozapps/extensions/jar.mn
+++ b/toolkit/mozapps/extensions/jar.mn
@@ -19,16 +19,17 @@ toolkit.jar:
   content/mozapps/extensions/update.html                        (content/update.html)
   content/mozapps/extensions/update.js                          (content/update.js)
   content/mozapps/extensions/update.css                         (content/update.css)
   content/mozapps/extensions/eula.xul                           (content/eula.xul)
   content/mozapps/extensions/eula.js                            (content/eula.js)
   content/mozapps/extensions/newaddon.xul                       (content/newaddon.xul)
   content/mozapps/extensions/newaddon.js                        (content/newaddon.js)
   content/mozapps/extensions/pluginPrefs.xul                    (content/pluginPrefs.xul)
+  content/mozapps/extensions/pluginPrefs.js                     (content/pluginPrefs.js)
   content/mozapps/extensions/gmpPrefs.xul                       (content/gmpPrefs.xul)
   content/mozapps/extensions/OpenH264-license.txt               (content/OpenH264-license.txt)
 #endif
   content/mozapps/extensions/setting.xml                        (content/setting.xml)
   content/mozapps/xpinstall/xpinstallConfirm.xul                (content/xpinstallConfirm.xul)
   content/mozapps/xpinstall/xpinstallConfirm.js                 (content/xpinstallConfirm.js)
   content/mozapps/xpinstall/xpinstallConfirm.css                (content/xpinstallConfirm.css)
   content/mozapps/xpinstall/xpinstallItem.xml                   (content/xpinstallItem.xml)
--- a/toolkit/mozapps/extensions/test/browser/browser_pluginprefs.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_pluginprefs.js
@@ -30,32 +30,39 @@ add_test(function() {
         testPluginId = plugin.id;
         break;
       }
     }
     ok(testPluginId, "Test Plug-in should exist");
 
     AddonManager.getAddonByID(testPluginId, function(testPlugin) {
       let pluginEl = get_addon_element(gManagerWindow, testPluginId);
-      is(pluginEl.mAddon.optionsType, AddonManager.OPTIONS_TYPE_INLINE, "Options should be inline type");
+      is(pluginEl.mAddon.optionsType, AddonManager.OPTIONS_TYPE_INLINE_BROWSER, "Options should be inline type");
       pluginEl.parentNode.ensureElementIsVisible(pluginEl);
 
       let button = gManagerWindow.document.getAnonymousElementByAttribute(pluginEl, "anonid", "preferences-btn");
       is_element_visible(button, "Preferences button should be visible");
 
       button = gManagerWindow.document.getAnonymousElementByAttribute(pluginEl, "anonid", "details-btn");
       EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
 
-      wait_for_view_load(gManagerWindow, function() {
-        let pluginLibraries = gManagerWindow.document.getElementById("pluginLibraries");
-        ok(pluginLibraries, "Plugin file name row should be displayed");
-        // the file name depends on the platform
-        ok(pluginLibraries.textContent, testPlugin.pluginLibraries, "Plugin file name should be displayed");
+      Services.obs.addObserver(function observer(subject, topic, data) {
+        Services.obs.removeObserver(observer, topic);
+
+        // Wait for PluginProvider to do its stuff.
+        executeSoon(function() {
+          let doc = gManagerWindow.document.getElementById("addon-options").contentDocument;
 
-        let pluginMimeTypes = gManagerWindow.document.getElementById("pluginMimeTypes");
-        ok(pluginMimeTypes, "Plugin mime type row should be displayed");
-        ok(pluginMimeTypes.textContent, "application/x-test (tst)", "Plugin mime type should be displayed");
+          let pluginLibraries = doc.getElementById("pluginLibraries");
+          ok(pluginLibraries, "Plugin file name row should be displayed");
+          // the file name depends on the platform
+          ok(pluginLibraries.textContent, testPlugin.pluginLibraries, "Plugin file name should be displayed");
 
-        run_next_test();
-      });
+          let pluginMimeTypes = doc.getElementById("pluginMimeTypes");
+          ok(pluginMimeTypes, "Plugin mime type row should be displayed");
+          ok(pluginMimeTypes.textContent, "application/x-test (tst)", "Plugin mime type should be displayed");
+
+          run_next_test();
+        });
+      }, AddonManager.OPTIONS_NOTIFICATION_DISPLAYED);
     });
   });
 });