Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7059)

Unified Diff: chrome/browser/renderer_host/resource_dispatcher_host.cc

Issue 159214: Return Error Status Upon Blocking Requests... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/net/chrome_url_request_context.cc ('k') | net/url_request/url_request.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/resource_dispatcher_host.cc
===================================================================
--- chrome/browser/renderer_host/resource_dispatcher_host.cc (revision 21526)
+++ chrome/browser/renderer_host/resource_dispatcher_host.cc (working copy)
@@ -364,8 +364,23 @@
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;
}
@@ -397,7 +412,7 @@
// 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);
@@ -1011,6 +1026,16 @@
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(
« no previous file with comments | « chrome/browser/net/chrome_url_request_context.cc ('k') | net/url_request/url_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698