(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 |
WebView 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 WebFrameLoadDelegateprotocol.
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:resource:willSendRequest:redirectResponse:fromDataSource:
– webView:resource:didFinishLoadingFromDataSource:
– webView:resource:didReceiveResponse:fromDataSource:
– webView:resource:didReceiveContentLength:fromDataSource:
– webView:resource:didFailLoadingWithError:fromDataSource:
– webView:plugInFailedWithError:dataSource:
– webView:resource:didReceiveAuthenticationChallenge:fromDataSource:
– webView:resource:didCancelAuthenticationChallenge:fromDataSource:
Returns an identifier object used to track the progress of loading a single resource.
- (id)webView:(WebView *)sender identifierForInitialRequest:(NSURLRequest *)request fromDataSource:(WebDataSource *)dataSource
The identifier returned by this delegate method will be retained by sender and passed as an argument to all other delegate messages pertaining to this resource. The request argument is the request that initiated this load for dataSource. 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 webView:resource:willSendRequest:redirectResponse:fromDataSource: may be invoked multiple times.
WebResourceLoadDelegate.hInvoked when a plug-in fails to load.
- (void)webView:(WebView *)sender plugInFailedWithError:(NSError *)error dataSource:(WebDataSource *)dataSource
For example, this method is invoked if a plug-in is not found, fails to load, or is not available for some reason. The error argument is the error that occurred during the process of loading that resource. Delegates might implement this method to display or log a detailed error message. If you do not implement this method, no action is taken.
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 will be a URL string of the SRC attribute. The value of the WebKitErrorPlugInNameKey key is will be a string containing the plug-in's name. The value for the WebKitErrorPlugInPageURLStringKey key will be a URL string of the PLUGINSPAGE attribute. The value of the WebKitErrorMIMETypeKey key will be a string of the TYPE attribute.
WebResourceLoadDelegate.hInvoked when an authentication challenge for a resource was cancelled.
- (void)webView:(WebView *)sender resource:(id)identifier didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource
The identifier argument is used to track the resource being loaded by dataSource, and challenge is the authentication challenge that was cancelled.
WebResourceLoadDelegate.hInvoked when a resource failed to load.
- (void)webView:(WebView *)sender resource:(id)identifier didFailLoadingWithError:(NSError *)error fromDataSource:(WebDataSource *)dataSource
The identifier argument is used to track the resource being loaded by dataSource, and error is the error that occurred loading that resource. 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.
- (void)webView:(WebView *)sender resource:(id)identifier didFinishLoadingFromDataSource:(WebDataSource *)dataSource
The identifier argument 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.
- (void)webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource
The identifier argument is used to track the resource being loaded by dataSource, and challenge is the authentication challenge that was received.
WebResourceLoadDelegate.hInvoked when some of the data for a given resource has arrived.
- (void)webView:(WebView *)sender resource:(id)identifier didReceiveContentLength:(WebNSInteger)length fromDataSource:(WebDataSource *)dataSource
The identifier argument is used to track the resource being loaded by dataSource, and length is 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. Delegates might implement this method to update the load status of an individual resource.
WebResourceLoadDelegate.hInvoked after a resource has been loaded.
- (void)webView:(WebView *)sender resource:(id)identifier didReceiveResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)dataSource
The identifier argument is used to track the resource being loaded by dataSource, and response is the reply that was received.
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.
- (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource
The identifier argument is used to track the resource being loaded by dataSource. The request argument is the request that will be sent, and redirectResponse is the redirect server response. The redirectResponse argument is nil if there is no redirect in progress. 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 webView:identifierForInitialRequest:fromDataSource: will be invoked once.
WebResourceLoadDelegate.h
Last updated: 2006-05-23