Roll src/third_party/skia 2440fcd:4de8c3a
[chromium-blink-merge.git] / content / shell / browser / shell_network_delegate.cc
blob2120904cae9bc6ff1f82cecdab931d54f9bca04a
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 "base/command_line.h"
8 #include "content/public/common/content_switches.h"
9 #include "net/base/net_errors.h"
10 #include "net/base/static_cookie_policy.h"
11 #include "net/url_request/url_request.h"
13 namespace content {
15 namespace {
16 bool g_accept_all_cookies = true;
19 ShellNetworkDelegate::ShellNetworkDelegate() {
22 ShellNetworkDelegate::~ShellNetworkDelegate() {
25 void ShellNetworkDelegate::SetAcceptAllCookies(bool accept) {
26 g_accept_all_cookies = accept;
29 int ShellNetworkDelegate::OnBeforeURLRequest(
30 net::URLRequest* request,
31 const net::CompletionCallback& callback,
32 GURL* new_url) {
33 return net::OK;
36 int ShellNetworkDelegate::OnBeforeSendHeaders(
37 net::URLRequest* request,
38 const net::CompletionCallback& callback,
39 net::HttpRequestHeaders* headers) {
40 return net::OK;
43 void ShellNetworkDelegate::OnSendHeaders(
44 net::URLRequest* request,
45 const net::HttpRequestHeaders& headers) {
48 int ShellNetworkDelegate::OnHeadersReceived(
49 net::URLRequest* request,
50 const net::CompletionCallback& callback,
51 const net::HttpResponseHeaders* original_response_headers,
52 scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
53 GURL* allowed_unsafe_redirect_url) {
54 return net::OK;
57 void ShellNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
58 const GURL& new_location) {
61 void ShellNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
64 void ShellNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) {
67 void ShellNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {
70 void ShellNetworkDelegate::OnPACScriptError(int line_number,
71 const base::string16& error) {
74 ShellNetworkDelegate::AuthRequiredResponse ShellNetworkDelegate::OnAuthRequired(
75 net::URLRequest* request,
76 const net::AuthChallengeInfo& auth_info,
77 const AuthCallback& callback,
78 net::AuthCredentials* credentials) {
79 return AUTH_REQUIRED_RESPONSE_NO_ACTION;
82 bool ShellNetworkDelegate::OnCanGetCookies(const net::URLRequest& request,
83 const net::CookieList& cookie_list) {
84 net::StaticCookiePolicy::Type policy_type = g_accept_all_cookies ?
85 net::StaticCookiePolicy::ALLOW_ALL_COOKIES :
86 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES;
87 net::StaticCookiePolicy policy(policy_type);
88 int rv = policy.CanGetCookies(
89 request.url(), request.first_party_for_cookies());
90 return rv == net::OK;
93 bool ShellNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
94 const std::string& cookie_line,
95 net::CookieOptions* options) {
96 net::StaticCookiePolicy::Type policy_type = g_accept_all_cookies ?
97 net::StaticCookiePolicy::ALLOW_ALL_COOKIES :
98 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES;
99 net::StaticCookiePolicy policy(policy_type);
100 int rv = policy.CanSetCookie(
101 request.url(), request.first_party_for_cookies());
102 return rv == net::OK;
105 bool ShellNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
106 const base::FilePath& path) const {
107 return true;
110 bool ShellNetworkDelegate::OnFirstPartyOnlyCookieExperimentEnabled() const {
111 return base::CommandLine::ForCurrentProcess()->HasSwitch(
112 switches::kEnableExperimentalWebPlatformFeatures);
115 } // namespace content