diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-23 08:31:14 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-23 08:31:14 +0000 |
commit | 8202d0cda0660d43f699160179df6c95058ab928 (patch) | |
tree | 0025c388d8e833fb1462eb84f94e63d38d1e353b /chrome/browser/net | |
parent | 1a3b42b3b153860e59831e71d59cecaf36a2454e (diff) | |
download | chromium_src-8202d0cda0660d43f699160179df6c95058ab928.zip chromium_src-8202d0cda0660d43f699160179df6c95058ab928.tar.gz chromium_src-8202d0cda0660d43f699160179df6c95058ab928.tar.bz2 |
Send fatal proxy errors to the network delegate.
BUG=60099
TEST=browser test
Review URL: http://codereview.chromium.org/6541021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75726 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r-- | chrome/browser/net/chrome_network_delegate.cc | 28 | ||||
-rw-r--r-- | chrome/browser/net/chrome_network_delegate.h | 2 |
2 files changed, 29 insertions, 1 deletions
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc index 0c92721..ce79045 100644 --- a/chrome/browser/net/chrome_network_delegate.cc +++ b/chrome/browser/net/chrome_network_delegate.cc @@ -1,12 +1,14 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/net/chrome_network_delegate.h" #include "base/logging.h" +#include "chrome/browser/extensions/extension_proxy_api.h" #include "chrome/browser/extensions/extension_webrequest_api.h" #include "chrome/browser/net/chrome_url_request_context.h" +#include "net/base/net_errors.h" #include "net/http/http_request_headers.h" #include "net/url_request/url_request.h" @@ -21,6 +23,21 @@ const ExtensionIOEventRouter* GetIOEventRouter( extension_io_event_router(); } +// If the |request| failed due to problems with a proxy, forward the error to +// the proxy extension API. +void ForwardProxyErrors(net::URLRequest* request) { + if (request->status().status() == net::URLRequestStatus::FAILED) { + switch (request->status().os_error()) { + case net::ERR_PROXY_AUTH_UNSUPPORTED: + case net::ERR_PROXY_CONNECTION_FAILED: + case net::ERR_TUNNEL_CONNECTION_FAILED: + ExtensionProxyEventRouter::GetInstance()->OnProxyError( + GetIOEventRouter(request->context()), + request->status().os_error()); + } + } +} + } // namespace ChromeNetworkDelegate::ChromeNetworkDelegate() {} @@ -37,3 +54,12 @@ void ChromeNetworkDelegate::OnSendHttpRequest( // TODO(willchan): Add Chrome-side hooks to listen / mutate requests here. } + +void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) { + ForwardProxyErrors(request); +} + +void ChromeNetworkDelegate::OnReadCompleted(net::URLRequest* request, + int bytes_read) { + ForwardProxyErrors(request); +} diff --git a/chrome/browser/net/chrome_network_delegate.h b/chrome/browser/net/chrome_network_delegate.h index 8bff160..06c7c93 100644 --- a/chrome/browser/net/chrome_network_delegate.h +++ b/chrome/browser/net/chrome_network_delegate.h @@ -19,6 +19,8 @@ class ChromeNetworkDelegate : public net::HttpNetworkDelegate { // net::HttpNetworkDelegate methods: virtual void OnBeforeURLRequest(net::URLRequest* request); virtual void OnSendHttpRequest(net::HttpRequestHeaders* headers); + virtual void OnResponseStarted(net::URLRequest* request); + virtual void OnReadCompleted(net::URLRequest* request, int bytes_read); // TODO(willchan): Add functions for consumers to register ways to // access/modify the request. |