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

        Get rid of the old MIMETypes getter method
        https://bugs.webkit.org/show_bug.cgi?id=40898

        * Plugins/WebBasePluginPackage.h:
        * Plugins/WebBasePluginPackage.mm:
        (-[WebBasePluginPackage supportsExtension:]):
        (-[WebBasePluginPackage supportsMIMEType:WebCore::]):
        (-[WebBasePluginPackage MIMETypeForExtension:]):
        * Plugins/WebPluginDatabase.mm:
        (-[WebPluginDatabase refresh]):
        (-[WebPluginDatabase _removePlugin:]):


Canonical link: https://commits.webkit.org/52535@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@61525 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Jun 21, 2010
1 parent 925a520 commit e356e20548a15050d01150a2727633af7fcdbc01
Showing 4 changed files with 46 additions and 22 deletions.
@@ -1,3 +1,19 @@
2010-06-20 Anders Carlsson <andersca@apple.com>

Reviewed by Dan Bernstein.

Get rid of the old MIMETypes getter method
https://bugs.webkit.org/show_bug.cgi?id=40898

* Plugins/WebBasePluginPackage.h:
* Plugins/WebBasePluginPackage.mm:
(-[WebBasePluginPackage supportsExtension:]):
(-[WebBasePluginPackage supportsMIMEType:WebCore::]):
(-[WebBasePluginPackage MIMETypeForExtension:]):
* Plugins/WebPluginDatabase.mm:
(-[WebPluginDatabase refresh]):
(-[WebPluginDatabase _removePlugin:]):

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

Reviewed by Dan Bernstein.
@@ -88,13 +88,10 @@ typedef void (*BP_CreatePluginMIMETypesPreferencesFuncPtr)(void);
- (WebCore::String)bundleIdentifier;

- (BOOL)supportsExtension:(const WebCore::String&)extension;
- (BOOL)supportsMIMEType:(NSString *)MIMEType;

- (NSArray *)MIMETypes;
- (BOOL)supportsMIMEType:(const WebCore::String&)MIMEType;

- (NSString *)descriptionForMIMEType:(NSString *)MIMEType;
- (NSString *)MIMETypeForExtension:(const WebCore::String&)extension;
- (NSArray *)extensionsForMIMEType:(NSString *)MIMEType;

- (void)setMIMEToDescriptionDictionary:(NSDictionary *)MIMEToDescriptionDictionary;
- (void)setMIMEToExtensionsDictionary:(NSDictionary *)MIMEToExtensionsDictionary;
@@ -28,6 +28,7 @@

#import <WebKit/WebBasePluginPackage.h>

#import <algorithm>
#import <WebCore/WebCoreObjCExtras.h>
#import <WebKit/WebKitNSStringExtras.h>
#import <WebKit/WebNSObjectExtras.h>
@@ -58,6 +59,7 @@ @interface NSArray (WebPluginExtensions)
- (NSArray *)_web_lowercaseStrings;
@end;

using namespace std;
using namespace WebCore;

@implementation WebBasePluginPackage
@@ -330,20 +332,25 @@ - (BOOL)supportsExtension:(const String&)extension
ASSERT(extension.lower() == extension);

for (size_t i = 0; i < mimeTypes.size(); ++i) {
const MimeClassInfo& mimeClassInfo = mimeTypes[i];

for (size_t j = 0; i < mimeClassInfo.extensions.size(); ++j) {
if (mimeClassInfo.extensions[j] == extension)
return YES;
}
const Vector<String>& extensions = mimeTypes[i].extensions;

if (find(extensions.begin(), extensions.end(), extension) != extensions.end())
return YES;
}

return NO;
}

- (BOOL)supportsMIMEType:(NSString *)MIMEType
- (BOOL)supportsMIMEType:(const WebCore::String&)mimeType
{
return [MIMEToExtensions objectForKey:MIMEType] != 0;
ASSERT(mimeType.lower() == mimeType);

for (size_t i = 0; i < mimeTypes.size(); ++i) {
if (mimeTypes[i].type == mimeType)
return YES;
}

return NO;
}

- (NSString *)descriptionForMIMEType:(NSString *)MIMEType
@@ -357,11 +364,10 @@ - (NSString *)MIMETypeForExtension:(const String&)extension

for (size_t i = 0; i < mimeTypes.size(); ++i) {
const MimeClassInfo& mimeClassInfo = mimeTypes[i];

for (size_t j = 0; j < mimeClassInfo.extensions.size(); ++j) {
if (mimeClassInfo.extensions[j] == extension)
return mimeClassInfo.type;
}
const Vector<String>& extensions = mimeClassInfo.extensions;

if (find(extensions.begin(), extensions.end(), extension) != extensions.end())
return mimeClassInfo.type;
}

return nil;
@@ -45,6 +45,8 @@
#import <WebKitSystemInterface.h>
#import <wtf/Assertions.h>

using namespace WebCore;

static void checkCandidate(WebBasePluginPackage **currentPlugin, WebBasePluginPackage **candidatePlugin);

@interface WebPluginDatabase (Internal)
@@ -304,8 +306,11 @@ - (void)refresh
// Build a list of MIME types.
NSMutableSet *MIMETypes = [[NSMutableSet alloc] init];
pluginEnumerator = [plugins objectEnumerator];
while ((plugin = [pluginEnumerator nextObject]) != nil)
[MIMETypes addObjectsFromArray:[plugin MIMETypes]];
while ((plugin = [pluginEnumerator nextObject])) {
const Vector<MimeClassInfo>& mimeTypes = [plugin mimeTypes];
for (size_t i = 0; i < mimeTypes.size(); ++i)
[MIMETypes addObject:mimeTypes[i].type];
}

// Register plug-in views and representations.
NSEnumerator *MIMEEnumerator = [MIMETypes objectEnumerator];
@@ -439,9 +444,9 @@ - (void)_removePlugin:(WebBasePluginPackage *)plugin
ASSERT(plugin);

// Unregister plug-in's MIME type registrations
NSArray *MIMETypes = [plugin MIMETypes];
for (NSUInteger i = 0; i < [MIMETypes count]; ++i) {
NSString *MIMEType = [MIMETypes objectAtIndex:i];
const Vector<MimeClassInfo>& mimeTypes = [plugin mimeTypes];
for (size_t i = 0; i < mimeTypes.size(); ++i) {
NSString *MIMEType = mimeTypes[i].type;

if ([registeredMIMETypes containsObject:MIMEType]) {
if (self == sharedDatabase)

0 comments on commit e356e20

Please sign in to comment.