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

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

Issue 7192016: chrome.experimental.downloads (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Bearings Before Woods Created 9 years, 6 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) 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 <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/bind.h" 13 #include "base/bind.h"
13 #include "base/command_line.h" 14 #include "base/command_line.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop.h" 17 #include "base/message_loop.h"
17 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
18 #include "base/shared_memory.h" 19 #include "base/shared_memory.h"
19 #include "base/stl_util-inl.h" 20 #include "base/stl_util-inl.h"
20 #include "base/time.h" 21 #include "base/time.h"
22 #include "base/values.h"
21 #include "chrome/browser/download/download_file_manager.h" 23 #include "chrome/browser/download/download_file_manager.h"
22 #include "chrome/browser/download/download_manager.h" 24 #include "chrome/browser/download/download_manager.h"
23 #include "chrome/browser/download/download_request_limiter.h" 25 #include "chrome/browser/download/download_request_limiter.h"
24 #include "chrome/browser/download/download_util.h" 26 #include "chrome/browser/download/download_util.h"
25 #include "chrome/browser/download/save_file_manager.h" 27 #include "chrome/browser/download/save_file_manager.h"
26 #include "chrome/browser/renderer_host/download_resource_handler.h" 28 #include "chrome/browser/renderer_host/download_resource_handler.h"
27 #include "chrome/browser/renderer_host/save_file_resource_handler.h" 29 #include "chrome/browser/renderer_host/save_file_resource_handler.h"
28 #include "content/browser/appcache/chrome_appcache_service.h" 30 #include "content/browser/appcache/chrome_appcache_service.h"
29 #include "content/browser/cert_store.h" 31 #include "content/browser/cert_store.h"
30 #include "content/browser/child_process_security_policy.h" 32 #include "content/browser/child_process_security_policy.h"
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 params.closing_route_id, 672 params.closing_route_id,
671 &RenderViewHost::OnSwapOutACK); 673 &RenderViewHost::OnSwapOutACK);
672 } 674 }
673 675
674 // We are explicitly forcing the download of 'url'. 676 // We are explicitly forcing the download of 'url'.
675 void ResourceDispatcherHost::BeginDownload( 677 void ResourceDispatcherHost::BeginDownload(
676 const GURL& url, 678 const GURL& url,
677 const GURL& referrer, 679 const GURL& referrer,
678 const DownloadSaveInfo& save_info, 680 const DownloadSaveInfo& save_info,
679 bool prompt_for_save_location, 681 bool prompt_for_save_location,
682 std::string method,
683 DictionaryValue* extra_headers,
684 std::string post_body,
685 DownloadResourceHandler::OnResponseStartedCallback started_cb,
686 DownloadResourceHandler::OnUnstartableCallback unstartable_cb,
680 int child_id, 687 int child_id,
681 int route_id, 688 int route_id,
682 const content::ResourceContext& context) { 689 const content::ResourceContext& context) {
683 if (is_shutdown_) 690 if (is_shutdown_)
684 return; 691 return;
685 692
686 // Check if the renderer is permitted to request the requested URL. 693 // Check if the renderer is permitted to request the requested URL.
687 if (!ChildProcessSecurityPolicy::GetInstance()-> 694 if (!ChildProcessSecurityPolicy::GetInstance()->
688 CanRequestURL(child_id, url)) { 695 CanRequestURL(child_id, url)) {
689 VLOG(1) << "Denied unauthorized download request for " 696 VLOG(1) << "Denied unauthorized download request for "
(...skipping 12 matching lines...) Expand all
702 709
703 scoped_refptr<ResourceHandler> handler( 710 scoped_refptr<ResourceHandler> handler(
704 new DownloadResourceHandler(this, 711 new DownloadResourceHandler(this,
705 child_id, 712 child_id,
706 route_id, 713 route_id,
707 request_id_, 714 request_id_,
708 url, 715 url,
709 download_file_manager_.get(), 716 download_file_manager_.get(),
710 request, 717 request,
711 prompt_for_save_location, 718 prompt_for_save_location,
719 started_cb,
720 unstartable_cb,
712 save_info)); 721 save_info));
713 722
714 if (delegate_) 723 if (delegate_) {
715 handler = delegate_->DownloadStarting(handler, child_id, route_id); 724 handler = delegate_->DownloadStarting(handler, child_id, route_id);
725 }
716 726
717 const net::URLRequestContext* request_context = context.request_context(); 727 const net::URLRequestContext* request_context = context.request_context();
718 728
719 if (!request_context->job_factory()->IsHandledURL(url)) { 729 if (!request_context->job_factory()->IsHandledURL(url)) {
720 VLOG(1) << "Download request for unsupported protocol: " 730 VLOG(1) << "Download request for unsupported protocol: "
721 << url.possibly_invalid_spec(); 731 << url.possibly_invalid_spec();
722 return; 732 return;
723 } 733 }
734 if (method.empty()) {
735 method = "GET";
736 }
724 737
725 request->set_method("GET"); 738 request->set_method(method);
726 request->set_referrer(MaybeStripReferrer(referrer).spec()); 739 request->set_referrer(MaybeStripReferrer(referrer).spec());
727 request->set_context(context.request_context()); 740 request->set_context(context.request_context());
728 request->set_load_flags(request->load_flags() | 741 request->set_load_flags(request->load_flags() |
729 net::LOAD_IS_DOWNLOAD); 742 net::LOAD_IS_DOWNLOAD);
730 743
744 if (extra_headers != NULL) {
745 DictionaryValue::key_iterator headers_end = extra_headers->end_keys();
746 for (DictionaryValue::key_iterator headers_iter =
747 extra_headers->begin_keys();
748 headers_iter != headers_end; ++headers_iter) {
749 std::string value;
750 if (extra_headers->GetStringWithoutPathExpansion(*headers_iter, &value)) {
751 request->SetExtraRequestHeaderByName(
752 *headers_iter, value, false/*overwrite*/);
753 }
754 }
755 }
756 if (!post_body.empty()) {
757 request->AppendBytesToUpload(post_body.data(), post_body.size());
758 }
759
731 ResourceDispatcherHostRequestInfo* extra_info = 760 ResourceDispatcherHostRequestInfo* extra_info =
732 CreateRequestInfoForBrowserRequest( 761 CreateRequestInfoForBrowserRequest(
733 handler, child_id, route_id, true, context); 762 handler, child_id, route_id, true, context);
734 SetRequestInfo(request, extra_info); // Request takes ownership. 763 SetRequestInfo(request, extra_info); // Request takes ownership.
735 764
736 BeginRequestInternal(request); 765 BeginRequestInternal(request);
737 } 766 }
738 767
739 // This function is only used for saving feature. 768 // This function is only used for saving feature.
740 void ResourceDispatcherHost::BeginSaveFile( 769 void ResourceDispatcherHost::BeginSaveFile(
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 return HTTP_AUTH_RESOURCE_BLOCKED_CROSS; 2034 return HTTP_AUTH_RESOURCE_BLOCKED_CROSS;
2006 } 2035 }
2007 2036
2008 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() { 2037 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() {
2009 return allow_cross_origin_auth_prompt_; 2038 return allow_cross_origin_auth_prompt_;
2010 } 2039 }
2011 2040
2012 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { 2041 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) {
2013 allow_cross_origin_auth_prompt_ = value; 2042 allow_cross_origin_auth_prompt_ = value;
2014 } 2043 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698