Commit 5a95a5f2 authored by aestes@apple.com's avatar aestes@apple.com

2011-03-27 Andy Estes <aestes@apple.com>

        Reviewed by Maciej Stachowiak.

        Correctly get a plug-in's MIME type when it uses WebPluginMIMETypesFilename
        https://bugs.webkit.org/show_bug.cgi?id=57205
        
        If the plug-in's Info.plist uses WebPluginMIMETypesFilename to specify
        plug-in MIME types, WebKit has to check for a property list file in
        ~/Library/Preferences for the MIME type dictionary.

        * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
        (WebKit::getMIMETypesFromPluginBundle): If the bundle's Info dictionary
        has the key WebPluginMIMETypesFilename, open the property list
        specified by that key's value and return the MIME type dictionary from
        there. Otherwise, return the MIME type dictionary specified by the key
        WebPluginMIMETypes.
        (WebKit::getPluginInfoFromPropertyLists): Call
        getMIMETypesFromPluginBundle().


git-svn-id: svn://svn.chromium.org/blink/trunk@82087 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2c902848
2011-03-27 Andy Estes <aestes@apple.com>
Reviewed by Maciej Stachowiak.
Correctly get a plug-in's MIME type when it uses WebPluginMIMETypesFilename
https://bugs.webkit.org/show_bug.cgi?id=57205
If the plug-in's Info.plist uses WebPluginMIMETypesFilename to specify
plug-in MIME types, WebKit has to check for a property list file in
~/Library/Preferences for the MIME type dictionary.
* Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
(WebKit::getMIMETypesFromPluginBundle): If the bundle's Info dictionary
has the key WebPluginMIMETypesFilename, open the property list
specified by that key's value and return the MIME type dictionary from
there. Otherwise, return the MIME type dictionary specified by the key
WebPluginMIMETypes.
(WebKit::getPluginInfoFromPropertyLists): Call
getMIMETypesFromPluginBundle().
2011-03-27 Jer Noble <jer.noble@apple.com>
Reviewed by Maciej Stachowiak.
......
......@@ -86,13 +86,35 @@ static bool getPluginArchitecture(CFBundleRef bundle, cpu_type_t& pluginArchitec
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.
......@@ -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<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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment