1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef IOS_NET_CRN_HTTP_PROTOCOL_HANDLER_H_
6 #define IOS_NET_CRN_HTTP_PROTOCOL_HANDLER_H_
8 #import <Foundation/Foundation.h>
11 class URLRequestContextGetter
;
13 class HTTPProtocolHandlerDelegate
{
15 // Sets the global instance of the HTTPProtocolHandlerDelegate.
16 static void SetInstance(HTTPProtocolHandlerDelegate
* delegate
);
18 virtual ~HTTPProtocolHandlerDelegate() {}
20 // Returns true if CRNHTTPProtocolHandler should handle the request.
21 // Returns false if the request should be passed down the NSURLProtocol chain.
22 virtual bool CanHandleRequest(NSURLRequest
* request
) = 0;
24 // If IsRequestSupported returns true, |request| will be processed, otherwise
25 // a NSURLErrorUnsupportedURL error is generated.
26 virtual bool IsRequestSupported(NSURLRequest
* request
) = 0;
28 // Returns the request context used for requests that are not associated with
29 // a RequestTracker. This includes in particular the requests that are not
30 // aware of the network stack. Must not return null.
31 virtual URLRequestContextGetter
* GetDefaultURLRequestContext() = 0;
36 // Custom NSURLProtocol handling HTTP and HTTPS requests.
37 // The HttpProtocolHandler is registered as a NSURLProtocol in the iOS system.
38 // This protocol is called for each NSURLRequest. This allows handling the
39 // requests issued by UIWebView using our own network stack.
40 @interface CRNHTTPProtocolHandler
: NSURLProtocol
43 // Custom NSURLProtocol handling HTTP and HTTPS requests.
44 // The HttpProtocolHandler is registered as a NSURLProtocol in the iOS system.
45 // This protocol is called for each NSURLRequest. This allows handling the
46 // requests issued by UIWebView using our own network stack. This protocol
47 // handler implements iOS 8 NSURLProtocol pause/resume semantics, in which
48 // |startLoading| means "start or resume" and |stopLoading| means "pause".
49 @interface CRNPauseableHTTPProtocolHandler
: CRNHTTPProtocolHandler
52 #endif // IOS_NET_CRN_HTTP_PROTOCOL_HANDLER_H_