Bug 574354 - Disable OOP for plugins wrapped by nspluginwrapper. r=josh
authorMartin Stránský <stransky@redhat.com>
Sun, 15 Aug 2010 11:10:15 +0200
changeset 50621 75caf7ab03760f6bc39775cd8c4e097f33161c58
parent 50620 43b490ef9dab30db2c4e2706110ad5d524a21597
child 50622 dec698262ea89ce531f25178682de5ac25cae934
push id15092
push userdgottwald@mozilla.com
push dateSun, 15 Aug 2010 09:10:55 +0000
treeherdermozilla-central@75caf7ab0376 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjosh
bugs574354
milestone2.0b4pre
first release with
nightly linux32
75caf7ab0376 / 4.0b4pre / 20100815031137 / files
nightly linux64
75caf7ab0376 / 4.0b4pre / 20100815030741 / files
nightly mac
75caf7ab0376 / 4.0b4pre / 20100815030716 / files
nightly win32
75caf7ab0376 / 4.0b4pre / 20100815040532 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 574354 - Disable OOP for plugins wrapped by nspluginwrapper. r=josh
modules/plugin/base/src/nsNPAPIPlugin.cpp
--- a/modules/plugin/base/src/nsNPAPIPlugin.cpp
+++ b/modules/plugin/base/src/nsNPAPIPlugin.cpp
@@ -71,16 +71,17 @@
 #include "nsIDOMElement.h"
 #include "nsIDOMDocument.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDocument.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptContext.h"
 #include "nsDOMJSUtils.h"
 #include "nsIPrincipal.h"
+#include "nsWildCard.h"
 
 #include "nsIXPConnect.h"
 
 #include "nsIObserverService.h"
 #include <prinrval.h>
 
 #ifdef XP_MACOSX
 #include <Carbon/Carbon.h>
@@ -360,32 +361,68 @@ RunPluginOOP(const char* aFilePath, cons
   nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
   if (!prefs) {
     return PR_FALSE;
   }
 
   // Get per-library whitelist/blacklist pref string
   // "dom.ipc.plugins.enabled.filename.dll" and fall back to the default value
   // of "dom.ipc.plugins.enabled"
-
-  nsCAutoString pluginLibPref(aFilePath);
-  PRInt32 slashPos = pluginLibPref.RFindCharInSet("/\\");
+  // The "filename.dll" part can contain shell wildcard pattern
+
+  nsCAutoString prefFile(aFilePath);
+  PRInt32 slashPos = prefFile.RFindCharInSet("/\\");
   if (kNotFound == slashPos)
     return PR_FALSE;
-  pluginLibPref.Cut(0, slashPos + 1);
-  ToLowerCase(pluginLibPref);
-  pluginLibPref.Insert("dom.ipc.plugins.enabled.", 0);
+  prefFile.Cut(0, slashPos + 1);
+  ToLowerCase(prefFile);
+
+  nsCAutoString prefGroupKey("dom.ipc.plugins.enabled.");
+
+  PRUint32 prefCount;
+  char** prefNames;
+  nsresult rv = prefs->GetChildList(prefGroupKey.get(),
+                                    &prefCount, &prefNames);
 
   PRBool oopPluginsEnabled = PR_FALSE;
-  if (NS_SUCCEEDED(prefs->GetBoolPref(pluginLibPref.get(),
-                                      &oopPluginsEnabled)))
-    return oopPluginsEnabled;
-
-  oopPluginsEnabled = PR_FALSE;
-  prefs->GetBoolPref("dom.ipc.plugins.enabled", &oopPluginsEnabled);
+  PRBool prefSet = PR_FALSE;
+
+  if (NS_SUCCEEDED(rv) && prefCount > 0) {
+    PRUint32 prefixLength = prefGroupKey.Length();
+    for (PRUint32 currentPref = 0; currentPref < prefCount; currentPref++) {
+      // Get the mask
+      const char* maskStart = prefNames[currentPref] + prefixLength;
+      PRBool match = PR_FALSE;
+
+      int valid = NS_WildCardValid(maskStart);
+      if (valid == INVALID_SXP) {
+         continue;
+      }
+      else if(valid == NON_SXP) {
+        // mask is not a shell pattern, compare it as normal string
+        match = (strcmp(prefFile.get(), maskStart) == 0);
+      }
+      else {
+        match = (NS_WildCardMatch(prefFile.get(), maskStart, 0) == MATCH);
+      }
+
+      if (match && NS_SUCCEEDED(prefs->GetBoolPref(prefNames[currentPref],
+                                                   &oopPluginsEnabled))) {
+        prefSet = PR_TRUE;
+        break;
+      }
+    }
+    NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(prefCount, prefNames);
+  }
+
+  if (!prefSet) {
+    oopPluginsEnabled = PR_FALSE;
+    prefs->GetBoolPref("dom.ipc.plugins.enabled", &oopPluginsEnabled);
+  }
+
   return oopPluginsEnabled;
 }
 
 #endif // MOZ_IPC
 
 inline PluginLibrary*
 GetNewPluginLibrary(const char* aFilePath,
                     PRLibrary* aLibrary)