Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / net / base / network_delegate.cc
blob40eb66545ed2d42b0c572c44f6dc095928f28d8a
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 "net/base/network_delegate.h"
7 #include "base/logging.h"
8 #include "base/profiler/scoped_tracker.h"
9 #include "net/base/load_flags.h"
10 #include "net/base/net_errors.h"
11 #include "net/proxy/proxy_info.h"
12 #include "net/url_request/url_request.h"
14 namespace net {
16 int NetworkDelegate::NotifyBeforeURLRequest(
17 URLRequest* request, const CompletionCallback& callback,
18 GURL* new_url) {
19 DCHECK(CalledOnValidThread());
20 DCHECK(request);
21 DCHECK(!callback.is_null());
22 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed.
23 tracked_objects::ScopedTracker tracking_profile(
24 FROM_HERE_WITH_EXPLICIT_FUNCTION(
25 "475753 NetworkDelegate::OnBeforeURLRequest"));
26 return OnBeforeURLRequest(request, callback, new_url);
29 void NetworkDelegate::NotifyResolveProxy(
30 const GURL& url,
31 int load_flags,
32 const ProxyService& proxy_service,
33 ProxyInfo* result) {
34 DCHECK(CalledOnValidThread());
35 DCHECK(result);
36 OnResolveProxy(url, load_flags, proxy_service, result);
39 void NetworkDelegate::NotifyProxyFallback(
40 const ProxyServer& bad_proxy,
41 int net_error) {
42 DCHECK(CalledOnValidThread());
43 OnProxyFallback(bad_proxy, net_error);
46 int NetworkDelegate::NotifyBeforeSendHeaders(
47 URLRequest* request, const CompletionCallback& callback,
48 HttpRequestHeaders* headers) {
49 DCHECK(CalledOnValidThread());
50 DCHECK(headers);
51 DCHECK(!callback.is_null());
52 return OnBeforeSendHeaders(request, callback, headers);
55 void NetworkDelegate::NotifyBeforeSendProxyHeaders(
56 URLRequest* request,
57 const ProxyInfo& proxy_info,
58 HttpRequestHeaders* headers) {
59 DCHECK(CalledOnValidThread());
60 DCHECK(headers);
61 OnBeforeSendProxyHeaders(request, proxy_info, headers);
64 void NetworkDelegate::NotifySendHeaders(URLRequest* request,
65 const HttpRequestHeaders& headers) {
66 DCHECK(CalledOnValidThread());
67 OnSendHeaders(request, headers);
70 int NetworkDelegate::NotifyHeadersReceived(
71 URLRequest* request,
72 const CompletionCallback& callback,
73 const HttpResponseHeaders* original_response_headers,
74 scoped_refptr<HttpResponseHeaders>* override_response_headers,
75 GURL* allowed_unsafe_redirect_url) {
76 DCHECK(CalledOnValidThread());
77 DCHECK(original_response_headers);
78 DCHECK(!callback.is_null());
79 return OnHeadersReceived(request,
80 callback,
81 original_response_headers,
82 override_response_headers,
83 allowed_unsafe_redirect_url);
86 void NetworkDelegate::NotifyResponseStarted(URLRequest* request) {
87 DCHECK(CalledOnValidThread());
88 DCHECK(request);
89 OnResponseStarted(request);
92 void NetworkDelegate::NotifyRawBytesRead(const URLRequest& request,
93 int bytes_read) {
94 DCHECK(CalledOnValidThread());
95 OnRawBytesRead(request, bytes_read);
98 void NetworkDelegate::NotifyBeforeRedirect(URLRequest* request,
99 const GURL& new_location) {
100 DCHECK(CalledOnValidThread());
101 DCHECK(request);
102 OnBeforeRedirect(request, new_location);
105 void NetworkDelegate::NotifyCompleted(URLRequest* request, bool started) {
106 DCHECK(CalledOnValidThread());
107 DCHECK(request);
108 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed.
109 tracked_objects::ScopedTracker tracking_profile(
110 FROM_HERE_WITH_EXPLICIT_FUNCTION("475753 NetworkDelegate::OnCompleted"));
111 OnCompleted(request, started);
114 void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) {
115 DCHECK(CalledOnValidThread());
116 DCHECK(request);
117 OnURLRequestDestroyed(request);
120 void NetworkDelegate::NotifyPACScriptError(int line_number,
121 const base::string16& error) {
122 DCHECK(CalledOnValidThread());
123 OnPACScriptError(line_number, error);
126 NetworkDelegate::AuthRequiredResponse NetworkDelegate::NotifyAuthRequired(
127 URLRequest* request,
128 const AuthChallengeInfo& auth_info,
129 const AuthCallback& callback,
130 AuthCredentials* credentials) {
131 DCHECK(CalledOnValidThread());
132 return OnAuthRequired(request, auth_info, callback, credentials);
135 bool NetworkDelegate::CanGetCookies(const URLRequest& request,
136 const CookieList& cookie_list) {
137 DCHECK(CalledOnValidThread());
138 DCHECK(!(request.load_flags() & LOAD_DO_NOT_SEND_COOKIES));
139 return OnCanGetCookies(request, cookie_list);
142 bool NetworkDelegate::CanSetCookie(const URLRequest& request,
143 const std::string& cookie_line,
144 CookieOptions* options) {
145 DCHECK(CalledOnValidThread());
146 DCHECK(!(request.load_flags() & LOAD_DO_NOT_SAVE_COOKIES));
147 return OnCanSetCookie(request, cookie_line, options);
150 bool NetworkDelegate::CanAccessFile(const URLRequest& request,
151 const base::FilePath& path) const {
152 DCHECK(CalledOnValidThread());
153 return OnCanAccessFile(request, path);
156 bool NetworkDelegate::CanEnablePrivacyMode(
157 const GURL& url,
158 const GURL& first_party_for_cookies) const {
159 DCHECK(CalledOnValidThread());
160 return OnCanEnablePrivacyMode(url, first_party_for_cookies);
163 bool NetworkDelegate::FirstPartyOnlyCookieExperimentEnabled() const {
164 return OnFirstPartyOnlyCookieExperimentEnabled();
167 bool NetworkDelegate::CancelURLRequestWithPolicyViolatingReferrerHeader(
168 const URLRequest& request,
169 const GURL& target_url,
170 const GURL& referrer_url) const {
171 DCHECK(CalledOnValidThread());
172 return OnCancelURLRequestWithPolicyViolatingReferrerHeader(
173 request, target_url, referrer_url);
176 } // namespace net