+2006-10-08 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Darin.
+
+ - pass all WebResourceLoadDelegate methods across client, removing need to include related headers
+
+ * Loader/WebFrameLoader.m:
+ (-[WebFrameLoader _willSendRequest:forResource:redirectResponse:]):
+ (-[WebFrameLoader _didReceiveAuthenticationChallenge:forResource:]):
+ (-[WebFrameLoader _didCancelAuthenticationChallenge:forResource:]):
+ (-[WebFrameLoader _didReceiveResponse:forResource:]):
+ (-[WebFrameLoader _didReceiveData:contentLength:forResource:]):
+ (-[WebFrameLoader _didFinishLoadingForResource:]):
+ (-[WebFrameLoader _didFailLoadingWithError:forResource:]):
+ (-[WebFrameLoader sendRemainingDelegateMessagesWithIdentifier:response:length:error:]):
+ (-[WebFrameLoader requestFromDelegateForRequest:identifier:error:]):
+ * Loader/WebFrameLoaderClient.h:
+ * WebView/WebFrame.m:
+ (-[WebFrame _dispatchDidHandleOnloadEventsForFrame]):
+ (-[WebFrame _dispatchDidReceiveServerRedirectForProvisionalLoadForFrame]):
+ (-[WebFrame _dispatchIdentifierForInitialRequest:fromDocumentLoader:]):
+ (-[WebFrame _dispatchResource:willSendRequest:redirectResponse:fromDocumentLoader:]):
+ (-[WebFrame _dispatchDidReceiveAuthenticationChallenge:forResource:fromDocumentLoader:]):
+ (-[WebFrame _dispatchDidCancelAuthenticationChallenge:forResource:fromDocumentLoader:]):
+ (-[WebFrame _dispatchResource:didReceiveResponse:fromDocumentLoader:]):
+ (-[WebFrame _dispatchResource:didReceiveContentLength:fromDocumentLoader:]):
+ (-[WebFrame _dispatchResource:didFinishLoadingFromDocumentLoader:]):
+ (-[WebFrame _dispatchResource:didFailLoadingWithError:fromDocumentLoader:]):
+
2006-10-08 Maciej Stachowiak <mjs@apple.com>
Reviewed by Darin.
#import <WebKitSystemInterface.h>
#import "WebDataSourceInternal.h"
-#import "WebDefaultResourceLoadDelegate.h"
#import "WebDefaultUIDelegate.h"
#import "WebDocumentLoaderMac.h"
#import "WebDownloadInternal.h"
#import "WebKitNSStringExtras.h"
#import "WebNSURLExtras.h"
#import "WebNSURLRequestExtras.h"
-#import "WebResourceLoadDelegate.h"
#import "WebResourcePrivate.h"
#import "WebScriptDebugServerPrivate.h"
#import "WebUIDelegate.h"
- (NSURLRequest *)_willSendRequest:(NSMutableURLRequest *)clientRequest forResource:(id)identifier redirectResponse:(NSURLResponse *)redirectResponse
{
WebView *webView = [client webView];
-
[clientRequest setValue:[webView userAgentForURL:[clientRequest URL]] forHTTPHeaderField:@"User-Agent"];
-
- if ([webView _resourceLoadDelegateImplementations].delegateImplementsWillSendRequest)
- return [[webView resourceLoadDelegate] webView:webView resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:[self activeDataSource]];
- else
- return [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:[self activeDataSource]];
+ return [client _dispatchResource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDocumentLoader:[self activeDocumentLoader]];
}
- (void)_didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier
{
- WebView *webView = [client webView];
-
- if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveAuthenticationChallenge)
- [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveAuthenticationChallenge:currentWebChallenge fromDataSource:[self activeDataSource]];
- else
- [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveAuthenticationChallenge:currentWebChallenge fromDataSource:[self activeDataSource]];
+ [client _dispatchDidReceiveAuthenticationChallenge:currentWebChallenge forResource:identifier fromDocumentLoader:[self activeDocumentLoader]];
}
- (void)_didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier
{
- WebView *webView = [client webView];
-
- if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidCancelAuthenticationChallenge)
- [[webView resourceLoadDelegate] webView:webView resource:identifier didCancelAuthenticationChallenge:currentWebChallenge fromDataSource:[self activeDataSource]];
- else
- [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didCancelAuthenticationChallenge:currentWebChallenge fromDataSource:[self activeDataSource]];
-
+ [client _dispatchDidCancelAuthenticationChallenge:currentWebChallenge forResource:identifier fromDocumentLoader:[self activeDocumentLoader]];
}
- (void)_didReceiveResponse:(NSURLResponse *)r forResource:(id)identifier
{
- WebView *webView = [client webView];
-
[[self activeDocumentLoader] addResponse:r];
- [webView _incrementProgressForIdentifier:identifier response:r];
-
- if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveResponse)
- [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveResponse:r fromDataSource:[self activeDataSource]];
- else
- [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveResponse:r fromDataSource:[self activeDataSource]];
+ [[client webView] _incrementProgressForIdentifier:identifier response:r];
+ [client _dispatchResource:identifier didReceiveResponse:r fromDocumentLoader:[self activeDocumentLoader]];
}
- (void)_didReceiveData:(NSData *)data contentLength:(int)lengthReceived forResource:(id)identifier
{
WebView *webView = [client webView];
-
[webView _incrementProgressForIdentifier:identifier data:data];
-
- if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveContentLength)
- [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveContentLength:(WebNSUInteger)lengthReceived fromDataSource:[self activeDataSource]];
- else
- [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveContentLength:(WebNSUInteger)lengthReceived fromDataSource:[self activeDataSource]];
+
+ [client _dispatchResource:identifier didReceiveContentLength:lengthReceived fromDocumentLoader:[self activeDocumentLoader]];
}
- (void)_didFinishLoadingForResource:(id)identifier
{
WebView *webView = [client webView];
-
- [webView _completeProgressForIdentifier:identifier];
-
- if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidFinishLoadingFromDataSource)
- [[webView resourceLoadDelegate] webView:webView resource:identifier didFinishLoadingFromDataSource:[self activeDataSource]];
- else
- [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didFinishLoadingFromDataSource:[self activeDataSource]];
+ [webView _completeProgressForIdentifier:identifier];
+ [client _dispatchResource:identifier didFinishLoadingFromDocumentLoader:[self activeDocumentLoader]];
}
- (void)_didFailLoadingWithError:(NSError *)error forResource:(id)identifier
[webView _completeProgressForIdentifier:identifier];
if (error)
- [[webView _resourceLoadDelegateForwarder] webView:webView resource:identifier didFailLoadingWithError:error fromDataSource:[self activeDataSource]];
+ [client _dispatchResource:identifier didFailLoadingWithError:error fromDocumentLoader:[self activeDocumentLoader]];
}
- (BOOL)_privateBrowsingEnabled
- (void)sendRemainingDelegateMessagesWithIdentifier:(id)identifier response:(NSURLResponse *)response length:(unsigned)length error:(NSError *)error
{
- WebView *wv = [client webView];
- id delegate = [wv resourceLoadDelegate];
- id sharedDelegate = [WebDefaultResourceLoadDelegate sharedResourceLoadDelegate];
- WebResourceDelegateImplementationCache implementations = [wv _resourceLoadDelegateImplementations];
- WebDataSource *dataSource = [self dataSource];
-
- if (response != nil) {
- if (implementations.delegateImplementsDidReceiveResponse)
- [delegate webView:wv resource:identifier didReceiveResponse:response fromDataSource:dataSource];
- else
- [sharedDelegate webView:wv resource:identifier didReceiveResponse:response fromDataSource:dataSource];
- }
+ if (response != nil)
+ [client _dispatchResource:identifier didReceiveResponse:response fromDocumentLoader:documentLoader];
- if (length > 0) {
- if (implementations.delegateImplementsDidReceiveContentLength)
- [delegate webView:wv resource:identifier didReceiveContentLength:(WebNSUInteger)length fromDataSource:dataSource];
- else
- [sharedDelegate webView:wv resource:identifier didReceiveContentLength:(WebNSUInteger)length fromDataSource:dataSource];
- }
+ if (length > 0)
+ [client _dispatchResource:identifier didReceiveContentLength:(WebNSUInteger)length fromDocumentLoader:documentLoader];
- if (error == nil) {
- if (implementations.delegateImplementsDidFinishLoadingFromDataSource)
- [delegate webView:wv resource:identifier didFinishLoadingFromDataSource:dataSource];
- else
- [sharedDelegate webView:wv resource:identifier didFinishLoadingFromDataSource:dataSource];
- [self checkLoadComplete];
- } else {
- [[wv _resourceLoadDelegateForwarder] webView:wv resource:identifier didFailLoadingWithError:error fromDataSource:dataSource];
- }
+ if (error == nil)
+ [client _dispatchResource:identifier didFinishLoadingFromDocumentLoader:documentLoader];
+ else
+ [client _dispatchResource:identifier didFailLoadingWithError:error fromDocumentLoader:documentLoader];
}
- (NSURLRequest *)requestFromDelegateForRequest:(NSURLRequest *)request identifier:(id *)identifier error:(NSError **)error
{
ASSERT(request != nil);
- WebView *wv = [client webView];
- id delegate = [wv resourceLoadDelegate];
- id sharedDelegate = [WebDefaultResourceLoadDelegate sharedResourceLoadDelegate];
- WebResourceDelegateImplementationCache implementations = [wv _resourceLoadDelegateImplementations];
- WebDataSource *dataSource = [self dataSource];
-
- if (implementations.delegateImplementsIdentifierForRequest)
- *identifier = [delegate webView:wv identifierForInitialRequest:request fromDataSource:dataSource];
- else
- *identifier = [sharedDelegate webView:wv identifierForInitialRequest:request fromDataSource:dataSource];
-
- NSURLRequest *newRequest;
- if (implementations.delegateImplementsWillSendRequest)
- newRequest = [delegate webView:wv resource:*identifier willSendRequest:request redirectResponse:nil fromDataSource:dataSource];
- else
- newRequest = [sharedDelegate webView:wv resource:*identifier willSendRequest:request redirectResponse:nil fromDataSource:dataSource];
+ *identifier = [client _dispatchIdentifierForInitialRequest:request fromDocumentLoader:documentLoader];
+ NSURLRequest *newRequest = [client _dispatchResource:*identifier willSendRequest:request redirectResponse:nil fromDocumentLoader:documentLoader];
if (newRequest == nil)
*error = [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled URL:[request URL]];
- (void)_dispatchDidHandleOnloadEventsForFrame
{
- [[[self webView] _frameLoadDelegateForwarder] webView:[self webView] didHandleOnloadEventsForFrame:self];
+ WebView *webView = [self webView];
+ [[webView _frameLoadDelegateForwarder] webView:webView didHandleOnloadEventsForFrame:self];
}
- (void)_dispatchDidReceiveServerRedirectForProvisionalLoadForFrame
{
- [[[self webView] _frameLoadDelegateForwarder] webView:[self webView]
+ WebView *webView = [self webView];
+ [[webView _frameLoadDelegateForwarder] webView:webView
didReceiveServerRedirectForProvisionalLoadForFrame:self];
}
-- (id)_dispatchIdentifierForInitialRequest:(NSURLRequest *)request fromDocumentLoader:(WebDocumentLoader *)loader
+- (id)_dispatchIdentifierForInitialRequest:(NSURLRequest *)clientRequest fromDocumentLoader:(WebDocumentLoader *)loader
{
WebView *webView = [self webView];
id resourceLoadDelegate = [webView resourceLoadDelegate];
if ([webView _resourceLoadDelegateImplementations].delegateImplementsIdentifierForRequest)
- return [resourceLoadDelegate webView:webView identifierForInitialRequest:request fromDataSource:dataSource(loader)];
+ return [resourceLoadDelegate webView:webView identifierForInitialRequest:clientRequest fromDataSource:dataSource(loader)];
+
+ return [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView identifierForInitialRequest:clientRequest fromDataSource:dataSource(loader)];
+}
+
+- (NSURLRequest *)_dispatchResource:(id)identifier willSendRequest:(NSURLRequest *)clientRequest redirectResponse:(NSURLResponse *)redirectResponse fromDocumentLoader:(WebDocumentLoader *)loader
+{
+ WebView *webView = [self webView];
+ id resourceLoadDelegate = [webView resourceLoadDelegate];
+
+ if ([webView _resourceLoadDelegateImplementations].delegateImplementsWillSendRequest)
+ return [resourceLoadDelegate webView:webView resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:dataSource(loader)];
+ else
+ return [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:dataSource(loader)];
+}
+
+- (void)_dispatchDidReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier fromDocumentLoader:(WebDocumentLoader *)loader
+{
+ WebView *webView = [self webView];
+ id resourceLoadDelegate = [webView resourceLoadDelegate];
+
+ if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveAuthenticationChallenge)
+ [resourceLoadDelegate webView:webView resource:identifier didReceiveAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];
+ else
+ [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];
+}
+
+- (void)_dispatchDidCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier fromDocumentLoader:(WebDocumentLoader *)loader
+{
+ WebView *webView = [self webView];
+ id resourceLoadDelegate = [webView resourceLoadDelegate];
+
+ if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidCancelAuthenticationChallenge)
+ [resourceLoadDelegate webView:webView resource:identifier didCancelAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];
+ else
+ [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didCancelAuthenticationChallenge:currentWebChallenge fromDataSource:dataSource(loader)];
+}
+
+- (void)_dispatchResource:(id)identifier didReceiveResponse:(NSURLResponse *)r fromDocumentLoader:(WebDocumentLoader *)loader
+{
+ WebView *webView = [self webView];
+
+ if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveResponse)
+ [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveResponse:r fromDataSource:dataSource(loader)];
+ else
+ [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveResponse:r fromDataSource:dataSource(loader)];
+}
+
+- (void)_dispatchResource:(id)identifier didReceiveContentLength:(int)lengthReceived fromDocumentLoader:(WebDocumentLoader *)loader
+{
+ WebView *webView = [self webView];
- return [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView identifierForInitialRequest:request fromDataSource:dataSource(loader)];
+ if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidReceiveContentLength)
+ [[webView resourceLoadDelegate] webView:webView resource:identifier didReceiveContentLength:(WebNSUInteger)lengthReceived fromDataSource:dataSource(loader)];
+ else
+ [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didReceiveContentLength:(WebNSUInteger)lengthReceived fromDataSource:dataSource(loader)];
+}
+
+- (void)_dispatchResource:(id)identifier didFinishLoadingFromDocumentLoader:(WebDocumentLoader *)loader
+{
+ WebView *webView = [self webView];
+
+ if ([webView _resourceLoadDelegateImplementations].delegateImplementsDidFinishLoadingFromDataSource)
+ [[webView resourceLoadDelegate] webView:webView resource:identifier didFinishLoadingFromDataSource:dataSource(loader)];
+ else
+ [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView resource:identifier didFinishLoadingFromDataSource:dataSource(loader)];
+}
+
+
+- (void)_dispatchResource:(id)identifier didFailLoadingWithError:error fromDocumentLoader:(WebDocumentLoader *)loader
+{
+ WebView *webView = [self webView];
+ [[webView _resourceLoadDelegateForwarder] webView:webView resource:identifier didFailLoadingWithError:error fromDataSource:dataSource(loader)];
}
- (void)_detachedFromParent1