2009-04-07 Anantanarayanan Iyengar <ananta@chromium.org>
authordarin@chromium.org <darin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Apr 2009 16:04:49 +0000 (16:04 +0000)
committerdarin@chromium.org <darin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Apr 2009 16:04:49 +0000 (16:04 +0000)
        Reviewed by Darin Fisher.

        Added support for returning plugins which support the wildcard mime type (*).
        This is on the same lines as Firefox, which uses a wildcard plugin (npnul32.dll) for
        plugin installation. The changes to support wildcard mime type matching are in
        PluginDatabase.cpp which is used by Webkit's plugin implementation, and
        PluginData.cpp/.h which is used by Chromium.

        https://bugs.webkit.org/show_bug.cgi?id=24988

        Test: plugins/netscape-plugin-wildcard-plugin.html

        * dom/DOMImplementation.cpp:
        (WebCore::DOMImplementation::createDocument):
        * plugins/PluginData.cpp:
        (WebCore::PluginData::supportsMimeType):
        (WebCore::PluginData::supportsMimeTypeIgnoringWildCards):
        * plugins/PluginData.h:
        * plugins/PluginDatabase.cpp:
        (WebCore::PluginDatabase::pluginForMIMEType):
        * plugins/win/PluginPackageWin.cpp:
        (WebCore::PluginPackage::isPluginBlacklisted):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@42321 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
LayoutTests/ChangeLog
LayoutTests/plugins/netscape-plugin-wildcard-plugin-expected.txt [new file with mode: 0644]
LayoutTests/plugins/netscape-plugin-wildcard-plugin.html [new file with mode: 0644]
LayoutTests/plugins/plugin-javascript-access-expected.txt
WebCore/ChangeLog
WebCore/dom/DOMImplementation.cpp
WebCore/plugins/PluginData.cpp
WebCore/plugins/PluginData.h
WebCore/plugins/PluginDatabase.cpp
WebCore/plugins/win/PluginPackageWin.cpp
WebKit/mac/ChangeLog
WebKit/mac/Plugins/WebPluginDatabase.mm
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/Info.plist
WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp
WebKitTools/DumpRenderTree/win/TestNetscapePlugin/TestNetscapePlugin.rc
WebKitTools/DumpRenderTree/win/TestNetscapePlugin/main.cpp

index 0835ae0f8178f8a4cd9e31e48b8d3c6c9bcdb584..fb4c9d028a15181e907f8e7731ff2f0615e43ce6 100644 (file)
@@ -1,3 +1,18 @@
+2009-04-03  Anantanarayanan Iyengar  <ananta@chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Added a layout test which verifies whether the wildcard plugin mime type match
+        succeeded. The plugins/plugin-javascript-access.html layout test had to be
+        re-baselined to account for the wildcard mime type supported by the layout test
+        plugin.
+        
+        https://bugs.webkit.org/show_bug.cgi?id=24988
+
+        * plugins/netscape-plugin-wildcard-plugin-expected.txt: Added.
+        * plugins/netscape-plugin-wildcard-plugin.html: Added.
+        * plugins/plugin-javascript-access-expected.txt:
+
 2009-04-07  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Maciej Stachowiak.
