Commit 419c3693 authored by mitz@apple.com's avatar mitz@apple.com
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:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51617 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 82d5b0f9
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 @@ bool WebFrameLoaderClient::canHandleRequest(const ResourceRequest& request) cons
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 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage()
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 @@ ObjectContentType WebFrameLoaderClient::objectContentType(const KURL& url, const
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 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
- (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 @@ enum {
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 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
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 @@ static bool runningTigerMail()
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 @@ static bool runningTigerMail()
- (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 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
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 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
- (WebBasePluginPackage *)_pluginForExtension:(NSString *)extension
{
if (![_private->preferences arePlugInsEnabled])
return nil;
WebBasePluginPackage *pluginPackage = [[WebPluginDatabase sharedDatabase] pluginForExtension:extension];
if (pluginPackage)
return pluginPackage;
......@@ -2429,6 +2445,9 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
- (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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment