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 "chrome/browser/download/chrome_download_manager_delegate.h" | 5 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 24 matching lines...) Expand all Loading... | |
35 #include "chrome/browser/platform_util.h" | 35 #include "chrome/browser/platform_util.h" |
36 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
37 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 37 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
38 #include "chrome/browser/ui/browser.h" | 38 #include "chrome/browser/ui/browser.h" |
39 #include "chrome/browser/ui/browser_finder.h" | 39 #include "chrome/browser/ui/browser_finder.h" |
40 #include "chrome/browser/ui/chrome_pages.h" | 40 #include "chrome/browser/ui/chrome_pages.h" |
41 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 41 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
42 #include "chrome/common/chrome_constants.h" | 42 #include "chrome/common/chrome_constants.h" |
43 #include "chrome/common/features.h" | 43 #include "chrome/common/features.h" |
44 #include "chrome/common/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
45 #include "chrome/common/safe_browsing/file_type_policies.h" | |
46 #include "chrome/grit/generated_resources.h" | |
45 #include "components/pref_registry/pref_registry_syncable.h" | 47 #include "components/pref_registry/pref_registry_syncable.h" |
46 #include "components/prefs/pref_member.h" | 48 #include "components/prefs/pref_member.h" |
47 #include "components/prefs/pref_service.h" | 49 #include "components/prefs/pref_service.h" |
48 #include "content/public/browser/download_item.h" | 50 #include "content/public/browser/download_item.h" |
49 #include "content/public/browser/download_manager.h" | 51 #include "content/public/browser/download_manager.h" |
50 #include "content/public/browser/notification_source.h" | 52 #include "content/public/browser/notification_source.h" |
51 #include "content/public/browser/page_navigator.h" | 53 #include "content/public/browser/page_navigator.h" |
52 #include "net/base/filename_util.h" | 54 #include "net/base/filename_util.h" |
53 #include "net/base/mime_util.h" | 55 #include "net/base/mime_util.h" |
56 #include "ui/base/l10n/l10n_util.h" | |
54 | 57 |
55 #if BUILDFLAG(ANDROID_JAVA_UI) | 58 #if BUILDFLAG(ANDROID_JAVA_UI) |
56 #include "chrome/browser/android/download/chrome_download_manager_overwrite_info bar_delegate.h" | 59 #include "chrome/browser/android/download/chrome_download_manager_overwrite_info bar_delegate.h" |
57 #include "chrome/browser/infobars/infobar_service.h" | 60 #include "chrome/browser/infobars/infobar_service.h" |
58 #endif | 61 #endif |
59 | 62 |
60 #if defined(OS_CHROMEOS) | 63 #if defined(OS_CHROMEOS) |
61 #include "chrome/browser/chromeos/drive/download_handler.h" | 64 #include "chrome/browser/chromeos/drive/download_handler.h" |
62 #include "chrome/browser/chromeos/drive/file_system_util.h" | 65 #include "chrome/browser/chromeos/drive/file_system_util.h" |
63 #endif | 66 #endif |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 // Deletes itself. | 428 // Deletes itself. |
426 new SavePackageFilePicker( | 429 new SavePackageFilePicker( |
427 web_contents, | 430 web_contents, |
428 suggested_path, | 431 suggested_path, |
429 default_extension, | 432 default_extension, |
430 can_save_as_complete, | 433 can_save_as_complete, |
431 download_prefs_.get(), | 434 download_prefs_.get(), |
432 callback); | 435 callback); |
433 } | 436 } |
434 | 437 |
438 void ChromeDownloadManagerDelegate::SanitizeSaveItemFilename( | |
439 base::FilePath* filename) { | |
440 safe_browsing::FileTypePolicies* file_type_policies = | |
441 safe_browsing::FileTypePolicies::GetInstance(); | |
442 if (!file_type_policies) | |
Nathan Parker
2016/06/13 21:15:00
This shouldn't be necessary. The Singleton guaran
| |
443 return; | |
444 | |
445 if (file_type_policies->GetFileDangerLevel(*filename) == | |
446 safe_browsing::DownloadFileType::NOT_DANGEROUS) | |
Nathan Parker
2016/06/13 21:15:00
So we're not actually checking with safe browsing
asanka
2016/06/14 21:24:07
Yeah. I was a bit on the fence about what to do wi
Nathan Parker
2016/06/15 00:01:21
While it's true that an archive can contain an exe
asanka
2016/06/16 18:35:16
On 2016/06/15 at 00:01:21, Nathan Parker wrote:
[.
| |
447 return; | |
448 | |
449 base::FilePath::FilePath default_filename = base::FilePath::FromUTF8Unsafe( | |
450 l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); | |
451 *filename = filename->AddExtension(default_filename.BaseName().value()); | |
452 } | |
453 | |
435 void ChromeDownloadManagerDelegate::OpenDownloadUsingPlatformHandler( | 454 void ChromeDownloadManagerDelegate::OpenDownloadUsingPlatformHandler( |
436 DownloadItem* download) { | 455 DownloadItem* download) { |
437 base::FilePath platform_path( | 456 base::FilePath platform_path( |
438 GetPlatformDownloadPath(profile_, download, PLATFORM_TARGET_PATH)); | 457 GetPlatformDownloadPath(profile_, download, PLATFORM_TARGET_PATH)); |
439 DCHECK(!platform_path.empty()); | 458 DCHECK(!platform_path.empty()); |
440 platform_util::OpenItem(profile_, platform_path, platform_util::OPEN_FILE, | 459 platform_util::OpenItem(profile_, platform_path, platform_util::OPEN_FILE, |
441 platform_util::OpenOperationCallback()); | 460 platform_util::OpenOperationCallback()); |
442 } | 461 } |
443 | 462 |
444 void ChromeDownloadManagerDelegate::OpenDownload(DownloadItem* download) { | 463 void ChromeDownloadManagerDelegate::OpenDownload(DownloadItem* download) { |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
772 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || | 791 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || |
773 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || | 792 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || |
774 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || | 793 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || |
775 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || | 794 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || |
776 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { | 795 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { |
777 return true; | 796 return true; |
778 } | 797 } |
779 #endif | 798 #endif |
780 return false; | 799 return false; |
781 } | 800 } |
OLD | NEW |