Bug 1308677 - If PluginContent hears an appropriate Decoder Doctor notification, have it show the hidden plugin notification bar. r=blassey
☠☠ backed out by 03c76266ea80 ☠ ☠
authorMike Conley <mconley@mozilla.com>
Sun, 13 Nov 2016 17:57:45 -0500
changeset 322902 ea17d4edd453337325be6140c4e9e8b1dbfd31fd
parent 322901 d35e32293f2173bd6480d9d0a0788e29cd2cb198
child 322903 8e874a9530d3e3a47ec8923b3e0568328bbc3eb3
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
reviewersblassey
bugs1308677
milestone53.0a1
Bug 1308677 - If PluginContent hears an appropriate Decoder Doctor notification, have it show the hidden plugin notification bar. r=blassey PluginContent listens for a particular type of Decoder Doctor notification. Specifically, it listens for ones of type "cannot-play" for mimetypes that include "application/x-mpegurl". If PluginContent sees that notification, and we've already shown the Click-to-Play notification, then what we're dealing with is web content that is probably using Flash to decode an HLS feed. Because we don't want to spring up the Click-to-Play PopupNotification on a Decoder Doctor notification (which might happen at any time), we show the Hidden Plugin notification bar instead to alert the user that they might need to enable Flash to view the HLS feed. MozReview-Commit-ID: IUFqhbhh0Sc
browser/modules/PluginContent.jsm
--- a/browser/modules/PluginContent.jsm
+++ b/browser/modules/PluginContent.jsm
@@ -127,27 +127,23 @@ PluginContent.prototype = {
         }
     }
   },
 
   observe: function observe(aSubject, aTopic, aData) {
     switch (aTopic) {
       case "decoder-doctor-notification":
         let data = JSON.parse(aData);
-        if (this.haveShownNotification &&
+        let type = data.type.toLowerCase();
+        if (type == "cannot-play" &&
+            this.haveShownNotification &&
             aSubject.top.document == this.content.document &&
             data.formats.toLowerCase().includes("application/x-mpegurl", 0)) {
-          let principal = this.content.document.nodePrincipal;
-          let location = this.content.document.location.href;
           this.global.content.pluginRequiresReload = true;
-          this.global.sendAsyncMessage("PluginContent:ShowClickToPlayNotification",
-                                       { plugins: [... this.pluginData.values()],
-                                         showNow: true,
-                                         location: location,
-                                       }, null, principal);
+          this.updateNotificationUI(this.content.document);
         }
     }
   },
 
   onPageShow: function (event) {
     // Ignore events that aren't from the main document.
     if (!this.content || event.target != this.content.document) {
       return;
@@ -230,16 +226,22 @@ PluginContent.prototype = {
              pluginName: pluginName,
              pluginTag: pluginTag,
              permissionString: permissionString,
              fallbackType: fallbackType,
              blocklistState: blocklistState,
            };
   },
 
+  /**
+   * _getPluginInfoForTag is called when iterating the plugins for a document,
+   * and what we get from nsIDOMWindowUtils is an nsIPluginTag, and not an
+   * nsIObjectLoadingContent. This only should happen if the plugin is
+   * click-to-play (see bug 1186948).
+   */
   _getPluginInfoForTag: function (pluginTag, tagMimetype) {
     let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
 
     let pluginName = gNavigatorBundle.GetStringFromName("pluginInfo.unknownPlugin");
     let permissionString = null;
     let blocklistState = null;
 
     if (pluginTag) {
@@ -264,17 +266,21 @@ PluginContent.prototype = {
         blocklistState = Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
       }
     }
 
     return { mimetype: tagMimetype,
              pluginName: pluginName,
              pluginTag: pluginTag,
              permissionString: permissionString,
-             fallbackType: null,
+             // Since we should only have entered _getPluginInfoForTag when
+             // examining a click-to-play plugin, we can safely hard-code
+             // this fallback type, since we don't actually have an
+             // nsIObjectLoadingContent to check.
+             fallbackType: Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
              blocklistState: blocklistState,
            };
   },
 
   /**
    * Update the visibility of the plugin overlay.
    */
   setVisibility : function (plugin, overlay, shouldShow) {