OLD | NEW |
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 #include "content/browser/download/download_manager_impl.h" | 5 #include "content/browser/download/download_manager_impl.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 void BeginDownload(scoped_ptr<DownloadUrlParameters> params, | 51 void BeginDownload(scoped_ptr<DownloadUrlParameters> params, |
52 DownloadId download_id) { | 52 DownloadId download_id) { |
53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
54 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and | 54 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and |
55 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so | 55 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so |
56 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4. | 56 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4. |
57 scoped_ptr<net::URLRequest> request( | 57 scoped_ptr<net::URLRequest> request( |
58 params->resource_context()->GetRequestContext()->CreateRequest( | 58 params->resource_context()->GetRequestContext()->CreateRequest( |
59 params->url(), NULL)); | 59 params->url(), NULL)); |
60 request->set_referrer(params->referrer().url.spec()); | 60 if (params->referrer().url.is_valid()) |
| 61 request->set_referrer(params->referrer().url.spec()); |
61 webkit_glue::ConfigureURLRequestForReferrerPolicy( | 62 webkit_glue::ConfigureURLRequestForReferrerPolicy( |
62 request.get(), params->referrer().policy); | 63 request.get(), params->referrer().policy); |
63 request->set_load_flags(request->load_flags() | params->load_flags()); | 64 request->set_load_flags(request->load_flags() | params->load_flags()); |
64 request->set_method(params->method()); | 65 request->set_method(params->method()); |
65 if (!params->post_body().empty()) { | 66 if (!params->post_body().empty()) { |
66 const std::string& body = params->post_body(); | 67 const std::string& body = params->post_body(); |
67 scoped_ptr<net::UploadElementReader> reader( | 68 scoped_ptr<net::UploadElementReader> reader( |
68 net::UploadOwnedBytesElementReader::CreateWithString(body)); | 69 net::UploadOwnedBytesElementReader::CreateWithString(body)); |
69 request->set_upload(make_scoped_ptr( | 70 request->set_upload(make_scoped_ptr( |
70 net::UploadDataStream::CreateWithReader(reader.Pass(), 0))); | 71 net::UploadDataStream::CreateWithReader(reader.Pass(), 0))); |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 if (delegate_) | 669 if (delegate_) |
669 delegate_->OpenDownload(download); | 670 delegate_->OpenDownload(download); |
670 } | 671 } |
671 | 672 |
672 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 673 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
673 if (delegate_) | 674 if (delegate_) |
674 delegate_->ShowDownloadInShell(download); | 675 delegate_->ShowDownloadInShell(download); |
675 } | 676 } |
676 | 677 |
677 } // namespace content | 678 } // namespace content |
OLD | NEW |