summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-23 08:31:14 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-23 08:31:14 +0000
commit8202d0cda0660d43f699160179df6c95058ab928 (patch)
tree0025c388d8e833fb1462eb84f94e63d38d1e353b /chrome
parent1a3b42b3b153860e59831e71d59cecaf36a2454e (diff)
downloadchromium_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')
-rw-r--r--chrome/browser/extensions/extension_proxy_apitest.cc4
-rw-r--r--chrome/browser/io_thread.cc3
-rw-r--r--chrome/browser/net/chrome_network_delegate.cc28
-rw-r--r--chrome/browser/net/chrome_network_delegate.h2
4 files changed, 33 insertions, 4 deletions
diff --git a/chrome/browser/extensions/extension_proxy_apitest.cc b/chrome/browser/extensions/extension_proxy_apitest.cc
index ad77ed4..970ca71 100644
--- a/chrome/browser/extensions/extension_proxy_apitest.cc
+++ b/chrome/browser/extensions/extension_proxy_apitest.cc
@@ -284,8 +284,8 @@ IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest,
pref_service);
}
-// TODO(jochen): enable once network side has landed. Tests error events.
-IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, DISABLED_ProxyEvents) {
+// Tests error events.
+IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, ProxyEvents) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableExperimentalExtensionApis);
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index 2a854b8..e966707 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -346,7 +346,8 @@ void IOThread::Init() {
globals_->proxy_script_fetcher_proxy_service.get();
session_params.http_auth_handler_factory =
globals_->http_auth_handler_factory.get();
- session_params.network_delegate = &globals_->network_delegate;
+ // TODO(willchan): Enable for proxy script fetcher context.
+ session_params.network_delegate = NULL;
session_params.net_log = net_log_;
session_params.ssl_config_service = globals_->ssl_config_service;
scoped_refptr<net::HttpNetworkSession> network_session(
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.