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.
5 #include "android_webview/browser/net/aw_network_delegate.h"
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"
13 namespace android_webview
{
15 AwNetworkDelegate::AwNetworkDelegate() {
18 AwNetworkDelegate::~AwNetworkDelegate() {
21 int AwNetworkDelegate::OnBeforeURLRequest(
22 net::URLRequest
* request
,
23 const net::CompletionCallback
& callback
,
28 int AwNetworkDelegate::OnBeforeSendHeaders(
29 net::URLRequest
* request
,
30 const net::CompletionCallback
& callback
,
31 net::HttpRequestHeaders
* headers
) {
34 headers
->SetHeaderIfMissing(
36 base::android::BuildInfo::GetInstance()->package_name());
40 void AwNetworkDelegate::OnSendHeaders(net::URLRequest
* request
,
41 const net::HttpRequestHeaders
& headers
) {
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
) {
52 void AwNetworkDelegate::OnBeforeRedirect(net::URLRequest
* request
,
53 const GURL
& new_location
) {
56 void AwNetworkDelegate::OnResponseStarted(net::URLRequest
* request
) {
59 void AwNetworkDelegate::OnRawBytesRead(const net::URLRequest
& request
,
63 void AwNetworkDelegate::OnCompleted(net::URLRequest
* request
, bool started
) {
66 void AwNetworkDelegate::OnURLRequestDestroyed(net::URLRequest
* request
) {
69 void AwNetworkDelegate::OnPACScriptError(int line_number
,
70 const base::string16
& error
) {
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
;
81 bool AwNetworkDelegate::OnCanGetCookies(const net::URLRequest
& request
,
82 const net::CookieList
& cookie_list
) {
83 return AwCookieAccessPolicy::GetInstance()->OnCanGetCookies(request
,
87 bool AwNetworkDelegate::OnCanSetCookie(const net::URLRequest
& request
,
88 const std::string
& cookie_line
,
89 net::CookieOptions
* options
) {
90 return AwCookieAccessPolicy::GetInstance()->OnCanSetCookie(request
,
95 bool AwNetworkDelegate::OnCanAccessFile(const net::URLRequest
& request
,
96 const base::FilePath
& path
) const {
100 bool AwNetworkDelegate::OnCanThrottleRequest(
101 const net::URLRequest
& request
) const {
105 int AwNetworkDelegate::OnBeforeSocketStreamConnect(
106 net::SocketStream
* stream
,
107 const net::CompletionCallback
& callback
) {
111 } // namespace android_webview