summaryrefslogtreecommitdiff
path: root/chromium/components/download/public
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/download/public')
-rw-r--r--chromium/components/download/public/common/download_create_info.h4
-rw-r--r--chromium/components/download/public/common/download_item.h5
-rw-r--r--chromium/components/download/public/common/download_item_factory.h3
-rw-r--r--chromium/components/download/public/common/download_item_impl.h8
-rw-r--r--chromium/components/download/public/common/download_response_handler.h4
-rw-r--r--chromium/components/download/public/common/mock_download_item.h3
-rw-r--r--chromium/components/download/public/common/mock_download_item_impl.cc1
-rw-r--r--chromium/components/download/public/common/mock_download_item_impl.h3
8 files changed, 30 insertions, 1 deletions
diff --git a/chromium/components/download/public/common/download_create_info.h b/chromium/components/download/public/common/download_create_info.h
index ec793ca4218..a256220b70f 100644
--- a/chromium/components/download/public/common/download_create_info.h
+++ b/chromium/components/download/public/common/download_create_info.h
@@ -27,6 +27,7 @@
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "ui/base/page_transition_types.h"
#include "url/gurl.h"
+#include "url/origin.h"
namespace net {
class HttpResponseHeaders;
@@ -67,6 +68,9 @@ struct COMPONENTS_DOWNLOAD_EXPORT DownloadCreateInfo {
// The referrer URL of the tab that started us.
GURL tab_referrer_url;
+ // The origin of the requester that originally initiated the download.
+ base::Optional<url::Origin> request_initiator;
+
// The time when the download started.
base::Time start_time;
diff --git a/chromium/components/download/public/common/download_item.h b/chromium/components/download/public/common/download_item.h
index 3b5d743ca57..07365431d5d 100644
--- a/chromium/components/download/public/common/download_item.h
+++ b/chromium/components/download/public/common/download_item.h
@@ -26,12 +26,14 @@
#include "base/callback_forward.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
+#include "base/optional.h"
#include "base/strings/string16.h"
#include "base/supports_user_data.h"
#include "components/download/public/common/download_danger_type.h"
#include "components/download/public/common/download_export.h"
#include "components/download/public/common/download_interrupt_reasons.h"
#include "ui/base/page_transition_types.h"
+#include "url/origin.h"
class GURL;
@@ -265,6 +267,9 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItem : public base::SupportsUserData {
// Referrer URL for top level frame.
virtual const GURL& GetTabReferrerUrl() const = 0;
+ // Origin of the original originator of this download, before redirects, etc.
+ virtual const base::Optional<url::Origin>& GetRequestInitiator() const = 0;
+
// For downloads initiated via <a download>, this is the suggested download
// filename from the download attribute.
virtual std::string GetSuggestedFilename() const = 0;
diff --git a/chromium/components/download/public/common/download_item_factory.h b/chromium/components/download/public/common/download_item_factory.h
index 0ceeea52ad6..8453cd85349 100644
--- a/chromium/components/download/public/common/download_item_factory.h
+++ b/chromium/components/download/public/common/download_item_factory.h
@@ -15,8 +15,10 @@
#include <string>
#include <vector>
+#include "base/optional.h"
#include "components/download/public/common/download_export.h"
#include "components/download/public/common/download_item.h"
+#include "url/origin.h"
class GURL;
@@ -46,6 +48,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemFactory {
const GURL& site_url,
const GURL& tab_url,
const GURL& tab_refererr_url,
+ const base::Optional<url::Origin>& initiator_origin,
const std::string& mime_type,
const std::string& original_mime_type,
base::Time start_time,
diff --git a/chromium/components/download/public/common/download_item_impl.h b/chromium/components/download/public/common/download_item_impl.h
index 4ede432f44f..c704ecc629c 100644
--- a/chromium/components/download/public/common/download_item_impl.h
+++ b/chromium/components/download/public/common/download_item_impl.h
@@ -16,6 +16,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
+#include "base/optional.h"
#include "base/threading/thread_checker_impl.h"
#include "base/time/time.h"
#include "components/download/public/common/download_create_info.h"
@@ -27,6 +28,7 @@
#include "components/download/public/common/download_url_parameters.h"
#include "components/download/public/common/resume_mode.h"
#include "url/gurl.h"
+#include "url/origin.h"
namespace net {
class URLRequestContextGetter;
@@ -53,6 +55,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImpl
const GURL& site_url,
const GURL& tab_url,
const GURL& tab_referrer_url,
+ const base::Optional<url::Origin>& request_initiator,
const std::string& suggested_filename,
const base::FilePath& forced_file_path,
ui::PageTransition transition_type,
@@ -79,6 +82,9 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImpl
// The URL of the referrer of the tab that initiated the download.
GURL tab_referrer_url;
+ // The origin of the requester that originally initiated the download.
+ base::Optional<url::Origin> request_initiator;
+
// Filename suggestion from DownloadSaveInfo. It could, among others, be the
// suggested filename in 'download' attribute of an anchor. Details:
// http://www.whatwg.org/specs/web-apps/current-work/#downloading-hyperlinks
@@ -169,6 +175,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImpl
const GURL& site_url,
const GURL& tab_url,
const GURL& tab_referrer_url,
+ const base::Optional<url::Origin>& request_initiator,
const std::string& mime_type,
const std::string& original_mime_type,
base::Time start_time,
@@ -238,6 +245,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImpl
const GURL& GetSiteUrl() const override;
const GURL& GetTabUrl() const override;
const GURL& GetTabReferrerUrl() const override;
+ const base::Optional<url::Origin>& GetRequestInitiator() const override;
std::string GetSuggestedFilename() const override;
const scoped_refptr<const net::HttpResponseHeaders>& GetResponseHeaders()
const override;
diff --git a/chromium/components/download/public/common/download_response_handler.h b/chromium/components/download/public/common/download_response_handler.h
index b0967deba49..caaab574b06 100644
--- a/chromium/components/download/public/common/download_response_handler.h
+++ b/chromium/components/download/public/common/download_response_handler.h
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "base/optional.h"
#include "components/download/public/common/download_create_info.h"
#include "components/download/public/common/download_export.h"
#include "components/download/public/common/download_source.h"
@@ -17,6 +18,7 @@
#include "net/cert/cert_status_flags.h"
#include "services/network/public/cpp/resource_response.h"
#include "services/network/public/mojom/url_loader.mojom.h"
+#include "url/origin.h"
namespace download {
@@ -94,7 +96,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadResponseHandler
DownloadSource download_source_;
net::CertStatus cert_status_;
bool has_strong_validators_;
- GURL origin_;
+ base::Optional<url::Origin> request_initiator_;
bool is_partial_request_;
bool completed_;
diff --git a/chromium/components/download/public/common/mock_download_item.h b/chromium/components/download/public/common/mock_download_item.h
index 5bc0b0a37fd..36d8d0fa2b9 100644
--- a/chromium/components/download/public/common/mock_download_item.h
+++ b/chromium/components/download/public/common/mock_download_item.h
@@ -12,11 +12,13 @@
#include "base/callback.h"
#include "base/observer_list.h"
+#include "base/optional.h"
#include "base/time/time.h"
#include "components/download/public/common/download_interrupt_reasons.h"
#include "components/download/public/common/download_item.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "url/gurl.h"
+#include "url/origin.h"
namespace download {
@@ -65,6 +67,7 @@ class MockDownloadItem : public DownloadItem {
MOCK_CONST_METHOD0(GetSiteUrl, const GURL&());
MOCK_CONST_METHOD0(GetTabUrl, const GURL&());
MOCK_CONST_METHOD0(GetTabReferrerUrl, const GURL&());
+ MOCK_CONST_METHOD0(GetRequestInitiator, const base::Optional<url::Origin>&());
MOCK_CONST_METHOD0(GetSuggestedFilename, std::string());
MOCK_CONST_METHOD0(GetContentDisposition, std::string());
MOCK_CONST_METHOD0(GetResponseHeaders,
diff --git a/chromium/components/download/public/common/mock_download_item_impl.cc b/chromium/components/download/public/common/mock_download_item_impl.cc
index 5282defc5f2..05b6a9117fc 100644
--- a/chromium/components/download/public/common/mock_download_item_impl.cc
+++ b/chromium/components/download/public/common/mock_download_item_impl.cc
@@ -17,6 +17,7 @@ MockDownloadItemImpl::MockDownloadItemImpl(DownloadItemImplDelegate* delegate)
GURL(),
GURL(),
GURL(),
+ url::Origin(),
"application/octet-stream",
"application/octet-stream",
base::Time(),
diff --git a/chromium/components/download/public/common/mock_download_item_impl.h b/chromium/components/download/public/common/mock_download_item_impl.h
index 7bbb9589d24..612485d1f7b 100644
--- a/chromium/components/download/public/common/mock_download_item_impl.h
+++ b/chromium/components/download/public/common/mock_download_item_impl.h
@@ -10,11 +10,13 @@
#include <vector>
#include "base/macros.h"
+#include "base/optional.h"
#include "components/download/public/common/download_create_info.h"
#include "components/download/public/common/download_file.h"
#include "components/download/public/common/download_item_impl.h"
#include "components/download/public/common/download_request_handle_interface.h"
#include "testing/gmock/include/gmock/gmock.h"
+#include "url/origin.h"
namespace download {
@@ -81,6 +83,7 @@ class MockDownloadItemImpl : public DownloadItemImpl {
MOCK_CONST_METHOD0(GetReferrerUrl, const GURL&());
MOCK_CONST_METHOD0(GetTabUrl, const GURL&());
MOCK_CONST_METHOD0(GetTabReferrerUrl, const GURL&());
+ MOCK_CONST_METHOD0(GetRequestInitiator, const base::Optional<url::Origin>&());
MOCK_CONST_METHOD0(GetSuggestedFilename, std::string());
MOCK_CONST_METHOD0(GetContentDisposition, std::string());
MOCK_CONST_METHOD0(GetMimeType, std::string());