Bug 837399 Part 1: make the click-to-play close box work r=Ratty
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Tue, 12 Feb 2013 19:21:48 +0000
changeset 14852 8a31b4fc6ce47f4e51f30e676a46e0cd0c6ede3d
parent 14851 d9f8f39bf0fac7cda35c5c5e01213f955e5a33a4
child 14853 918a7b8058ee7b88cd8a40e60131468199bedfcd
push id867
push userbugzilla@standard8.plus.com
push dateMon, 01 Apr 2013 20:44:27 +0000
treeherdercomm-beta@797726b8d244 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersRatty
bugs837399
Bug 837399 Part 1: make the click-to-play close box work r=Ratty
suite/common/bindings/notification.xml
--- a/suite/common/bindings/notification.xml
+++ b/suite/common/bindings/notification.xml
@@ -691,16 +691,18 @@
                clicks on a link in the click-to-play UI (e.g. to check for
                plugin updates)
              */
             let callbackArgs = Array.slice(arguments, 2);
             linkNode.addEventListener("click",
                                       function(aEvent) {
                                         if (!aEvent.isTrusted)
                                           return;
+                                        if (aEvent.button != 0)
+                                          return;
                                         aEvent.preventDefault();
                                         aEvent.stopPropagation();
                                         if (callbackArgs.length == 0)
                                           callbackArgs = [ aEvent ];
                                         callback.apply(this, callbackArgs);
                                       }.bind(this),
                                       false);
 
@@ -1220,23 +1222,28 @@
             var pm = Components.classes["@mozilla.org/permissionmanager;1"]
                                .getService(nsIPermissionManager);
             var pluginPermission = pm.testPermission(this.activeBrowser.currentURI, "plugins");
             if (pluginPermission == nsIPermissionManager.DENY_ACTION) {
               overlay.style.visibility = "hidden";
               return;
             }
 
-            this.addLinkClickCallback(overlay, this.activateSinglePlugin, pluginElement);
-
             if (!this.clickToPlayPromptShown)
               this.showPluginClickToPlayPrompt();
 
-            if (this.isTooSmall(pluginElement, overlay))
+            if (this.isTooSmall(pluginElement, overlay)) {
               overlay.style.visibility = "hidden";
+              return;
+            }
+
+            this.addLinkClickCallback(overlay, this.activateSinglePlugin, pluginElement);
+
+            var closeIcon = doc.getAnonymousElementByAttribute(pluginElement, "anonid", "closeIcon");
+            this.addLinkClickCallback(closeIcon, this.hideClickToPlayOverlay, pluginElement);
           ]]>
         </body>
       </method>
 
       <method name="handlePlayPreviewEvent">
         <parameter name="pluginElement"/>
         <body>
           <![CDATA[
@@ -2327,23 +2334,32 @@
                                     mainAction, secondaryActions, options);
            ]]>
         </body>
       </method>
 
       <method name="removeClickToPlayOverlays">
         <body>
           <![CDATA[
-            var doc = this.activeBrowser.contentWindow.document;
             var plugins = this.contentWindowUtils.plugins;
-            for (let plugin of plugins) {
-              let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
+            for (let plugin of plugins)
+              this.hideClickToPlayOverlay(plugin);
+          ]]>
+        </body>
+      </method>
+
+      <method name="hideClickToPlayOverlay">
+        <parameter name="pluginElement"/>
+        <body>
+          <![CDATA[
+            var doc = pluginElement.ownerDocument;
+            var overlay = doc.getAnonymousElementByAttribute(pluginElement, "class", "mainBox");
+            if (overlay) // no overlay if plugin has been activated
               overlay.style.visibility = "hidden";
-            }
-           ]]>
+          ]]>
         </body>
       </method>
 
       <method name="showGeolocationPrompt">
         <parameter name="file"/>
         <parameter name="site"/>
         <parameter name="allowCallback"/>
         <parameter name="cancelCallback"/>