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

Unified Diff: chrome/browser/download/chrome_download_manager_delegate.cc

Issue 2060923002: Neutralize dangerous subresource files during Save Page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@save-package-cleanup-1
Patch Set: Catch up with ToT Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/chrome_download_manager_delegate.cc
diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc
index e36ed85f7feedd7ba9b28d3fccf2de0386ed8712..c3aa96086756d847e1c5d6509157a4893bb51e3e 100644
--- a/chrome/browser/download/chrome_download_manager_delegate.cc
+++ b/chrome/browser/download/chrome_download_manager_delegate.cc
@@ -42,6 +42,8 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/features.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/safe_browsing/file_type_policies.h"
+#include "chrome/grit/generated_resources.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h"
@@ -51,6 +53,7 @@
#include "content/public/browser/page_navigator.h"
#include "net/base/filename_util.h"
#include "net/base/mime_util.h"
+#include "ui/base/l10n/l10n_util.h"
#if BUILDFLAG(ANDROID_JAVA_UI)
#include "chrome/browser/android/download/chrome_download_manager_overwrite_infobar_delegate.h"
@@ -432,6 +435,20 @@ void ChromeDownloadManagerDelegate::ChooseSavePath(
callback);
}
+void ChromeDownloadManagerDelegate::SanitizeSavePackageResourceName(
+ base::FilePath* filename) {
+ safe_browsing::FileTypePolicies* file_type_policies =
+ safe_browsing::FileTypePolicies::GetInstance();
+
+ if (file_type_policies->GetFileDangerLevel(*filename) ==
+ safe_browsing::DownloadFileType::NOT_DANGEROUS)
+ return;
+
+ base::FilePath default_filename = base::FilePath::FromUTF8Unsafe(
+ l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
+ *filename = filename->AddExtension(default_filename.BaseName().value());
+}
+
void ChromeDownloadManagerDelegate::OpenDownloadUsingPlatformHandler(
DownloadItem* download) {
base::FilePath platform_path(
« no previous file with comments | « chrome/browser/download/chrome_download_manager_delegate.h ('k') | chrome/browser/download/save_page_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698