| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 #include "content/public/browser/render_view_host.h" | 79 #include "content/public/browser/render_view_host.h" |
| 80 #include "content/public/browser/resource_context.h" | 80 #include "content/public/browser/resource_context.h" |
| 81 #include "content/public/browser/web_contents.h" | 81 #include "content/public/browser/web_contents.h" |
| 82 #include "content/public/common/content_switches.h" | 82 #include "content/public/common/content_switches.h" |
| 83 #include "content/public/common/context_menu_params.h" | 83 #include "content/public/common/context_menu_params.h" |
| 84 #include "content/public/common/page_transition_types.h" | 84 #include "content/public/common/page_transition_types.h" |
| 85 #include "content/public/test/browser_test_utils.h" | 85 #include "content/public/test/browser_test_utils.h" |
| 86 #include "content/public/test/download_test_observer.h" | 86 #include "content/public/test/download_test_observer.h" |
| 87 #include "content/public/test/test_file_error_injector.h" | 87 #include "content/public/test/test_file_error_injector.h" |
| 88 #include "content/public/test/test_navigation_observer.h" | 88 #include "content/public/test/test_navigation_observer.h" |
| 89 #include "content/test/net/url_request_mock_http_job.h" | |
| 90 #include "content/test/net/url_request_slow_download_job.h" | 89 #include "content/test/net/url_request_slow_download_job.h" |
| 91 #include "extensions/browser/extension_system.h" | 90 #include "extensions/browser/extension_system.h" |
| 92 #include "extensions/common/feature_switch.h" | 91 #include "extensions/common/feature_switch.h" |
| 93 #include "net/base/filename_util.h" | 92 #include "net/base/filename_util.h" |
| 94 #include "net/test/spawned_test_server/spawned_test_server.h" | 93 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 94 #include "net/test/url_request/url_request_mock_http_job.h" |
| 95 #include "testing/gtest/include/gtest/gtest.h" | 95 #include "testing/gtest/include/gtest/gtest.h" |
| 96 #include "ui/base/l10n/l10n_util.h" | 96 #include "ui/base/l10n/l10n_util.h" |
| 97 | 97 |
| 98 using content::BrowserContext; | 98 using content::BrowserContext; |
| 99 using content::BrowserThread; | 99 using content::BrowserThread; |
| 100 using content::DownloadItem; | 100 using content::DownloadItem; |
| 101 using content::DownloadManager; | 101 using content::DownloadManager; |
| 102 using content::DownloadUrlParameters; | 102 using content::DownloadUrlParameters; |
| 103 using content::URLRequestMockHTTPJob; | |
| 104 using content::URLRequestSlowDownloadJob; | 103 using content::URLRequestSlowDownloadJob; |
| 105 using content::WebContents; | 104 using content::WebContents; |
| 106 using extensions::Extension; | 105 using extensions::Extension; |
| 107 using extensions::FeatureSwitch; | 106 using extensions::FeatureSwitch; |
| 107 using net::URLRequestMockHTTPJob; |
| 108 | 108 |
| 109 namespace { | 109 namespace { |
| 110 | 110 |
| 111 class CreatedObserver : public content::DownloadManager::Observer { | 111 class CreatedObserver : public content::DownloadManager::Observer { |
| 112 public: | 112 public: |
| 113 explicit CreatedObserver(content::DownloadManager* manager) | 113 explicit CreatedObserver(content::DownloadManager* manager) |
| 114 : manager_(manager), | 114 : manager_(manager), |
| 115 waiting_(false) { | 115 waiting_(false) { |
| 116 manager->AddObserver(this); | 116 manager->AddObserver(this); |
| 117 } | 117 } |
| (...skipping 3221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3339 // happen regardless of whether the request is served via the cache or from | 3339 // happen regardless of whether the request is served via the cache or from |
| 3340 // the network. | 3340 // the network. |
| 3341 DownloadAndWait(browser(), url); | 3341 DownloadAndWait(browser(), url); |
| 3342 DownloadAndWait(browser(), url); | 3342 DownloadAndWait(browser(), url); |
| 3343 } | 3343 } |
| 3344 | 3344 |
| 3345 #if defined(FULL_SAFE_BROWSING) | 3345 #if defined(FULL_SAFE_BROWSING) |
| 3346 IN_PROC_BROWSER_TEST_F(DownloadTest, FeedbackService) { | 3346 IN_PROC_BROWSER_TEST_F(DownloadTest, FeedbackService) { |
| 3347 // Make a dangerous file. | 3347 // Make a dangerous file. |
| 3348 base::FilePath file(FILE_PATH_LITERAL("downloads/dangerous/dangerous.swf")); | 3348 base::FilePath file(FILE_PATH_LITERAL("downloads/dangerous/dangerous.swf")); |
| 3349 GURL download_url(content::URLRequestMockHTTPJob::GetMockUrl(file)); | 3349 GURL download_url(net::URLRequestMockHTTPJob::GetMockUrl(file)); |
| 3350 scoped_ptr<content::DownloadTestObserverInterrupted> observer( | 3350 scoped_ptr<content::DownloadTestObserverInterrupted> observer( |
| 3351 new content::DownloadTestObserverInterrupted( | 3351 new content::DownloadTestObserverInterrupted( |
| 3352 DownloadManagerForBrowser(browser()), 1, | 3352 DownloadManagerForBrowser(browser()), 1, |
| 3353 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_QUIT)); | 3353 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_QUIT)); |
| 3354 ui_test_utils::NavigateToURLWithDisposition( | 3354 ui_test_utils::NavigateToURLWithDisposition( |
| 3355 browser(), | 3355 browser(), |
| 3356 GURL(download_url), | 3356 GURL(download_url), |
| 3357 NEW_BACKGROUND_TAB, | 3357 NEW_BACKGROUND_TAB, |
| 3358 ui_test_utils::BROWSER_TEST_NONE); | 3358 ui_test_utils::BROWSER_TEST_NONE); |
| 3359 observer->WaitForFinished(); | 3359 observer->WaitForFinished(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3387 *(downloads[0]))); | 3387 *(downloads[0]))); |
| 3388 | 3388 |
| 3389 // Begin feedback and check that the file is "stolen". | 3389 // Begin feedback and check that the file is "stolen". |
| 3390 download_protection_service->feedback_service()->BeginFeedbackForDownload( | 3390 download_protection_service->feedback_service()->BeginFeedbackForDownload( |
| 3391 downloads[0]); | 3391 downloads[0]); |
| 3392 std::vector<DownloadItem*> updated_downloads; | 3392 std::vector<DownloadItem*> updated_downloads; |
| 3393 GetDownloads(browser(), &updated_downloads); | 3393 GetDownloads(browser(), &updated_downloads); |
| 3394 ASSERT_TRUE(updated_downloads.empty()); | 3394 ASSERT_TRUE(updated_downloads.empty()); |
| 3395 } | 3395 } |
| 3396 #endif | 3396 #endif |
| OLD | NEW |