Skip to content
Permalink
Browse files
Fixed <rdar://problem/7254127> WebKit can load plug-ins even when
plug-ins are disabled

Reviewed by Anders Carlsson.

Ensure that the shared WebPluginDatabase is not instantiated if no
WebViews are used that have plug-ins enabled.

* DefaultDelegates/WebDefaultPolicyDelegate.m:
(-[WebDefaultPolicyDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]):
Call -[WebView _canShowMIMEType:] on the WebView instead of calling the
class method.

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::canShowMIMEType): Ditto.
(WebFrameLoaderClient::transitionToCommittedForNewPage): Call
-[WebFrameView _viewClassForMIMEType:] on the WebView instead of calling
the class method.
(WebFrameLoaderClient::objectContentType): Ditto.

* WebView/WebDataSource.mm:
(+[WebDataSource _representationClassForMIMEType:allowingPlugins:]):
Added the allowPlugins parameter, which is passed through to
+[WebView _viewClass:andRepresentationClass:forMIMEType:allowingPlugins:].
(-[WebDataSource _makeRepresentation]): Pass an allowPlugins value
based on the WebView’s preferences.

* WebView/WebFrameView.mm:
(-[WebFrameView _makeDocumentViewForDataSource:]): Call
-[WebFrameView _viewClassForMIMEType:] instead of calling the class
method.
(+[WebFrameView _viewClassForMIMEType:allowingPlugins:]): Added the
allowPlugins parameter, which is passed through to
+[WebView _viewClass:andRepresentationClass:forMIMEType:allowingPlugins:].
(-[WebFrameView _viewClassForMIMEType:]): Added. Passes an allowPlugins
value based on the WebView’s preferences.

* WebView/WebFrameViewInternal.h:
* WebView/WebView.mm:
(+[WebView _viewClass:andRepresentationClass:forMIMEType:allowingPlugins:]):
Added the allowPlugins parameter. If false, skip the instantiation of
the shared WebPluginDatabase.
(-[WebView _viewClass:andRepresentationClass:forMIMEType:]): Pass an
allowPlugins value based on the WebView’s preferences.
(+[WebView _canShowMIMEType:allowingPlugins:]): Passes allowPlugins to
+_viewClass:andRepresentationClass:forMIMEType:allowingPlugins:.
(+[WebView canShowMIMEType:]): Changed to pass YES to
+_canShowMIMEType:allowingPlugins:.
(-[WebView _canShowMIMEType:]): Added. Passes an allowPlugins value
based on the WebView’s preferences.
(-[WebView _pluginForMIMEType:]): Return nil if plug-ins are disabled.
(-[WebView _pluginForExtension:]): Ditto.
(-[WebView _isMIMETypeRegisteredAsPlugin:]): Return NO if plug-ins are
disabled.
* WebView/WebViewInternal.h:



Canonical link: https://commits.webkit.org/43044@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51617 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Dan Bernstein committed Dec 3, 2009
1 parent cad0c06 commit d00123776aeefc7438a772080a4651ae67d73ec9
Showing 8 changed files with 102 additions and 17 deletions.
@@ -1,3 +1,61 @@
2009-12-02 Dan Bernstein <mitz@apple.com>

Reviewed by Anders Carlsson.

Fixed <rdar://problem/7254127> WebKit can load plug-ins even when
plug-ins are disabled

Ensure that the shared WebPluginDatabase is not instantiated if no
WebViews are used that have plug-ins enabled.

* DefaultDelegates/WebDefaultPolicyDelegate.m:
(-[WebDefaultPolicyDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]):
Call -[WebView _canShowMIMEType:] on the WebView instead of calling the
class method.

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::canShowMIMEType): Ditto.
(WebFrameLoaderClient::transitionToCommittedForNewPage): Call
-[WebFrameView _viewClassForMIMEType:] on the WebView instead of calling
the class method.
(WebFrameLoaderClient::objectContentType): Ditto.

* WebView/WebDataSource.mm:
(+[WebDataSource _representationClassForMIMEType:allowingPlugins:]):
Added the allowPlugins parameter, which is passed through to
+[WebView _viewClass:andRepresentationClass:forMIMEType:allowingPlugins:].
(-[WebDataSource _makeRepresentation]): Pass an allowPlugins value
based on the WebView’s preferences.

* WebView/WebFrameView.mm:
(-[WebFrameView _makeDocumentViewForDataSource:]): Call
-[WebFrameView _viewClassForMIMEType:] instead of calling the class
method.
(+[WebFrameView _viewClassForMIMEType:allowingPlugins:]): Added the
allowPlugins parameter, which is passed through to
+[WebView _viewClass:andRepresentationClass:forMIMEType:allowingPlugins:].
(-[WebFrameView _viewClassForMIMEType:]): Added. Passes an allowPlugins
value based on the WebView’s preferences.

