2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #import <WebKit/WebNetscapePlugInStreamLoader.h>
31 #import <WebKit/WebFrameLoader.h>
33 #import <WebKit/WebNetscapePluginStream.h>
35 @implementation WebNetscapePlugInStreamLoader
37 - (id)initWithStream:(WebNetscapePluginStream *)theStream frameLoader:(WebFrameLoader *)fl
40 stream = [theStream retain];
41 [self setFrameLoader:fl];
50 - (void)releaseResources
54 [super releaseResources];
57 - (void)didReceiveResponse:(NSURLResponse *)theResponse
59 // retain/release self in this delegate method since the additional processing can do
60 // anything including possibly releasing self; one example of this is 3266216
62 [stream startStreamWithResponse:theResponse];
64 // Don't continue if the stream is cancelled in startStreamWithResponse or didReceiveResponse.
66 [super didReceiveResponse:theResponse];
68 if ([theResponse isKindOfClass:[NSHTTPURLResponse class]] &&
69 ([(NSHTTPURLResponse *)theResponse statusCode] >= 400 || [(NSHTTPURLResponse *)theResponse statusCode] < 100)) {
70 NSError *error = [frameLoader fileDoesNotExistErrorWithResponse:theResponse];
71 [stream cancelLoadAndDestroyStreamWithError:error];
78 - (void)didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived allAtOnce:(BOOL)allAtOnce
80 // retain/release self in this delegate method since the additional processing can do
81 // anything including possibly releasing self; one example of this is 3266216
83 [stream receivedData:data];
84 [super didReceiveData:data lengthReceived:lengthReceived allAtOnce:(BOOL)allAtOnce];
88 - (void)didFinishLoading
90 // Calling _removePlugInStreamLoader will likely result in a call to release, so we must retain.
93 [frameLoader _removePlugInStreamLoader:self];
94 [frameLoader _finishedLoadingResource];
95 [stream finishedLoadingWithData:[self resourceData]];
96 [super didFinishLoading];
101 - (void)didFailWithError:(NSError *)error
103 // Calling _removePlugInStreamLoader will likely result in a call to release, so we must retain.
104 // The other additional processing can do anything including possibly releasing self;
105 // one example of this is 3266216
108 [[self frameLoader] _removePlugInStreamLoader:self];
109 [[self frameLoader] _receivedError:error];
110 [stream destroyStreamWithError:error];
111 [super didFailWithError:error];
116 - (void)cancelWithError:(NSError *)error
118 // Calling _removePlugInStreamLoader will likely result in a call to release, so we must retain.
121 [[self frameLoader] _removePlugInStreamLoader:self];
122 [stream destroyStreamWithError:error];
123 [super cancelWithError:error];