Changeset 51617 in webkit


Ignore:
Timestamp:
Dec 2, 2009 4:22:38 PM (14 years ago)
Author:
mitz@apple.com
Message:

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

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/mac/ChangeLog

    r51616 r51617  
     12009-12-02  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Fixed <rdar://problem/7254127> WebKit can load plug-ins even when
     6        plug-ins are disabled
     7
     8        Ensure that the shared WebPluginDatabase is not instantiated if no
     9        WebViews are used that have plug-ins enabled.
     10
     11        * DefaultDelegates/WebDefaultPolicyDelegate.m:
     12        (-[WebDefaultPolicyDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]):
     13        Call -[WebView _canShowMIMEType:] on the WebView instead of calling the
     14        class method.
     15
     16        * WebCoreSupport/WebFrameLoaderClient.mm:
     17        (WebFrameLoaderClient::canShowMIMEType): Ditto.
     18        (WebFrameLoaderClient::transitionToCommittedForNewPage): Call
     19        -[WebFrameView _viewClassForMIMEType:] on the WebView instead of calling
     20        the class method.
     21        (WebFrameLoaderClient::objectContentType): Ditto.
     22
     23        * WebView/WebDataSource.mm:
     24        (+[WebDataSource _representationClassForMIMEType:allowingPlugins:]):
     25        Added the allowPlugins parameter, which is passed through to
     26        +[WebView _viewClass:andRepresentationClass:forMIMEType:allowingPlugins:].
     27        (-[WebDataSource _makeRepresentation]): Pass an allowPlugins value
     28        based on the WebView’s preferences.
     29
     30        * WebView/WebFrameView.mm:
     31        (-[WebFrameView _makeDocumentViewForDataSource:]): Call
     32        -[WebFrameView _viewClassForMIMEType:] instead of calling the class
     33        method.
     34        (+[WebFrameView _viewClassForMIMEType:allowingPlugins:]): Added the
     35        allowPlugins parameter, which is passed through to
     36        +[WebView _viewClass:andRepresentationClass:forMIMEType:allowingPlugins:].
     37        (-[WebFrameView _viewClassForMIMEType:]): Added. Passes an allowPlugins
     38        value based on the WebView’s preferences.
     39
     40        * WebView/WebFrameViewInternal.h:
     41        * WebView/WebView.mm:
     42        (+[WebView _viewClass:andRepresentationClass:forMIMEType:allowingPlugins:]):
     43        Added the allowPlugins parameter. If false, skip the instantiation of
     44        the shared WebPluginDatabase.
     45        (-[WebView _viewClass:andRepresentationClass:forMIMEType:]): Pass an
     46        allowPlugins value based on the WebView’s preferences.
     47        (+[WebView _canShowMIMEType:allowingPlugins:]): Passes allowPlugins to
     48        +_viewClass:andRepresentationClass:forMIMEType:allowingPlugins:.
     49        (+[WebView canShowMIMEType:]): Changed to pass YES to
     50        +_canShowMIMEType:allowingPlugins:.
     51        (-[WebView _canShowMIMEType:]): Added. Passes an allowPlugins value
     52        based on the WebView’s preferences.
     53        (-[WebView _pluginForMIMEType:]): Return nil if plug-ins are disabled.
     54        (-[WebView _pluginForExtension:]): Ditto.
     55        (-[WebView _isMIMETypeRegisteredAsPlugin:]): Return NO if plug-ins are
     56        disabled.
     57        * WebView/WebViewInternal.h:
     58
    1592009-12-02  Timothy Hatcher  <timothy@apple.com>
    260
  • trunk/WebKit/mac/DefaultDelegates/WebDefaultPolicyDelegate.m

    r36880 r51617  
    6767        BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:[[request URL] path] isDirectory:&isDirectory];
    6868
    69         if (exists && !isDirectory && [WebView canShowMIMEType:type])
     69        if (exists && !isDirectory && [wv _canShowMIMEType:type])
    7070            [listener use];
    7171        else
    7272            [listener ignore];
    73     } else if ([WebView canShowMIMEType:type])
     73    } else if ([wv _canShowMIMEType:type])
    7474        [listener use];
    7575    else
  • trunk/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r51562 r51617  
    954954bool WebFrameLoaderClient::canShowMIMEType(const String& MIMEType) const
    955955{
    956     return [WebView canShowMIMEType:MIMEType];
     956    return [getWebView(m_webFrame.get()) _canShowMIMEType:MIMEType];
    957957}
    958958
     
    11181118    if (usesDocumentViews) {
    11191119        // FIXME (Viewless): I assume we want the equivalent of this optimization for viewless mode too.
    1120         bool willProduceHTMLView = [[WebFrameView class] _viewClassForMIMEType:[dataSource _responseMIMEType]] == [WebHTMLView class];
     1120        bool willProduceHTMLView = [m_webFrame->_private->webFrameView _viewClassForMIMEType:[dataSource _responseMIMEType]] == [WebHTMLView class];
    11211121        bool canSkipCreation = core(m_webFrame.get())->loader()->committingFirstRealLoad() && willProduceHTMLView;
    11221122        if (canSkipCreation) {
     
    13661366    }
    13671367
    1368     if ([WebFrameView _viewClassForMIMEType:type])
     1368    if ([m_webFrame->_private->webFrameView _viewClassForMIMEType:type])
    13691369        return ObjectContentFrame;
    13701370   
  • trunk/WebKit/mac/WebView/WebDataSource.mm

    r46786 r51617  
    141141}
    142142
    143 + (Class)_representationClassForMIMEType:(NSString *)MIMEType
     143+ (Class)_representationClassForMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins
    144144{
    145145    Class repClass;
    146     return [WebView _viewClass:nil andRepresentationClass:&repClass forMIMEType:MIMEType] ? repClass : nil;
     146    return [WebView _viewClass:nil andRepresentationClass:&repClass forMIMEType:MIMEType allowingPlugins:allowPlugins] ? repClass : nil;
    147147}
    148148@end
     
    341341- (void)_makeRepresentation
    342342{
    343     Class repClass = [[self class] _representationClassForMIMEType:[self _responseMIMEType]];
     343    Class repClass = [[self class] _representationClassForMIMEType:[self _responseMIMEType] allowingPlugins:[[[self _webView] preferences] arePlugInsEnabled]];
    344344   
    345345    // Check if the data source was already bound?
  • trunk/WebKit/mac/WebView/WebFrameView.mm

    r50665 r51617  
    157157    if (!MIMEType)
    158158        MIMEType = @"text/html";
    159     Class viewClass = [[self class] _viewClassForMIMEType:MIMEType];
     159    Class viewClass = [self _viewClassForMIMEType:MIMEType];
    160160    NSView <WebDocumentView> *documentView;
    161161    if (viewClass) {
     
    245245}
    246246
    247 + (Class)_viewClassForMIMEType:(NSString *)MIMEType
     247+ (Class)_viewClassForMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins
    248248{
    249249    Class viewClass;
    250     return [WebView _viewClass:&viewClass andRepresentationClass:nil forMIMEType:MIMEType] ? viewClass : nil;
     250    return [WebView _viewClass:&viewClass andRepresentationClass:nil forMIMEType:MIMEType allowingPlugins:allowPlugins] ? viewClass : nil;
     251}
     252
     253- (Class)_viewClassForMIMEType:(NSString *)MIMEType
     254{
     255    return [[self class] _viewClassForMIMEType:MIMEType allowingPlugins:[[[self _webView] preferences] arePlugInsEnabled]];
    251256}
    252257
  • trunk/WebKit/mac/WebView/WebFrameViewInternal.h

    r37371 r51617  
    4040- (float)_verticalPageScrollDistance;
    4141+ (NSMutableDictionary *)_viewTypesAllowImageTypeOmission:(BOOL)allowImageTypeOmission;
    42 + (Class)_viewClassForMIMEType:(NSString *)MIMEType;
     42- (Class)_viewClassForMIMEType:(NSString *)MIMEType;
     43+ (Class)_viewClassForMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins;
    4344+ (BOOL)_canShowMIMETypeAsHTML:(NSString *)MIMEType;
    4445- (WebDynamicScrollBarsView *)_scrollView;
  • trunk/WebKit/mac/WebView/WebView.mm

    r51562 r51617  
    823823}
    824824
    825 + (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType
     825+ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins
    826826{
    827827    MIMEType = [MIMEType lowercaseString];
     
    829829    Class repClass = [[WebDataSource _repTypesAllowImageTypeOmission:YES] _webkit_objectForMIMEType:MIMEType];
    830830   
    831     if (!viewClass || !repClass || [[WebPDFView supportedMIMETypes] containsObject:MIMEType]) {
     831    if (allowPlugins && (!viewClass || !repClass || [[WebPDFView supportedMIMETypes] containsObject:MIMEType])) {
    832832        // Our optimization to avoid loading the plug-in DB and image types for the HTML case failed.
    833833        // Load the plug-in DB allowing plug-ins to install types.
     
    858858- (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType
    859859{
    860     if ([[self class] _viewClass:vClass andRepresentationClass:rClass forMIMEType:MIMEType])
     860    if ([[self class] _viewClass:vClass andRepresentationClass:rClass forMIMEType:MIMEType allowingPlugins:[[[self _webView] preferences] arePlugInsEnabled]])
    861861        return YES;
    862862
     
    23802380}
    23812381
     2382+ (BOOL)_canShowMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins
     2383{
     2384    return [self _viewClass:nil andRepresentationClass:nil forMIMEType:MIMEType allowingPlugins:allowPlugins];
     2385}
     2386
    23822387+ (BOOL)canShowMIMEType:(NSString *)MIMEType
    23832388{
    2384     return [self _viewClass:nil andRepresentationClass:nil forMIMEType:MIMEType];
     2389    return [self _canShowMIMEType:MIMEType allowingPlugins:YES];
     2390}
     2391
     2392- (BOOL)_canShowMIMEType:(NSString *)MIMEType
     2393{
     2394    return [[self class] _canShowMIMEType:MIMEType allowingPlugins:[[[self _webView] preferences] arePlugInsEnabled]];
    23852395}
    23862396
    23872397- (WebBasePluginPackage *)_pluginForMIMEType:(NSString *)MIMEType
    23882398{
     2399    if (![_private->preferences arePlugInsEnabled])
     2400        return nil;
     2401
    23892402    WebBasePluginPackage *pluginPackage = [[WebPluginDatabase sharedDatabase] pluginForMIMEType:MIMEType];
    23902403    if (pluginPackage)
     
    23992412- (WebBasePluginPackage *)_pluginForExtension:(NSString *)extension
    24002413{
     2414    if (![_private->preferences arePlugInsEnabled])
     2415        return nil;
     2416
    24012417    WebBasePluginPackage *pluginPackage = [[WebPluginDatabase sharedDatabase] pluginForExtension:extension];
    24022418    if (pluginPackage)
     
    24302446- (BOOL)_isMIMETypeRegisteredAsPlugin:(NSString *)MIMEType
    24312447{
     2448    if (![_private->preferences arePlugInsEnabled])
     2449        return NO;
     2450
    24322451    if ([[WebPluginDatabase sharedDatabase] isMIMETypeRegistered:MIMEType])
    24332452        return YES;
  • trunk/WebKit/mac/WebView/WebViewInternal.h

    r51562 r51617  
    116116- (void)_popPerformingProgrammaticFocus;
    117117- (void)_didStartProvisionalLoadForFrame:(WebFrame *)frame;
    118 + (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType;
     118+ (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins;
    119119- (BOOL)_viewClass:(Class *)vClass andRepresentationClass:(Class *)rClass forMIMEType:(NSString *)MIMEType;
     120+ (BOOL)_canShowMIMEType:(NSString *)MIMEType allowingPlugins:(BOOL)allowPlugins;
     121- (BOOL)_canShowMIMEType:(NSString *)MIMEType;
    120122+ (NSString *)_MIMETypeForFile:(NSString *)path;
    121123- (WebDownload *)_downloadURL:(NSURL *)URL;
Note: See TracChangeset for help on using the changeset viewer.