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/background_service/download_metadata.h4
-rw-r--r--chromium/components/download/public/common/BUILD.gn3
-rw-r--r--chromium/components/download/public/common/base_file.h2
-rw-r--r--chromium/components/download/public/common/download_create_info.h8
-rw-r--r--chromium/components/download/public/common/download_features.cc10
-rw-r--r--chromium/components/download/public/common/download_features.h2
-rw-r--r--chromium/components/download/public/common/download_file.h4
-rw-r--r--chromium/components/download/public/common/download_file_impl.h8
-rw-r--r--chromium/components/download/public/common/download_item.h12
-rw-r--r--chromium/components/download/public/common/download_item_factory.h2
-rw-r--r--chromium/components/download/public/common/download_item_impl.h17
-rw-r--r--chromium/components/download/public/common/download_item_impl_delegate.h2
-rw-r--r--chromium/components/download/public/common/download_response_handler.h5
-rw-r--r--chromium/components/download/public/common/download_stats.h8
-rw-r--r--chromium/components/download/public/common/in_progress_download_manager.h13
-rw-r--r--chromium/components/download/public/common/mock_download_file.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.cc2
-rw-r--r--chromium/components/download/public/common/storage_partition_config.cc59
-rw-r--r--chromium/components/download/public/common/storage_partition_config.h50
-rw-r--r--chromium/components/download/public/common/storage_partition_config_unittest.cc99
21 files changed, 63 insertions, 254 deletions
diff --git a/chromium/components/download/public/background_service/download_metadata.h b/chromium/components/download/public/background_service/download_metadata.h
index 1f313cc4fc9..b2db90238c8 100644
--- a/chromium/components/download/public/background_service/download_metadata.h
+++ b/chromium/components/download/public/background_service/download_metadata.h
@@ -14,7 +14,7 @@
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
-#if !defined(OS_IOS)
+#if !BUILDFLAG(IS_IOS)
#include "storage/browser/blob/blob_data_handle.h"
#endif
@@ -26,7 +26,7 @@ struct CompletionInfo {
// to retrieve data.
base::FilePath path;
-#if !defined(OS_IOS)
+#if !BUILDFLAG(IS_IOS)
// The blob data handle that contains download data.
// Will be available after the download is completed in incognito mode.
absl::optional<storage::BlobDataHandle> blob_handle;
diff --git a/chromium/components/download/public/common/BUILD.gn b/chromium/components/download/public/common/BUILD.gn
index f79fbdc8e8d..b1881d51cc3 100644
--- a/chromium/components/download/public/common/BUILD.gn
+++ b/chromium/components/download/public/common/BUILD.gn
@@ -64,8 +64,6 @@ component("public") {
"resume_mode.h",
"simple_download_manager.h",
"simple_download_manager_coordinator.h",
- "storage_partition_config.cc",
- "storage_partition_config.h",
"stream_handle_input_stream.h",
"url_download_handler_factory.h",
"url_download_request_handle.h",
@@ -180,7 +178,6 @@ source_set("unit_tests") {
sources = [
"auto_resumption_handler_unittest.cc",
"download_schedule_unittest.cc",
- "storage_partition_config_unittest.cc",
]
deps = [
diff --git a/chromium/components/download/public/common/base_file.h b/chromium/components/download/public/common/base_file.h
index c577ee8d2ae..3d747c981bf 100644
--- a/chromium/components/download/public/common/base_file.h
+++ b/chromium/components/download/public/common/base_file.h
@@ -172,7 +172,7 @@ class COMPONENTS_DOWNLOAD_EXPORT BaseFile {
mojo::PendingRemote<quarantine::mojom::Quarantine> remote_quarantine,
OnAnnotationDoneCallback on_annotation_done_callback);
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
// Publishes the intermediate download to public download collection.
DownloadInterruptReason PublishDownload();
#endif
diff --git a/chromium/components/download/public/common/download_create_info.h b/chromium/components/download/public/common/download_create_info.h
index 36c85afc292..ab845bf75d6 100644
--- a/chromium/components/download/public/common/download_create_info.h
+++ b/chromium/components/download/public/common/download_create_info.h
@@ -70,8 +70,9 @@ struct COMPONENTS_DOWNLOAD_EXPORT DownloadCreateInfo {
GURL referrer_url;
net::ReferrerPolicy referrer_policy;
- // Site URL for the site instance that initiated the download.
- GURL site_url;
+ // The serialized embedder download data for the site instance that initiated
+ // the download.
+ std::string serialized_embedder_download_data;
// The URL of the tab that started us.
GURL tab_url;
@@ -101,6 +102,9 @@ struct COMPONENTS_DOWNLOAD_EXPORT DownloadCreateInfo {
// short-lived and is not shown in the UI.
bool transient;
+ // Whether this download requires safety checks.
+ bool require_safety_checks;
+
absl::optional<ui::PageTransition> transition_type;
// The HTTP response headers. This contains a nullptr when the response has
diff --git a/chromium/components/download/public/common/download_features.cc b/chromium/components/download/public/common/download_features.cc
index 5a8eda50fa6..9610df2af6c 100644
--- a/chromium/components/download/public/common/download_features.cc
+++ b/chromium/components/download/public/common/download_features.cc
@@ -14,7 +14,7 @@ const base::Feature kUseDownloadOfflineContentProvider{
const base::Feature kDownloadAutoResumptionNative {
"DownloadsAutoResumptionNative",
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
@@ -23,7 +23,7 @@ const base::Feature kDownloadAutoResumptionNative {
const base::Feature kParallelDownloading {
"ParallelDownloading",
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
@@ -33,7 +33,7 @@ const base::Feature kParallelDownloading {
const base::Feature kDownloadLater{"DownloadLater",
base::FEATURE_DISABLED_BY_DEFAULT};
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
const base::Feature kSmartSuggestionForLargeDownloads{
"SmartSuggestionForLargeDownloads", base::FEATURE_DISABLED_BY_DEFAULT};
@@ -47,7 +47,7 @@ const base::Feature kUseInProgressDownloadManagerForDownloadService{
const base::Feature kAllowDownloadResumptionWithoutStrongValidators{
"AllowDownloadResumptionWithoutStrongValidators",
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
@@ -76,7 +76,7 @@ const base::Feature kIncognitoDownloadsWarning{
"IncognitoDownloadsWarning", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kDownloadRange{"DownloadRange",
- base::FEATURE_DISABLED_BY_DEFAULT};
+ base::FEATURE_ENABLED_BY_DEFAULT};
} // namespace features
diff --git a/chromium/components/download/public/common/download_features.h b/chromium/components/download/public/common/download_features.h
index 0a98283b87a..72388eedc0f 100644
--- a/chromium/components/download/public/common/download_features.h
+++ b/chromium/components/download/public/common/download_features.h
@@ -34,7 +34,7 @@ COMPONENTS_DOWNLOAD_EXPORT extern const base::Feature kParallelDownloading;
// Whether to enable download later feature.
COMPONENTS_DOWNLOAD_EXPORT extern const base::Feature kDownloadLater;
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
// Whether download expiration date will be refreshed on resumption.
COMPONENTS_DOWNLOAD_EXPORT extern const base::Feature kRefreshExpirationDate;
diff --git a/chromium/components/download/public/common/download_file.h b/chromium/components/download/public/common/download_file.h
index a10a77ff667..e6cb459ee19 100644
--- a/chromium/components/download/public/common/download_file.h
+++ b/chromium/components/download/public/common/download_file.h
@@ -114,7 +114,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadFile {
virtual void Pause() = 0;
virtual void Resume() = 0;
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
// Renames the download file to an intermediate URI. If current_path is a
// content URI, it will be used for the renaming. Otherwise, A new
// intermediate URI will be created to write the download file. Once
@@ -132,7 +132,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadFile {
// Returns the suggested file path from the system.
virtual base::FilePath GetDisplayName() = 0;
-#endif // defined(OS_ANDROID)
+#endif // BUILDFLAG(IS_ANDROID)
};
} // namespace download
diff --git a/chromium/components/download/public/common/download_file_impl.h b/chromium/components/download/public/common/download_file_impl.h
index c0b63332324..d7932701275 100644
--- a/chromium/components/download/public/common/download_file_impl.h
+++ b/chromium/components/download/public/common/download_file_impl.h
@@ -79,7 +79,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadFileImpl : public DownloadFile {
void Pause() override;
void Resume() override;
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
void RenameToIntermediateUri(const GURL& original_url,
const GURL& referrer_url,
const base::FilePath& file_name,
@@ -88,7 +88,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadFileImpl : public DownloadFile {
RenameCompletionCallback callback) override;
void PublishDownload(RenameCompletionCallback callback) override;
base::FilePath GetDisplayName() override;
-#endif // defined(OS_ANDROID)
+#endif // BUILDFLAG(IS_ANDROID)
// Wrapper of a ByteStreamReader or ScopedDataPipeConsumerHandle, and the meta
// data needed to write to a slice of the target file.
@@ -387,9 +387,9 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadFileImpl : public DownloadFile {
// TaskRunner this object lives on after initialization.
scoped_refptr<base::SequencedTaskRunner> task_runner_;
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
base::FilePath display_name_;
-#endif // defined(OS_ANDROID)
+#endif // BUILDFLAG(IS_ANDROID)
SEQUENCE_CHECKER(sequence_checker_);
diff --git a/chromium/components/download/public/common/download_item.h b/chromium/components/download/public/common/download_item.h
index b59a486d4c5..f7b65b6f442 100644
--- a/chromium/components/download/public/common/download_item.h
+++ b/chromium/components/download/public/common/download_item.h
@@ -299,10 +299,10 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItem : public base::SupportsUserData {
// URL of document that is considered the referrer for the original URL.
virtual const GURL& GetReferrerUrl() const = 0;
- // Site instance URL. Used to locate the correct storage partition during
- // subsequent browser sessions. This may be different from all of
- // GetOriginalUrl(), GetURL() and GetReferrerUrl().
- virtual const GURL& GetSiteUrl() const = 0;
+ // The serialized EmbedderDownloadData string. This is used by the embedder
+ // for placing extra download data, such as the appropriate storage partition
+ // for this download.
+ virtual const std::string& GetSerializedEmbedderDownloadData() const = 0;
// URL of the top level frame at the time the download was initiated.
virtual const GURL& GetTabUrl() const = 0;
@@ -531,6 +531,10 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItem : public base::SupportsUserData {
// for target file path determination.
virtual bool IsTransient() const = 0;
+ // Returns whether the download requires safety checks. Only downloads
+ // triggered by Chrome itself are excluded from safety checks.
+ virtual bool RequireSafetyChecks() const = 0;
+
// Returns whether the download item corresponds to a parallel download. This
// usually means parallel download has been enabled and the download job is
// parallelizable.
diff --git a/chromium/components/download/public/common/download_item_factory.h b/chromium/components/download/public/common/download_item_factory.h
index d50e2b3f792..7de423c77fe 100644
--- a/chromium/components/download/public/common/download_item_factory.h
+++ b/chromium/components/download/public/common/download_item_factory.h
@@ -45,7 +45,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemFactory {
const base::FilePath& target_path,
const std::vector<GURL>& url_chain,
const GURL& referrer_url,
- const GURL& site_url,
+ const std::string& serialized_embedder_data,
const GURL& tab_url,
const GURL& tab_refererr_url,
const absl::optional<url::Origin>& initiator_origin,
diff --git a/chromium/components/download/public/common/download_item_impl.h b/chromium/components/download/public/common/download_item_impl.h
index 8b9118a9ca2..88a52cb2bbf 100644
--- a/chromium/components/download/public/common/download_item_impl.h
+++ b/chromium/components/download/public/common/download_item_impl.h
@@ -53,7 +53,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImpl
struct COMPONENTS_DOWNLOAD_EXPORT RequestInfo {
RequestInfo(const std::vector<GURL>& url_chain,
const GURL& referrer_url,
- const GURL& site_url,
+ const std::string& serialized_embedder_download_data,
const GURL& tab_url,
const GURL& tab_referrer_url,
const absl::optional<url::Origin>& request_initiator,
@@ -78,8 +78,11 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImpl
// The URL of the page that initiated the download.
GURL referrer_url;
- // Site URL for the site instance that initiated this download.
- GURL site_url;
+ // The serialized embedder download data for the site instance that
+ // initiated this download. The embedder can use this field to add
+ // additional information about the download, such as the
+ // StoragePartitionConfig that pertains to it.
+ std::string serialized_embedder_download_data;
// The URL of the tab that initiated the download.
GURL tab_url;
@@ -191,7 +194,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImpl
const base::FilePath& target_path,
const std::vector<GURL>& url_chain,
const GURL& referrer_url,
- const GURL& site_url,
+ const std::string& serialized_embedder_download_data,
const GURL& tab_url,
const GURL& tab_referrer_url,
const absl::optional<url::Origin>& request_initiator,
@@ -272,7 +275,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImpl
const std::vector<GURL>& GetUrlChain() const override;
const GURL& GetOriginalUrl() const override;
const GURL& GetReferrerUrl() const override;
- const GURL& GetSiteUrl() const override;
+ const std::string& GetSerializedEmbedderDownloadData() const override;
const GURL& GetTabUrl() const override;
const GURL& GetTabReferrerUrl() const override;
const absl::optional<url::Origin>& GetRequestInitiator() const override;
@@ -325,6 +328,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImpl
bool GetOpened() const override;
base::Time GetLastAccessTime() const override;
bool IsTransient() const override;
+ bool RequireSafetyChecks() const override;
bool IsParallelDownload() const override;
DownloadCreationType GetDownloadCreationType() const override;
const absl::optional<DownloadSchedule>& GetDownloadSchedule() const override;
@@ -832,6 +836,9 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImpl
// Whether the download item should be transient and not shown in the UI.
bool transient_ = false;
+ // Whether the download requires safe browsing check.
+ bool require_safety_checks_ = true;
+
// Did the delegate delay calling Complete on this download?
bool delegate_delayed_complete_ = false;
diff --git a/chromium/components/download/public/common/download_item_impl_delegate.h b/chromium/components/download/public/common/download_item_impl_delegate.h
index 3f7124e36c9..87da60ee9fb 100644
--- a/chromium/components/download/public/common/download_item_impl_delegate.h
+++ b/chromium/components/download/public/common/download_item_impl_delegate.h
@@ -96,7 +96,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadItemImplDelegate {
// Called when an interrupted download is resumed.
virtual void ResumeInterruptedDownload(
std::unique_ptr<DownloadUrlParameters> params,
- const GURL& site_url);
+ const std::string& serialized_embedder_data);
// Update the persistent store with our information.
virtual void UpdatePersistence(DownloadItemImpl* download);
diff --git a/chromium/components/download/public/common/download_response_handler.h b/chromium/components/download/public/common/download_response_handler.h
index 76bc7af8f04..d56dad69b1a 100644
--- a/chromium/components/download/public/common/download_response_handler.h
+++ b/chromium/components/download/public/common/download_response_handler.h
@@ -55,6 +55,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadResponseHandler
const DownloadUrlParameters::RequestHeadersType& request_headers,
const std::string& request_origin,
DownloadSource download_source,
+ bool require_safety_checks,
std::vector<GURL> url_chain,
bool is_background_mode);
@@ -65,7 +66,8 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadResponseHandler
// network::mojom::URLLoaderClient
void OnReceiveEarlyHints(network::mojom::EarlyHintsPtr early_hints) override;
- void OnReceiveResponse(network::mojom::URLResponseHeadPtr head) override;
+ void OnReceiveResponse(network::mojom::URLResponseHeadPtr head,
+ mojo::ScopedDataPipeConsumerHandle body) override;
void OnReceiveRedirect(const net::RedirectInfo& redirect_info,
network::mojom::URLResponseHeadPtr head) override;
void OnUploadProgress(int64_t current_position,
@@ -110,6 +112,7 @@ class COMPONENTS_DOWNLOAD_EXPORT DownloadResponseHandler
absl::optional<net::IsolationInfo> isolation_info_;
bool is_partial_request_;
bool completed_;
+ bool require_safety_checks_;
// The abort reason if this class decides to block the download.
DownloadInterruptReason abort_reason_;
diff --git a/chromium/components/download/public/common/download_stats.h b/chromium/components/download/public/common/download_stats.h
index abd47345c25..80d432369db 100644
--- a/chromium/components/download/public/common/download_stats.h
+++ b/chromium/components/download/public/common/download_stats.h
@@ -370,7 +370,7 @@ COMPONENTS_DOWNLOAD_EXPORT void RecordParallelRequestCreationFailure(
COMPONENTS_DOWNLOAD_EXPORT void RecordDownloadLaterEvent(
DownloadLaterEvent event);
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
enum class BackgroudTargetDeterminationResultTypes {
// Target determination succeeded.
kSuccess = 0,
@@ -388,12 +388,12 @@ enum class BackgroudTargetDeterminationResultTypes {
// reduced mode.
COMPONENTS_DOWNLOAD_EXPORT void RecordBackgroundTargetDeterminationResult(
BackgroudTargetDeterminationResultTypes type);
-#endif // defined(OS_ANDROID)
+#endif // BUILDFLAG(IS_ANDROID)
-#if defined(OS_WIN)
+#if BUILDFLAG(IS_WIN)
// Records the OS error code when moving a file on Windows.
COMPONENTS_DOWNLOAD_EXPORT void RecordWinFileMoveError(int os_error);
-#endif // defined(OS_WIN)
+#endif // BUILDFLAG(IS_WIN)
} // namespace download
#endif // COMPONENTS_DOWNLOAD_PUBLIC_COMMON_DOWNLOAD_STATS_H_
diff --git a/chromium/components/download/public/common/in_progress_download_manager.h b/chromium/components/download/public/common/in_progress_download_manager.h
index 1e5b4fe70c8..eab50360526 100644
--- a/chromium/components/download/public/common/in_progress_download_manager.h
+++ b/chromium/components/download/public/common/in_progress_download_manager.h
@@ -111,7 +111,7 @@ class COMPONENTS_DOWNLOAD_EXPORT InProgressDownloadManager
std::unique_ptr<network::PendingSharedURLLoaderFactory>
pending_url_loader_factory,
bool is_new_download,
- const GURL& site_url,
+ const std::string& serialized_embedder_download_data,
const GURL& tab_url,
const GURL& tab_referrer_url);
@@ -120,7 +120,7 @@ class COMPONENTS_DOWNLOAD_EXPORT InProgressDownloadManager
std::unique_ptr<network::ResourceRequest> resource_request,
int render_process_id,
int render_frame_id,
- const GURL& site_url,
+ const std::string& serialized_embedder_download_data,
const GURL& tab_url,
const GURL& tab_referrer_url,
std::vector<GURL> url_chain,
@@ -144,8 +144,9 @@ class COMPONENTS_DOWNLOAD_EXPORT InProgressDownloadManager
// DownloadItemImplDelegate implementations.
void DetermineDownloadTarget(DownloadItemImpl* download,
DownloadTargetCallback callback) override;
- void ResumeInterruptedDownload(std::unique_ptr<DownloadUrlParameters> params,
- const GURL& site_url) override;
+ void ResumeInterruptedDownload(
+ std::unique_ptr<DownloadUrlParameters> params,
+ const std::string& serialized_embedder_download_data) override;
bool ShouldOpenDownload(DownloadItemImpl* item,
ShouldOpenDownloadCallback callback) override;
void ReportBytesWasted(DownloadItemImpl* download) override;
@@ -157,7 +158,7 @@ class COMPONENTS_DOWNLOAD_EXPORT InProgressDownloadManager
download_start_observer_ = observer;
}
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
// Callback to generate an intermediate file path from the given target file
// path;
using IntermediatePathCallback =
@@ -275,7 +276,7 @@ class COMPONENTS_DOWNLOAD_EXPORT InProgressDownloadManager
// callback to check if an origin is secure.
IsOriginSecureCallback is_origin_secure_cb_;
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
// Callback to generate the intermediate file path.
IntermediatePathCallback intermediate_path_cb_;
diff --git a/chromium/components/download/public/common/mock_download_file.h b/chromium/components/download/public/common/mock_download_file.h
index 17c9711e89e..81ca131356d 100644
--- a/chromium/components/download/public/common/mock_download_file.h
+++ b/chromium/components/download/public/common/mock_download_file.h
@@ -69,7 +69,7 @@ class MockDownloadFile : public DownloadFile {
MOCK_CONST_METHOD0(DebugString, std::string());
MOCK_METHOD0(Pause, void());
MOCK_METHOD0(Resume, void());
-#if defined(OS_ANDROID)
+#if BUILDFLAG(IS_ANDROID)
MOCK_METHOD6(RenameToIntermediateUri,
void(const GURL& original_url,
const GURL& referrer_url,
@@ -79,7 +79,7 @@ class MockDownloadFile : public DownloadFile {
RenameCompletionCallback callback));
MOCK_METHOD1(PublishDownload, void(RenameCompletionCallback callback));
MOCK_METHOD0(GetDisplayName, base::FilePath());
-#endif // defined(OS_ANDROID)
+#endif // BUILDFLAG(IS_ANDROID)
};
} // namespace download
diff --git a/chromium/components/download/public/common/mock_download_item.h b/chromium/components/download/public/common/mock_download_item.h
index c0b0357eeca..4e45bf86ab8 100644
--- a/chromium/components/download/public/common/mock_download_item.h
+++ b/chromium/components/download/public/common/mock_download_item.h
@@ -69,7 +69,7 @@ class MockDownloadItem : public DownloadItem {
MOCK_CONST_METHOD0(GetUrlChain, const std::vector<GURL>&());
MOCK_CONST_METHOD0(GetOriginalUrl, const GURL&());
MOCK_CONST_METHOD0(GetReferrerUrl, const GURL&());
- MOCK_CONST_METHOD0(GetSiteUrl, const GURL&());
+ MOCK_CONST_METHOD0(GetSerializedEmbedderDownloadData, const std::string&());
MOCK_CONST_METHOD0(GetTabUrl, const GURL&());
MOCK_CONST_METHOD0(GetTabReferrerUrl, const GURL&());
MOCK_CONST_METHOD0(GetRequestInitiator, const absl::optional<url::Origin>&());
@@ -130,6 +130,7 @@ class MockDownloadItem : public DownloadItem {
MOCK_CONST_METHOD0(GetOpened, bool());
MOCK_CONST_METHOD0(GetLastAccessTime, base::Time());
MOCK_CONST_METHOD0(IsTransient, bool());
+ MOCK_CONST_METHOD0(RequireSafetyChecks, bool());
MOCK_CONST_METHOD0(IsParallelDownload, bool());
MOCK_CONST_METHOD0(GetDownloadCreationType, DownloadCreationType());
MOCK_CONST_METHOD0(GetDownloadSchedule,
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 08aaf11e86b..f929a37fc05 100644
--- a/chromium/components/download/public/common/mock_download_item_impl.cc
+++ b/chromium/components/download/public/common/mock_download_item_impl.cc
@@ -14,7 +14,7 @@ MockDownloadItemImpl::MockDownloadItemImpl(DownloadItemImplDelegate* delegate)
base::FilePath(),
std::vector<GURL>(),
GURL(),
- GURL(),
+ std::string(),
GURL(),
GURL(),
url::Origin(),
diff --git a/chromium/components/download/public/common/storage_partition_config.cc b/chromium/components/download/public/common/storage_partition_config.cc
deleted file mode 100644
index 293e6f1aa92..00000000000
--- a/chromium/components/download/public/common/storage_partition_config.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2021 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/download/public/common/storage_partition_config.h"
-
-#include "base/strings/string_split.h"
-
-namespace download {
-
-namespace {
-static const char* kDelimiter = "|";
-static const char* kInMemorySetValue = "in_memory";
-} // namespace
-
-StoragePartitionConfig::StoragePartitionConfig(
- const std::string& partition_domain,
- const std::string& partition_name,
- bool in_memory)
- : partition_domain_(partition_domain),
- partition_name_(partition_name),
- in_memory_(in_memory) {
- DCHECK(partition_domain_.find(kDelimiter) == std::string::npos);
- DCHECK(partition_name.find(kDelimiter) == std::string::npos);
-}
-
-bool StoragePartitionConfig::operator==(
- const StoragePartitionConfig& rhs) const {
- return partition_domain_ == rhs.partition_domain_ &&
- partition_name_ == rhs.partition_name_ && in_memory_ == rhs.in_memory_;
-}
-
-bool StoragePartitionConfig::operator!=(
- const StoragePartitionConfig& rhs) const {
- return !(*this == rhs);
-}
-
-std::string StoragePartitionConfig::SerializeToString() {
- return partition_domain_ + kDelimiter + partition_name_ + kDelimiter +
- (in_memory_ ? kInMemorySetValue : "");
-}
-
-// static
-StoragePartitionConfig StoragePartitionConfig::DeserializeFromString(
- const std::string& str) {
- std::vector<std::string> fields = base::SplitString(
- str, kDelimiter, base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
-
- if (fields.size() != 3)
- return StoragePartitionConfig();
-
- std::string partition_domain = fields[0];
- std::string partition_name = fields[1];
- bool in_memory = fields[2] == kInMemorySetValue;
-
- return StoragePartitionConfig(partition_domain, partition_name, in_memory);
-}
-
-} // namespace download
diff --git a/chromium/components/download/public/common/storage_partition_config.h b/chromium/components/download/public/common/storage_partition_config.h
deleted file mode 100644
index b944a282b89..00000000000
--- a/chromium/components/download/public/common/storage_partition_config.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2021 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPONENTS_DOWNLOAD_PUBLIC_COMMON_STORAGE_PARTITION_CONFIG_H_
-#define COMPONENTS_DOWNLOAD_PUBLIC_COMMON_STORAGE_PARTITION_CONFIG_H_
-
-#include <string>
-
-#include "components/download/public/common/download_export.h"
-
-namespace download {
-
-// This class represents a content::StoragePartitionConfig that can be within
-// components/download. It contains methods for serializing the
-// StoragePartitionConfig for storage in the downloads table and to deserialize
-// from storage back into this class. It also enables the configs to be compared
-// to each other.
-class COMPONENTS_DOWNLOAD_EXPORT StoragePartitionConfig {
- public:
- StoragePartitionConfig() = default;
- StoragePartitionConfig(const std::string& partition_domain,
- const std::string& partition_name,
- bool in_memory);
-
- StoragePartitionConfig(const StoragePartitionConfig& rhs) = default;
- StoragePartitionConfig& operator=(const StoragePartitionConfig& rhs) =
- default;
-
- bool operator==(const StoragePartitionConfig& rhs) const;
- bool operator!=(const StoragePartitionConfig& rhs) const;
-
- // Serialize and Deserialize methods to store the StoragePartitionConfig in
- // the DownloadDatabase.
- std::string SerializeToString();
- static StoragePartitionConfig DeserializeFromString(const std::string& str);
-
- std::string partition_domain() const { return partition_domain_; }
- std::string partition_name() const { return partition_name_; }
- bool in_memory() const { return in_memory_; }
-
- private:
- std::string partition_domain_;
- std::string partition_name_;
- bool in_memory_;
-};
-
-} // namespace download
-
-#endif // COMPONENTS_DOWNLOAD_PUBLIC_COMMON_STORAGE_PARTITION_CONFIG_H_
diff --git a/chromium/components/download/public/common/storage_partition_config_unittest.cc b/chromium/components/download/public/common/storage_partition_config_unittest.cc
deleted file mode 100644
index 07262685773..00000000000
--- a/chromium/components/download/public/common/storage_partition_config_unittest.cc
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2021 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/download/public/common/storage_partition_config.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace download {
-
-TEST(StoragePartitionConfigTest, EqualityOperators) {
- StoragePartitionConfig c1(std::string(), std::string(), false);
- StoragePartitionConfig c2(std::string(), std::string(), true);
- StoragePartitionConfig c3("a", std::string(), true);
- StoragePartitionConfig c4("b", std::string(), true);
- StoragePartitionConfig c5(std::string(), "abc", false);
- StoragePartitionConfig c6(std::string(), "abc", true);
- StoragePartitionConfig c7("a", "abc", true);
- StoragePartitionConfig c8("a", "abc", true);
-
- EXPECT_FALSE(c1 == c2);
- EXPECT_FALSE(c1 == c8);
- EXPECT_FALSE(c2 == c8);
- EXPECT_FALSE(c3 == c4);
- EXPECT_FALSE(c3 == c8);
- EXPECT_FALSE(c4 == c8);
- EXPECT_FALSE(c5 == c6);
- EXPECT_FALSE(c5 == c8);
- EXPECT_FALSE(c6 == c8);
- EXPECT_TRUE(c7 == c8);
- EXPECT_TRUE(c8 == c8);
-}
-
-TEST(StoragePartitionConfigTest, SerializeToString) {
- // Check that all of the config's values are serialized properly.
- StoragePartitionConfig c1("a", "abc", true);
- auto c1_str = c1.SerializeToString();
- EXPECT_EQ(c1_str, std::string("a|abc|in_memory"));
-
- // Check that "in_memory" is not set if the value is false.
- StoragePartitionConfig c2("b", "xyz", false);
- auto c2_str = c2.SerializeToString();
- EXPECT_EQ(c2_str, std::string("b|xyz|"));
-
- // Check that the partition domain is not set if the value is empty.
- StoragePartitionConfig c3("", "def", true);
- auto c3_str = c3.SerializeToString();
- EXPECT_EQ(c3_str, std::string("|def|in_memory"));
-
- // Check that the partition name is not set if the value is empty.
- StoragePartitionConfig c4("uvw", "", false);
- auto c4_str = c4.SerializeToString();
- EXPECT_EQ(c4_str, std::string("uvw||"));
-
- // Check that no values are set if the values are empty or false.
- StoragePartitionConfig c5("", "", false);
- auto c5_str = c5.SerializeToString();
- EXPECT_EQ(c5_str, std::string("||"));
-}
-
-TEST(StoragePartitionConfigTest, DeserializeFromString) {
- // Check that all of the values are deserialized properly into the config.
- std::string c1_str = "a|abc|in_memory";
- StoragePartitionConfig expected_c1("a", "abc", true);
- EXPECT_EQ(StoragePartitionConfig::DeserializeFromString(c1_str), expected_c1);
-
- // Check that deserialization is correct if in memory is missing.
- std::string c2_str = "b|xyz|";
- StoragePartitionConfig expected_c2("b", "xyz", false);
- EXPECT_EQ(StoragePartitionConfig::DeserializeFromString(c2_str), expected_c2);
-
- // Check that deserialization is correct if partition domain is missing.
- std::string c3_str = "|def|in_memory";
- StoragePartitionConfig expected_c3("", "def", true);
- EXPECT_EQ(StoragePartitionConfig::DeserializeFromString(c3_str), expected_c3);
-
- // Check that deserialization is correct if partition name is missing.
- std::string c4_str = "uvw||";
- StoragePartitionConfig expected_c4("uvw", "", false);
- EXPECT_EQ(StoragePartitionConfig::DeserializeFromString(c4_str), expected_c4);
-
- std::string empty_str = "";
- StoragePartitionConfig expected_c5("", "", false);
- EXPECT_EQ(StoragePartitionConfig::DeserializeFromString(empty_str),
- expected_c5);
-
- std::string invalid_value_str = "a|abc|invalid";
- StoragePartitionConfig expected_c6("a", "abc", false);
- EXPECT_EQ(StoragePartitionConfig::DeserializeFromString(invalid_value_str),
- expected_c6);
-
- std::string too_many_delimiters_str = "a|abc|in_memory|extra|delimiters";
- StoragePartitionConfig expected_c7("", "", false);
- EXPECT_EQ(
- StoragePartitionConfig::DeserializeFromString(too_many_delimiters_str),
- expected_c7);
-}
-
-} // namespace download