OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/net/chrome_network_delegate.h" | 5 #include "chrome/browser/net/chrome_network_delegate.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/extensions/extension_proxy_api.h" |
8 #include "chrome/browser/extensions/extension_webrequest_api.h" | 9 #include "chrome/browser/extensions/extension_webrequest_api.h" |
9 #include "chrome/browser/net/chrome_url_request_context.h" | 10 #include "chrome/browser/net/chrome_url_request_context.h" |
| 11 #include "net/base/net_errors.h" |
10 #include "net/http/http_request_headers.h" | 12 #include "net/http/http_request_headers.h" |
11 #include "net/url_request/url_request.h" | 13 #include "net/url_request/url_request.h" |
12 | 14 |
13 namespace { | 15 namespace { |
14 | 16 |
15 // Get the event router from the request context. Currently only | 17 // Get the event router from the request context. Currently only |
16 // ChromeURLRequestContexts use a network delegate, so the cast is guaranteed to | 18 // ChromeURLRequestContexts use a network delegate, so the cast is guaranteed to |
17 // work. | 19 // work. |
18 const ExtensionIOEventRouter* GetIOEventRouter( | 20 const ExtensionIOEventRouter* GetIOEventRouter( |
19 net::URLRequestContext* context) { | 21 net::URLRequestContext* context) { |
(...skipping 10 matching lines...) Expand all Loading... |
30 ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest( | 32 ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest( |
31 GetIOEventRouter(request->context()), request->url(), request->method()); | 33 GetIOEventRouter(request->context()), request->url(), request->method()); |
32 } | 34 } |
33 | 35 |
34 void ChromeNetworkDelegate::OnSendHttpRequest( | 36 void ChromeNetworkDelegate::OnSendHttpRequest( |
35 net::HttpRequestHeaders* headers) { | 37 net::HttpRequestHeaders* headers) { |
36 DCHECK(headers); | 38 DCHECK(headers); |
37 | 39 |
38 // TODO(willchan): Add Chrome-side hooks to listen / mutate requests here. | 40 // TODO(willchan): Add Chrome-side hooks to listen / mutate requests here. |
39 } | 41 } |
| 42 |
| 43 void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) { |
| 44 if (request->status().status() == net::URLRequestStatus::FAILED && |
| 45 request->status().os_error() == net::ERR_PROXY_CONNECTION_FAILED) { |
| 46 ExtensionProxyEventRouter::GetInstance()->OnProxyError( |
| 47 GetIOEventRouter(request->context())); |
| 48 } |
| 49 } |
OLD | NEW |