diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-10 00:29:37 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-10 00:29:37 +0000 |
commit | 4b50cb5974b9465055113a92494ec68fe0a33ea8 (patch) | |
tree | 98609f2d31a9749abd013a0191e613c54a98db2e /net/url_request | |
parent | b3a5bb10518d4710e0434934450cdfb0b9ca5784 (diff) | |
download | chromium_src-4b50cb5974b9465055113a92494ec68fe0a33ea8.zip chromium_src-4b50cb5974b9465055113a92494ec68fe0a33ea8.tar.gz chromium_src-4b50cb5974b9465055113a92494ec68fe0a33ea8.tar.bz2 |
Extends NetworkDelegate to avoid use of static_cast<> when handling RegisterProtocolHandler URLs.
Currently we use a static_cast<> to convert a URLRequestContext into a
ChromeURLRequestContext in a ProtocolFactory. However, ProtocolFactory is
global and not all URLRequestContexts are instances of ChromeURLRequestContext,
so this will always crash in certain circumstances (such as the one described
in the TEST field).
This change solves the problem by providing a MaybeCreateURLRequestJob() method
in NetworkDelegate and then having the ProtocolHandlerRegistry::Factory() call
it instead of casting.
BUG=74063
TEST=Requesting a URL that has a registerProtocolHandler() from chrome://net-internals/#tests doesn't crash.
Review URL: http://codereview.chromium.org/6592060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77559 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request')
-rw-r--r-- | net/url_request/url_request.h | 3 | ||||
-rw-r--r-- | net/url_request/url_request_test_util.cc | 5 | ||||
-rw-r--r-- | net/url_request/url_request_test_util.h | 2 |
3 files changed, 10 insertions, 0 deletions
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h index b98282a..2c58db1 100644 --- a/net/url_request/url_request.h +++ b/net/url_request/url_request.h @@ -261,6 +261,9 @@ class URLRequest : public base::NonThreadSafe { // Returns true if the url can be handled by URLRequest. False otherwise. // The function returns true for invalid urls because URLRequest knows how // to handle those. + // NOTE: This will also return true for URLs that are handled by + // ProtocolFactories that only work for requests that are scoped to a + // Profile. static bool IsHandledURL(const GURL& url); // Allow access to file:// on ChromeOS for tests. diff --git a/net/url_request/url_request_test_util.cc b/net/url_request/url_request_test_util.cc index 8fd7cab..d13ee06 100644 --- a/net/url_request/url_request_test_util.cc +++ b/net/url_request/url_request_test_util.cc @@ -319,3 +319,8 @@ void TestNetworkDelegate::OnReadCompleted(net::URLRequest* request, last_os_error_ = request->status().os_error(); } } + +net::URLRequestJob* TestNetworkDelegate::OnMaybeCreateURLRequestJob( + net::URLRequest* request) { + return NULL; +} diff --git a/net/url_request/url_request_test_util.h b/net/url_request/url_request_test_util.h index d166f9e..6dcd39d 100644 --- a/net/url_request/url_request_test_util.h +++ b/net/url_request/url_request_test_util.h @@ -206,6 +206,8 @@ class TestNetworkDelegate : public net::NetworkDelegate { virtual void OnSendHttpRequest(net::HttpRequestHeaders* headers); virtual void OnResponseStarted(net::URLRequest* request); virtual void OnReadCompleted(net::URLRequest* request, int bytes_read); + virtual net::URLRequestJob* OnMaybeCreateURLRequestJob( + net::URLRequest* request); int last_os_error_; int error_count_; |