Changeset 61519 in webkit


Ignore:
Timestamp:
Jun 20, 2010 6:30:14 PM (14 years ago)
Author:
andersca@apple.com
Message:

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]):
Location:
trunk/WebKit/mac
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/mac/ChangeLog

    r61510 r61519  
     12010-06-20  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Move the NSBundle ivar to WebPluginPackage
     6        https://bugs.webkit.org/show_bug.cgi?id=40894
     7
     8        * Plugins/WebBasePluginPackage.h:
     9        * Plugins/WebBasePluginPackage.mm:
     10        (-[WebBasePluginPackage initWithPath:]):
     11        (-[WebBasePluginPackage _objectForInfoDictionaryKey:]):
     12        (-[WebBasePluginPackage getPluginInfoFromPLists]):
     13        (-[WebBasePluginPackage load]):
     14        (-[WebBasePluginPackage dealloc]):
     15        * Plugins/WebNetscapePluginPackage.mm:
     16        (-[WebNetscapePluginPackage _initWithPath:]):
     17        * Plugins/WebPluginPackage.h:
     18        * Plugins/WebPluginPackage.mm:
     19        (-[WebPluginPackage initWithPath:]):
     20        (-[WebPluginPackage dealloc]):
     21        (-[WebPluginPackage viewFactory]):
     22        (-[WebPluginPackage load]):
     23
    1242010-06-20  Anders Carlsson  <andersca@apple.com>
    225
  • trunk/WebKit/mac/Plugins/WebBasePluginPackage.h

    r61510 r61519  
    6161    WebCore::String pluginDescription;
    6262
    63     NSBundle *bundle;
    6463    CFBundleRef cfBundle;
    6564
  • trunk/WebKit/mac/Plugins/WebBasePluginPackage.mm

    r61510 r61519  
    125125       
    126126    path = pathByResolvingSymlinksAndAliases(pluginPath);
    127     bundle = [[NSBundle alloc] initWithPath:path];
     127    cfBundle = CFBundleCreate(kCFAllocatorDefault, (CFURLRef)[NSURL fileURLWithPath:path]);
     128
    128129#ifndef __ppc__
    129130    // 32-bit PowerPC is the only platform where non-bundled CFM plugins are supported
    130     if (!bundle) {
     131    if (!cfBundle) {
    131132        [self release];
    132133        return nil;
    133134    }
    134135#endif
    135     cfBundle = CFBundleCreate(NULL, (CFURLRef)[NSURL fileURLWithPath:path]);
    136136    extensionToMIME = [[NSMutableDictionary alloc] init];
    137137   
     
    168168}
    169169
     170- (id)_objectForInfoDictionaryKey:(NSString *)key
     171{
     172    CFDictionaryRef bundleInfoDictionary = CFBundleGetInfoDictionary(cfBundle);
     173    if (!bundleInfoDictionary)
     174        return nil;
     175
     176    return (id)CFDictionaryGetValue(bundleInfoDictionary, key);
     177}
     178
    170179- (BOOL)getPluginInfoFromPLists
    171180{
    172     if (!bundle)
     181    if (!cfBundle)
    173182        return NO;
    174183   
    175184    NSDictionary *MIMETypes = nil;
    176     NSString *pListFilename = [bundle objectForInfoDictionaryKey:WebPluginMIMETypesFilenameKey];
     185    NSString *pListFilename = [self _objectForInfoDictionaryKey:WebPluginMIMETypesFilenameKey];
    177186   
    178187    // Check if the MIME types are claimed in a plist in the user's preferences directory.
     
    192201
    193202    if (!MIMETypes) {
    194         MIMETypes = [bundle objectForInfoDictionaryKey:WebPluginMIMETypesKey];
     203        MIMETypes = [self _objectForInfoDictionaryKey:WebPluginMIMETypesKey];
    195204        if (!MIMETypes)
    196205            return NO;
     
    232241    NSString *filename = [self filename];
    233242
    234     NSString *theName = [bundle objectForInfoDictionaryKey:WebPluginNameKey];
     243    NSString *theName = [self _objectForInfoDictionaryKey:WebPluginNameKey];
    235244    if (!theName)
    236245        theName = filename;
    237246    name = theName;
    238247
    239     description = [bundle objectForInfoDictionaryKey:WebPluginDescriptionKey];
     248    description = [self _objectForInfoDictionaryKey:WebPluginDescriptionKey];
    240249    if (!description)
    241250        description = filename;
     
    247256- (BOOL)load
    248257{
    249     if (bundle && !BP_CreatePluginMIMETypesPreferences)
     258    if (cfBundle && !BP_CreatePluginMIMETypesPreferences)
    250259        BP_CreatePluginMIMETypesPreferences = (BP_CreatePluginMIMETypesPreferencesFuncPtr)CFBundleGetFunctionPointerForName(cfBundle, CFSTR("BP_CreatePluginMIMETypesPreferences"));
    251260   
     
    262271    [extensionToMIME release];
    263272
    264     [bundle release];
    265273    if (cfBundle)
    266274        CFRelease(cfBundle);
     
    329337{
    330338    return [MIMEToExtensions objectForKey:MIMEType];
    331 }
    332 
    333 - (NSBundle *)bundle
    334 {
    335     return bundle;
    336339}
    337340
  • trunk/WebKit/mac/Plugins/WebNetscapePluginPackage.mm

    r61510 r61519  
    3636#import "WebNetscapeDeprecatedFunctions.h"
    3737#import <WebCore/npruntime_impl.h>
     38#import <wtf/RetainPtr.h>
    3839
    3940#if USE(PLUGIN_HOST_PROCESS)
     
    209210    OSType type = 0;
    210211
    211     if (bundle) {
     212    if (cfBundle) {
    212213        // Bundle
    213214        CFBundleGetPackageInfo(cfBundle, &type, NULL);
     
    231232
    232233    // Check if the executable is Mach-O or CFM.
    233     if (bundle) {
    234         NSFileHandle *executableFile = [NSFileHandle fileHandleForReadingAtPath:[bundle executablePath]];
     234    if (cfBundle) {
     235        RetainPtr<CFURLRef> executableURL(AdoptCF, CFBundleCopyExecutableURL(cfBundle));
     236        if (!executableURL)
     237            return NO;
     238        NSFileHandle *executableFile = [NSFileHandle fileHandleForReadingAtPath:[(NSURL *)executableURL.get() path]];
    235239        NSData *data = [executableFile readDataOfLength:512];
    236240        [executableFile closeFile];
     
    247251
    248252#if USE(PLUGIN_HOST_PROCESS)
    249         NSArray *archs = [bundle executableArchitectures];
    250        
    251         if ([archs containsObject:[NSNumber numberWithInteger:NSBundleExecutableArchitectureX86_64]])
     253        RetainPtr<CFArrayRef> archs(AdoptCF, CFBundleCopyExecutableArchitectures(cfBundle));
     254       
     255        if ([(NSArray *)archs.get() containsObject:[NSNumber numberWithInteger:NSBundleExecutableArchitectureX86_64]])
    252256            pluginHostArchitecture = CPU_TYPE_X86_64;
    253         else if ([archs containsObject:[NSNumber numberWithInteger:NSBundleExecutableArchitectureI386]])
     257        else if ([(NSArray *)archs.get() containsObject:[NSNumber numberWithInteger:NSBundleExecutableArchitectureI386]])
    254258            pluginHostArchitecture = CPU_TYPE_X86;
    255259        else
  • trunk/WebKit/mac/Plugins/WebPluginPackage.h

    r11962 r61519  
    3333@protocol WebPluginViewFactory;
    3434
    35 @interface WebPluginPackage : WebBasePluginPackage
     35@interface WebPluginPackage : WebBasePluginPackage {
     36    NSBundle *nsBundle;
     37}
    3638
    3739- (Class)viewFactory;
  • trunk/WebKit/mac/Plugins/WebPluginPackage.mm

    r61509 r61519  
    4141@implementation WebPluginPackage
    4242
    43 - initWithPath:(NSString *)pluginPath
     43- (id)initWithPath:(NSString *)pluginPath
    4444{
    4545    if (!(self = [super initWithPath:pluginPath]))
    4646        return nil;
    4747
    48     if (bundle == nil) {
     48    nsBundle = [[NSBundle alloc] initWithPath:path];
     49
     50    if (!nsBundle) {
    4951        [self release];
    5052        return nil;
     
    6062    }
    6163   
    62     NSFileHandle *executableFile = [NSFileHandle fileHandleForReadingAtPath:[bundle executablePath]];
     64    NSFileHandle *executableFile = [NSFileHandle fileHandleForReadingAtPath:[nsBundle executablePath]];
    6365    NSData *data = [executableFile readDataOfLength:512];
    6466    [executableFile closeFile];
     
    7678}
    7779
     80- (void)dealloc
     81{
     82    [nsBundle release];
     83
     84    [super dealloc];
     85}
     86
    7887- (Class)viewFactory
    7988{
    80     return [bundle principalClass];
     89    return [nsBundle principalClass];
    8190}
    8291
     
    8897   
    8998    // Load the bundle
    90     if (![bundle isLoaded]) {
    91         if (![bundle load])
     99    if (![nsBundle isLoaded]) {
     100        if (![nsBundle load])
    92101            return NO;
    93102    }
Note: See TracChangeset for help on using the changeset viewer.