[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

cblu cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:31:35 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit c2fb25ebd7f032f42b94a96b85cca5378f7cbbaa
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Mar 26 02:40:50 2003 +0000

    	Fixed: 3135385 - many file types don't work with the QuickTime plugin in Safari
    
            Reviewed by trey.
    
            * Plugins.subproj/WebBasePluginPackage.h:
            * Plugins.subproj/WebBasePluginPackage.m:
            (+[WebBasePluginPackage pluginWithPath:]): tweak
            (-[WebBasePluginPackage pathByResolvingSymlinksAndAliasesInPath:]): moved up from WebNetscapePluginPackage
            (-[WebBasePluginPackage initWithPath:]): retain path, create bundle so subclasses don't have to do this work
            (-[WebBasePluginPackage getPluginInfoFromBundleAndMIMEDictionary:]): was getMIMEInformation from WebPluginPackage
            (-[WebBasePluginPackage dealloc]): release the bundle
            (-[WebBasePluginPackage setMIMEToExtensionsDictionary:]): tweak
            * Plugins.subproj/WebNetscapePluginPackage.h:
            * Plugins.subproj/WebNetscapePluginPackage.m:
            (+[WebNetscapePluginPackage preferredLocalizationName]): new
            (-[WebNetscapePluginPackage openResourceFile]): tweak
            (-[WebNetscapePluginPackage closeResourceFile:]): tweak
            (-[WebNetscapePluginPackage stringForStringListID:andIndex:]): tweak
            (-[WebNetscapePluginPackage getPluginInfoFromResources]): was getMIMEInformation
            (-[WebNetscapePluginPackage pListForPath:createFile:]): new, calls BP_CreatePluginMIMETypesPreferences if createFile==YES
            (-[WebNetscapePluginPackage getPluginInfoFromPLists]): calls getPluginInfoFromBundleAndMIMEDictionary with the MIME dictionary from the user's home dir.
            (-[WebNetscapePluginPackage initWithPath:]): have the superclass do some initialization, call getPluginInfoFromPLists and/or getPluginInfoFromResources
            (-[WebNetscapePluginPackage executableType]): tweak
            (-[WebNetscapePluginPackage load]): get the BP_CreatePluginMIMETypesPreferences symbol
            (-[WebNetscapePluginPackage unload]): tweak
            (-[WebNetscapePluginPackage dealloc]): tweak
            * Plugins.subproj/WebPluginPackage.h:
            * Plugins.subproj/WebPluginPackage.m:
            (-[WebPluginPackage initWithPath:]): have the superclass do some initialization, call getPluginInfoFromBundleAndMIMEDictionary
            (-[WebPluginPackage viewFactory]): tweak
            (-[WebPluginPackage load]): call principalClass
            (-[WebPluginPackage isLoaded]): tweak
            * Plugins.subproj/npapi.h: added declaration for the BP_CreatePluginMIMETypesPreferences function pointer.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3920 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index c16350c..db2b975 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,39 @@
+2003-03-25  Chris Blumenberg  <cblu at apple.com>
+
+	Fixed: 3135385 - many file types don't work with the QuickTime plugin in Safari
+
+        Reviewed by trey.
+
+        * Plugins.subproj/WebBasePluginPackage.h:
+        * Plugins.subproj/WebBasePluginPackage.m:
+        (+[WebBasePluginPackage pluginWithPath:]): tweak
+        (-[WebBasePluginPackage pathByResolvingSymlinksAndAliasesInPath:]): moved up from WebNetscapePluginPackage
+        (-[WebBasePluginPackage initWithPath:]): retain path, create bundle so subclasses don't have to do this work
+        (-[WebBasePluginPackage getPluginInfoFromBundleAndMIMEDictionary:]): was getMIMEInformation from WebPluginPackage
+        (-[WebBasePluginPackage dealloc]): release the bundle
+        (-[WebBasePluginPackage setMIMEToExtensionsDictionary:]): tweak
+        * Plugins.subproj/WebNetscapePluginPackage.h:
+        * Plugins.subproj/WebNetscapePluginPackage.m:
+        (+[WebNetscapePluginPackage preferredLocalizationName]): new
+        (-[WebNetscapePluginPackage openResourceFile]): tweak
+        (-[WebNetscapePluginPackage closeResourceFile:]): tweak
+        (-[WebNetscapePluginPackage stringForStringListID:andIndex:]): tweak
+        (-[WebNetscapePluginPackage getPluginInfoFromResources]): was getMIMEInformation
+        (-[WebNetscapePluginPackage pListForPath:createFile:]): new, calls BP_CreatePluginMIMETypesPreferences if createFile==YES
+        (-[WebNetscapePluginPackage getPluginInfoFromPLists]): calls getPluginInfoFromBundleAndMIMEDictionary with the MIME dictionary from the user's home dir.
+        (-[WebNetscapePluginPackage initWithPath:]): have the superclass do some initialization, call getPluginInfoFromPLists and/or getPluginInfoFromResources
+        (-[WebNetscapePluginPackage executableType]): tweak
+        (-[WebNetscapePluginPackage load]): get the BP_CreatePluginMIMETypesPreferences symbol
+        (-[WebNetscapePluginPackage unload]): tweak
+        (-[WebNetscapePluginPackage dealloc]): tweak
+        * Plugins.subproj/WebPluginPackage.h:
+        * Plugins.subproj/WebPluginPackage.m:
+        (-[WebPluginPackage initWithPath:]): have the superclass do some initialization, call getPluginInfoFromBundleAndMIMEDictionary
+        (-[WebPluginPackage viewFactory]): tweak
+        (-[WebPluginPackage load]): call principalClass
+        (-[WebPluginPackage isLoaded]): tweak
+        * Plugins.subproj/npapi.h: added declaration for the BP_CreatePluginMIMETypesPreferences function pointer. 
+
 2003-03-25  John Sullivan  <sullivan at apple.com>
 
 	- WebKit part of fix for 3141794 -- No scroll bar for the 
diff --git a/WebKit/Plugins.subproj/WebBasePluginPackage.h b/WebKit/Plugins.subproj/WebBasePluginPackage.h
index 917e53a..c6403f4 100644
--- a/WebKit/Plugins.subproj/WebBasePluginPackage.h
+++ b/WebKit/Plugins.subproj/WebBasePluginPackage.h
@@ -10,21 +10,33 @@
 
 #import <WebCore/WebCoreViewFactory.h>
 
+#define WebPluginExtensionsKey		@"WebPluginExtensions"
+#define WebPluginDescriptionKey 	@"WebPluginDescription"
+#define WebPluginLocalizationNameKey	@"WebPluginLocalizationName"
+#define WebPluginMIMETypesFilenameKey	@"WebPluginMIMETypesFilename"
+#define WebPluginMIMETypesKey 		@"WebPluginMIMETypes"
+#define WebPluginNameKey 		@"WebPluginName"
+#define WebPluginTypeDescriptionKey 	@"WebPluginTypeDescription"
+#define WebPluginTypeEnabledKey 	@"WebPluginTypeEnabled"
+
 @interface WebBasePluginPackage : NSObject <WebCorePluginInfo>
 {
     NSString *name;
     NSString *path;
     NSString *pluginDescription;
 
+    NSBundle *nsBundle;
+
     NSDictionary *MIMEToDescription;
     NSDictionary *MIMEToExtensions;
     NSMutableDictionary *extensionToMIME;
 }
 
 + (WebBasePluginPackage *)pluginWithPath:(NSString *)pluginPath;
-
 - initWithPath:(NSString *)pluginPath;
 
+- (BOOL)getPluginInfoFromBundleAndMIMEDictionary:(NSDictionary *)MIMETypes;
+
 - (BOOL)load;
 - (void)unload;
 - (BOOL)isLoaded;
diff --git a/WebKit/Plugins.subproj/WebBasePluginPackage.m b/WebKit/Plugins.subproj/WebBasePluginPackage.m
index b432fa5..6dff937 100644
--- a/WebKit/Plugins.subproj/WebBasePluginPackage.m
+++ b/WebKit/Plugins.subproj/WebBasePluginPackage.m
@@ -11,26 +11,121 @@
 #import <WebKit/WebNetscapePluginPackage.h>
 #import <WebKit/WebPluginPackage.h>
 
+
 @implementation WebBasePluginPackage
 
 + (WebBasePluginPackage *)pluginWithPath:(NSString *)pluginPath
 {
     WebBasePluginPackage *pluginPackage = [[WebPluginPackage alloc] initWithPath:pluginPath];
 
-    if(!pluginPackage){
+    if (!pluginPackage) {
         pluginPackage = [[WebNetscapePluginPackage alloc] initWithPath:pluginPath];
     }
 
     return [pluginPackage autorelease];
 }
 
+- (NSString *)pathByResolvingSymlinksAndAliasesInPath:(NSString *)thePath
+{
+    NSString *newPath = [thePath stringByResolvingSymlinksInPath];
+
+    FSRef fref;
+    OSErr err;
+
+    err = FSPathMakeRef((const UInt8 *)[thePath fileSystemRepresentation], &fref, NULL);
+    if (err != noErr) {
+        return newPath;
+    }
+
+    Boolean targetIsFolder;
+    Boolean wasAliased;
+    err = FSResolveAliasFile (&fref, TRUE, &targetIsFolder, &wasAliased);
+    if (err != noErr) {
+        return newPath;
+    }
+
+    if (wasAliased) {
+        NSURL *URL = (NSURL *)CFURLCreateFromFSRef(kCFAllocatorDefault, &fref);
+        newPath = [URL path];
+        [URL release];
+    }
+
+    return newPath;
+}
+
 - initWithPath:(NSString *)pluginPath
 {
     [super init];
     extensionToMIME = [[NSMutableDictionary dictionary] retain];
+    path = [[self pathByResolvingSymlinksAndAliasesInPath:pluginPath] retain];
+    nsBundle = [[NSBundle alloc] initWithPath:path];
     return self;
 }
 
+- (BOOL)getPluginInfoFromBundleAndMIMEDictionary:(NSDictionary *)MIMETypes
+{
+    if (!nsBundle) {
+        return NO;
+    }
+    
+    if (!MIMETypes) {
+        MIMETypes = [nsBundle objectForInfoDictionaryKey:WebPluginMIMETypesKey];
+        if (!MIMETypes) {
+            return NO;
+        }
+    }
+
+    NSMutableDictionary *MIMEToExtensionsDictionary = [NSMutableDictionary dictionary];
+    NSMutableDictionary *MIMEToDescriptionDictionary = [NSMutableDictionary dictionary];
+    NSEnumerator *keyEnumerator = [MIMETypes keyEnumerator];
+    NSDictionary *MIMEDictionary;
+    NSString *MIME, *description;
+    NSArray *extensions;
+
+    while ((MIME = [keyEnumerator nextObject]) != nil) {
+        MIMEDictionary = [MIMETypes objectForKey:MIME];
+
+        // FIXME: Consider storing disabled MIME types.
+        NSNumber *isEnabled = [MIMEDictionary objectForKey:WebPluginTypeEnabledKey];
+        if (isEnabled && [isEnabled boolValue] == NO) {
+            continue;
+        }
+
+        extensions = [MIMEDictionary objectForKey:WebPluginExtensionsKey];
+        if (!extensions) {
+            extensions = [NSArray arrayWithObject:@""];
+        }
+
+        [MIMEToExtensionsDictionary setObject:extensions forKey:MIME];
+
+        description = [MIMEDictionary objectForKey:WebPluginTypeDescriptionKey];
+        if (!description) {
+            description = @"";
+        }
+
+        [MIMEToDescriptionDictionary setObject:description forKey:MIME];
+    }
+
+    [self setMIMEToExtensionsDictionary:MIMEToExtensionsDictionary];
+    [self setMIMEToDescriptionDictionary:MIMEToDescriptionDictionary];
+
+    NSString *filename = [self filename];
+
+    NSString *theName = [nsBundle objectForInfoDictionaryKey:WebPluginNameKey];
+    if (!theName) {
+        theName = filename;
+    }
+    [self setName:theName];
+
+    description = [nsBundle objectForInfoDictionaryKey:WebPluginDescriptionKey];
+    if (!description) {
+        description = filename;
+    }
+    [self setPluginDescription:description];
+
+    return YES;
+}
+
 - (BOOL)isLoaded
 {
     return NO;
@@ -54,6 +149,9 @@
     [MIMEToDescription release];
     [MIMEToExtensions release];
     [extensionToMIME release];
+
+    [nsBundle release];
+    
     [super dealloc];
 }
 
@@ -143,7 +241,7 @@
         extensionEnumerator = [extensions objectEnumerator];
 
         while ((extension = [extensionEnumerator nextObject]) != nil) {
-            if(![extension isEqualToString:@""]){
+            if (![extension isEqualToString:@""]) {
                 [extensionToMIME setObject:MIME forKey:extension];
             }
         }
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginPackage.h b/WebKit/Plugins.subproj/WebNetscapePluginPackage.h
index a6e381f..bfb8042 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginPackage.h
+++ b/WebKit/Plugins.subproj/WebNetscapePluginPackage.h
@@ -13,7 +13,7 @@
 typedef enum {
     WebCFMExecutableType,
     WebMachOExecutableType
-}WebExecutableType;
+} WebExecutableType;
 
 @interface WebNetscapePluginPackage : WebBasePluginPackage
 {
@@ -27,7 +27,7 @@ typedef enum {
     uint16 pluginSize;
     uint16 pluginVersion;
     
-    CFBundleRef bundle;
+    CFBundleRef cfBundle;
     
     CFragConnectionID connID;
     
@@ -47,6 +47,8 @@ typedef enum {
     NPP_GetValueProcPtr NPP_GetValue;
     NPP_SetValueProcPtr NPP_SetValue;
     NPP_ShutdownProcPtr NPP_Shutdown;
+
+    BP_CreatePluginMIMETypesPreferencesFuncPtr BP_CreatePluginMIMETypesPreferences;
 }
 
 - (WebExecutableType)executableType;
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginPackage.m b/WebKit/Plugins.subproj/WebNetscapePluginPackage.m
index fefebef..c5ac9f1 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginPackage.m
+++ b/WebKit/Plugins.subproj/WebNetscapePluginPackage.m
@@ -7,6 +7,8 @@
 
 #import <WebKit/WebKitLogging.h>
 
+#import <CoreFoundation/CFBundlePriv.h>
+
 typedef void (* FunctionPointer) (void);
 typedef void (* TransitionVector) (void);
 static FunctionPointer functionPointerForTVector(TransitionVector);
@@ -30,16 +32,28 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
     }
 }
 
++ (NSString *)preferredLocalizationName
+{
+    SInt32 languageCode;
+    SInt32 regionCode;
+    SInt32 scriptCode;
+    CFStringEncoding stringEncoding;
+
+    CFBundleGetLocalizationInfoForLocalization(NULL, &languageCode, &regionCode, &scriptCode, &stringEncoding);
+    NSString *localizationName = (NSString *)CFBundleCopyLocalizationForLocalizationInfo(languageCode, regionCode, scriptCode, stringEncoding);
+    return [localizationName autorelease];
+}
+
 - (SInt16)openResourceFile
 {
     FSRef fref;
     OSErr err;
     
-    if(isBundle){
-        return CFBundleOpenBundleResourceMap(bundle);
-    }else{
+    if (isBundle) {
+        return CFBundleOpenBundleResourceMap(cfBundle);
+    } else {
         err = FSPathMakeRef((const UInt8 *)[path fileSystemRepresentation], &fref, NULL);
-        if(err != noErr){
+        if (err != noErr) {
             return -1;
         }
         
@@ -49,9 +63,9 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
 
 - (void)closeResourceFile:(SInt16)resRef
 {
-    if(isBundle){
-        CFBundleCloseBundleResourceMap(bundle, resRef);
-    }else{
+    if (isBundle) {
+        CFBundleCloseBundleResourceMap(cfBundle, resRef);
+    } else {
         CloseResFile(resRef);
     }
 }
@@ -62,7 +76,7 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
     char cString[256];
         
     GetIndString(pString, stringListID, index);
-    if (pString[0] == 0){
+    if (pString[0] == 0) {
         return nil;
     }
 
@@ -71,15 +85,15 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
     return [NSString stringWithCString:cString];
 }
 
-- (BOOL)getMIMEInformation
+- (BOOL)getPluginInfoFromResources
 {
     SInt16 resRef = [self openResourceFile];
-    if(resRef == -1){
+    if (resRef == -1) {
         return NO;
     }
     
     UseResFile(resRef);
-    if(ResError() != noErr){
+    if (ResError() != noErr) {
         return NO;
     }
 
@@ -91,31 +105,31 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
     NSMutableDictionary *MIMEToExtensionsDictionary = [NSMutableDictionary dictionary];
     NSMutableDictionary *MIMEToDescriptionDictionary = [NSMutableDictionary dictionary];
 
-    for(i=1; 1; i+=2){
+    for (i=1; 1; i+=2) {
         MIME = [self stringForStringListID:128 andIndex:i];
-        if(!MIME){
+        if (!MIME) {
             break;
         }
 
         // FIXME: Avoid mime types with semi-colons because KJS can't properly parse them using KWQKConfigBase
         r = [MIME rangeOfString:@";"];
-        if(r.length > 0){
+        if (r.length > 0) {
             continue;
         }
 
         extensionsList = [self stringForStringListID:128 andIndex:i+1];
-        if(extensionsList){
+        if (extensionsList) {
             extensions = [extensionsList componentsSeparatedByString:@","];
             [MIMEToExtensionsDictionary setObject:extensions forKey:MIME];
-        }else{
+        } else {
             // DRM and WMP claim MIMEs without extensions. Use a @"" extension in this case.
             [MIMEToExtensionsDictionary setObject:[NSArray arrayWithObject:@""] forKey:MIME];
         }
         
         description = [self stringForStringListID:127 andIndex:[MIMEToExtensionsDictionary count]];
-        if(description){
+        if (description) {
             [MIMEToDescriptionDictionary setObject:description forKey:MIME];
-        }else{
+        } else {
             [MIMEToDescriptionDictionary setObject:@"" forKey:MIME];
         }
     }
@@ -140,14 +154,14 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
     NSString *filename = [self filename];
     
     description = [self stringForStringListID:126 andIndex:1];
-    if(!description){
+    if (!description) {
         description = filename;
     }
     [self setPluginDescription:description];
     
     
     NSString *theName = [self stringForStringListID:126 andIndex:2];
-    if(!theName){
+    if (!theName) {
         theName = filename;
     }
     [self setName:theName];
@@ -157,56 +171,72 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
     return YES;
 }
 
-- (NSString *)pathByResolvingSymlinksAndAliasesInPath:(NSString *)thePath
+- (NSDictionary *)pListForPath:(NSString *)pListPath createFile:(BOOL)createFile
 {
-    NSString *newPath = [thePath stringByResolvingSymlinksInPath];
-
-    FSRef fref;
-    OSErr err;
+    if (createFile && [self load] && BP_CreatePluginMIMETypesPreferences) {
+        BP_CreatePluginMIMETypesPreferences();
+    }
 
-    err = FSPathMakeRef((const UInt8 *)[thePath fileSystemRepresentation], &fref, NULL);
-    if(err != noErr){
-        return newPath;
+    NSDictionary *pList = nil;
+    NSData *data = [NSData dataWithContentsOfFile:pListPath];
+    if (data) {
+        pList = [NSPropertyListSerialization propertyListFromData:data
+                                                 mutabilityOption:NSPropertyListImmutable
+                                                           format:nil
+                                                 errorDescription:nil];
     }
 
-    Boolean targetIsFolder;
-    Boolean wasAliased;
-    err = FSResolveAliasFile (&fref, TRUE, &targetIsFolder, &wasAliased);
-    if(err != noErr){
-        return newPath;
+    return pList;
+}
+
+- (BOOL)getPluginInfoFromPLists
+{
+    if (!nsBundle) {
+        return NO;
     }
-    
-    if(wasAliased){
-        NSURL *URL = (NSURL *)CFURLCreateFromFSRef(kCFAllocatorDefault, &fref);
-        newPath = [URL path];
-        [URL release];
+
+    NSDictionary *MIMETypes = nil;
+    NSString *pListFilename = [nsBundle objectForInfoDictionaryKey:WebPluginMIMETypesFilenameKey];
+
+    // Check if the MIME types are claimed in a plist in the user's preferences directory.
+    if (pListFilename) {
+        NSString *pListPath = [NSString stringWithFormat:@"%@/Library/Preferences/%@", NSHomeDirectory(), pListFilename];
+        NSDictionary *pList = [self pListForPath:pListPath createFile:NO];
+        if (pList) {
+            // If the plist isn't localized, have the plug-in recreate it in the preferred language.
+            NSString *localizationName = [pList objectForKey:WebPluginLocalizationNameKey];
+            if (![localizationName isEqualToString:[[self class] preferredLocalizationName]]) {
+                pList = [self pListForPath:pListPath createFile:YES];
+            }
+            MIMETypes = [pList objectForKey:WebPluginMIMETypesKey];
+        } else {
+            // Plist doesn't exist, ask the plug-in to create it.
+            MIMETypes = [[self pListForPath:pListPath createFile:YES] objectForKey:WebPluginMIMETypesKey];
+        }
     }
 
-    return newPath;
+    // Pass the MIME dictionary to the superclass to parse it.
+    return [self getPluginInfoFromBundleAndMIMEDictionary:MIMETypes];
 }
 
 - initWithPath:(NSString *)pluginPath
 {
     [super initWithPath:pluginPath];
     
-    NSString *thePath = [self pathByResolvingSymlinksAndAliasesInPath:pluginPath];
-    
-    [self setPath:thePath];
-    
-    NSDictionary *fileInfo = [[NSFileManager defaultManager] fileAttributesAtPath:thePath traverseLink:YES];
+    NSDictionary *fileInfo = [[NSFileManager defaultManager] fileAttributesAtPath:path traverseLink:YES];
     OSType type = 0;
 
-    // bundle
+    // Bundle
     if ([[fileInfo objectForKey:NSFileType] isEqualToString:NSFileTypeDirectory]) {
-        bundle = CFBundleCreate(NULL, (CFURLRef)[NSURL fileURLWithPath:thePath]);
-        if (bundle) {
+        cfBundle = CFBundleCreate(NULL, (CFURLRef)[NSURL fileURLWithPath:path]);
+        if (cfBundle) {
             isBundle = YES;
-            CFBundleGetPackageInfo(bundle, &type, NULL);
+            CFBundleGetPackageInfo(cfBundle, &type, NULL);
         }
     }
     
 #ifdef __ppc__
-    // single-file plug-in with resource fork
+    // Single-file plug-in with resource fork
     if ([[fileInfo objectForKey:NSFileType] isEqualToString:NSFileTypeRegular]) {
         type = [fileInfo fileHFSTypeCode];
         isBundle = NO;
@@ -219,8 +249,8 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
     }
 
     // Check if the executable is Mach-O or CFM.
-    if (bundle) {
-        NSURL *executableURL = (NSURL *)CFBundleCopyExecutableURL(bundle);
+    if (cfBundle) {
+        NSURL *executableURL = (NSURL *)CFBundleCopyExecutableURL(cfBundle);
         NSFileHandle *executableFile = [NSFileHandle fileHandleForReadingAtPath:[executableURL path]];
         [executableURL release];
         NSData *data = [executableFile readDataOfLength:8];
@@ -239,9 +269,11 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
 #endif
     }
 
-    if (![self getMIMEInformation]) {
-        [self release];
-        return nil;
+    if (![self getPluginInfoFromPLists]) {
+        if (![self getPluginInfoFromResources]) {
+            [self release];
+            return nil;
+        }
     }
 
     return self;
@@ -249,9 +281,9 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
 
 - (WebExecutableType)executableType
 {
-    if(isCFM){
+    if (isCFM) {
         return WebCFMExecutableType;
-    }else{
+    } else {
         return WebMachOExecutableType;
     }
 }
@@ -263,55 +295,55 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
 
 - (BOOL)load
 {    
-    getEntryPointsFuncPtr NP_GetEntryPoints = NULL;
-    initializeFuncPtr NP_Initialize = NULL;
-    mainFuncPtr pluginMainFunc;
+    NP_GetEntryPointsFuncPtr NP_GetEntryPoints = NULL;
+    NP_InitializeFuncPtr NP_Initialize = NULL;
+    MainFuncPtr pluginMainFunc;
     NPError npErr;
     OSErr err;
 
 
-    if(isLoaded){
+    if (isLoaded) {
         return YES;
     }
     
-    if(isBundle){
-        if (!CFBundleLoadExecutable(bundle)){
+    if (isBundle) {
+        if (!CFBundleLoadExecutable(cfBundle)) {
             return NO;
         }
-
-        if(isCFM){
-            pluginMainFunc = (mainFuncPtr)CFBundleGetFunctionPointerForName(bundle, CFSTR("main") );
+        if (isCFM) {
+            pluginMainFunc = (MainFuncPtr)CFBundleGetFunctionPointerForName(cfBundle, CFSTR("main") );
             if(!pluginMainFunc)
                 return NO;
-        }else{
-            NP_Initialize = (initializeFuncPtr)CFBundleGetFunctionPointerForName(bundle, CFSTR("NP_Initialize") );
-            NP_GetEntryPoints = (getEntryPointsFuncPtr)CFBundleGetFunctionPointerForName(bundle, CFSTR("NP_GetEntryPoints") );
-            NPP_Shutdown = (NPP_ShutdownProcPtr)CFBundleGetFunctionPointerForName(bundle, CFSTR("NP_Shutdown") );
-            if(!NP_Initialize || !NP_GetEntryPoints || !NPP_Shutdown){
+        } else {
+            NP_Initialize = (NP_InitializeFuncPtr)CFBundleGetFunctionPointerForName(cfBundle, CFSTR("NP_Initialize"));
+            NP_GetEntryPoints = (NP_GetEntryPointsFuncPtr)CFBundleGetFunctionPointerForName(cfBundle, CFSTR("NP_GetEntryPoints"));
+            NPP_Shutdown = (NPP_ShutdownProcPtr)CFBundleGetFunctionPointerForName(cfBundle, CFSTR("NP_Shutdown"));
+            if (!NP_Initialize || !NP_GetEntryPoints || !NPP_Shutdown) {
                 return NO;
             }
         }
-    }else{ // single CFM file
+        BP_CreatePluginMIMETypesPreferences = (BP_CreatePluginMIMETypesPreferencesFuncPtr)CFBundleGetFunctionPointerForName(cfBundle, CFSTR("BP_CreatePluginMIMETypesPreferences"));
+    } else { // single CFM file
         FSSpec spec;
         FSRef fref;
         
         err = FSPathMakeRef((UInt8 *)[path fileSystemRepresentation], &fref, NULL);
-        if(err != noErr){
+        if (err != noErr) {
             ERROR("FSPathMakeRef failed. Error=%d", err);
             return NO;
         }
         err = FSGetCatalogInfo(&fref, kFSCatInfoNone, NULL, NULL, &spec, NULL);
-        if(err != noErr){
+        if (err != noErr) {
             ERROR("FSGetCatalogInfo failed. Error=%d", err);
             return NO;
         }
         err = GetDiskFragment(&spec, 0, kCFragGoesToEOF, nil, kPrivateCFragCopy, &connID, (Ptr *)&pluginMainFunc, nil);
-        if(err != noErr){
+        if (err != noErr) {
             ERROR("GetDiskFragment failed. Error=%d", err);
             return NO;
         }
-        pluginMainFunc = (mainFuncPtr)functionPointerForTVector((TransitionVector)pluginMainFunc);
-        if(!pluginMainFunc){
+        pluginMainFunc = (MainFuncPtr)functionPointerForTVector((TransitionVector)pluginMainFunc);
+        if (!pluginMainFunc) {
             return NO;
         }
             
@@ -319,15 +351,15 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
     }
     
     // Plugins (at least QT) require that you call UseResFile on the resource file before loading it.
-    
     resourceRef = [self openResourceFile];
-    if(resourceRef == -1)
+    if (resourceRef == -1) {
         return NO;
+    }
     
     UseResFile(resourceRef);
     
     // swap function tables
-    if(isCFM){
+    if (isCFM) {
         browserFuncs.version = 11;
         browserFuncs.size = sizeof(NPNetscapeFuncs);
         browserFuncs.geturl = (NPN_GetURLProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_GetURL);
@@ -371,7 +403,8 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
         NPP_URLNotify = (NPP_URLNotifyProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.urlnotify);
         NPP_GetValue = (NPP_GetValueProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.getvalue);
         NPP_SetValue = (NPP_SetValueProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.setvalue);
-    }else{ // no function pointer conversion necessary for mach-o
+    } else {
+        // no function pointer conversion necessary for mach-o
         browserFuncs.version = 11;
         browserFuncs.size = sizeof(NPNetscapeFuncs);
         browserFuncs.geturl = NPN_GetURL;
@@ -427,11 +460,11 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
     
     [self closeResourceFile:resourceRef];
     
-    if(isBundle){
-        CFBundleUnloadExecutable(bundle);
-        CFRelease(bundle);
-        bundle = 0;
-    }else{
+    if (isBundle) {
+        CFBundleUnloadExecutable(cfBundle);
+        CFRelease(cfBundle);
+        cfBundle = NULL;
+    } else {
         CloseConnection(&connID);
     }
     LOG(Plugins, "Plugin Unloaded");
@@ -440,8 +473,8 @@ static TransitionVector tVectorForFunctionPointer(FunctionPointer);
 
 - (void)dealloc
 {
-    if (bundle) {
-        CFRelease(bundle);
+    if (cfBundle) {
+        CFRelease(cfBundle);
     }
     [super dealloc];
 }
diff --git a/WebKit/Plugins.subproj/WebPluginPackage.h b/WebKit/Plugins.subproj/WebPluginPackage.h
index 9e3e25f..f088f95 100644
--- a/WebKit/Plugins.subproj/WebPluginPackage.h
+++ b/WebKit/Plugins.subproj/WebPluginPackage.h
@@ -14,7 +14,6 @@
 
 @interface WebPluginPackage : WebBasePluginPackage
 {
-    NSBundle *bundle;
 }
 
 - (Class)viewFactory;
diff --git a/WebKit/Plugins.subproj/WebPluginPackage.m b/WebKit/Plugins.subproj/WebPluginPackage.m
index ff97d7e..a67eaba 100644
--- a/WebKit/Plugins.subproj/WebPluginPackage.m
+++ b/WebKit/Plugins.subproj/WebPluginPackage.m
@@ -8,75 +8,22 @@
 
 #import <WebKit/WebPluginPackage.h>
 
-#define WebPluginMIMETypesKey 		@"WebPluginMIMETypes"
-#define WebPluginNameKey 		@"WebPluginName"
-#define WebPluginDescriptionKey 	@"WebPluginDescription"
-#define WebPluginExtensionsKey 		@"WebPluginExtensions"
-#define WebPluginTypeDescriptionKey 	@"WebPluginTypeDescription"
-
 @implementation WebPluginPackage
 
-- (BOOL)getMIMEInformation
-{
-    NSDictionary *MIMETypes = [bundle objectForInfoDictionaryKey:WebPluginMIMETypesKey];
-    if(!MIMETypes){
-        return NO;
-    }
-
-    NSMutableDictionary *MIMEToExtensionsDictionary = [NSMutableDictionary dictionary];
-    NSMutableDictionary *MIMEToDescriptionDictionary = [NSMutableDictionary dictionary];
-    NSEnumerator *keyEnumerator = [MIMETypes keyEnumerator];
-    NSDictionary *MIMEDictionary;
-    NSString *MIME, *description;
-    NSArray *extensions;
-    
-    while ((MIME = [keyEnumerator nextObject]) != nil) {
-        MIMEDictionary = [MIMETypes objectForKey:MIME];
-
-        extensions = [MIMEDictionary objectForKey:WebPluginExtensionsKey];
-        if(!extensions){
-            extensions = [NSArray arrayWithObject:@""];
-        }
-
-        [MIMEToExtensionsDictionary setObject:extensions forKey:MIME];
-
-        description = [MIMEDictionary objectForKey:WebPluginTypeDescriptionKey];
-        if(!description){
-            description = @"";
-        }
-
-        [MIMEToDescriptionDictionary setObject:description forKey:MIME];
-    }
-
-    [self setMIMEToExtensionsDictionary:MIMEToExtensionsDictionary];
-    [self setMIMEToDescriptionDictionary:MIMEToDescriptionDictionary];
-
-    NSString *filename = [self filename];
-    
-    NSString *theName = [bundle objectForInfoDictionaryKey:WebPluginNameKey];
-    if(!theName){
-        theName = filename;
-    }
-    [self setName:theName];
-
-    description = [bundle objectForInfoDictionaryKey:WebPluginDescriptionKey];
-    if(!description){
-        description = filename;
-    }
-    [self setPluginDescription:description];
-
-    return YES;
-}
-
 - initWithPath:(NSString *)pluginPath
 {
     [super initWithPath:pluginPath];
+
+    if (!nsBundle) {
+        [self release];
+        return nil;
+    }
     
     UInt32 type = 0;
-    CFBundleRef coreFoundationBundle = CFBundleCreate(NULL, (CFURLRef)[NSURL fileURLWithPath:pluginPath]);        
-    if (coreFoundationBundle) {
-        CFBundleGetPackageInfo(coreFoundationBundle, &type, NULL);
-        CFRelease(coreFoundationBundle);
+    CFBundleRef cfBundle = CFBundleCreate(NULL, (CFURLRef)[NSURL fileURLWithPath:path]);        
+    if (cfBundle) {
+        CFBundleGetPackageInfo(cfBundle, &type, NULL);
+        CFRelease(cfBundle);
     }
     
     if (type != FOUR_CHAR_CODE('WBPL')) {
@@ -84,15 +31,7 @@
         return nil;
     }
 
-    bundle = [[NSBundle alloc] initWithPath:pluginPath];
-    if (!bundle) {
-        [self release];
-        return nil;
-    }
-
-    [self setPath:pluginPath];
-
-    if (![self getMIMEInformation]) {
+    if (![self getPluginInfoFromBundleAndMIMEDictionary:nil]) {
         [self release];
         return nil;
     }
@@ -100,19 +39,14 @@
     return self;
 }
 
-- (void)dealloc
-{
-    [bundle release];
-    [super dealloc];
-}
-
 - (Class)viewFactory
 {
-    return [bundle principalClass];
+    return [nsBundle principalClass];
 }
 
 - (BOOL)load
 {
+    [nsBundle principalClass];
     return YES;
 }
 
@@ -122,7 +56,7 @@
 
 - (BOOL)isLoaded
 {
-    return [bundle isLoaded];
+    return [nsBundle isLoaded];
 }
 
 @end
diff --git a/WebKit/Plugins.subproj/npapi.h b/WebKit/Plugins.subproj/npapi.h
index f35b856..5e01d48 100644
--- a/WebKit/Plugins.subproj/npapi.h
+++ b/WebKit/Plugins.subproj/npapi.h
@@ -316,10 +316,11 @@ typedef struct _NPPluginFuncs {
 extern "C" {
 #endif
 
-typedef NPError (* mainFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownProcPtr*);
+typedef NPError (* MainFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownProcPtr*);
 
-typedef NPError (* initializeFuncPtr)(NPNetscapeFuncs*);
-typedef NPError (* getEntryPointsFuncPtr)(NPPluginFuncs*);
+typedef NPError (* NP_InitializeFuncPtr)(NPNetscapeFuncs*);
+typedef NPError (* NP_GetEntryPointsFuncPtr)(NPPluginFuncs*);
+typedef void 	(* BP_CreatePluginMIMETypesPreferencesFuncPtr)(void);
 
 /*
  * NPN_* functions are provided by the navigator and called by the plugin.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list