Backed out 3 changesets (bug 889480, bug 889788, bug 888908) for mochitest-bc orange.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 17 Jul 2013 11:34:25 -0400
changeset 139232 e6d3454da7a7adb19056383175dfe37416d2e272
parent 139231 aeff293dadd33ec2bcfd2234e366491720407b78
child 139233 5e3d564cd1b551eda17fcb7056a91db5dc866306
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
bugs889480, 889788, 888908
milestone25.0a1
backs outd1c616745325be5a7770b71c0f7fb78a7c2411be
6fe281a19554e73240ce1bfa2255d214bee10285
9b855bab8073cdb8c64b211663ab9f093eb6d254
Backed out 3 changesets (bug 889480, bug 889788, bug 888908) for mochitest-bc orange. Backed out changeset d1c616745325 (bug 889788) Backed out changeset 6fe281a19554 (bug 888908) Backed out changeset 9b855bab8073 (bug 889480)
browser/base/content/browser-plugins.js
browser/base/content/browser.js
browser/base/content/urlbarBindings.xml
content/base/src/nsObjectLoadingContent.cpp
dom/plugins/ipc/PluginModuleParent.cpp
--- a/browser/base/content/browser-plugins.js
+++ b/browser/base/content/browser-plugins.js
@@ -212,31 +212,24 @@ var gPluginHandler = {
     let pluginName = this.nameForSupportedPlugin(aMimeType);
     if (pluginName && "install" + os in this.supportedPlugins.plugins[pluginName]) {
       return true;
     }
     return false;
   },
 
   handleEvent : function(event) {
-    let plugin;
-    let doc;
+    let plugin = event.target;
+    let doc = plugin.ownerDocument;
+
+    // We're expecting the target to be a plugin.
+    if (!(plugin instanceof Ci.nsIObjectLoadingContent))
+      return;
 
     let eventType = event.type;
-    if (eventType === "PluginRemoved") {
-      doc = event.target;
-    }
-    else {
-      plugin = event.target;
-      doc = plugin.ownerDocument;
-
-      if (!(plugin instanceof Ci.nsIObjectLoadingContent))
-        return;
-    }
-
     if (eventType == "PluginBindingAttached") {
       // The plugin binding fires this event when it is created.
       // As an untrusted event, ensure that this object actually has a binding
       // and make sure we don't handle it twice
       let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
       if (!overlay || overlay._bindingHandled) {
         return;
       }
@@ -306,17 +299,16 @@ var gPluginHandler = {
 
       case "PluginDisabled":
         let manageLink = doc.getAnonymousElementByAttribute(plugin, "class", "managePluginsLink");
         this.addLinkClickCallback(manageLink, "managePlugins");
         this._showClickToPlayNotification(browser);
         break;
 
       case "PluginInstantiated":
-      case "PluginRemoved":
         this._showClickToPlayNotification(browser);
         break;
     }
 
     // Hide the in-content UI if it's too big. The crashed plugin handler already did this.
     if (eventType != "PluginCrashed") {
       let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
       if (overlay != null && this.isTooSmall(plugin, overlay))
@@ -689,51 +681,54 @@ var gPluginHandler = {
    */
   _updatePluginPermission: function PH_setPermissionForPlugins(aNotification, aPluginInfo, aNewState) {
     let permission;
     let expireType;
     let expireTime;
 
     switch (aNewState) {
       case "allownow":
+        if (aPluginInfo.fallbackType == Ci.nsIObjectLoadingContent.PLUGIN_ACTIVE) {
+          return;
+        }
         permission = Ci.nsIPermissionManager.ALLOW_ACTION;
         expireType = Ci.nsIPermissionManager.EXPIRE_SESSION;
         expireTime = Date.now() + Services.prefs.getIntPref(this.PREF_SESSION_PERSIST_MINUTES) * 60 * 1000;
         break;
 
       case "allowalways":
+        if (aPluginInfo.fallbackType == Ci.nsIObjectLoadingContent.PLUGIN_ACTIVE) {
+          return;
+        }
         permission = Ci.nsIPermissionManager.ALLOW_ACTION;
         expireType = Ci.nsIPermissionManager.EXPIRE_TIME;
         expireTime = Date.now() +
           Services.prefs.getIntPref(this.PREF_PERSISTENT_DAYS) * 24 * 60 * 60 * 1000;
         break;
 
       case "block":
+        if (aPluginInfo.fallbackType != Ci.nsIObjectLoadingContent.PLUGIN_ACTIVE) {
+          return;
+        }
         permission = Ci.nsIPermissionManager.PROMPT_ACTION;
         expireType = Ci.nsIPermissionManager.EXPIRE_NEVER;
         expireTime = 0;
         break;
 
-      // In case a plugin has already been allowed in another tab, the "continue allowing" button
-      // shouldn't change any permissions but should run the plugin-enablement code below.
-      case "continue":
-        break;
       default:
         Cu.reportError(Error("Unexpected plugin state: " + aNewState));
         return;
     }
 
     let browser = aNotification.browser;
-    if (aNewState != "continue") {
-      Services.perms.add(browser.currentURI, aPluginInfo.permissionString,
-                         permission, expireType, expireTime);
+    Services.perms.add(browser.currentURI, aPluginInfo.permissionString,
+                       permission, expireType, expireTime);
 
-      if (aNewState == "block") {
-        return;
-      }
+    if (aNewState == "block") {
+      return;
     }
 
     // Manually activate the plugins that would have been automatically
     // activated.
     let contentWindow = browser.contentWindow;
     let cwu = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                            .getInterface(Ci.nsIDOMWindowUtils);
     let plugins = cwu.plugins;
@@ -766,17 +761,18 @@ var gPluginHandler = {
 
     let haveVulnerablePlugin = plugins.some(function(plugin) {
       let fallbackType = plugin.pluginFallbackType;
       return fallbackType == plugin.PLUGIN_VULNERABLE_UPDATABLE ||
         fallbackType == plugin.PLUGIN_VULNERABLE_NO_UPDATE ||
         fallbackType == plugin.PLUGIN_BLOCKLISTED;
     });
     let dismissed = notification ? notification.dismissed : true;
-    if (aPrimaryPlugin)
+    // Always show the doorhanger if the anchor is not available.
+    if (!isElementVisible(gURLBar) || aPrimaryPlugin)
       dismissed = false;
 
     let primaryPluginPermission = null;
     if (aPrimaryPlugin) {
       primaryPluginPermission = this._getPluginInfo(aPrimaryPlugin).permissionString;
     }
 
     let options = {
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -750,17 +750,16 @@ var gBrowserInit = {
 
     gBrowser.addEventListener("DOMUpdatePageReport", gPopupBlockerObserver, false);
 
     // Note that the XBL binding is untrusted
     gBrowser.addEventListener("PluginBindingAttached", gPluginHandler, true, true);
     gBrowser.addEventListener("PluginCrashed",         gPluginHandler, true);
     gBrowser.addEventListener("PluginOutdated",        gPluginHandler, true);
     gBrowser.addEventListener("PluginInstantiated",    gPluginHandler, true);
-    gBrowser.addEventListener("PluginRemoved",         gPluginHandler, true);
 
     gBrowser.addEventListener("NewPluginInstalled", gPluginHandler.newPluginInstalled, true);
 
     Services.obs.addObserver(gPluginHandler.pluginCrashed, "plugin-crashed", false);
 
     window.addEventListener("AppCommand", HandleAppCommandEvent, true);
 
     messageManager.loadFrameScript("chrome://browser/content/content.js", true);
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -1569,29 +1569,22 @@
         const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
         for (let action of this.notification.options.centerActions) {
           let item = document.createElementNS(XUL_NS, "row");
           item.setAttribute("class", "plugin-popupnotification-centeritem");
           item.action = action;
           this.appendChild(item);
           this._items.push(item);
         }
-        switch (this.notification.options.centerActions.length) {
-          case 0:
-            PopupNotifications._dismiss();
-            break;
-          case 1:
-            this._setState(this._states.SINGLE);
-            break;
-          default:
-            if (this.notification.options.primaryPlugin) {
-              this._setState(this._states.MULTI_COLLAPSED);
-            } else {
-              this._setState(this._states.MULTI_EXPANDED);
-            }
+        if (this.notification.options.centerActions.length == 1) {
+          this._setState(this._states.SINGLE);
+        } else if (this.notification.options.primaryPlugin) {
+          this._setState(this._states.MULTI_COLLAPSED);
+        } else {
+          this._setState(this._states.MULTI_EXPANDED);
         }
       ]]></constructor>
       <method name="_setState">
         <parameter name="state" />
         <body><![CDATA[
           var grid = document.getAnonymousElementByAttribute(this, "anonid", "click-to-play-plugins-notification-center-box");
 
           if (this._states.SINGLE == state) {
@@ -1647,17 +1640,17 @@
             button1 = {
               label: "pluginBlockNow.label",
               accesskey: "pluginBlockNow.accesskey",
               action: "_singleBlock"
             };
             button2 = {
               label: "pluginContinue.label",
               accesskey: "pluginContinue.accesskey",
-              action: "_singleContinue",
+              action: "_cancel",
               default: true
             };
             switch (action.blocklistState) {
             case Ci.nsIBlocklistService.STATE_NOT_BLOCKED:
               label = "pluginEnabled.message";
               linkLabel = "pluginActivate.learnMore";
               break;
 
@@ -1821,24 +1814,16 @@
       <method name="_singleActivateAlways">
         <body><![CDATA[
           gPluginHandler._updatePluginPermission(this.notification,
             this.notification.options.centerActions[0],
             "allowalways");
           this._cancel();
         ]]></body>
       </method>
-      <method name="_singleContinue">
-        <body><![CDATA[
-          gPluginHandler._updatePluginPermission(this.notification,
-            this.notification.options.centerActions[0],
-            "continue");
-          this._cancel();
-        ]]></body>
-      </method>
       <method name="_multiAccept">
         <body><![CDATA[
           for (let item of this._items) {
             let action = item.action;
             if (action.pluginTag.enabledState == Ci.nsIPluginTag.STATE_DISABLED ||
                 action.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED) {
               continue;
             }
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -191,46 +191,36 @@ CheckPluginStopEvent::Run()
   return NS_OK;
 }
 
 /**
  * Helper task for firing simple events
  */
 class nsSimplePluginEvent : public nsRunnable {
 public:
-  nsSimplePluginEvent(nsIContent* aTarget, const nsAString &aEvent)
-    : mTarget(aTarget)
-    , mDocument(aTarget->GetCurrentDoc())
-    , mEvent(aEvent)
-  {
-  }
-
-  nsSimplePluginEvent(nsIDocument* aTarget, const nsAString& aEvent)
-    : mTarget(aTarget)
-    , mDocument(aTarget)
-    , mEvent(aEvent)
-  {
-  }
+  nsSimplePluginEvent(nsIContent* aContent, const nsAString &aEvent)
+    : mContent(aContent),
+      mEvent(aEvent)
+  {}
 
   ~nsSimplePluginEvent() {}
 
   NS_IMETHOD Run();
 
 private:
-  nsCOMPtr<nsISupports> mTarget;
-  nsCOMPtr<nsIDocument> mDocument;
+  nsCOMPtr<nsIContent> mContent;
   nsString mEvent;
 };
 
 NS_IMETHODIMP
 nsSimplePluginEvent::Run()
 {
-  LOG(("OBJLC [%p]: nsSimplePluginEvent firing event \"%s\"", mTarget.get(),
+  LOG(("OBJLC [%p]: nsSimplePluginEvent firing event \"%s\"", mContent.get(),
        mEvent.get()));
-  nsContentUtils::DispatchTrustedEvent(mDocument, mTarget,
+  nsContentUtils::DispatchTrustedEvent(mContent->GetDocument(), mContent,
                                        mEvent, true, true);
   return NS_OK;
 }
 
 /**
  * A task for firing PluginCrashed DOM Events.
  */
 class nsPluginCrashedEvent : public nsRunnable {
@@ -679,19 +669,17 @@ nsObjectLoadingContent::UnbindFromTree(b
     QueueCheckPluginStopEvent();
   } else if (mType != eType_Image) {
     // nsImageLoadingContent handles the image case.
     // Reset state and clear pending events
     /// XXX(johns): The implementation for GenericFrame notes that ideally we
     ///             would keep the docshell around, but trash the frameloader
     UnloadObject();
   }
-  nsCOMPtr<nsIRunnable> ev = new nsSimplePluginEvent(thisContent->GetCurrentDoc(),
-                                           NS_LITERAL_STRING("PluginRemoved"));
-  NS_DispatchToCurrentThread(ev);
+
 }
 
 nsObjectLoadingContent::nsObjectLoadingContent()
   : mType(eType_Loading)
   , mFallbackType(eFallbackAlternate)
   , mChannelLoaded(false)
   , mInstantiating(false)
   , mNetworkCreated(true)
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -1187,21 +1187,19 @@ PluginModuleParent::NP_Initialize(NPNets
     if (mShutdown) {
         *error = NPERR_GENERIC_ERROR;
         return NS_ERROR_FAILURE;
     }
 
     uint32_t flags = 0;
 
     if (!CallNP_Initialize(flags, error)) {
-        mShutdown = true;
         return NS_ERROR_FAILURE;
     }
     else if (*error != NPERR_NO_ERROR) {
-        mShutdown = true;
         return NS_OK;
     }
 
     SetPluginFuncs(pFuncs);
 
     return NS_OK;
 }
 #else
@@ -1217,24 +1215,18 @@ PluginModuleParent::NP_Initialize(NPNets
         return NS_ERROR_FAILURE;
     }
 
     uint32_t flags = 0;
 #ifdef XP_WIN
     flags |= kAllowAsyncDrawing;
 #endif
 
-    if (!CallNP_Initialize(flags, error)) {
-        mShutdown = true;
+    if (!CallNP_Initialize(flags, error))
         return NS_ERROR_FAILURE;
-    }
-    if (*error != NPERR_NO_ERROR) {
-        mShutdown = true;
-        return NS_OK;
-    }
 
 #if defined XP_WIN
     // Send the info needed to join the chrome process's audio session to the
     // plugin process
     nsID id;
     nsString sessionName;
     nsString iconPath;