Skip to content
Permalink
Browse files
2010-06-20 Anders Carlsson <andersca@apple.com>
        Reviewed by Dan Bernstein.

        Move the NSBundle ivar to WebPluginPackage
        https://bugs.webkit.org/show_bug.cgi?id=40894

        * Plugins/WebBasePluginPackage.h:
        * Plugins/WebBasePluginPackage.mm:
        (-[WebBasePluginPackage initWithPath:]):
        (-[WebBasePluginPackage _objectForInfoDictionaryKey:]):
        (-[WebBasePluginPackage getPluginInfoFromPLists]):
        (-[WebBasePluginPackage load]):
        (-[WebBasePluginPackage dealloc]):
        * Plugins/WebNetscapePluginPackage.mm:
        (-[WebNetscapePluginPackage _initWithPath:]):
        * Plugins/WebPluginPackage.h:
        * Plugins/WebPluginPackage.mm:
        (-[WebPluginPackage initWithPath:]):
        (-[WebPluginPackage dealloc]):
        (-[WebPluginPackage viewFactory]):
        (-[WebPluginPackage load]):


Canonical link: https://commits.webkit.org/52529@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@61519 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Jun 21, 2010
1 parent d1b1d51 commit 266134eb1732986d308ada29fb54dac23b711f10
Showing 6 changed files with 69 additions and 29 deletions.
@@ -1,3 +1,26 @@
2010-06-20 Anders Carlsson <andersca@apple.com>

Reviewed by Dan Bernstein.

Move the NSBundle ivar to WebPluginPackage
https://bugs.webkit.org/show_bug.cgi?id=40894

* Plugins/WebBasePluginPackage.h:
* Plugins/WebBasePluginPackage.mm:
(-[WebBasePluginPackage initWithPath:]):
(-[WebBasePluginPackage _objectForInfoDictionaryKey:]):
(-[WebBasePluginPackage getPluginInfoFromPLists]):
(-[WebBasePluginPackage load]):
(-[WebBasePluginPackage dealloc]):
* Plugins/WebNetscapePluginPackage.mm:
(-[WebNetscapePluginPackage _initWithPath:]):
* Plugins/WebPluginPackage.h:
* Plugins/WebPluginPackage.mm:
(-[WebPluginPackage initWithPath:]):
(-[WebPluginPackage dealloc]):
(-[WebPluginPackage viewFactory]):
(-[WebPluginPackage load]):

2010-06-20 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.
@@ -60,7 +60,6 @@ typedef void (*BP_CreatePluginMIMETypesPreferencesFuncPtr)(void);
WebCore::String path;
WebCore::String pluginDescription;

NSBundle *bundle;
CFBundleRef cfBundle;

NSDictionary *MIMEToDescription;
@@ -124,15 +124,15 @@ - (id)initWithPath:(NSString *)pluginPath
return nil;

path = pathByResolvingSymlinksAndAliases(pluginPath);
bundle = [[NSBundle alloc] initWithPath:path];
cfBundle = CFBundleCreate(kCFAllocatorDefault, (CFURLRef)[NSURL fileURLWithPath:path]);

#ifndef __ppc__
// 32-bit PowerPC is the only platform where non-bundled CFM plugins are supported
if (!bundle) {
if (!cfBundle) {
[self release];
return nil;
}
#endif
cfBundle = CFBundleCreate(NULL, (CFURLRef)[NSURL fileURLWithPath:path]);
extensionToMIME = [[NSMutableDictionary alloc] init];

return self;
@@ -167,13 +167,22 @@ - (NSDictionary *)pListForPath:(NSString *)pListPath createFile:(BOOL)createFile
return pList;
}

- (id)_objectForInfoDictionaryKey:(NSString *)key
{
CFDictionaryRef bundleInfoDictionary = CFBundleGetInfoDictionary(cfBundle);
if (!bundleInfoDictionary)
return nil;

return (id)CFDictionaryGetValue(bundleInfoDictionary, key);
}

