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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 2454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2465 }, | 2465 }, |
2466 { // Navigated download with 400 error. | 2466 { // Navigated download with 400 error. |
2467 "zip_file_not_found.zip", | 2467 "zip_file_not_found.zip", |
2468 DOWNLOAD_NAVIGATE, | 2468 DOWNLOAD_NAVIGATE, |
2469 content::DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, | 2469 content::DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, |
2470 false, | 2470 false, |
2471 false | 2471 false |
2472 } | 2472 } |
2473 }; | 2473 }; |
2474 | 2474 |
2475 DownloadFilesCheckErrors(ARRAYSIZE_UNSAFE(download_info), download_info); | 2475 DownloadFilesCheckErrors(arraysize(download_info), download_info); |
2476 } | 2476 } |
2477 | 2477 |
2478 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadErrorsFile) { | 2478 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadErrorsFile) { |
2479 FileErrorInjectInfo error_info[] = { | 2479 FileErrorInjectInfo error_info[] = { |
2480 { // Navigated download with injected "Disk full" error in Initialize(). | 2480 { // Navigated download with injected "Disk full" error in Initialize(). |
2481 { "a_zip_file.zip", | 2481 { "a_zip_file.zip", |
2482 DOWNLOAD_NAVIGATE, | 2482 DOWNLOAD_NAVIGATE, |
2483 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | 2483 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
2484 1 | 2484 1 |
2485 }, | 2485 }, |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2642 }, | 2642 }, |
2643 { | 2643 { |
2644 "", | 2644 "", |
2645 content::TestFileErrorInjector::FILE_OPERATION_WRITE, | 2645 content::TestFileErrorInjector::FILE_OPERATION_WRITE, |
2646 1, | 2646 1, |
2647 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, | 2647 content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE, |
2648 } | 2648 } |
2649 } | 2649 } |
2650 }; | 2650 }; |
2651 | 2651 |
2652 DownloadInsertFilesErrorCheckErrors(ARRAYSIZE_UNSAFE(error_info), error_info); | 2652 DownloadInsertFilesErrorCheckErrors(arraysize(error_info), error_info); |
2653 } | 2653 } |
2654 | 2654 |
2655 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadErrorReadonlyFolder) { | 2655 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadErrorReadonlyFolder) { |
2656 DownloadInfo download_info[] = { | 2656 DownloadInfo download_info[] = { |
2657 { | 2657 { |
2658 "a_zip_file.zip", | 2658 "a_zip_file.zip", |
2659 DOWNLOAD_DIRECT, | 2659 DOWNLOAD_DIRECT, |
2660 // This passes because we switch to the My Documents folder. | 2660 // This passes because we switch to the My Documents folder. |
2661 content::DOWNLOAD_INTERRUPT_REASON_NONE, | 2661 content::DOWNLOAD_INTERRUPT_REASON_NONE, |
2662 true, | 2662 true, |
2663 true | 2663 true |
2664 }, | 2664 }, |
2665 { | 2665 { |
2666 "a_zip_file.zip", | 2666 "a_zip_file.zip", |
2667 DOWNLOAD_NAVIGATE, | 2667 DOWNLOAD_NAVIGATE, |
2668 // This passes because we switch to the My Documents folder. | 2668 // This passes because we switch to the My Documents folder. |
2669 content::DOWNLOAD_INTERRUPT_REASON_NONE, | 2669 content::DOWNLOAD_INTERRUPT_REASON_NONE, |
2670 true, | 2670 true, |
2671 true | 2671 true |
2672 } | 2672 } |
2673 }; | 2673 }; |
2674 | 2674 |
2675 DownloadFilesToReadonlyFolder(ARRAYSIZE_UNSAFE(download_info), download_info); | 2675 DownloadFilesToReadonlyFolder(arraysize(download_info), download_info); |
2676 } | 2676 } |
2677 | 2677 |
2678 // Test that we show a dangerous downloads warning for a dangerous file | 2678 // Test that we show a dangerous downloads warning for a dangerous file |
2679 // downloaded through a blob: URL. | 2679 // downloaded through a blob: URL. |
2680 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadDangerousBlobData) { | 2680 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadDangerousBlobData) { |
2681 #if defined(OS_WIN) | 2681 #if defined(OS_WIN) |
2682 // On Windows, if SafeBrowsing is enabled, certain file types (.exe, .cab, | 2682 // On Windows, if SafeBrowsing is enabled, certain file types (.exe, .cab, |
2683 // .msi) will be handled by the DownloadProtectionService. However, if the URL | 2683 // .msi) will be handled by the DownloadProtectionService. However, if the URL |
2684 // is non-standard (e.g. blob:) then those files won't be handled by the | 2684 // is non-standard (e.g. blob:) then those files won't be handled by the |
2685 // DPS. We should be showing the dangerous download warning for any file | 2685 // DPS. We should be showing the dangerous download warning for any file |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3528 *(downloads[0]))); | 3528 *(downloads[0]))); |
3529 | 3529 |
3530 // Begin feedback and check that the file is "stolen". | 3530 // Begin feedback and check that the file is "stolen". |
3531 download_protection_service->feedback_service()->BeginFeedbackForDownload( | 3531 download_protection_service->feedback_service()->BeginFeedbackForDownload( |
3532 downloads[0]); | 3532 downloads[0]); |
3533 std::vector<DownloadItem*> updated_downloads; | 3533 std::vector<DownloadItem*> updated_downloads; |
3534 GetDownloads(browser(), &updated_downloads); | 3534 GetDownloads(browser(), &updated_downloads); |
3535 ASSERT_TRUE(updated_downloads.empty()); | 3535 ASSERT_TRUE(updated_downloads.empty()); |
3536 } | 3536 } |
3537 #endif | 3537 #endif |
OLD | NEW |