Upstream version 10.38.208.0
[platform/framework/web/crosswalk.git] / src / net / base / network_delegate.h
index 882701c..a290d16 100644 (file)
@@ -35,6 +35,9 @@ namespace net {
 class CookieOptions;
 class HttpRequestHeaders;
 class HttpResponseHeaders;
+class ProxyInfo;
+class ProxyServer;
+class ProxyService;
 class SocketStream;
 class URLRequest;
 
@@ -60,16 +63,26 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe {
   int NotifyBeforeURLRequest(URLRequest* request,
                              const CompletionCallback& callback,
                              GURL* new_url);
+  void NotifyResolveProxy(const GURL& url,
+                          int load_flags,
+                          const ProxyService& proxy_service,
+                          ProxyInfo* result);
+  void NotifyProxyFallback(const ProxyServer& bad_proxy,
+                           int net_error);
   int NotifyBeforeSendHeaders(URLRequest* request,
                               const CompletionCallback& callback,
                               HttpRequestHeaders* headers);
+  void NotifyBeforeSendProxyHeaders(URLRequest* request,
+                                    const ProxyInfo& proxy_info,
+                                    HttpRequestHeaders* headers);
   void NotifySendHeaders(URLRequest* request,
                          const HttpRequestHeaders& headers);
   int NotifyHeadersReceived(
       URLRequest* request,
       const CompletionCallback& callback,
       const HttpResponseHeaders* original_response_headers,
-      scoped_refptr<HttpResponseHeaders>* override_response_headers);
+      scoped_refptr<HttpResponseHeaders>* override_response_headers,
+      GURL* allowed_unsafe_redirect_url);
   void NotifyBeforeRedirect(URLRequest* request,
                             const GURL& new_location);
   void NotifyResponseStarted(URLRequest* request);
@@ -101,18 +114,36 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe {
   // member function, which will perform basic sanity checking.
 
   // Called before a request is sent. Allows the delegate to rewrite the URL
-  // being fetched by modifying |new_url|. |callback| and |new_url| are valid
-  // only until OnURLRequestDestroyed is called for this request. Returns a net
-  // status code, generally either OK to continue with the request or
-  // ERR_IO_PENDING if the result is not ready yet. A status code other than OK
-  // and ERR_IO_PENDING will cancel the request and report the status code as
-  // the reason.
+  // being fetched by modifying |new_url|. If set, the URL must be valid. The
+  // reference fragment from the original URL is not automatically appended to
+  // |new_url|; callers are responsible for copying the reference fragment if
+  // desired.
+  // |callback| and |new_url| are valid only until OnURLRequestDestroyed is
+  // called for this request. Returns a net status code, generally either OK to
+  // continue with the request or ERR_IO_PENDING if the result is not ready yet.
+  // A status code other than OK and ERR_IO_PENDING will cancel the request and
+  // report the status code as the reason.
   //
   // The default implementation returns OK (continue with request).
   virtual int OnBeforeURLRequest(URLRequest* request,
                                  const CompletionCallback& callback,
                                  GURL* new_url);
 
+  // Called as the proxy is being resolved for |url|. Allows the delegate to
+  // override the proxy resolution decision made by ProxyService. The delegate
+  // may override the decision by modifying the ProxyInfo |result|.
+  virtual void OnResolveProxy(const GURL& url,
+                              int load_flags,
+                              const ProxyService& proxy_service,
+                              ProxyInfo* result);
+
+  // Called when use of |bad_proxy| fails due to |net_error|. |net_error| is
+  // the network error encountered, if any, and OK if the fallback was
+  // for a reason other than a network error (e.g. the proxy service was
+  // explicitly directed to skip a proxy).
+  virtual void OnProxyFallback(const ProxyServer& bad_proxy,
+                               int net_error);
+
   // Called right before the HTTP headers are sent. Allows the delegate to
   // read/write |headers| before they get sent out. |callback| and |headers| are
   // valid only until OnCompleted or OnURLRequestDestroyed is called for this
@@ -122,6 +153,13 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe {
                                   const CompletionCallback& callback,
                                   HttpRequestHeaders* headers);
 
+  // Called after a proxy connection. Allows the delegate to read/write
+  // |headers| before they get sent out. |headers| is valid only until
+  // OnCompleted or OnURLRequestDestroyed is called for this request.
+  virtual void OnBeforeSendProxyHeaders(URLRequest* request,
+                                        const ProxyInfo& proxy_info,
+                                        HttpRequestHeaders* headers);
+
   // Called right before the HTTP request(s) are being sent to the network.
   // |headers| is only valid until OnCompleted or OnURLRequestDestroyed is
   // called for this request.
@@ -133,6 +171,11 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe {
   // network, these must not be modified. |override_response_headers| can be set
   // to new values, that should be considered as overriding
   // |original_response_headers|.
+  // If the response is a redirect, and the Location response header value is
+  // identical to |allowed_unsafe_redirect_url|, then the redirect is never
+  // blocked and the reference fragment is not copied from the original URL
+  // to the redirection target.
+  //
   // |callback|, |original_response_headers|, and |override_response_headers|
   // are only valid until OnURLRequestDestroyed is called for this request.
   // See OnBeforeURLRequest for return value description. Returns OK by default.
@@ -140,7 +183,8 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe {
       URLRequest* request,
       const CompletionCallback& callback,
       const HttpResponseHeaders* original_response_headers,
-      scoped_refptr<HttpResponseHeaders>* override_response_headers);
+      scoped_refptr<HttpResponseHeaders>* override_response_headers,
+      GURL* allowed_unsafe_redirect_url);
 
   // Called right after a redirect response code was received.
   // |new_location| is only valid until OnURLRequestDestroyed is called for this