(informal protocol)
| Framework | /System/Library/Frameworks/WebKit.framework |
| Availability | Available in Mac OS X v10.2 with Safari 1.0 and later. Available in Mac OS X v10.2.7 and later. |
| Companion guide | |
| Declared in | WebResourceLoadDelegate.h |
Web view resource load delegates implement this informal protocol to be notified on the progress of loading individual resources. Note that there can be hundreds of resources, such as images and other media, per page. So, if you just want to get page loading status see the WebFrameLoadDelegate protocol.
There’s a separate client request and server response made for each resource on a page. By implementing the webView:identifierForInitialRequest:fromDataSource: method, resource load delegates provide a tracking object used to identify individual resources in subsequent calls to delegate methods. Delegates are then notified when resource loading starts, when data is incrementally received, when any load errors occur, and when the load is complete. Delegates may also change a request before it is sent. In some cases, depending on the page content and server redirects, methods defined in this protocol may be invoked multiple times (see individual method descriptions for more details). All the methods in this protocol are optional.
– webView:identifierForInitialRequest:fromDataSource: required method
– webView:resource:willSendRequest:redirectResponse:fromDataSource: required method
– webView:resource:didFinishLoadingFromDataSource: required method
– webView:resource:didReceiveResponse:fromDataSource: required method
– webView:resource:didReceiveContentLength:fromDataSource: required method
– webView:resource:didFailLoadingWithError:fromDataSource: required method
– webView:plugInFailedWithError:dataSource: required method
Returns an identifier object used to track the progress of loading a single resource. (required)
- (id)webView:(WebView *)sender identifierForInitialRequest:(NSURLRequest *)request fromDataSource:(WebDataSource *)dataSource
The web view that sent this message.
The request that initiated this load for dataSource.
The data source for this web view.
An identifier object that is retained by sender and passed as an parameter to all other delegate messages pertaining to this resource.
Delegates might implement this method to begin tracking the progress of loading an individual resource. Note that this method is invoked once per load where as the webView:resource:willSendRequest:redirectResponse:fromDataSource: method may be invoked multiple times.
WebResourceLoadDelegate.hInvoked when a plug-in fails to load. (required)
- (void)webView:(WebView *)sender plugInFailedWithError:(NSError *)error dataSource:(WebDataSource *)dataSource
The web view that sent this message.
The error that occurred during the process of loading that resource.
The userInfo dictionary of error may contain additional information about the failure. If the userInfo dictionary is not nil, it may contain some or all of these key-value pairs. The value of the NSErrorFailingURLKey key is a URL string of the SRC attribute. The value of the WebKitErrorPlugInNameKey key is a string containing the plug-in's name. The value for the WebKitErrorPlugInPageURLStringKey key is a URL string of the PLUGINSPAGE attribute. The value of the WebKitErrorMIMETypeKey key is a string of the TYPE attribute.
The data source for this web view.
This method might be invoked if a plug-in is not found, fails to load, or is not available for some reason. Delegates might implement this method to display or log a detailed error message. If you do not implement this method, no action is taken.
WebResourceLoadDelegate.hInvoked when an authentication challenge for a resource was canceled. (required)
- (void)webView:(WebView *)sender resource:(id)identifier didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource
The web view that sent this message.
An identifier object used to track the resource being loaded by dataSource.
The authentication challenge that was canceled.
The data source for this web view.
WebResourceLoadDelegate.hInvoked when a resource failed to load. (required)
- (void)webView:(WebView *)sender resource:(id)identifier didFailLoadingWithError:(NSError *)error fromDataSource:(WebDataSource *)dataSource
The web view that sent this message.
An identifier object used to track the resource being loaded by dataSource.
The error that occurred loading that resource.
The data source for this web view.
Delegates might implement this method to display or log a detailed error message.
WebResourceLoadDelegate.hInvoked when all of the data for a given resource is loaded. (required)
- (void)webView:(WebView *)sender resource:(id)identifier didFinishLoadingFromDataSource:(WebDataSource *)dataSource
The web view that sent this message.
An identifier object used to track the resource being loaded by dataSource.
The data source for this web view.
The identifier parameter is used to track the resource being loaded by dataSource. Delegates might implement this method to update the load status of an individual resource.
WebResourceLoadDelegate.hInvoked when an authentication challenge has been received for a resource. (required)
- (void)webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource
The web view that sent this message.
An identifier object used to track the resource being loaded by dataSource.
The authentication challenge that was received.
The data source for this web view.
WebResourceLoadDelegate.hInvoked when some of the data for a given resource has arrived. (required)
- (void)webView:(WebView *)sender resource:(id)identifier didReceiveContentLength:(NSUInteger)length fromDataSource:(WebDataSource *)dataSource
The web view that sent this message.
An identifier object used to track the resource being loaded by dataSource.
The amount of incremental data received for this resource—the amount of data loaded since the last time this method was invoked for this resource, not the total amount received for this resource.
The length parameter type was changed from type unsigned int to type NSUInteger in Mac OS X v10.5.
The data source for this web view.
Delegates might implement this method to update the load status of an individual resource.
WebResourceLoadDelegate.hInvoked after a resource has been loaded. (required)
- (void)webView:(WebView *)sender resource:(id)identifier didReceiveResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)dataSource
The web view that sent this message.
An identifier object used to track the resource being loaded by dataSource.
The reply that was received.
The data source for this web view.
In some rare cases, multiple responses may be received for a single resource. This happens in the case of multipart/x-mixed-replace, also known as a server push. In this case, delegates should assume that the progress of loading this resource restarts, and the expected content length may change.
WebResourceLoadDelegate.hInvoked before a request is initiated for a resource and returns a possibly modified request. (required)
- (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource
The web view that sent this message.
An identifier object used to track the resource being loaded by dataSource.
The request that is sent.
The redirect server response. If nil, there is no redirect in progress.
The data source for this web view.
A possibly modified request.
Delegates might implement this method to modify resource requests before they are sent. Note that this method might be invoked multiple times per load (as a result of a server redirect) where as the webView:identifierForInitialRequest:fromDataSource: method is invoked once.
WebResourceLoadDelegate.hLast updated: 2009-08-17