Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / shell / browser / shell_network_delegate.cc
blob5ed9634491c8ff0546c7dda1fe979ff59a4ca088
1 // Copyright 2013 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 "content/shell/browser/shell_network_delegate.h"
7 #include "net/base/net_errors.h"
8 #include "net/base/static_cookie_policy.h"
9 #include "net/url_request/url_request.h"
11 namespace content {
13 namespace {
14 bool g_accept_all_cookies = true;
17 ShellNetworkDelegate::ShellNetworkDelegate() {
20 ShellNetworkDelegate::~ShellNetworkDelegate() {
23 void ShellNetworkDelegate::SetAcceptAllCookies(bool accept) {
24 g_accept_all_cookies = accept;
27 int ShellNetworkDelegate::OnBeforeURLRequest(
28 net::URLRequest* request,
29 const net::CompletionCallback& callback,
30 GURL* new_url) {
31 return net::OK;
34 int ShellNetworkDelegate::OnBeforeSendHeaders(
35 net::URLRequest* request,
36 const net::CompletionCallback& callback,
37 net::HttpRequestHeaders* headers) {
38 return net::OK;
41 void ShellNetworkDelegate::OnSendHeaders(
42 net::URLRequest* request,
43 const net::HttpRequestHeaders& headers) {
46 int ShellNetworkDelegate::OnHeadersReceived(
47 net::URLRequest* request,
48 const net::CompletionCallback& callback,
49 const net::HttpResponseHeaders* original_response_headers,
50 scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
51 GURL* allowed_unsafe_redirect_url) {
52 return net::OK;
55 void ShellNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
56 const GURL& new_location) {
59 void ShellNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
62 void ShellNetworkDelegate::OnRawBytesRead(const net::URLRequest& request,
63 int bytes_read) {
66 void ShellNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) {
69 void ShellNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {
72 void ShellNetworkDelegate::OnPACScriptError(int line_number,
73 const base::string16& error) {
76 ShellNetworkDelegate::AuthRequiredResponse ShellNetworkDelegate::OnAuthRequired(
77 net::URLRequest* request,
78 const net::AuthChallengeInfo& auth_info,
79 const AuthCallback& callback,
80 net::AuthCredentials* credentials) {
81 return AUTH_REQUIRED_RESPONSE_NO_ACTION;
84 bool ShellNetworkDelegate::OnCanGetCookies(const net::URLRequest& request,
85 const net::CookieList& cookie_list) {
86 net::StaticCookiePolicy::Type policy_type = g_accept_all_cookies ?
87 net::StaticCookiePolicy::ALLOW_ALL_COOKIES :
88 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES;
89 net::StaticCookiePolicy policy(policy_type);
90 int rv = policy.CanGetCookies(
91 request.url(), request.first_party_for_cookies());
92 return rv == net::OK;
95 bool ShellNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
96 const std::string& cookie_line,
97 net::CookieOptions* options) {
98 net::StaticCookiePolicy::Type policy_type = g_accept_all_cookies ?
99 net::StaticCookiePolicy::ALLOW_ALL_COOKIES :
100 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES;
101 net::StaticCookiePolicy policy(policy_type);
102 int rv = policy.CanSetCookie(
103 request.url(), request.first_party_for_cookies());
104 return rv == net::OK;
107 bool ShellNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
108 const base::FilePath& path) const {
109 return true;
112 bool ShellNetworkDelegate::OnCanThrottleRequest(
113 const net::URLRequest& request) const {
114 return false;
117 int ShellNetworkDelegate::OnBeforeSocketStreamConnect(
118 net::SocketStream* socket,
119 const net::CompletionCallback& callback) {
120 return net::OK;
123 } // namespace content