From 2bde8e466a4451c7319e3a072d118917957d6554 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Wed, 25 May 2011 19:08:45 +0100 Subject: Merge WebKit at r82507: Initial merge by git Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e --- .../Netscape/mac/NetscapePluginModuleMac.mm | 61 +++++++++++++++++++--- 1 file changed, 53 insertions(+), 8 deletions(-) (limited to 'Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm') diff --git a/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm b/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm index accab46..d290f5b 100644 --- a/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm +++ b/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm @@ -86,13 +86,35 @@ static bool getPluginArchitecture(CFBundleRef bundle, cpu_type_t& pluginArchitec return false; } + +static RetainPtr getMIMETypesFromPluginBundle(CFBundleRef bundle) +{ + CFStringRef propertyListFilename = static_cast(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypesFilename"))); + if (propertyListFilename) { + RetainPtr propertyListPath(AdoptCF, CFStringCreateWithFormat(kCFAllocatorDefault, 0, CFSTR("%@/Library/Preferences/%@"), NSHomeDirectory(), propertyListFilename)); + RetainPtr propertyListURL(AdoptCF, CFURLCreateWithFileSystemPath(kCFAllocatorDefault, propertyListPath.get(), kCFURLPOSIXPathStyle, FALSE)); + + CFDataRef propertyListData; + CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, propertyListURL.get(), &propertyListData, 0, 0, 0); + RetainPtr 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(CFDictionaryGetValue(static_cast(propertyList.get()), CFSTR("WebPluginMIMETypes"))); + } + + return static_cast(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypes"))); +} static bool getPluginInfoFromPropertyLists(CFBundleRef bundle, PluginInfo& pluginInfo) { - // FIXME: Handle WebPluginMIMETypesFilenameKey. - - CFDictionaryRef mimeTypes = static_cast(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypes"))); - if (!mimeTypes || CFGetTypeID(mimeTypes) != CFDictionaryGetTypeID()) + RetainPtr mimeTypes = getMIMETypesFromPluginBundle(bundle); + if (!mimeTypes || CFGetTypeID(mimeTypes.get()) != CFDictionaryGetTypeID()) return false; // Get the plug-in name. @@ -106,10 +128,10 @@ static bool getPluginInfoFromPropertyLists(CFBundleRef bundle, PluginInfo& plugi pluginInfo.desc = pluginDescription; // Get the MIME type mapping dictionary. - CFIndex numMimeTypes = CFDictionaryGetCount(mimeTypes); + CFIndex numMimeTypes = CFDictionaryGetCount(mimeTypes.get()); Vector mimeTypesVector(numMimeTypes); Vector mimeTypeInfoVector(numMimeTypes); - CFDictionaryGetKeysAndValues(mimeTypes, reinterpret_cast(mimeTypesVector.data()), reinterpret_cast(mimeTypeInfoVector.data())); + CFDictionaryGetKeysAndValues(mimeTypes.get(), reinterpret_cast(mimeTypesVector.data()), reinterpret_cast(mimeTypeInfoVector.data())); for (CFIndex i = 0; i < numMimeTypes; ++i) { MimeClassInfo mimeClassInfo; @@ -142,8 +164,15 @@ static bool getPluginInfoFromPropertyLists(CFBundleRef bundle, PluginInfo& plugi CFStringRef extension = static_cast(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 extensionComponents; + String(extension).lower().split(',', extensionComponents); + + for (size_t i = 0; i < extensionComponents.size(); ++i) + mimeClassInfo.extensions.append(extensionComponents[i]); } // Add this MIME type. @@ -333,8 +362,24 @@ void NetscapePluginModule::determineQuirks() 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 -- cgit v1.1