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 #include "android_webview/browser/net/aw_network_delegate.h" 6 7 #include "android_webview/browser/aw_cookie_access_policy.h" 8 #include "base/android/build_info.h" 9 #include "net/base/net_errors.h" 10 #include "net/base/completion_callback.h" 11 #include "net/url_request/url_request.h" 12 13 namespace android_webview { 14 15 AwNetworkDelegate::AwNetworkDelegate() { 16 } 17 18 AwNetworkDelegate::~AwNetworkDelegate() { 19 } 20 21 int AwNetworkDelegate::OnBeforeURLRequest( 22 net::URLRequest* request, 23 const net::CompletionCallback& callback, 24 GURL* new_url) { 25 return net::OK; 26 } 27 28 int AwNetworkDelegate::OnBeforeSendHeaders( 29 net::URLRequest* request, 30 const net::CompletionCallback& callback, 31 net::HttpRequestHeaders* headers) { 32 33 DCHECK(headers); 34 headers->SetHeaderIfMissing( 35 "X-Requested-With", 36 base::android::BuildInfo::GetInstance()->package_name()); 37 return net::OK; 38 } 39 40 void AwNetworkDelegate::OnSendHeaders(net::URLRequest* request, 41 const net::HttpRequestHeaders& headers) { 42 } 43 44 int AwNetworkDelegate::OnHeadersReceived( 45 net::URLRequest* request, 46 const net::CompletionCallback& callback, 47 const net::HttpResponseHeaders* original_response_headers, 48 scoped_refptr<net::HttpResponseHeaders>* override_response_headers) { 49 return net::OK; 50 } 51 52 void AwNetworkDelegate::OnBeforeRedirect(net::URLRequest* request, 53 const GURL& new_location) { 54 } 55 56 void AwNetworkDelegate::OnResponseStarted(net::URLRequest* request) { 57 } 58 59 void AwNetworkDelegate::OnRawBytesRead(const net::URLRequest& request, 60 int bytes_read) { 61 } 62 63 void AwNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) { 64 } 65 66 void AwNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) { 67 } 68 69 void AwNetworkDelegate::OnPACScriptError(int line_number, 70 const string16& error) { 71 } 72 73 net::NetworkDelegate::AuthRequiredResponse AwNetworkDelegate::OnAuthRequired( 74 net::URLRequest* request, 75 const net::AuthChallengeInfo& auth_info, 76 const AuthCallback& callback, 77 net::AuthCredentials* credentials) { 78 return AUTH_REQUIRED_RESPONSE_NO_ACTION; 79 } 80 81 bool AwNetworkDelegate::OnCanGetCookies(const net::URLRequest& request, 82 const net::CookieList& cookie_list) { 83 return AwCookieAccessPolicy::GetInstance()->OnCanGetCookies(request, 84 cookie_list); 85 } 86 87 bool AwNetworkDelegate::OnCanSetCookie(const net::URLRequest& request, 88 const std::string& cookie_line, 89 net::CookieOptions* options) { 90 return AwCookieAccessPolicy::GetInstance()->OnCanSetCookie(request, 91 cookie_line, 92 options); 93 } 94 95 bool AwNetworkDelegate::OnCanAccessFile(const net::URLRequest& request, 96 const base::FilePath& path) const { 97 return true; 98 } 99 100 bool AwNetworkDelegate::OnCanThrottleRequest( 101 const net::URLRequest& request) const { 102 return false; 103 } 104 105 int AwNetworkDelegate::OnBeforeSocketStreamConnect( 106 net::SocketStream* stream, 107 const net::CompletionCallback& callback) { 108 return net::OK; 109 } 110 111 void AwNetworkDelegate::OnRequestWaitStateChange(const net::URLRequest& request, 112 RequestWaitState state) { 113 } 114 115 } // namespace android_webview 116