Title: [88735] trunk/Source/WebKit2
Revision
88735
Author
[email protected]
Date
2011-06-13 17:10:23 -0700 (Mon, 13 Jun 2011)

Log Message

2011-06-13  Anders Carlsson  <[email protected]>

        Reviewed by Sam Weinig.

        Crash when trying to use Netflix Watch Instantly with Silverlight 3
        https://bugs.webkit.org/show_bug.cgi?id=62611
        <rdar://problem/9058370>

        * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
        (WebKit::NetscapePluginModule::getPluginInfo):
        Get the plug-in version string instead of the version number.

        (WebKit::PluginVersion::isValid):
        (WebKit::PluginVersion::PluginVersion):
        (WebKit::PluginVersion::parse):
        (WebKit::PluginVersion::isLessThan):
        Add a new PluginVersion class that represents a plug-in version. The idea is
        that this class be made cross platform.

        (WebKit::NetscapePluginModule::determineQuirks):
        Add the ReturnsNonRetainedScriptableNPObject quirk for versions of Silverlight less than 4.

        * Shared/Plugins/PluginQuirks.h:
        Add the ReturnsNonRetainedScriptableNPObject quirk.

        * UIProcess/Plugins/PluginInfoStore.h:
        Use a version string. Eventually this should hold the PluginVersion class we added.

        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
        (WebKit::NetscapePlugin::pluginScriptableNPObject):
        If the plug-in has the ReturnsNonRetainedScriptableNPObject quirk, do an extra retain.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (88734 => 88735)


--- trunk/Source/WebKit2/ChangeLog	2011-06-14 00:09:47 UTC (rev 88734)
+++ trunk/Source/WebKit2/ChangeLog	2011-06-14 00:10:23 UTC (rev 88735)
@@ -1,3 +1,35 @@
+2011-06-13  Anders Carlsson  <[email protected]>
+
+        Reviewed by Sam Weinig.
+
+        Crash when trying to use Netflix Watch Instantly with Silverlight 3
+        https://bugs.webkit.org/show_bug.cgi?id=62611
+        <rdar://problem/9058370>
+
+        * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
+        (WebKit::NetscapePluginModule::getPluginInfo):
+        Get the plug-in version string instead of the version number.
+
+        (WebKit::PluginVersion::isValid):
+        (WebKit::PluginVersion::PluginVersion):
+        (WebKit::PluginVersion::parse):
+        (WebKit::PluginVersion::isLessThan):
+        Add a new PluginVersion class that represents a plug-in version. The idea is
+        that this class be made cross platform.
+
+        (WebKit::NetscapePluginModule::determineQuirks):
+        Add the ReturnsNonRetainedScriptableNPObject quirk for versions of Silverlight less than 4.
+
+        * Shared/Plugins/PluginQuirks.h:
+        Add the ReturnsNonRetainedScriptableNPObject quirk.
+
+        * UIProcess/Plugins/PluginInfoStore.h:
+        Use a version string. Eventually this should hold the PluginVersion class we added.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::pluginScriptableNPObject):
+        If the plug-in has the ReturnsNonRetainedScriptableNPObject quirk, do an extra retain.
+
 2011-06-13  Ryuan Choi  <[email protected]>
 
         Reviewed by Kenneth Rohde Christiansen.

Modified: trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm (88734 => 88735)


--- trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm	2011-06-14 00:09:47 UTC (rev 88734)
+++ trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm	2011-06-14 00:10:23 UTC (rev 88735)
@@ -364,7 +364,10 @@
 
     plugin.path = pluginPath;
     plugin.bundleIdentifier = CFBundleGetIdentifier(bundle.get());
-    plugin.versionNumber = CFBundleGetVersionNumber(bundle.get());
+    if (CFTypeRef versionTypeRef = CFBundleGetValueForInfoDictionaryKey(bundle.get(), kCFBundleVersionKey)) {
+        if (CFGetTypeID(versionTypeRef) == CFStringGetTypeID())
+            plugin.versionString = static_cast<CFStringRef>(versionTypeRef);
+    }
     
     // Check that there's valid info for this plug-in.
     if (!getPluginInfoFromPropertyLists(bundle.get(), plugin) &&
@@ -398,11 +401,52 @@
     void (*createPluginMIMETypesPreferences)(void) = reinterpret_cast<void (*)(void)>(CFBundleGetFunctionPointerForName(bundle.get(), CFSTR("BP_CreatePluginMIMETypesPreferences")));
     if (!createPluginMIMETypesPreferences)
         return false;
-    
+
     createPluginMIMETypesPreferences();
     return true;
 }
 
