* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "NetscapePluginModule.h"
+#import "config.h"
+#import "NetscapePluginModule.h"
-#include <WebCore/WebCoreNSStringExtras.h>
-#include <wtf/HashSet.h>
+#import <WebCore/WebCoreNSStringExtras.h>
+#import <wtf/HashSet.h>
using namespace WebCore;
return false;
}
+
+static RetainPtr<CFDictionaryRef> getMIMETypesFromPluginBundle(CFBundleRef bundle)
+{
+ CFStringRef propertyListFilename = static_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypesFilename")));
+ if (propertyListFilename) {
+ RetainPtr<CFStringRef> propertyListPath(AdoptCF, CFStringCreateWithFormat(kCFAllocatorDefault, 0, CFSTR("%@/Library/Preferences/%@"), NSHomeDirectory(), propertyListFilename));
+ RetainPtr<CFURLRef> propertyListURL(AdoptCF, CFURLCreateWithFileSystemPath(kCFAllocatorDefault, propertyListPath.get(), kCFURLPOSIXPathStyle, FALSE));
+
+ CFDataRef propertyListData;
+ CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, propertyListURL.get(), &propertyListData, 0, 0, 0);
+ RetainPtr<CFPropertyListRef> propertyList(AdoptCF, CFPropertyListCreateWithData(kCFAllocatorDefault, propertyListData, kCFPropertyListImmutable, 0, 0));
+ if (propertyListData)
+ CFRelease(propertyListData);
+
+ // FIXME: Have the plug-in create the MIME types property list if it doesn't exist.
+ // https://bugs.webkit.org/show_bug.cgi?id=57204
+ if (!propertyList || CFGetTypeID(propertyList.get()) != CFDictionaryGetTypeID())
+ return 0;
+
+ return static_cast<CFDictionaryRef>(CFDictionaryGetValue(static_cast<CFDictionaryRef>(propertyList.get()), CFSTR("WebPluginMIMETypes")));
+ }
+
+ return static_cast<CFDictionaryRef>(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypes")));
+}
static bool getPluginInfoFromPropertyLists(CFBundleRef bundle, PluginInfo& pluginInfo)
{
- // FIXME: Handle WebPluginMIMETypesFilenameKey.
-
- CFDictionaryRef mimeTypes = static_cast<CFDictionaryRef>(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypes")));
- if (!mimeTypes || CFGetTypeID(mimeTypes) != CFDictionaryGetTypeID())
+ RetainPtr<CFDictionaryRef> mimeTypes = getMIMETypesFromPluginBundle(bundle);
+ if (!mimeTypes || CFGetTypeID(mimeTypes.get()) != CFDictionaryGetTypeID())
return false;
// Get the plug-in name.
pluginInfo.desc = pluginDescription;
// Get the MIME type mapping dictionary.
- CFIndex numMimeTypes = CFDictionaryGetCount(mimeTypes);
+ CFIndex numMimeTypes = CFDictionaryGetCount(mimeTypes.get());
Vector<CFStringRef> mimeTypesVector(numMimeTypes);
Vector<CFDictionaryRef> mimeTypeInfoVector(numMimeTypes);
- CFDictionaryGetKeysAndValues(mimeTypes, reinterpret_cast<const void**>(mimeTypesVector.data()), reinterpret_cast<const void**>(mimeTypeInfoVector.data()));
+ CFDictionaryGetKeysAndValues(mimeTypes.get(), reinterpret_cast<const void**>(mimeTypesVector.data()), reinterpret_cast<const void**>(mimeTypeInfoVector.data()));
for (CFIndex i = 0; i < numMimeTypes; ++i) {
MimeClassInfo mimeClassInfo;
CFStringRef extension = static_cast<CFStringRef>(CFArrayGetValueAtIndex(extensionsArray, i));
if (!extension || CFGetTypeID(extension) != CFStringGetTypeID())
continue;
-
- mimeClassInfo.extensions.append(String(extension).lower());
+
+ // The DivX plug-in lists multiple extensions in a comma separated string instead of using
+ // multiple array elements in the property list. Work around this here by splitting the
+ // extension string into components.
+ Vector<String> extensionComponents;
+ String(extension).lower().split(',', extensionComponents);
+
+ for (size_t i = 0; i < extensionComponents.size(); ++i)
+ mimeClassInfo.extensions.append(extensionComponents[i]);
}
// Add this MIME type.
if (mimeTypesAndExtensions.size() % 2)
return false;
- size_t numMimeTypes = mimeTypesAndExtensions.size() / 2;
-
// Now get the MIME type descriptions string list. This string list needs to be the same length as the number of MIME types.
Vector<String> mimeTypeDescriptions;
if (!getStringListResource(MIMEDescriptionStringNumber, mimeTypeDescriptions))
return false;
- if (mimeTypeDescriptions.size() != numMimeTypes)
- return false;
-
// Add all MIME types.
for (size_t i = 0; i < mimeTypesAndExtensions.size() / 2; ++i) {
MimeClassInfo mimeClassInfo;
const String& mimeType = mimeTypesAndExtensions[i * 2];
- const String& description = mimeTypeDescriptions[i];
+ String description;
+ if (i < mimeTypeDescriptions.size())
+ description = mimeTypeDescriptions[i];
mimeClassInfo.type = mimeType.lower();
mimeClassInfo.desc = description;
if (plugin.bundleIdentifier == "com.macromedia.Flash Player.plugin") {
// Flash requires that the return value of getprogname() be "WebKitPluginHost".
m_pluginQuirks.add(PluginQuirks::PrognameShouldBeWebKitPluginHost);
+
+ // Flash supports snapshotting.
+ m_pluginQuirks.add(PluginQuirks::SupportsSnapshotting);
}
+
+ if (plugin.bundleIdentifier == "com.microsoft.SilverlightPlugin") {
+ // Silverlight doesn't explicitly opt into transparency, so we'll do it whenever
+ // there's a 'background' attribute.
+ m_pluginQuirks.add(PluginQuirks::MakeTransparentIfBackgroundAttributeExists);
+ }
+
+#ifndef NP_NO_QUICKDRAW
+ if (plugin.bundleIdentifier == "com.apple.ist.ds.appleconnect.webplugin") {
+ // The AppleConnect plug-in uses QuickDraw but doesn't paint or receive events
+ // so we'll allow it to be instantiated even though we don't support QuickDraw.
+ m_pluginQuirks.add(PluginQuirks::AllowHalfBakedQuickDrawSupport);
+ }
+#endif
}
} // namespace WebKit