1 // Copyright (c) 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. 4 5 #ifndef ANDROID_WEBVIEW_BROWSER_NET_AW_NETWORK_DELEGATE_H_ 6 #define ANDROID_WEBVIEW_BROWSER_NET_AW_NETWORK_DELEGATE_H_ 7 8 #include "base/basictypes.h" 9 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" 10 #include "net/base/network_delegate.h" 11 12 namespace android_webview { 13 14 // WebView's implementation of the NetworkDelegate. 15 class AwNetworkDelegate : public net::NetworkDelegate { 16 public: 17 AwNetworkDelegate(); 18 virtual ~AwNetworkDelegate(); 19 20 // Sets the |DataReductionProxySettings| object to use. If not set, the 21 // NetworkDelegate will not perform any operations related to the data 22 // reduction proxy. 23 void set_data_reduction_proxy_params( 24 data_reduction_proxy::DataReductionProxyParams* params) { 25 data_reduction_proxy_params_ = params; 26 } 27 28 private: 29 // NetworkDelegate implementation. 30 virtual int OnBeforeURLRequest(net::URLRequest* request, 31 const net::CompletionCallback& callback, 32 GURL* new_url) OVERRIDE; 33 virtual int OnBeforeSendHeaders(net::URLRequest* request, 34 const net::CompletionCallback& callback, 35 net::HttpRequestHeaders* headers) OVERRIDE; 36 virtual void OnSendHeaders(net::URLRequest* request, 37 const net::HttpRequestHeaders& headers) OVERRIDE; 38 virtual int OnHeadersReceived( 39 net::URLRequest* request, 40 const net::CompletionCallback& callback, 41 const net::HttpResponseHeaders* original_response_headers, 42 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, 43 GURL* allowed_unsafe_redirect_url) OVERRIDE; 44 virtual void OnBeforeRedirect(net::URLRequest* request, 45 const GURL& new_location) OVERRIDE; 46 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; 47 virtual void OnRawBytesRead(const net::URLRequest& request, 48 int bytes_read) OVERRIDE; 49 virtual void OnCompleted(net::URLRequest* request, bool started) OVERRIDE; 50 virtual void OnURLRequestDestroyed(net::URLRequest* request) OVERRIDE; 51 virtual void OnPACScriptError(int line_number, 52 const base::string16& error) OVERRIDE; 53 virtual net::NetworkDelegate::AuthRequiredResponse OnAuthRequired( 54 net::URLRequest* request, 55 const net::AuthChallengeInfo& auth_info, 56 const AuthCallback& callback, 57 net::AuthCredentials* credentials) OVERRIDE; 58 virtual bool OnCanGetCookies(const net::URLRequest& request, 59 const net::CookieList& cookie_list) OVERRIDE; 60 virtual bool OnCanSetCookie(const net::URLRequest& request, 61 const std::string& cookie_line, 62 net::CookieOptions* options) OVERRIDE; 63 virtual bool OnCanAccessFile(const net::URLRequest& request, 64 const base::FilePath& path) const OVERRIDE; 65 virtual bool OnCanThrottleRequest( 66 const net::URLRequest& request) const OVERRIDE; 67 virtual int OnBeforeSocketStreamConnect( 68 net::SocketStream* stream, 69 const net::CompletionCallback& callback) OVERRIDE; 70 71 // Data reduction proxy parameters object. Must outlive this. 72 data_reduction_proxy::DataReductionProxyParams* data_reduction_proxy_params_; 73 74 DISALLOW_COPY_AND_ASSIGN(AwNetworkDelegate); 75 }; 76 77 } // namespace android_webview 78 79 #endif // ANDROID_WEBVIEW_BROWSER_NET_AW_NETWORK_DELEGATE_H_ 80