diff options
author | idanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-24 17:00:15 +0000 |
---|---|---|
committer | idanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-24 17:00:15 +0000 |
commit | 9fa75843d1f81abc9c8bf445be16d6f28fbd3577 (patch) | |
tree | 644d8dcc391799c4855a7bf89de9e56df2460b95 /chrome/browser/renderer_host/resource_dispatcher_host.cc | |
parent | 5e56a3a8e84ee5b4417077f5f3ec17b7dbe73bd1 (diff) | |
download | chromium_src-9fa75843d1f81abc9c8bf445be16d6f28fbd3577.zip chromium_src-9fa75843d1f81abc9c8bf445be16d6f28fbd3577.tar.gz chromium_src-9fa75843d1f81abc9c8bf445be16d6f28fbd3577.tar.bz2 |
Return Error Status Upon Blocking Requests
Blocked requests now return an error status so that the Chrome throbber does
not spin indefinitely when blocking URL requests.
This code shall be replaced with resource substitution next but gives a better
experience until then. Same goes for the added type-based interception.
TEST=none
BUG=16932
Review URL: http://codereview.chromium.org/159214
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21536 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/resource_dispatcher_host.cc')
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host.cc | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index a7b034f..0ea39ca 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -393,8 +393,23 @@ void ResourceDispatcherHost::BeginRequest( Blacklist::Match* match = context && context->blacklist() ? context->blacklist()->findMatch(request_data.url) : NULL; if (match && match->IsBlocked(request_data.url)) { - // TODO(idanan): Send a ResourceResponse to replace the blocked resource. + // TODO(idanan): Send a ResourceResponse to replace the blocked resource + // instead of the FAILED return code below. delete match; + URLRequestStatus status(URLRequestStatus::FAILED, net::ERR_ABORTED); + if (sync_result) { + SyncLoadResult result; + result.status = status; + ViewHostMsg_SyncLoad::WriteReplyParams(sync_result, result); + receiver_->Send(sync_result); + } else { + // Tell the renderer that this request was disallowed. + receiver_->Send(new ViewMsg_Resource_RequestComplete( + route_id, + request_id, + status, + std::string())); // No connection, security info not needed. + } return; } @@ -426,7 +441,7 @@ void ResourceDispatcherHost::BeginRequest( // Construct the request. URLRequest* request = new URLRequest(request_data.url, this); if (match) { - request->SetUserData((void*)&Blacklist::kRequestDataKey, match); + request->SetUserData(&Blacklist::kRequestDataKey, match); } request->set_method(request_data.method); request->set_first_party_for_cookies(request_data.first_party_for_cookies); @@ -1045,6 +1060,16 @@ bool ResourceDispatcherHost::CompleteResponseStarted(URLRequest* request) { response->response_head.app_cache_id = WebAppCacheContext::kNoAppCacheId; request->GetMimeType(&response->response_head.mime_type); + const URLRequest::UserData* d = + request->GetUserData(&Blacklist::kRequestDataKey); + if (d) { + const Blacklist::Match* match = static_cast<const Blacklist::Match*>(d); + if (match->attributes() & Blacklist::kBlockByType) { + if (match->MatchType(response->response_head.mime_type)) + return false; // TODO(idanan): Generate a replacement response. + } + } + if (request->ssl_info().cert) { int cert_id = CertStore::GetSharedInstance()->StoreCert( |