* WebView/WebFrameViewInternal.h:
* WebView/WebView.mm:
(+[WebView _viewClass:andRepresentationClass:forMIMEType:allowingPlugins:]):
Added the allowPlugins parameter. If false, skip the instantiation of
the shared WebPluginDatabase.
(-[WebView _viewClass:andRepresentationClass:forMIMEType:]): Pass an
allowPlugins value based on the WebView’s preferences.
(+[WebView _canShowMIMEType:allowingPlugins:]): Passes allowPlugins to
+_viewClass:andRepresentationClass:forMIMEType:allowingPlugins:.
(+[WebView canShowMIMEType:]): Changed to pass YES to
+_canShowMIMEType:allowingPlugins:.
(-[WebView _canShowMIMEType:]): Added. Passes an allowPlugins value
based on the WebView’s preferences.
(-[WebView _pluginForMIMEType:]): Return nil if plug-ins are disabled.
(-[WebView _pluginForExtension:]): Ditto.
(-[WebView _isMIMETypeRegisteredAsPlugin:]): Return NO if plug-ins are
disabled.
* WebView/WebViewInternal.h:

2009-12-02 Timothy Hatcher <timothy@apple.com>

Fixes a crash when scrolling a frame that goes away mid-scroll.
@@ -66,11 +66,11 @@ - (void)webView: (WebView *)wv decidePolicyForMIMEType:(NSString *)type
BOOL isDirectory = NO;
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:[[request URL] path] isDirectory:&isDirectory];

