Closed Bug 564485 Opened 16 years ago Closed 15 years ago

Support WebPluginMIMETypesFilename in plugin loading

Categories

(Core Graveyard :: Plug-ins, defect)

All
macOS
defect
Not set
normal

Tracking

(blocking2.0 betaN+)

RESOLVED FIXED
Tracking Status
blocking2.0 --- betaN+

People

(Reporter: stuart.morgan+bugzilla, Assigned: sgreenlay)

References

Details

Attachments

(1 file, 8 obsolete files)

It looks like Gecko is still relying on BP_GetSupportedMIMETypesProcPtr to get QuickTime MIME types; the new plist-y way of doing this is using the WebPluginMIMETypesFilename key. Supporting that would presumably mean that BP_GetSupportedMIMETypes could be completely dropped (Chromium doesn't support it, and it doesn't appear that WebKit does either).
We need to support this in Firefox 4 in order to load Quicktime in a 64-bit browser. Otherwise we can't find MIME types and we skip the plugin altogether.
Assignee: nobody → joshmoz
blocking2.0: --- → betaN+
Assignee: joshmoz → sgreenlay
Chromium's implementation and a bit of explanation is here: http://src.chromium.org/svn/trunk/src/webkit/glue/plugins/plugin_lib_mac.mm which may be handy since AFAIK there's no real documentation of this anywhere.
Attached patch WebPluginMIMETypesFilename patch (obsolete) — Splinter Review
Attachment #481501 - Flags: review?(joshmoz)
Status: NEW → ASSIGNED
Comment on attachment 481501 [details] [diff] [review] WebPluginMIMETypesFilename patch I don't think we need to bring obj-c/cocoa into this. Let's use "CFPropertyList".
Attachment #481501 - Flags: review?(joshmoz) → review-
Uses CF instead of Obj-C/Cocoa
Attachment #481501 - Attachment is obsolete: true
Comment on attachment 481865 [details] [diff] [review] WebPluginMIMETypesFilename patch (v1.1) >+ CFURLRef mimeTypeFileURL = ::CFURLCreateWithString(kCFAllocatorDefault, mimeTypeFilePath, NULL); This needs to be null checked in case it wasn't created properly. >+ if (::CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, mimeTypeFileURL, &resourceData, NULL, NULL, &errorCode) && !errorCode) { I dislike boolean checks on numerical returns ("!errorCode") except for pointers, it incorrectly implies that the return value is boolean. Please check for 0. >+ mimeDict = ::CFDictionaryCreateCopy(kCFAllocatorDefault, static_cast<CFDictionaryRef>(mimeTypes)); Why create a copy of this dictionary? Can you just retain it? >+ if (mimeDict == NULL) { Please make this "!mimeDict".
Attachment #481865 - Attachment is obsolete: true
Attachment #481969 - Flags: review?(joshmoz)
Scott - I think you mentioned before that you were seeing a crash in tbox opt builds with a previous patch. Did you figure that out?
It was a problem in the tree at the time of the run. I did a clean run today (30e51c7019d5).
Comment on attachment 481969 [details] [diff] [review] WebPluginMIMETypesFilename patch (v1.2) > static void ParsePlistPluginInfo(nsPluginInfo& info, CFBundleRef bundle) > { >- CFTypeRef mimeDict = ::CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypes")); >+ CFTypeRef mimeDict = NULL; >+ CFTypeRef mimeFileName = ::CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypesFilename")); >+ Put the blank line before 'mimeFileName' with no blank line after it. That variable is tied to the following "if" block only. >+ CFStringRef errorString = NULL; >+ CFPropertyListRef propertyList = ::CFPropertyListCreateFromXMLData(kCFAllocatorDefault, mimeFileData, kCFPropertyListImmutable, &errorString); Pass 'NULL' for the error string. You're not using it so don't get it. >+ } while (0); Why is this a do-while loop? If you're doing this simply to provide a more limited scope you can just use '{}'. >+ if (!mimeDict) { >+ CFTypeRef mimeTypes = ::CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypes")); >+ if (mimeTypes) { >+ mimeDict = ::CFRetain(mimeTypes); >+ } >+ } >+ > if (mimeDict && ::CFGetTypeID(mimeDict) == ::CFDictionaryGetTypeID() && ::CFDictionaryGetCount(static_cast<CFDictionaryRef>(mimeDict)) > 0) { > int mimeDictKeyCount = ::CFDictionaryGetCount(static_cast<CFDictionaryRef>(mimeDict)); > > // Allocate memory for mime data > int mimeDataArraySize = mimeDictKeyCount * sizeof(char*); > info.fMimeTypeArray = static_cast<char**>(NS_Alloc(mimeDataArraySize)); > if (!info.fMimeTypeArray) > return; Now that you're retaining 'mimeDict' you're leaking it every time you do an early return here. I suggest bringing back the stack-based CFType release object. You can also use it for other things you have to release more than once, like 'currentLocale'.
Attachment #481969 - Flags: review?(joshmoz) → review-
Attachment #481969 - Attachment is obsolete: true
Attachment #482705 - Flags: review?(joshmoz)
Comment on attachment 482705 [details] [diff] [review] WebPluginMIMETypesFilename patch (v1.3) >+ AutoCFTypeObject mimeDictAutorelease(mimeDict); 'mimeDict' can be 'NULL' here and in that case '::CFRelease' will be called on 'NULL'. The docs for '::CFRelease' specifically say "This value must not be NULL". Also, after further thought I'm not comfortable with the "do-while-false" scheme. Please write that code in a more recognizable way.
Attachment #482705 - Flags: review?(joshmoz) → review-
Attachment #482705 - Attachment is obsolete: true
Attachment #482772 - Flags: review?(joshmoz)
(In reply to comment #12) > Also, after further thought I'm not comfortable with the "do-while-false" > scheme. Please write that code in a more recognizable way. Can I suggest splitting that part out into a helper function that takes a path and returns either a dict or NULL? That way you can use early returns (instead of ever-increasing nesting you were trying to avoid).
Attachment #482772 - Flags: review?(joshmoz)
Attachment #482772 - Attachment is obsolete: true
Attachment #484352 - Flags: review?(joshmoz)
Small syntax change
Attachment #484352 - Attachment is obsolete: true
Attachment #484394 - Flags: review?(joshmoz)
Attachment #484352 - Flags: review?(joshmoz)
Attachment #484394 - Flags: review?(joshmoz) → review+
Attachment #484394 - Attachment is obsolete: true
Added home directory evaluation (since CFURL doesn't evaluate '~')
Attachment #485211 - Flags: review?(joshmoz)
Comment on attachment 485211 [details] [diff] [review] WebPluginMIMETypesFilename patch (v1.6) >+static CFTypeRef ParsePlistForMIMETypesFilename(CFBundleRef bundle) Make this return a "CFDictionaryRef" since you're checking the type before returning. >+ if (FSFindFolder(kUserDomain, kCurrentUserFolderType, kDontCreateFolder, &homeDir) != noErr) { "FSFindFolder" -> "::FSFindFolder" >+ CFURLRef userDirURL = CFURLCreateFromFSRef(kCFAllocatorDefault, &homeDir); "CFURLCreateFromFSRef" -> "::CFURLCreateFromFSRef" >+ CFTypeRef mimeDict = ParsePlistForMIMETypesFilename(bundle); Make "mimeDict" type "CFDictionaryRef".
Attachment #485211 - Flags: review?(joshmoz) → review-
Attachment #485211 - Attachment is obsolete: true
Attachment #485314 - Flags: review?(joshmoz)
Attachment #485314 - Flags: review?(joshmoz) → review+
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Depends on: 607444
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: