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

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

Issue 10381122: Add flag to specify if explicitly requested download is from web. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated comments. Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_impl.h" 7 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 ResourceRequestInfoImpl* info = 459 ResourceRequestInfoImpl* info =
460 ResourceRequestInfoImpl::ForRequest(requests->front()); 460 ResourceRequestInfoImpl::ForRequest(requests->front());
461 // http://crbug.com/90971 461 // http://crbug.com/90971
462 CHECK_NE(info->GetContext(), context); 462 CHECK_NE(info->GetContext(), context);
463 } 463 }
464 } 464 }
465 } 465 }
466 466
467 net::Error ResourceDispatcherHostImpl::BeginDownload( 467 net::Error ResourceDispatcherHostImpl::BeginDownload(
468 scoped_ptr<net::URLRequest> request, 468 scoped_ptr<net::URLRequest> request,
469 bool is_content_initiated,
469 ResourceContext* context, 470 ResourceContext* context,
470 int child_id, 471 int child_id,
471 int route_id, 472 int route_id,
472 bool prefer_cache, 473 bool prefer_cache,
473 const DownloadSaveInfo& save_info, 474 const DownloadSaveInfo& save_info,
474 const DownloadStartedCallback& started_callback) { 475 const DownloadStartedCallback& started_callback) {
475 if (is_shutdown_) 476 if (is_shutdown_)
476 return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES); 477 return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES);
477 478
478 const GURL& url = request->original_url(); 479 const GURL& url = request->original_url();
(...skipping 28 matching lines...) Expand all
507 << url.possibly_invalid_spec(); 508 << url.possibly_invalid_spec();
508 return CallbackAndReturn(started_callback, net::ERR_ACCESS_DENIED); 509 return CallbackAndReturn(started_callback, net::ERR_ACCESS_DENIED);
509 } 510 }
510 511
511 request_id_--; 512 request_id_--;
512 513
513 // From this point forward, the |DownloadResourceHandler| is responsible for 514 // From this point forward, the |DownloadResourceHandler| is responsible for
514 // |started_callback|. 515 // |started_callback|.
515 scoped_refptr<ResourceHandler> handler( 516 scoped_refptr<ResourceHandler> handler(
516 CreateResourceHandlerForDownload(request.get(), context, child_id, 517 CreateResourceHandlerForDownload(request.get(), context, child_id,
517 route_id, request_id_, save_info, 518 route_id, request_id_,
519 is_content_initiated, save_info,
518 started_callback)); 520 started_callback));
519 521
520 if (!request_context->job_factory()->IsHandledURL(url)) { 522 if (!request_context->job_factory()->IsHandledURL(url)) {
521 VLOG(1) << "Download request for unsupported protocol: " 523 VLOG(1) << "Download request for unsupported protocol: "
522 << url.possibly_invalid_spec(); 524 << url.possibly_invalid_spec();
523 return net::ERR_ACCESS_DENIED; 525 return net::ERR_ACCESS_DENIED;
524 } 526 }
525 527
526 ResourceRequestInfoImpl* extra_info = 528 ResourceRequestInfoImpl* extra_info =
527 CreateRequestInfo(handler, child_id, route_id, true, context); 529 CreateRequestInfo(handler, child_id, route_id, true, context);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 base::Unretained(this))); 571 base::Unretained(this)));
570 } 572 }
571 573
572 scoped_refptr<ResourceHandler> 574 scoped_refptr<ResourceHandler>
573 ResourceDispatcherHostImpl::CreateResourceHandlerForDownload( 575 ResourceDispatcherHostImpl::CreateResourceHandlerForDownload(
574 net::URLRequest* request, 576 net::URLRequest* request,
575 ResourceContext* context, 577 ResourceContext* context,
576 int child_id, 578 int child_id,
577 int route_id, 579 int route_id,
578 int request_id, 580 int request_id,
581 bool is_content_initiated,
579 const DownloadSaveInfo& save_info, 582 const DownloadSaveInfo& save_info,
580 const DownloadResourceHandler::OnStartedCallback& started_cb) { 583 const DownloadResourceHandler::OnStartedCallback& started_cb) {
581 scoped_refptr<ResourceHandler> handler( 584 scoped_refptr<ResourceHandler> handler(
582 new DownloadResourceHandler(child_id, route_id, request_id, 585 new DownloadResourceHandler(child_id, route_id, request_id,
583 request->url(), download_file_manager_.get(), 586 request->url(), download_file_manager_.get(),
584 request, started_cb, save_info)); 587 request, started_cb, save_info));
585 if (delegate_) { 588 if (delegate_) {
586 ScopedVector<ResourceThrottle> throttles; 589 ScopedVector<ResourceThrottle> throttles;
587 delegate_->DownloadStarting(request, context, child_id, route_id, 590 delegate_->DownloadStarting(request, context, child_id, route_id,
588 request_id, !request->is_pending(), &throttles); 591 request_id, is_content_initiated, &throttles);
589 if (!throttles.empty()) { 592 if (!throttles.empty()) {
590 handler = new ThrottlingResourceHandler(this, handler, child_id, 593 handler = new ThrottlingResourceHandler(this, handler, child_id,
591 request_id, throttles.Pass()); 594 request_id, throttles.Pass());
592 } 595 }
593 } 596 }
594 return handler; 597 return handler;
595 } 598 }
596 599
597 // static 600 // static
598 bool ResourceDispatcherHostImpl::RenderViewForRequest( 601 bool ResourceDispatcherHostImpl::RenderViewForRequest(
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 return allow_cross_origin_auth_prompt_; 2337 return allow_cross_origin_auth_prompt_;
2335 } 2338 }
2336 2339
2337 bool ResourceDispatcherHostImpl::IsTransferredNavigation( 2340 bool ResourceDispatcherHostImpl::IsTransferredNavigation(
2338 const GlobalRequestID& transferred_request_id) const { 2341 const GlobalRequestID& transferred_request_id) const {
2339 return transferred_navigations_.find(transferred_request_id) != 2342 return transferred_navigations_.find(transferred_request_id) !=
2340 transferred_navigations_.end(); 2343 transferred_navigations_.end();
2341 } 2344 }
2342 2345
2343 } // namespace content 2346 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698