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

Side by Side Diff: content/browser/download/download_item_impl.cc

Issue 1891623003: [Downloads] Set the Referrer header for resumed requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Catch up with ToT Created 4 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
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 // File method ordering: Methods in this file are in the same order as 5 // File method ordering: Methods in this file are in the same order as
6 // in download_item_impl.h, with the following exception: The public 6 // in download_item_impl.h, with the following exception: The public
7 // interface Start is placed in chronological order with the other 7 // interface Start is placed in chronological order with the other
8 // (private) routines that together define a DownloadItem's state 8 // (private) routines that together define a DownloadItem's state
9 // transitions as the download progresses. See "Download progression 9 // transitions as the download progresses. See "Download progression
10 // cascade" later in this file. 10 // cascade" later in this file.
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 " reason = %s" 803 " reason = %s"
804 " paused = %c" 804 " paused = %c"
805 " resume_mode = %s" 805 " resume_mode = %s"
806 " auto_resume_count = %d" 806 " auto_resume_count = %d"
807 " danger = %d" 807 " danger = %d"
808 " all_data_saved = %c" 808 " all_data_saved = %c"
809 " last_modified = '%s'" 809 " last_modified = '%s'"
810 " etag = '%s'" 810 " etag = '%s'"
811 " has_download_file = %s" 811 " has_download_file = %s"
812 " url_chain = \n\t\"%s\"\n\t" 812 " url_chain = \n\t\"%s\"\n\t"
813 " current_path = \"%" PRFilePath 813 " current_path = \"%" PRFilePath "\"\n\t"
814 "\"\n\t" 814 " target_path = \"%" PRFilePath "\""
815 " target_path = \"%" PRFilePath "\"", 815 " referrer = \"%s\"",
816 GetTotalBytes(), 816 GetTotalBytes(),
817 GetReceivedBytes(), 817 GetReceivedBytes(),
818 DownloadInterruptReasonToString(last_reason_).c_str(), 818 DownloadInterruptReasonToString(last_reason_).c_str(),
819 IsPaused() ? 'T' : 'F', 819 IsPaused() ? 'T' : 'F',
820 DebugResumeModeString(GetResumeMode()), 820 DebugResumeModeString(GetResumeMode()),
821 auto_resume_count_, 821 auto_resume_count_,
822 GetDangerType(), 822 GetDangerType(),
823 AllDataSaved() ? 'T' : 'F', 823 AllDataSaved() ? 'T' : 'F',
824 GetLastModifiedTime().c_str(), 824 GetLastModifiedTime().c_str(),
825 GetETag().c_str(), 825 GetETag().c_str(),
826 download_file_.get() ? "true" : "false", 826 download_file_.get() ? "true" : "false",
827 url_list.c_str(), 827 url_list.c_str(),
828 GetFullPath().value().c_str(), 828 GetFullPath().value().c_str(),
829 GetTargetFilePath().value().c_str()); 829 GetTargetFilePath().value().c_str(),
830 GetReferrerUrl().spec().c_str());
830 } else { 831 } else {
831 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); 832 description += base::StringPrintf(" url = \"%s\"", url_list.c_str());
832 } 833 }
833 834
834 description += " }"; 835 description += " }";
835 836
836 return description; 837 return description;
837 } 838 }
838 839
839 DownloadItemImpl::ResumeMode DownloadItemImpl::GetResumeMode() const { 840 DownloadItemImpl::ResumeMode DownloadItemImpl::GetResumeMode() const {
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 std::unique_ptr<DownloadUrlParameters> download_params( 1908 std::unique_ptr<DownloadUrlParameters> download_params(
1908 new DownloadUrlParameters(GetURL(), -1, -1, -1, 1909 new DownloadUrlParameters(GetURL(), -1, -1, -1,
1909 GetBrowserContext()->GetResourceContext())); 1910 GetBrowserContext()->GetResourceContext()));
1910 download_params->set_file_path(GetFullPath()); 1911 download_params->set_file_path(GetFullPath());
1911 download_params->set_offset(GetReceivedBytes()); 1912 download_params->set_offset(GetReceivedBytes());
1912 download_params->set_last_modified(GetLastModifiedTime()); 1913 download_params->set_last_modified(GetLastModifiedTime());
1913 download_params->set_etag(GetETag()); 1914 download_params->set_etag(GetETag());
1914 download_params->set_hash_of_partial_file(hash_); 1915 download_params->set_hash_of_partial_file(hash_);
1915 download_params->set_hash_state(std::move(hash_state_)); 1916 download_params->set_hash_state(std::move(hash_state_));
1916 1917
1918 // Note that resumed downloads disallow redirects. Hence the referrer URL
1919 // (which is the contents of the Referer header for the last download request)
1920 // will only be sent to the URL returned by GetURL().
1921 download_params->set_referrer(
1922 Referrer(GetReferrerUrl(), blink::WebReferrerPolicyAlways));
1923
1917 TransitionTo(RESUMING_INTERNAL); 1924 TransitionTo(RESUMING_INTERNAL);
1918 delegate_->ResumeInterruptedDownload(std::move(download_params), GetId()); 1925 delegate_->ResumeInterruptedDownload(std::move(download_params), GetId());
1919 // Just in case we were interrupted while paused. 1926 // Just in case we were interrupted while paused.
1920 is_paused_ = false; 1927 is_paused_ = false;
1921 } 1928 }
1922 1929
1923 // static 1930 // static
1924 DownloadItem::DownloadState DownloadItemImpl::InternalToExternalState( 1931 DownloadItem::DownloadState DownloadItemImpl::InternalToExternalState(
1925 DownloadInternalState internal_state) { 1932 DownloadInternalState internal_state) {
1926 switch (internal_state) { 1933 switch (internal_state) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 case RESUME_MODE_USER_CONTINUE: 2097 case RESUME_MODE_USER_CONTINUE:
2091 return "USER_CONTINUE"; 2098 return "USER_CONTINUE";
2092 case RESUME_MODE_USER_RESTART: 2099 case RESUME_MODE_USER_RESTART:
2093 return "USER_RESTART"; 2100 return "USER_RESTART";
2094 } 2101 }
2095 NOTREACHED() << "Unknown resume mode " << mode; 2102 NOTREACHED() << "Unknown resume mode " << mode;
2096 return "unknown"; 2103 return "unknown";
2097 } 2104 }
2098 2105
2099 } // namespace content 2106 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_browsertest.cc ('k') | content/public/test/test_download_request_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698