+// FIXME: This doesn't need to be platform-specific.
+class PluginVersion {
+public:
+    static PluginVersion parse(const String& versionString);
+
+    bool isLessThan(unsigned componentA) const;
+    bool isValid() const { return !m_versionComponents.isEmpty(); }
+
+private:
+    PluginVersion()
+    {
+    }
+
+    Vector<unsigned, 4> m_versionComponents;
+};
+
+PluginVersion PluginVersion::parse(const String& versionString)
+{
+    PluginVersion version;
+
+    Vector<String> versionStringComponents;
+    versionString.split(".", versionStringComponents);
+    for (size_t i = 0; i < versionStringComponents.size(); ++i) {
+        bool successfullyParsed = false;
+        unsigned versionComponent = versionStringComponents[i].toUInt(&successfullyParsed);
+        if (!successfullyParsed)
+            return PluginVersion();
+
+        version.m_versionComponents.append(versionComponent);
+    }
+
+    return version;
+}
+
+bool PluginVersion::isLessThan(unsigned componentA) const
+{
+    ASSERT(isValid());
+
+    return m_versionComponents[0] < componentA;
+}
+
 void NetscapePluginModule::determineQuirks()
 {
     PluginInfoStore::Plugin plugin;
@@ -427,6 +471,14 @@
         // Silverlight doesn't explicitly opt into transparency, so we'll do it whenever
         // there's a 'background' attribute.
         m_pluginQuirks.add(PluginQuirks::MakeTransparentIfBackgroundAttributeExists);
+
+        PluginVersion pluginVersion = PluginVersion::parse(plugin.versionString);
+        if (pluginVersion.isValid()) {
+            if (pluginVersion.isLessThan(4)) {
+                // Versions of Silverlight prior to 4 don't retain the scriptable NPObject.
+                m_pluginQuirks.add(PluginQuirks::ReturnsNonRetainedScriptableNPObject);
+            }
+        }
     }
 
 #ifndef NP_NO_QUICKDRAW

Modified: trunk/Source/WebKit2/Shared/Plugins/PluginQuirks.h (88734 => 88735)


--- trunk/Source/WebKit2/Shared/Plugins/PluginQuirks.h	2011-06-14 00:09:47 UTC (rev 88734)
+++ trunk/Source/WebKit2/Shared/Plugins/PluginQuirks.h	2011-06-14 00:10:23 UTC (rev 88735)
@@ -59,6 +59,10 @@
         // WebKit1 expects a retained plug-in layer. We use this for Flash to avoid leaking OpenGL layers.
         ReturnsRetainedCoreAnimationLayer,
 
+        // Whether NPP_GetValue with NPPVpluginScriptableNPObject returns a non-retained NPObject or not.
+        // Versions of Silverlight prior to 4 never retained the returned NPObject.
+        ReturnsNonRetainedScriptableNPObject,
+
 #ifndef NP_NO_QUICKDRAW
         // Allow the plug-in to use the QuickDraw drawing model, since we know that the plug-in
         // will never paint or receive events. Used by the AppleConnect plug-in.

Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h (88734 => 88735)


--- trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h	2011-06-14 00:09:47 UTC (rev 88734)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h	2011-06-14 00:10:23 UTC (rev 88735)
@@ -47,7 +47,7 @@
 #if PLATFORM(MAC)
         cpu_type_t pluginArchitecture;
         String bundleIdentifier;
-        unsigned versionNumber;
+        String versionString;
 #elif PLATFORM(WIN)
         uint64_t fileVersion;
 #endif

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (88734 => 88735)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-06-14 00:09:47 UTC (rev 88734)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-06-14 00:10:23 UTC (rev 88735)
@@ -27,6 +27,7 @@
 #include "NetscapePlugin.h"
 
 #include "NPRuntimeObjectMap.h"
+#include "NPRuntimeUtilities.h"
 #include "NetscapePluginStream.h"
 #include "PluginController.h"
 #include "ShareableBitmap.h"
@@ -737,7 +738,12 @@
     
     if (NPP_GetValue(NPPVpluginScriptableNPObject, &scriptableNPObject) != NPERR_NO_ERROR)
         return 0;
-    
+
+#if PLUGIN_ARCHITECTURE(MAC)
+    if (m_pluginModule->pluginQuirks().contains(PluginQuirks::ReturnsNonRetainedScriptableNPObject))
+        retainNPObject(scriptableNPObject);        
+#endif    
+
     return scriptableNPObject;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to