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

Side by Side Diff: content/browser/renderer_host/resource_dispatcher_host.cc

Issue 8588039: Remove "open in new tab" items from context menu if the process doesn't (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return GURL(); 147 return GURL();
148 return possible_referrer; 148 return possible_referrer;
149 } 149 }
150 150
151 // Consults the RendererSecurity policy to determine whether the 151 // Consults the RendererSecurity policy to determine whether the
152 // ResourceDispatcherHost should service this request. A request might be 152 // ResourceDispatcherHost should service this request. A request might be
153 // disallowed if the renderer is not authorized to retrieve the request URL or 153 // disallowed if the renderer is not authorized to retrieve the request URL or
154 // if the renderer is attempting to upload an unauthorized file. 154 // if the renderer is attempting to upload an unauthorized file.
155 bool ShouldServiceRequest(content::ProcessType process_type, 155 bool ShouldServiceRequest(content::ProcessType process_type,
156 int child_id, 156 int child_id,
157 const ResourceHostMsg_Request& request_data) { 157 const ResourceHostMsg_Request& request_data,
158 const net::URLRequestJobFactory* job_factory) {
158 if (process_type == content::PROCESS_TYPE_PLUGIN) 159 if (process_type == content::PROCESS_TYPE_PLUGIN)
159 return true; 160 return true;
160 161
161 ChildProcessSecurityPolicy* policy = 162 ChildProcessSecurityPolicy* policy =
162 ChildProcessSecurityPolicy::GetInstance(); 163 ChildProcessSecurityPolicy::GetInstance();
163 164
164 // Check if the renderer is permitted to request the requested URL. 165 // Check if the renderer is permitted to request the requested URL.
165 if (!policy->CanRequestURL(child_id, request_data.url)) { 166 if (!policy->CanRequestURL(child_id, request_data.url, job_factory)) {
166 VLOG(1) << "Denied unauthorized request for " 167 VLOG(1) << "Denied unauthorized request for "
167 << request_data.url.possibly_invalid_spec(); 168 << request_data.url.possibly_invalid_spec();
168 return false; 169 return false;
169 } 170 }
170 171
171 // Check if the renderer is permitted to upload the requested files. 172 // Check if the renderer is permitted to upload the requested files.
172 if (request_data.upload_data) { 173 if (request_data.upload_data) {
173 const std::vector<net::UploadData::Element>* uploads = 174 const std::vector<net::UploadData::Element>* uploads =
174 request_data.upload_data->elements(); 175 request_data.upload_data->elements();
175 std::vector<net::UploadData::Element>::const_iterator iter; 176 std::vector<net::UploadData::Element>::const_iterator iter;
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 const content::ResourceContext& resource_context = 484 const content::ResourceContext& resource_context =
484 filter_->resource_context(); 485 filter_->resource_context();
485 486
486 // Might need to resolve the blob references in the upload data. 487 // Might need to resolve the blob references in the upload data.
487 if (request_data.upload_data) { 488 if (request_data.upload_data) {
488 resource_context.blob_storage_context()->controller()-> 489 resource_context.blob_storage_context()->controller()->
489 ResolveBlobReferencesInUploadData(request_data.upload_data.get()); 490 ResolveBlobReferencesInUploadData(request_data.upload_data.get());
490 } 491 }
491 492
492 if (is_shutdown_ || 493 if (is_shutdown_ ||
493 !ShouldServiceRequest(process_type, child_id, request_data)) { 494 !ShouldServiceRequest(
495 process_type, child_id, request_data,
496 resource_context.request_context()->job_factory())) {
494 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); 497 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id);
495 return; 498 return;
496 } 499 }
497 500
498 const GURL referrer = MaybeStripReferrer(request_data.referrer); 501 const GURL referrer = MaybeStripReferrer(request_data.referrer);
499 502
500 // Allow the observer to block/handle the request. 503 // Allow the observer to block/handle the request.
501 if (delegate_ && !delegate_->ShouldBeginRequest(child_id, 504 if (delegate_ && !delegate_->ShouldBeginRequest(child_id,
502 route_id, 505 route_id,
503 request_data.method, 506 request_data.method,
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 const GURL& url = request->original_url(); 869 const GURL& url = request->original_url();
867 const net::URLRequestContext* request_context = context.request_context(); 870 const net::URLRequestContext* request_context = context.request_context();
868 request->set_referrer(MaybeStripReferrer(GURL(request->referrer())).spec()); 871 request->set_referrer(MaybeStripReferrer(GURL(request->referrer())).spec());
869 request->set_method("GET"); 872 request->set_method("GET");
870 request->set_context(request_context); 873 request->set_context(request_context);
871 request->set_load_flags(request->load_flags() | 874 request->set_load_flags(request->load_flags() |
872 net::LOAD_IS_DOWNLOAD | net::LOAD_DISABLE_CACHE); 875 net::LOAD_IS_DOWNLOAD | net::LOAD_DISABLE_CACHE);
873 876
874 // Check if the renderer is permitted to request the requested URL. 877 // Check if the renderer is permitted to request the requested URL.
875 if (!ChildProcessSecurityPolicy::GetInstance()-> 878 if (!ChildProcessSecurityPolicy::GetInstance()->
876 CanRequestURL(child_id, url)) { 879 CanRequestURL(child_id, url, request_context->job_factory())) {
877 VLOG(1) << "Denied unauthorized download request for " 880 VLOG(1) << "Denied unauthorized download request for "
878 << url.possibly_invalid_spec(); 881 << url.possibly_invalid_spec();
879 if (!started_cb.is_null()) 882 if (!started_cb.is_null())
880 started_cb.Run(DownloadId::Invalid(), net::ERR_ACCESS_DENIED); 883 started_cb.Run(DownloadId::Invalid(), net::ERR_ACCESS_DENIED);
881 return; 884 return;
882 } 885 }
883 886
884 request_id_--; 887 request_id_--;
885 888
886 DownloadId dl_id = context.download_id_factory()->GetNextId(); 889 DownloadId dl_id = context.download_id_factory()->GetNextId();
(...skipping 10 matching lines...) Expand all
897 prompt_for_save_location, 900 prompt_for_save_location,
898 started_cb, 901 started_cb,
899 save_info)); 902 save_info));
900 903
901 if (delegate_) { 904 if (delegate_) {
902 handler = delegate_->DownloadStarting( 905 handler = delegate_->DownloadStarting(
903 handler, context, request, child_id, route_id, request_id_, true, 906 handler, context, request, child_id, route_id, request_id_, true,
904 false); 907 false);
905 } 908 }
906 909
910 // FIXME(tsepez); probably redundant in face of passing job_factory to
911 // ChildProcessSecurityPolicy above.
907 if (!request_context->job_factory()->IsHandledURL(url)) { 912 if (!request_context->job_factory()->IsHandledURL(url)) {
908 VLOG(1) << "Download request for unsupported protocol: " 913 VLOG(1) << "Download request for unsupported protocol: "
909 << url.possibly_invalid_spec(); 914 << url.possibly_invalid_spec();
910 if (!started_cb.is_null()) 915 if (!started_cb.is_null())
911 started_cb.Run(DownloadId::Invalid(), net::ERR_ACCESS_DENIED); 916 started_cb.Run(DownloadId::Invalid(), net::ERR_ACCESS_DENIED);
912 return; 917 return;
913 } 918 }
914 919
915 ResourceDispatcherHostRequestInfo* extra_info = 920 ResourceDispatcherHostRequestInfo* extra_info =
916 CreateRequestInfo(handler, child_id, route_id, true, context); 921 CreateRequestInfo(handler, child_id, route_id, true, context);
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 1262
1258 void ResourceDispatcherHost::OnReceivedRedirect(net::URLRequest* request, 1263 void ResourceDispatcherHost::OnReceivedRedirect(net::URLRequest* request,
1259 const GURL& new_url, 1264 const GURL& new_url,
1260 bool* defer_redirect) { 1265 bool* defer_redirect) {
1261 VLOG(1) << "OnReceivedRedirect: " << request->url().spec(); 1266 VLOG(1) << "OnReceivedRedirect: " << request->url().spec();
1262 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); 1267 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request);
1263 1268
1264 DCHECK(request->status().is_success()); 1269 DCHECK(request->status().is_success());
1265 1270
1266 if (info->process_type() != content::PROCESS_TYPE_PLUGIN && 1271 if (info->process_type() != content::PROCESS_TYPE_PLUGIN &&
1267 !ChildProcessSecurityPolicy::GetInstance()-> 1272 !ChildProcessSecurityPolicy::GetInstance()->CanRequestURL(
1268 CanRequestURL(info->child_id(), new_url)) { 1273 info->child_id(), new_url, request->context()->job_factory())) {
1269 VLOG(1) << "Denied unauthorized request for " 1274 VLOG(1) << "Denied unauthorized request for "
1270 << new_url.possibly_invalid_spec(); 1275 << new_url.possibly_invalid_spec();
1271 1276
1272 // Tell the renderer that this request was disallowed. 1277 // Tell the renderer that this request was disallowed.
1273 CancelRequestInternal(request, false); 1278 CancelRequestInternal(request, false);
1274 return; 1279 return;
1275 } 1280 }
1276 1281
1277 NotifyReceivedRedirect(request, info->child_id(), new_url); 1282 NotifyReceivedRedirect(request, info->child_id(), new_url);
1278 1283
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 2237
2233 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { 2238 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) {
2234 allow_cross_origin_auth_prompt_ = value; 2239 allow_cross_origin_auth_prompt_ = value;
2235 } 2240 }
2236 2241
2237 void ResourceDispatcherHost::MarkAsTransferredNavigation( 2242 void ResourceDispatcherHost::MarkAsTransferredNavigation(
2238 const GlobalRequestID& transferred_request_id, 2243 const GlobalRequestID& transferred_request_id,
2239 net::URLRequest* ransferred_request) { 2244 net::URLRequest* ransferred_request) {
2240 transferred_navigations_[transferred_request_id] = ransferred_request; 2245 transferred_navigations_[transferred_request_id] = ransferred_request;
2241 } 2246 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698