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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 #include "chrome/browser/extensions/api/downloads/downloads_api.h" | 66 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
67 #include "chrome/browser/extensions/crx_installer.h" | 67 #include "chrome/browser/extensions/crx_installer.h" |
68 #include "chrome/browser/extensions/webstore_installer.h" | 68 #include "chrome/browser/extensions/webstore_installer.h" |
69 #include "extensions/browser/notification_types.h" | 69 #include "extensions/browser/notification_types.h" |
70 #include "extensions/common/constants.h" | 70 #include "extensions/common/constants.h" |
71 #endif | 71 #endif |
72 | 72 |
73 using content::BrowserThread; | 73 using content::BrowserThread; |
74 using content::DownloadItem; | 74 using content::DownloadItem; |
75 using content::DownloadManager; | 75 using content::DownloadManager; |
| 76 using safe_browsing::DownloadFileType; |
76 using safe_browsing::DownloadProtectionService; | 77 using safe_browsing::DownloadProtectionService; |
77 | 78 |
78 namespace { | 79 namespace { |
79 | 80 |
80 #if defined(FULL_SAFE_BROWSING) | 81 #if defined(FULL_SAFE_BROWSING) |
81 | 82 |
82 // String pointer used for identifying safebrowing data associated with | 83 // String pointer used for identifying safebrowing data associated with |
83 // a download item. | 84 // a download item. |
84 const char kSafeBrowsingUserDataKey[] = "Safe Browsing ID"; | 85 const char kSafeBrowsingUserDataKey[] = "Safe Browsing ID"; |
85 | 86 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 base::Bind(&ChromeDownloadManagerDelegate::CheckClientDownloadDone, | 319 base::Bind(&ChromeDownloadManagerDelegate::CheckClientDownloadDone, |
319 weak_ptr_factory_.GetWeakPtr(), | 320 weak_ptr_factory_.GetWeakPtr(), |
320 item->GetId())); | 321 item->GetId())); |
321 return false; | 322 return false; |
322 } | 323 } |
323 | 324 |
324 // In case the service was disabled between the download starting and now, | 325 // In case the service was disabled between the download starting and now, |
325 // we need to restore the danger state. | 326 // we need to restore the danger state. |
326 content::DownloadDangerType danger_type = item->GetDangerType(); | 327 content::DownloadDangerType danger_type = item->GetDangerType(); |
327 if (DownloadItemModel(item).GetDangerLevel() != | 328 if (DownloadItemModel(item).GetDangerLevel() != |
328 download_util::NOT_DANGEROUS && | 329 DownloadFileType::NOT_DANGEROUS && |
329 (danger_type == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS || | 330 (danger_type == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS || |
330 danger_type == | 331 danger_type == |
331 content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT)) { | 332 content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT)) { |
332 DVLOG(2) << __FUNCTION__ | 333 DVLOG(2) << __FUNCTION__ |
333 << "() SB service disabled. Marking download as DANGEROUS FILE"; | 334 << "() SB service disabled. Marking download as DANGEROUS FILE"; |
334 item->OnContentCheckCompleted( | 335 item->OnContentCheckCompleted( |
335 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE); | 336 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE); |
336 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 337 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
337 internal_complete_callback); | 338 internal_complete_callback); |
338 return false; | 339 return false; |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 // has not been set to DANGEROUS yet. We don't want to show two warnings. | 662 // has not been set to DANGEROUS yet. We don't want to show two warnings. |
662 if (item->GetDangerType() == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS || | 663 if (item->GetDangerType() == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS || |
663 item->GetDangerType() == | 664 item->GetDangerType() == |
664 content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT) { | 665 content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT) { |
665 content::DownloadDangerType danger_type = | 666 content::DownloadDangerType danger_type = |
666 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS; | 667 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS; |
667 switch (result) { | 668 switch (result) { |
668 case DownloadProtectionService::UNKNOWN: | 669 case DownloadProtectionService::UNKNOWN: |
669 // The check failed or was inconclusive. | 670 // The check failed or was inconclusive. |
670 if (DownloadItemModel(item).GetDangerLevel() != | 671 if (DownloadItemModel(item).GetDangerLevel() != |
671 download_util::NOT_DANGEROUS) | 672 DownloadFileType::NOT_DANGEROUS) |
672 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE; | 673 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE; |
673 break; | 674 break; |
674 case DownloadProtectionService::SAFE: | 675 case DownloadProtectionService::SAFE: |
675 // If this file type require explicit consent, then set the danger type | 676 // If this file type require explicit consent, then set the danger type |
676 // to DANGEROUS_FILE so that the user be required to manually vet | 677 // to DANGEROUS_FILE so that the user be required to manually vet |
677 // whether the download is intended or not. | 678 // whether the download is intended or not. |
678 if (DownloadItemModel(item).GetDangerLevel() == | 679 if (DownloadItemModel(item).GetDangerLevel() == |
679 download_util::DANGEROUS) | 680 DownloadFileType::DANGEROUS) |
680 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE; | 681 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE; |
681 break; | 682 break; |
682 case DownloadProtectionService::DANGEROUS: | 683 case DownloadProtectionService::DANGEROUS: |
683 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT; | 684 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT; |
684 break; | 685 break; |
685 case DownloadProtectionService::UNCOMMON: | 686 case DownloadProtectionService::UNCOMMON: |
686 danger_type = content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT; | 687 danger_type = content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT; |
687 break; | 688 break; |
688 case DownloadProtectionService::DANGEROUS_HOST: | 689 case DownloadProtectionService::DANGEROUS_HOST: |
689 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST; | 690 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || | 772 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || |
772 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || | 773 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || |
773 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || | 774 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || |
774 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || | 775 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || |
775 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { | 776 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { |
776 return true; | 777 return true; |
777 } | 778 } |
778 #endif | 779 #endif |
779 return false; | 780 return false; |
780 } | 781 } |
OLD | NEW |