- (BOOL)getPluginInfoFromPLists
{
if (!bundle)
if (!cfBundle)
return NO;

NSDictionary *MIMETypes = nil;
NSString *pListFilename = [bundle objectForInfoDictionaryKey:WebPluginMIMETypesFilenameKey];
NSString *pListFilename = [self _objectForInfoDictionaryKey:WebPluginMIMETypesFilenameKey];

// Check if the MIME types are claimed in a plist in the user's preferences directory.
if (pListFilename) {
@@ -191,7 +200,7 @@ - (BOOL)getPluginInfoFromPLists
}

if (!MIMETypes) {
MIMETypes = [bundle objectForInfoDictionaryKey:WebPluginMIMETypesKey];
MIMETypes = [self _objectForInfoDictionaryKey:WebPluginMIMETypesKey];
if (!MIMETypes)
return NO;
}
@@ -231,12 +240,12 @@ - (BOOL)getPluginInfoFromPLists

NSString *filename = [self filename];

NSString *theName = [bundle objectForInfoDictionaryKey:WebPluginNameKey];
NSString *theName = [self _objectForInfoDictionaryKey:WebPluginNameKey];
if (!theName)
theName = filename;
name = theName;

description = [bundle objectForInfoDictionaryKey:WebPluginDescriptionKey];
description = [self _objectForInfoDictionaryKey:WebPluginDescriptionKey];
if (!description)
description = filename;
pluginDescription = description;
@@ -246,7 +255,7 @@ - (BOOL)getPluginInfoFromPLists

- (BOOL)load
{
if (bundle && !BP_CreatePluginMIMETypesPreferences)
if (cfBundle && !BP_CreatePluginMIMETypesPreferences)
BP_CreatePluginMIMETypesPreferences = (BP_CreatePluginMIMETypesPreferencesFuncPtr)CFBundleGetFunctionPointerForName(cfBundle, CFSTR("BP_CreatePluginMIMETypesPreferences"));

return YES;
@@ -261,7 +270,6 @@ - (void)dealloc
[MIMEToExtensions release];
[extensionToMIME release];

[bundle release];
if (cfBundle)
CFRelease(cfBundle);

@@ -330,11 +338,6 @@ - (NSArray *)extensionsForMIMEType:(NSString *)MIMEType
return [MIMEToExtensions objectForKey:MIMEType];
}

- (NSBundle *)bundle
{
return bundle;
}

- (void)setMIMEToDescriptionDictionary:(NSDictionary *)MIMEToDescriptionDictionary
{
[MIMEToDescription release];
@@ -35,6 +35,7 @@
#import "WebNSObjectExtras.h"
#import "WebNetscapeDeprecatedFunctions.h"
#import <WebCore/npruntime_impl.h>
#import <wtf/RetainPtr.h>

#if USE(PLUGIN_HOST_PROCESS)
#import "NetscapePluginHostManager.h"
@@ -208,7 +209,7 @@ - (BOOL)_initWithPath:(NSString *)pluginPath

OSType type = 0;

if (bundle) {
if (cfBundle) {
// Bundle
CFBundleGetPackageInfo(cfBundle, &type, NULL);
#ifdef SUPPORT_CFM
@@ -230,8 +231,11 @@ - (BOOL)_initWithPath:(NSString *)pluginPath
return NO;

// Check if the executable is Mach-O or CFM.
if (bundle) {
NSFileHandle *executableFile = [NSFileHandle fileHandleForReadingAtPath:[bundle executablePath]];
if (cfBundle) {
RetainPtr<CFURLRef> executableURL(AdoptCF, CFBundleCopyExecutableURL(cfBundle));
if (!executableURL)
return NO;
NSFileHandle *executableFile = [NSFileHandle fileHandleForReadingAtPath:[(NSURL *)executableURL.get() path]];
NSData *data = [executableFile readDataOfLength:512];
[executableFile closeFile];
// Check the length of the data before calling memcmp. We think this fixes 3782543.
@@ -246,11 +250,11 @@ - (BOOL)_initWithPath:(NSString *)pluginPath
#endif

#if USE(PLUGIN_HOST_PROCESS)
NSArray *archs = [bundle executableArchitectures];
RetainPtr<CFArrayRef> archs(AdoptCF, CFBundleCopyExecutableArchitectures(cfBundle));

if ([archs containsObject:[NSNumber numberWithInteger:NSBundleExecutableArchitectureX86_64]])
if ([(NSArray *)archs.get() containsObject:[NSNumber numberWithInteger:NSBundleExecutableArchitectureX86_64]])
pluginHostArchitecture = CPU_TYPE_X86_64;
else if ([archs containsObject:[NSNumber numberWithInteger:NSBundleExecutableArchitectureI386]])
else if ([(NSArray *)archs.get() containsObject:[NSNumber numberWithInteger:NSBundleExecutableArchitectureI386]])
pluginHostArchitecture = CPU_TYPE_X86;
else
return NO;
@@ -32,7 +32,9 @@

@protocol WebPluginViewFactory;

@interface WebPluginPackage : WebBasePluginPackage
@interface WebPluginPackage : WebBasePluginPackage {
NSBundle *nsBundle;
}

- (Class)viewFactory;

@@ -40,12 +40,14 @@

@implementation WebPluginPackage

- initWithPath:(NSString *)pluginPath
- (id)initWithPath:(NSString *)pluginPath
{
if (!(self = [super initWithPath:pluginPath]))
return nil;

if (bundle == nil) {
nsBundle = [[NSBundle alloc] initWithPath:path];

if (!nsBundle) {
[self release];
return nil;
}
@@ -59,7 +61,7 @@ @implementation WebPluginPackage
}
}

NSFileHandle *executableFile = [NSFileHandle fileHandleForReadingAtPath:[bundle executablePath]];
NSFileHandle *executableFile = [NSFileHandle fileHandleForReadingAtPath:[nsBundle executablePath]];
NSData *data = [executableFile readDataOfLength:512];
[executableFile closeFile];
if (![self isNativeLibraryData:data]) {
@@ -75,9 +77,16 @@ @implementation WebPluginPackage
return self;
}

- (void)dealloc
{
[nsBundle release];

[super dealloc];
}

- (Class)viewFactory
{
return [bundle principalClass];
return [nsBundle principalClass];
}

- (BOOL)load
@@ -87,8 +96,8 @@ - (BOOL)load
#endif

// Load the bundle
if (![bundle isLoaded]) {
if (![bundle load])
if (![nsBundle isLoaded]) {
if (![nsBundle load])
return NO;
}

0 comments on commit 266134e

Please sign in to comment.