diff --git a/LayoutTests/plugins/netscape-plugin-wildcard-plugin-expected.txt b/LayoutTests/plugins/netscape-plugin-wildcard-plugin-expected.txt
new file mode 100644 (file)
index 0000000..3c5b52b
--- /dev/null
@@ -0,0 +1,3 @@
+CONSOLE MESSAGE: line 0: PLUGIN: NPAPI Wildcard plugin instance loaded
+
+This tests that a plugin which supports the wildcard mime type * is loaded correctly.
diff --git a/LayoutTests/plugins/netscape-plugin-wildcard-plugin.html b/LayoutTests/plugins/netscape-plugin-wildcard-plugin.html
new file mode 100644 (file)
index 0000000..553eab0
--- /dev/null
@@ -0,0 +1,16 @@
+<html>
+<head>
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.setWindowIsKey(false);
+    }
+    
+</script>
+<body>
+<embed id="testPlugin" type="application/x-webkit-test-netscape-wildcard-plugin" width="200" height="200"></embed>
+<div>
+    This tests that a plugin which supports the wildcard mime type * is loaded correctly.
+</div>
+</body>
+</html>
index 925c86b6910bb6fc0166565ea124663b6bfa8e56..4b1a57b7f6815d7ce5b5943bbbcd2adae6738c13 100644 (file)
@@ -13,6 +13,17 @@ Description: test netscape content
 Suffixes: testnetscape
 
 
+Plugin.item() works.
+
+Plugin.namedItem() works.
+
+Type: *
+
+Description: test netscape wildcard plugin
+
+Suffixes: wildcardplugin
+
+
 Plugin.item() works.
 
 Plugin.namedItem() works.
index 58253eb0c84d060c6ea71528e58d278b5fddf3bc..3a85dbe693c6e52548c75c342f79ea540b689b1d 100644 (file)
@@ -1,3 +1,28 @@
+2009-04-07  Anantanarayanan Iyengar  <ananta@chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Added support for returning plugins which support the wildcard mime type (*).
+        This is on the same lines as Firefox, which uses a wildcard plugin (npnul32.dll) for
+        plugin installation. The changes to support wildcard mime type matching are in
+        PluginDatabase.cpp which is used by Webkit's plugin implementation, and
+        PluginData.cpp/.h which is used by Chromium. 
+
+        https://bugs.webkit.org/show_bug.cgi?id=24988
+
+        Test: plugins/netscape-plugin-wildcard-plugin.html
+
+        * dom/DOMImplementation.cpp:
+        (WebCore::DOMImplementation::createDocument):
+        * plugins/PluginData.cpp:
+        (WebCore::PluginData::supportsMimeType):
+        (WebCore::PluginData::supportsMimeTypeIgnoringWildCards):
+        * plugins/PluginData.h:
+        * plugins/PluginDatabase.cpp:
+        (WebCore::PluginDatabase::pluginForMIMEType):
+        * plugins/win/PluginPackageWin.cpp:
+        (WebCore::PluginPackage::isPluginBlacklisted):
+
 2009-04-08  Eric Carlson  <eric.carlson@apple.com>
 
         Reviewed by Simon Fraser.
index 4f29f969113f457820df439dc62b0caf365d4f75..98bed5f203190fac282b43fa441f44266d6b31bc 100644 (file)
@@ -341,7 +341,7 @@ PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame
 
     // PDF is one image type for which a plugin can override built-in support.
     // We do not want QuickTime to take over all image types, obviously.
-    if ((type == "application/pdf" || type == "text/pdf") && pluginData && pluginData->supportsMimeType(type))
+    if ((type == "application/pdf" || type == "text/pdf") && pluginData && pluginData->supportsMimeTypeIgnoringWildCards(type))
         return PluginDocument::create(frame);
     if (Image::supportsType(type))
         return ImageDocument::create(frame);
@@ -355,7 +355,7 @@ PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame
     // Everything else except text/plain can be overridden by plugins. In particular, Adobe SVG Viewer should be used for SVG, if installed.
     // Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a fundamental type that the browser is expected to handle,
     // and also serves as an optimization to prevent loading the plug-in database in the common case.
-    if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type)) 
+    if (type != "text/plain" && pluginData && pluginData->supportsMimeTypeIgnoringWildCards(type)) 
         return PluginDocument::create(frame);
     if (isTextMIMEType(type))
         return TextDocument::create(frame);
@@ -376,3 +376,5 @@ PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame
 }
 
 }
