Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 7 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 // Tell the renderer that this request was disallowed. | 137 // Tell the renderer that this request was disallowed. |
| 138 filter->Send(new ResourceMsg_RequestComplete( | 138 filter->Send(new ResourceMsg_RequestComplete( |
| 139 route_id, | 139 route_id, |
| 140 request_id, | 140 request_id, |
| 141 status, | 141 status, |
| 142 std::string(), // No security info needed, connection was not | 142 std::string(), // No security info needed, connection was not |
| 143 base::Time())); // established. | 143 base::Time())); // established. |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Aborts a request before an URLRequest has actually been created. | |
| 148 void CancelRequestBeforeItStarts(ResourceMessageFilter* filter, | |
|
gavinp
2011/06/15 15:31:23
Instead of writing this function, add a bool or en
| |
| 149 IPC::Message* sync_result, | |
| 150 int route_id, | |
| 151 int request_id) { | |
| 152 net::URLRequestStatus status(net::URLRequestStatus::CANCELED, | |
| 153 net::ERR_ABORTED); | |
| 154 if (sync_result) { | |
| 155 SyncLoadResult result; | |
| 156 result.status = status; | |
| 157 ResourceHostMsg_SyncLoad::WriteReplyParams(sync_result, result); | |
| 158 filter->Send(sync_result); | |
| 159 } else { | |
| 160 // Tell the renderer that this request was disallowed. | |
| 161 filter->Send(new ResourceMsg_RequestComplete( | |
| 162 route_id, | |
| 163 request_id, | |
| 164 status, | |
| 165 std::string(), // No security info needed, connection was not | |
| 166 base::Time())); // established. | |
| 167 } | |
| 168 } | |
| 169 | |
| 147 GURL MaybeStripReferrer(const GURL& possible_referrer) { | 170 GURL MaybeStripReferrer(const GURL& possible_referrer) { |
| 148 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoReferrers)) | 171 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoReferrers)) |
| 149 return GURL(); | 172 return GURL(); |
| 150 return possible_referrer; | 173 return possible_referrer; |
| 151 } | 174 } |
| 152 | 175 |
| 153 // Consults the RendererSecurity policy to determine whether the | 176 // Consults the RendererSecurity policy to determine whether the |
| 154 // ResourceDispatcherHost should service this request. A request might be | 177 // ResourceDispatcherHost should service this request. A request might be |
| 155 // disallowed if the renderer is not authorized to retrieve the request URL or | 178 // disallowed if the renderer is not authorized to retrieve the request URL or |
| 156 // if the renderer is attempting to upload an unauthorized file. | 179 // if the renderer is attempting to upload an unauthorized file. |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 return; | 413 return; |
| 391 } | 414 } |
| 392 | 415 |
| 393 const GURL referrer = MaybeStripReferrer(request_data.referrer); | 416 const GURL referrer = MaybeStripReferrer(request_data.referrer); |
| 394 | 417 |
| 395 // Allow the observer to block/handle the request. | 418 // Allow the observer to block/handle the request. |
| 396 if (delegate_ && !delegate_->ShouldBeginRequest(child_id, route_id, | 419 if (delegate_ && !delegate_->ShouldBeginRequest(child_id, route_id, |
| 397 request_data, | 420 request_data, |
| 398 resource_context, | 421 resource_context, |
| 399 referrer)) { | 422 referrer)) { |
| 400 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); | 423 CancelRequestBeforeItStarts(filter_, sync_result, route_id, request_id); |
| 401 return; | 424 return; |
| 402 } | 425 } |
| 403 | 426 |
| 404 // Construct the event handler. | 427 // Construct the event handler. |
| 405 scoped_refptr<ResourceHandler> handler; | 428 scoped_refptr<ResourceHandler> handler; |
| 406 if (sync_result) { | 429 if (sync_result) { |
| 407 handler = new SyncResourceHandler( | 430 handler = new SyncResourceHandler( |
| 408 filter_, request_data.url, sync_result, this); | 431 filter_, request_data.url, sync_result, this); |
| 409 } else { | 432 } else { |
| 410 handler = new AsyncResourceHandler( | 433 handler = new AsyncResourceHandler( |
| (...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2007 | 2030 |
| 2008 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() { | 2031 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() { |
| 2009 return allow_cross_origin_auth_prompt_; | 2032 return allow_cross_origin_auth_prompt_; |
| 2010 } | 2033 } |
| 2011 | 2034 |
| 2012 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { | 2035 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { |
| 2013 allow_cross_origin_auth_prompt_ = value; | 2036 allow_cross_origin_auth_prompt_ = value; |
| 2014 } | 2037 } |
| 2015 | 2038 |
| 2016 | 2039 |
| OLD | NEW |