if (exists && !isDirectory && [WebView canShowMIMEType:type])
if (exists && !isDirectory && [wv _canShowMIMEType:type])
[listener use];
else
[listener ignore];
} else if ([WebView canShowMIMEType:type])
} else if ([wv _canShowMIMEType:type])
[listener use];
else
[listener ignore];
@@ -953,7 +953,7 @@ static inline void applyAppleDictionaryApplicationQuirk(WebFrameLoaderClient* cl

bool WebFrameLoaderClient::canShowMIMEType(const String& MIMEType) const
{
return [WebView canShowMIMEType:MIMEType];
return [getWebView(m_webFrame.get()) _canShowMIMEType:MIMEType];
}

bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const
@@ -1117,7 +1117,7 @@ static inline void applyAppleDictionaryApplicationQuirk(WebFrameLoaderClient* cl

if (usesDocumentViews) {
// FIXME (Viewless): I assume we want the equivalent of this optimization for viewless mode too.
bool willProduceHTMLView = [[WebFrameView class] _viewClassForMIMEType:[dataSource _responseMIMEType]] == [WebHTMLView class];
bool willProduceHTMLView = [m_webFrame->_private->webFrameView _viewClassForMIMEType:[dataSource _responseMIMEType]] == [WebHTMLView class];
bool canSkipCreation = core(m_webFrame.get())->loader()->committingFirstRealLoad() && willProduceHTMLView;
if (canSkipCreation) {
[[m_webFrame->_private->webFrameView documentView] setDataSource:dataSource];
@@ -1365,7 +1365,7 @@ static inline void applyAppleDictionaryApplicationQuirk(WebFrameLoaderClient* cl
return ObjectContentOtherPlugin;
}

if ([WebFrameView _viewClassForMIMEType:type])
if ([m_webFrame->_private->webFrameView _viewClassForMIMEType:type])
return ObjectContentFrame;

return ObjectContentNone;
@@ -140,10 +140,10 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
}
}

+ (Class)_representationClassForMIMEType:(NSString *)MIMEType
+ (Class)_representationClassForMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins
{
Class repClass;
return [WebView _viewClass:nil andRepresentationClass:&repClass forMIMEType:MIMEType] ? repClass : nil;
return [WebView _viewClass:nil andRepresentationClass:&repClass forMIMEType:MIMEType allowingPlugins:allowPlugins] ? repClass : nil;
}
@end

@@ -340,7 +340,7 @@ - (BOOL)_isDocumentHTML

- (void)_makeRepresentation
{
Class repClass = [[self class] _representationClassForMIMEType:[self _responseMIMEType]];
Class repClass = [[self class] _representationClassForMIMEType:[self _responseMIMEType] allowingPlugins:[[[self _webView] preferences] arePlugInsEnabled]];

// Check if the data source was already bound?
if (![[self representation] isKindOfClass:repClass]) {
@@ -156,7 +156,7 @@ - (void)_setDocumentView:(NSView <WebDocumentView> *)view
NSString* MIMEType = [dataSource _responseMIMEType];
if (!MIMEType)
MIMEType = @"text/html";
Class viewClass = [[self class] _viewClassForMIMEType:MIMEType];
Class viewClass = [self _viewClassForMIMEType:MIMEType];
NSView <WebDocumentView> *documentView;
if (viewClass) {
// If the dataSource's representation has already been created, and it is also the
@@ -244,10 +244,15 @@ + (BOOL)_canShowMIMETypeAsHTML:(NSString *)MIMEType
return [[[self _viewTypesAllowImageTypeOmission:YES] _webkit_objectForMIMEType:MIMEType] isSubclassOfClass:[WebHTMLView class]];
}

+ (Class)_viewClassForMIMEType:(NSString *)MIMEType
+ (Class)_viewClassForMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins
{
Class viewClass;
return [WebView _viewClass:&viewClass andRepresentationClass:nil forMIMEType:MIMEType] ? viewClass : nil;
return [WebView _viewClass:&viewClass andRepresentationClass:nil forMIMEType:MIMEType allowingPlugins:allowPlugins] ? viewClass : nil;
}

- (Class)_viewClassForMIMEType:(NSString *)MIMEType
{
return [[self class] _viewClassForMIMEType:MIMEType allowingPlugins:[[[self _webView] preferences] arePlugInsEnabled]];
}

- (void)_install
@@ -39,7 +39,8 @@
- (void)_setWebFrame:(WebFrame *)webFrame;
- (float)_verticalPageScrollDistance;
+ (NSMutableDictionary *)_viewTypesAllowImageTypeOmission:(BOOL)allowImageTypeOmission;
+ (Class)_viewClassForMIMEType:(NSString *)MIMEType;
- (Class)_viewClassForMIMEType:(NSString *)MIMEType;
+ (Class)_viewClassForMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins;
+ (BOOL)_canShowMIMETypeAsHTML:(NSString *)MIMEType;
- (WebDynamicScrollBarsView *)_scrollView;
- (void)_install;
@@ -822,13 +822,13 @@ + (NSArray *)_supportedFileExtensions
return uniqueExtensions;
}

+ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType
+ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins
{
MIMEType = [MIMEType lowercaseString];
Class viewClass = [[WebFrameView _viewTypesAllowImageTypeOmission:YES] _webkit_objectForMIMEType:MIMEType];
Class repClass = [[WebDataSource _repTypesAllowImageTypeOmission:YES] _webkit_objectForMIMEType:MIMEType];

if (!viewClass || !repClass || [[WebPDFView supportedMIMETypes] containsObject:MIMEType]) {
if (allowPlugins && (!viewClass || !repClass || [[WebPDFView supportedMIMETypes] containsObject:MIMEType])) {
// Our optimization to avoid loading the plug-in DB and image types for the HTML case failed.
// Load the plug-in DB allowing plug-ins to install types.
[WebPluginDatabase sharedDatabase];
@@ -857,7 +857,7 @@ + (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIM

- (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType
{
if ([[self class] _viewClass:vClass andRepresentationClass:rClass forMIMEType:MIMEType])
if ([[self class] _viewClass:vClass andRepresentationClass:rClass forMIMEType:MIMEType allowingPlugins:[[[self _webView] preferences] arePlugInsEnabled]])
return YES;

if (_private->pluginDatabase) {
@@ -2379,13 +2379,26 @@ + (void)_applicationWillTerminate
PageGroup::closeLocalStorage();
}

+ (BOOL)_canShowMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins
{
return [self _viewClass:nil andRepresentationClass:nil forMIMEType:MIMEType allowingPlugins:allowPlugins];
}

+ (BOOL)canShowMIMEType:(NSString *)MIMEType
{
return [self _viewClass:nil andRepresentationClass:nil forMIMEType:MIMEType];
return [self _canShowMIMEType:MIMEType allowingPlugins:YES];
}

- (BOOL)_canShowMIMEType:(NSString *)MIMEType
{
return [[self class] _canShowMIMEType:MIMEType allowingPlugins:[[[self _webView] preferences] arePlugInsEnabled]];
}

- (WebBasePluginPackage *)_pluginForMIMEType:(NSString *)MIMEType
{
if (![_private->preferences arePlugInsEnabled])
return nil;

WebBasePluginPackage *pluginPackage = [[WebPluginDatabase sharedDatabase] pluginForMIMEType:MIMEType];
if (pluginPackage)
return pluginPackage;
@@ -2398,6 +2411,9 @@ - (WebBasePluginPackage *)_pluginForMIMEType:(NSString *)MIMEType

- (WebBasePluginPackage *)_pluginForExtension:(NSString *)extension
{
if (![_private->preferences arePlugInsEnabled])
return nil;

WebBasePluginPackage *pluginPackage = [[WebPluginDatabase sharedDatabase] pluginForExtension:extension];
if (pluginPackage)
return pluginPackage;
@@ -2429,6 +2445,9 @@ - (void)removePluginInstanceViewsFor:(WebFrame*)webFrame

- (BOOL)_isMIMETypeRegisteredAsPlugin:(NSString *)MIMEType
{
if (![_private->preferences arePlugInsEnabled])
return NO;

if ([[WebPluginDatabase sharedDatabase] isMIMETypeRegistered:MIMEType])
return YES;

@@ -115,8 +115,10 @@ namespace WebCore {
- (void)_pushPerformingProgrammaticFocus;
- (void)_popPerformingProgrammaticFocus;
- (void)_didStartProvisionalLoadForFrame:(WebFrame *)frame;
+ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType;
+ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins;
- (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType;
+ (BOOL)_canShowMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins;
- (BOOL)_canShowMIMEType:(NSString *)MIMEType;
+ (NSString *)_MIMETypeForFile:(NSString *)path;
- (WebDownload *)_downloadURL:(NSURL *)URL;
+ (NSString *)_generatedMIMETypeForURLScheme:(NSString *)URLScheme;

0 comments on commit d001237

Please sign in to comment.