+
+
index ca4bda50537bbcd0e1daa28c3f09ef606cd57c2d..3a76a8c810e19d8a5ed77061e3cf81cc535b551c 100644 (file)
@@ -45,6 +45,14 @@ PluginData::~PluginData()
 }
 
 bool PluginData::supportsMimeType(const String& mimeType) const
+{
+    for (unsigned i = 0; i < m_mimes.size(); ++i)
+        if (m_mimes[i]->type == mimeType || m_mimes[i]->type == "*")
+            return true;
+    return false;
+}
+
+bool PluginData::supportsMimeTypeIgnoringWildCards(const String& mimeType) const
 {
     for (unsigned i = 0; i < m_mimes.size(); ++i)
         if (m_mimes[i]->type == mimeType)
index b2866bff8c9986ec9c1f4312eabd07da2be260ca..5f94c7a03f863013a94e5e317bfc39feb3675409 100644 (file)
@@ -56,6 +56,7 @@ namespace WebCore {
         const Vector<MimeClassInfo*>& mimes() const { return m_mimes; }
 
         bool supportsMimeType(const String& mimeType) const;
+        bool supportsMimeTypeIgnoringWildCards(const String& mimeType) const;
         String pluginNameForMimeType(const String& mimeType) const;
 
         static void refresh();
index 8626277aa615df73a55bc9d0a666a3edf6636a40..dbd0c9e7e43877fea31458522a10c316b2d00ec4 100644 (file)
@@ -162,8 +162,17 @@ PluginPackage* PluginDatabase::pluginForMIMEType(const String& mimeType)
     Vector<PluginPackage*, 2> pluginChoices;
 
     for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
-        if ((*it)->mimeToDescriptions().contains(key))
-            pluginChoices.append((*it).get());
+        PluginPackage* package = (*it).get();
+
+        const MIMEToDescriptionsMap& mimeToDescriptions = package->mimeToDescriptions();
+
+        MIMEToDescriptionsMap::const_iterator end = mimeToDescriptions.end();
+        
+        for (MIMEToDescriptionsMap::const_iterator mimeIter = mimeToDescriptions.begin(); mimeIter != end; ++mimeIter) {
+            // We check for exact mime type matches and wildcard (*) matches. 
+            if (mimeIter->first == key || mimeIter->first == "*")
+                pluginChoices.append(package);
+        }
     }
 
     if (pluginChoices.isEmpty())
index 0edcef39d1c0464646c66934ff4b6d513bf8c423..5bcb35525a2aa129b8a254dbbd4c3f16043180a6 100644 (file)
@@ -81,9 +81,14 @@ bool PluginPackage::isPluginBlacklisted()
 
         if (compareFileVersion(slPluginMinRequired) < 0)
             return true;
-    } else if (fileName() == "npmozax.dll")
+    } else if (fileName() == "npmozax.dll") {
         // Bug 15217: Mozilla ActiveX control complains about missing xpcom_core.dll
         return true;
+    } else if (fileName() == "npnul32.dll") {
+        // We don't want to load the Mozilla null plugin, which is used to install
+        // NPAPI plugins.
+        return true;
+    }
 
     return false;
 }
index b07c2fba1b315d259dcdee680bf5b30b49d71f0c..64118d7476a2ea8a52bb67874fd64535bf36800a 100644 (file)
@@ -1,3 +1,18 @@
+2009-04-03  Anantanarayanan Iyengar  <ananta@chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Added support for returning plugins which support the wildcard mime type (*).
+        This is on the same lines as Firefox, which uses a wildcard plugin (npnul32.dll) for
+        plugin installation. The changes to support wildcard mime type matching are in
+        PluginDatabase.cpp which is used by Webkit's plugin implementation, and
+        PluginData.cpp/.h which is used by Chromium. 
+
+        https://bugs.webkit.org/show_bug.cgi?id=24988
+
+        * Plugins/WebPluginDatabase.mm:
+        (-[WebPluginDatabase pluginForKey:withEnumeratorSelector:]):
+
 2009-04-07  Anders Carlsson  <andersca@apple.com>
 
         Fix Tiger build for real this time.
