Changeset 18910 in webkit


Ignore:
Timestamp:
Jan 17, 2007, 10:45:57 AM (18 years ago)
Author:
andersca
Message:

Reviewed by John Sullivan.


Move all code in WebNetscapePluginEmbeddedView down to WebBaseNetscapePluginView.


  • Plugins/WebBaseNetscapePluginView.h:
  • Plugins/WebBaseNetscapePluginView.mm: (-[WebBaseNetscapePluginView initWithFrame:pluginPackage:URL:baseURL:MIMEType:attributeKeys:attributeValues:loadManually:DOMElement:]): (-[WebBaseNetscapePluginView didStart]): (-[WebBaseNetscapePluginView dataSource]): (-[WebBaseNetscapePluginView dealloc]): (-[WebBaseNetscapePluginView pluginView:receivedResponse:]): (-[WebBaseNetscapePluginView pluginView:receivedData:]): (-[WebBaseNetscapePluginView pluginView:receivedError:]): (-[WebBaseNetscapePluginView pluginViewFinishedLoading:]): (-[WebBaseNetscapePluginView _redeliverStream]):
  • Plugins/WebNetscapePluginEmbeddedView.h:
  • Plugins/WebNetscapePluginEmbeddedView.mm:
Location:
trunk/WebKit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/ChangeLog

    r18903 r18910  
     12007-01-17  Anders Carlsson  <acarlsson@apple.com>
     2
     3        Reviewed by John Sullivan.
     4       
     5        Move all code in WebNetscapePluginEmbeddedView down to WebBaseNetscapePluginView.
     6       
     7        * Plugins/WebBaseNetscapePluginView.h:
     8        * Plugins/WebBaseNetscapePluginView.mm:
     9        (-[WebBaseNetscapePluginView initWithFrame:pluginPackage:URL:baseURL:MIMEType:attributeKeys:attributeValues:loadManually:DOMElement:]):
     10        (-[WebBaseNetscapePluginView didStart]):
     11        (-[WebBaseNetscapePluginView dataSource]):
     12        (-[WebBaseNetscapePluginView dealloc]):
     13        (-[WebBaseNetscapePluginView pluginView:receivedResponse:]):
     14        (-[WebBaseNetscapePluginView pluginView:receivedData:]):
     15        (-[WebBaseNetscapePluginView pluginView:receivedError:]):
     16        (-[WebBaseNetscapePluginView pluginViewFinishedLoading:]):
     17        (-[WebBaseNetscapePluginView _redeliverStream]):
     18        * Plugins/WebNetscapePluginEmbeddedView.h:
     19        * Plugins/WebNetscapePluginEmbeddedView.mm:
     20
    1212007-01-17  Maciej Stachowiak  <mjs@apple.com>
    222
  • trunk/WebKit/Plugins/WebBaseNetscapePluginView.h

    r18420 r18910  
    3232#import <WebKit/npfunctions.h>
    3333#import <WebKit/npapi.h>
     34#import <WebKit/WebBasePluginPackage.h>
    3435
    3536@class DOMElement;
     
    3839@class WebNetscapePluginPackage;
    3940@class WebNetscapePluginNullEventSender;
     41@class WebNetscapePluginStream;
    4042@class WebView;
    4143
     
    4850} PluginPort;
    4951
    50 @interface WebBaseNetscapePluginView : NSView
     52@interface WebBaseNetscapePluginView : NSView <WebPluginManualLoader>
    5153{
    5254    WebNetscapePluginPackage *pluginPackage;
     55   
     56    NSURL *sourceURL;
     57    WebFrame *_webFrame;
     58   
     59    BOOL _loadManually;
     60    WebNetscapePluginStream *_manualStream;
     61    unsigned _dataLengthReceived;
     62    NSError *_error;
    5363   
    5464    int mode;
     
    110120+ (WebBaseNetscapePluginView *)currentPluginView;
    111121
     122
     123- (id)initWithFrame:(NSRect)r
     124      pluginPackage:(WebNetscapePluginPackage *)thePluginPackage
     125                URL:(NSURL *)URL
     126            baseURL:(NSURL *)baseURL
     127           MIMEType:(NSString *)MIME
     128      attributeKeys:(NSArray *)keys
     129    attributeValues:(NSArray *)values
     130       loadManually:(BOOL)loadManually
     131         DOMElement:(DOMElement *)anElement;
     132
     133
    112134- (BOOL)start;
    113135- (BOOL)isStarted;
  • trunk/WebKit/Plugins/WebBaseNetscapePluginView.mm

    r18441 r18910  
    5151#import <JavaScriptCore/Assertions.h>
    5252#import <JavaScriptCore/npruntime_impl.h>
     53#import <WebCore/Document.h>
     54#import <WebCore/Element.h>
    5355#import <WebCore/FrameLoader.h>
    5456#import <WebCore/FrameMac.h>
     
    8385- (void)_hideAGLWindow;
    8486- (NSImage *)_aglOffscreenImageForDrawingInRect:(NSRect)drawingInRect;
     87- (void)_redeliverStream;
    8588@end
    8689
     
    140143@interface WebBaseNetscapePluginView (ForwardDeclarations)
    141144- (void)setWindowIfNecessary;
     145- (NPError)loadRequest:(NSMutableURLRequest *)request inTarget:(const char *)cTarget withNotifyData:(void *)notifyData sendNotification:(BOOL)sendNotification;
    142146@end
    143147
    144148@implementation WebBaseNetscapePluginView
     149
     150- (id)initWithFrame:(NSRect)frame
     151      pluginPackage:(WebNetscapePluginPackage *)thePluginPackage
     152                URL:(NSURL *)theURL
     153            baseURL:(NSURL *)theBaseURL
     154           MIMEType:(NSString *)MIME
     155      attributeKeys:(NSArray *)keys
     156    attributeValues:(NSArray *)values
     157       loadManually:(BOOL)loadManually
     158         DOMElement:(DOMElement *)anElement
     159{
     160    [super initWithFrame:frame];
     161   
     162    // load the plug-in if it is not already loaded
     163    if (![thePluginPackage load]) {
     164        [self release];
     165        return nil;
     166    }
     167    [self setPluginPackage:thePluginPackage];
     168   
     169    element = [anElement retain];
     170   
     171    sourceURL = [theURL retain];
     172   
     173    [self setMIMEType:MIME];
     174    [self setBaseURL:theBaseURL];
     175    [self setAttributeKeys:keys andValues:values];
     176    if (loadManually)
     177        [self setMode:NP_FULL];
     178    else
     179        [self setMode:NP_EMBED];
     180   
     181    _loadManually = loadManually;
     182   
     183    return self;
     184}
    145185
    146186+ (void)initialize
     
    11561196- (void)didStart
    11571197{
    1158     // Do nothing. Overridden by subclasses.
     1198    if (_loadManually) {
     1199        [self _redeliverStream];
     1200        return;
     1201    }
     1202   
     1203    // If the OBJECT/EMBED tag has no SRC, the URL is passed to us as "".
     1204    // Check for this and don't start a load in this case.
     1205    if (sourceURL != nil && ![sourceURL _web_isEmpty]) {
     1206        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:sourceURL];
     1207        [request _web_setHTTPReferrer:core([self webFrame])->loader()->outgoingReferrer()];
     1208        [self loadRequest:request inTarget:nil withNotifyData:nil sendNotification:NO];
     1209    }
    11591210}
    11601211
     
    13121363- (WebDataSource *)dataSource
    13131364{
    1314     // Do nothing. Overridden by subclasses.
    1315     return nil;
     1365    WebFrame *webFrame = kit(core(element)->document()->frame());
     1366    return [webFrame dataSource];
    13161367}
    13171368
     
    14511502    ASSERT(!isStarted);
    14521503
     1504    [sourceURL release];
     1505    [_manualStream release];
     1506    [_error release];
     1507   
    14531508    [pluginPackage release];
    14541509    [streams release];
     
    17311786        [self stop];
    17321787    }
     1788}
     1789
     1790-(void)pluginView:(NSView *)pluginView receivedResponse:(NSURLResponse *)response
     1791{
     1792    ASSERT(_loadManually);
     1793    ASSERT(!_manualStream);
     1794   
     1795    _manualStream = [[WebNetscapePluginStream alloc] init];
     1796}
     1797
     1798- (void)pluginView:(NSView *)pluginView receivedData:(NSData *)data
     1799{
     1800    ASSERT(_loadManually);
     1801    ASSERT(_manualStream);
     1802   
     1803    _dataLengthReceived += [data length];
     1804   
     1805    if (![self isStarted])
     1806        return;
     1807   
     1808    if ([_manualStream plugin] == NULL) {
     1809        [_manualStream setRequestURL:[[[self dataSource] request] URL]];
     1810        [_manualStream setPlugin:[self plugin]];
     1811        ASSERT([_manualStream plugin]);
     1812        [_manualStream startStreamWithResponse:[[self dataSource] response]];
     1813    }
     1814   
     1815    if ([_manualStream plugin])
     1816        [_manualStream receivedData:data];
     1817}
     1818
     1819- (void)pluginView:(NSView *)pluginView receivedError:(NSError *)error
     1820{
     1821    ASSERT(_loadManually);
     1822   
     1823    [error retain];
     1824    [_error release];
     1825    _error = error;
     1826   
     1827    if (![self isStarted]) {
     1828        return;
     1829    }
     1830   
     1831    [_manualStream destroyStreamWithError:error];
     1832}
     1833
     1834- (void)pluginViewFinishedLoading:(NSView *)pluginView
     1835{
     1836    ASSERT(_loadManually);
     1837    ASSERT(_manualStream);
     1838   
     1839    if ([self isStarted])
     1840        [_manualStream finishedLoadingWithData:[[self dataSource] data]];   
    17331841}
    17341842
     
    28212929}
    28222930
     2931- (void)_redeliverStream
     2932{
     2933    if ([self dataSource] && [self isStarted]) {
     2934        // Deliver what has not been passed to the plug-in up to this point.
     2935        if (_dataLengthReceived > 0) {
     2936            NSData *data = [[[self dataSource] data] subdataWithRange:NSMakeRange(0, _dataLengthReceived)];
     2937            _dataLengthReceived = 0;
     2938            [self pluginView:self receivedData:data];
     2939            if (![[self dataSource] isLoading]) {
     2940                if (_error)
     2941                    [self pluginView:self receivedError:_error];
     2942                else
     2943                    [self pluginViewFinishedLoading:self];
     2944            }
     2945        }
     2946    }
     2947}
     2948
    28232949@end
    28242950
  • trunk/WebKit/Plugins/WebNetscapePluginEmbeddedView.h

    r18430 r18910  
    3030
    3131#import <WebKit/WebBaseNetscapePluginView.h>
    32 #import <WebKit/WebBasePluginPackage.h>
    3332
    3433@class WebFrame;
    3534@class WebNetscapePluginStream;
    3635
    37 @interface WebNetscapePluginEmbeddedView : WebBaseNetscapePluginView <WebPluginManualLoader>
     36@interface WebNetscapePluginEmbeddedView : WebBaseNetscapePluginView
    3837{
    39     NSURL *URL;
    40     WebFrame *_webFrame;
    41    
    42     BOOL _loadManually;
    43     WebNetscapePluginStream *_manualStream;
    44     unsigned _dataLengthReceived;
    45     NSError *_error;
    4638}
    47 
    48 - (id)initWithFrame:(NSRect)r
    49       pluginPackage:(WebNetscapePluginPackage *)thePluginPackage
    50                 URL:(NSURL *)URL
    51             baseURL:(NSURL *)baseURL
    52            MIMEType:(NSString *)MIME
    53       attributeKeys:(NSArray *)keys
    54     attributeValues:(NSArray *)values
    55        loadManually:(BOOL)loadManually
    56          DOMElement:(DOMElement *)anElement;
    57 
    58 - (void)redeliverStream;
    59 
    6039@end
  • trunk/WebKit/Plugins/WebNetscapePluginEmbeddedView.mm

    r18725 r18910  
    4242#import "WebView.h"
    4343#import <JavaScriptCore/Assertions.h>
    44 #import <WebCore/Document.h>
    45 #import <WebCore/Element.h>
    4644#import <WebCore/FrameMac.h>
    4745#import <WebCore/FrameLoader.h>
     
    4947@implementation WebNetscapePluginEmbeddedView
    5048
    51 - (id)initWithFrame:(NSRect)frame
    52       pluginPackage:(WebNetscapePluginPackage *)thePluginPackage
    53                 URL:(NSURL *)theURL
    54             baseURL:(NSURL *)theBaseURL
    55            MIMEType:(NSString *)MIME
    56       attributeKeys:(NSArray *)keys
    57     attributeValues:(NSArray *)values
    58        loadManually:(BOOL)loadManually
    59          DOMElement:(DOMElement *)anElement
    60 {
    61     [super initWithFrame:frame];
    62 
    63     // load the plug-in if it is not already loaded
    64     if (![thePluginPackage load]) {
    65         [self release];
    66         return nil;
    67     }
    68     [self setPluginPackage:thePluginPackage];
    69 
    70     element = [anElement retain];
    71    
    72     URL = [theURL retain];
    73    
    74     [self setMIMEType:MIME];
    75     [self setBaseURL:theBaseURL];
    76     [self setAttributeKeys:keys andValues:values];
    77     if (loadManually)
    78         [self setMode:NP_FULL];
    79     else
    80         [self setMode:NP_EMBED];
    81 
    82     _loadManually = loadManually;
    83    
    84     return self;
    85 }
    86 
    87 - (void)dealloc
    88 {
    89     [URL release];
    90     [_manualStream release];
    91     [_error release];
    92     [super dealloc];
    93 }
    94 
    95 - (void)didStart
    96 {
    97     if (_loadManually) {
    98         [self redeliverStream];
    99         return;
    100     }
    101    
    102     // If the OBJECT/EMBED tag has no SRC, the URL is passed to us as "".
    103     // Check for this and don't start a load in this case.
    104     if (URL != nil && ![URL _web_isEmpty]) {
    105         NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
    106         [request _web_setHTTPReferrer:core([self webFrame])->loader()->outgoingReferrer()];
    107         [self loadRequest:request inTarget:nil withNotifyData:nil sendNotification:NO];
    108     }
    109 }
    110 
    111 - (WebDataSource *)dataSource
    112 {
    113     WebFrame *webFrame = kit(core(element)->document()->frame());
    114     return [webFrame dataSource];
    115 }
    116 
    117 -(void)pluginView:(NSView *)pluginView receivedResponse:(NSURLResponse *)response
    118 {
    119     ASSERT(_loadManually);
    120     ASSERT(!_manualStream);
    121    
    122     _manualStream = [[WebNetscapePluginStream alloc] init];
    123 }
    124 
    125 - (void)pluginView:(NSView *)pluginView receivedData:(NSData *)data
    126 {
    127     ASSERT(_loadManually);
    128     ASSERT(_manualStream);
    129    
    130     _dataLengthReceived += [data length];
    131    
    132     if (![self isStarted])
    133         return;
    134    
    135     if ([_manualStream plugin] == NULL) {
    136         [_manualStream setRequestURL:[[[self dataSource] request] URL]];
    137         [_manualStream setPlugin:[self plugin]];
    138         ASSERT([_manualStream plugin]);
    139         [_manualStream startStreamWithResponse:[[self dataSource] response]];
    140     }
    141    
    142     if ([_manualStream plugin])
    143         [_manualStream receivedData:data];
    144 }
    145 
    146 - (void)pluginView:(NSView *)pluginView receivedError:(NSError *)error
    147 {
    148     ASSERT(_loadManually);
    149    
    150     [error retain];
    151     [_error release];
    152     _error = error;
    153    
    154     if (![self isStarted]) {
    155         return;
    156     }
    157    
    158     [_manualStream destroyStreamWithError:error];
    159 }
    160 
    161 - (void)pluginViewFinishedLoading:(NSView *)pluginView
    162 {
    163     ASSERT(_loadManually);
    164     ASSERT(_manualStream);
    165    
    166     if ([self isStarted])
    167         [_manualStream finishedLoadingWithData:[[self dataSource] data]];   
    168 }
    169 
    170 - (void)redeliverStream
    171 {
    172     if ([self dataSource] && [self isStarted]) {
    173         // Deliver what has not been passed to the plug-in up to this point.
    174         if (_dataLengthReceived > 0) {
    175             NSData *data = [[[self dataSource] data] subdataWithRange:NSMakeRange(0, _dataLengthReceived)];
    176             _dataLengthReceived = 0;
    177             [self pluginView:self receivedData:data];
    178             if (![[self dataSource] isLoading]) {
    179                 if (_error)
    180                     [self pluginView:self receivedError:_error];
    181                 else
    182                     [self pluginViewFinishedLoading:self];
    183             }
    184         }
    185     }
    186 }
    187 
    18849@end
Note: See TracChangeset for help on using the changeset viewer.