index 4f2bdd8d4c422553b87cd2a72658aac19fc46c87..3f2231c331ad4b0041769111a084d5a03a312409 100644 (file)
@@ -99,7 +99,9 @@ static void checkCandidate(WebBasePluginPackage **currentPlugin, WebBasePluginPa
     key = [key lowercaseString];
 
     while ((plugin = [pluginEnumerator nextObject]) != nil) {
-        if ([[[plugin performSelector:enumeratorSelector] allObjects] containsObject:key]) {
+        NSArray *pluginMimeTypes = [[plugin performSelector:enumeratorSelector] allObjects];
+    
+        if ([pluginMimeTypes containsObject:key] || [pluginMimeTypes containsObject:@"*"]) {
             if ([plugin isKindOfClass:[WebPluginPackage class]]) 
                 checkCandidate(&webPlugin, &plugin);
 #if ENABLE(NETSCAPE_PLUGIN_API)
index 0808c26ec268d0a96d9cb0bac8d4a847d1e98ec9..2a099b5ab20fa5558c1bdd69d7775f5ae9f88aa9 100644 (file)
@@ -1,3 +1,21 @@
+2009-04-03  Anantanarayanan Iyengar  <ananta@chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Added the wildcard mime type (*) to the list of mime types supported by the
+        layout test plugin. The plugin emits a trace in its NPP_New implementation
+        on receiving the application/x-webkit-test-netscape-wildcard-plugin mime type,
+        indicating that the wildcard plugin mime type match succeeded.
+
+        https://bugs.webkit.org/show_bug.cgi?id=24988
+
+        * DumpRenderTree/TestNetscapePlugIn.subproj/Info.plist:
+        * DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp:
+        (NPP_New):
+        * DumpRenderTree/win/TestNetscapePlugin/TestNetscapePlugin.rc:
+        * DumpRenderTree/win/TestNetscapePlugin/main.cpp:
+        (NPP_New):
+
 2009-04-07  Adam Roben  <aroben@apple.com>
 
         Print the number of files being compiled when using pdevenv
index 7444b84670108a003a4dceb4a78f1ef82fafbf90..bb6bb30b893447cf70d16baf50059c65945ecd73 100644 (file)
                        <key>WebPluginTypeDescription</key>
                        <string>test netscape content</string>
                </dict>
+               <key>*</key>
+               <dict>
+                       <key>WebPluginExtensions</key>
+                       <array>
+                               <string>wildcardplugin</string>
+                       </array>
+                       <key>WebPluginTypeDescription</key>
+                       <string>test netscape wildcard plugin</string>
+               </dict>
        </dict>
        <key>WebPluginName</key>
        <string>WebKit Test PlugIn</string>
index c764cfdf6f78c24ba380cb2392242f9a264e28f1..330fae5f448484a8faaeda38b194b44aa59fb50c 100644 (file)
@@ -165,6 +165,11 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, ch
         
         obj->eventModel = NPEventModelCocoa;
     }
+
+    if (strcasecmp(pluginType, "application/x-webkit-test-netscape-wildcard-plugin") == 0) {
+        log(instance, "NPAPI Wildcard plugin instance loaded");
+        fflush(stdout);
+    }
     
     browser->setvalue(instance, NPPVpluginEventModel, (void *)obj->eventModel);
     return NPERR_NO_ERROR;
index cccc69c7f18d49ba50f535430ad15d79f32f4883..b515a836d4d37487742beac928a6634b11f471fd 100644 (file)
-// Microsoft Visual C++ generated resource script.\r
-//\r
-#include "resource.h"\r
-\r
-#define APSTUDIO_READONLY_SYMBOLS\r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Generated from the TEXTINCLUDE 2 resource.\r
-//\r
-#include "afxres.h"\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-#undef APSTUDIO_READONLY_SYMBOLS\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// English (U.S.) resources\r
-\r
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r
-#ifdef _WIN32\r
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\r
-#pragma code_page(1252)\r
-#endif //_WIN32\r
-\r
-#ifdef APSTUDIO_INVOKED\r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// TEXTINCLUDE\r
-//\r
-\r
-1 TEXTINCLUDE \r
-BEGIN\r
-    "resource.h\0"\r
-END\r
-\r
-2 TEXTINCLUDE \r
-BEGIN\r
-    "#include ""afxres.h""\r\n"\r
-    "\0"\r
-END\r
-\r
-3 TEXTINCLUDE \r
-BEGIN\r
-    "\r\n"\r
-    "\0"\r
-END\r
-\r
-#endif    // APSTUDIO_INVOKED\r
-\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Version\r
-//\r
-\r
-VS_VERSION_INFO VERSIONINFO\r
- FILEVERSION 1,0,0,1\r
- PRODUCTVERSION 1,0,0,1\r
- FILEFLAGSMASK 0x17L\r
-#ifdef _DEBUG\r
- FILEFLAGS 0x1L\r
-#else\r
- FILEFLAGS 0x0L\r
-#endif\r
- FILEOS 0x4L\r
- FILETYPE 0x2L\r
- FILESUBTYPE 0x0L\r
-BEGIN\r
-    BLOCK "StringFileInfo"\r
-    BEGIN\r
-        BLOCK "040904e4"\r
-        BEGIN\r
-            VALUE "CompanyName", "Apple Inc."\r
-            VALUE "FileDescription", "TestNetscapePlugIn"\r
-            VALUE "FileOpenName", "test netscape content"\r
-            VALUE "LegalCopyright", "Copyright Apple Inc. 2007-2009"\r
-            VALUE "MIMEType", "application/x-webkit-test-netscape"\r
-            VALUE "OriginalFilename", "npTestNetscapePlugin.dll"\r
-            VALUE "ProductName", "TestNetscapePlugIn"\r
-        END\r
-    END\r
-    BLOCK "VarFileInfo"\r
-    BEGIN\r
-        VALUE "Translation", 0x409, 1252\r
-    END\r
-END\r
-\r
-#endif    // English (U.S.) resources\r
-/////////////////////////////////////////////////////////////////////////////\r
-\r
-\r
-\r
-#ifndef APSTUDIO_INVOKED\r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Generated from the TEXTINCLUDE 3 resource.\r
-//\r
-\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-#endif    // not APSTUDIO_INVOKED\r
-\r
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE 
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904e4"
+        BEGIN
+            VALUE "CompanyName", "Apple Inc."
+            VALUE "FileDescription", "TestNetscapePlugIn"
+            VALUE "FileOpenName", "test netscape content"
+            VALUE "LegalCopyright", "Copyright Apple Inc. 2007-2009"
+            VALUE "MIMEType", "application/x-webkit-test-netscape|*"
+            VALUE "OriginalFilename", "npTestNetscapePlugin.dll"
+            VALUE "ProductName", "TestNetscapePlugIn"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1252
+    END
+END
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
index ab548724ecbd3c6ab769f4077acef51a7acf8551..547be1e0858ff92a4a591e59a8d1705d188bdf4c 100644 (file)
@@ -85,7 +85,12 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, ch
             else if (_stricmp(argn[i], "onURLNotify") == 0 && !obj->onURLNotify)
                 obj->onURLNotify = _strdup(argv[i]);
         }
-        
+
+        if (_stricmp(pluginType, "application/x-webkit-test-netscape-wildcard-plugin") == 0) {
+            printf("CONSOLE MESSAGE: line 0: PLUGIN: NPAPI Wildcard plugin instance loaded\n");
+            fflush(stdout);
+        }
+
         instance->pdata = obj;
     }