| 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 <stddef.h> |
| 6 #include <stdint.h> |
| 7 |
| 5 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
| 6 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" |
| 9 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 10 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 11 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 12 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 13 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 14 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 15 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
| 16 #include "base/value_conversions.h" | 20 #include "base/value_conversions.h" |
| 21 #include "build/build_config.h" |
| 17 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 22 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 18 #include "chrome/browser/download/download_extensions.h" | 23 #include "chrome/browser/download/download_extensions.h" |
| 19 #include "chrome/browser/download/download_prefs.h" | 24 #include "chrome/browser/download/download_prefs.h" |
| 20 #include "chrome/browser/download/download_target_determiner.h" | 25 #include "chrome/browser/download/download_target_determiner.h" |
| 21 #include "chrome/browser/download/download_target_info.h" | 26 #include "chrome/browser/download/download_target_info.h" |
| 22 #include "chrome/browser/history/history_service_factory.h" | 27 #include "chrome/browser/history/history_service_factory.h" |
| 23 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 29 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 25 #include "chrome/test/base/testing_profile.h" | 30 #include "chrome/test/base/testing_profile.h" |
| 26 #include "components/history/core/browser/history_service.h" | 31 #include "components/history/core/browser/history_service.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 }; | 200 }; |
| 196 | 201 |
| 197 class DownloadTargetDeterminerTest : public ChromeRenderViewHostTestHarness { | 202 class DownloadTargetDeterminerTest : public ChromeRenderViewHostTestHarness { |
| 198 public: | 203 public: |
| 199 // ::testing::Test | 204 // ::testing::Test |
| 200 void SetUp() override; | 205 void SetUp() override; |
| 201 void TearDown() override; | 206 void TearDown() override; |
| 202 | 207 |
| 203 // Creates MockDownloadItem and sets up default expectations. | 208 // Creates MockDownloadItem and sets up default expectations. |
| 204 content::MockDownloadItem* CreateActiveDownloadItem( | 209 content::MockDownloadItem* CreateActiveDownloadItem( |
| 205 int32 id, | 210 int32_t id, |
| 206 const DownloadTestCase& test_case); | 211 const DownloadTestCase& test_case); |
| 207 | 212 |
| 208 // Sets the AutoOpenBasedOnExtension user preference for |path|. | 213 // Sets the AutoOpenBasedOnExtension user preference for |path|. |
| 209 void EnableAutoOpenBasedOnExtension(const base::FilePath& path); | 214 void EnableAutoOpenBasedOnExtension(const base::FilePath& path); |
| 210 | 215 |
| 211 // Set the kDownloadDefaultDirectory managed preference to |path|. | 216 // Set the kDownloadDefaultDirectory managed preference to |path|. |
| 212 void SetManagedDownloadPath(const base::FilePath& path); | 217 void SetManagedDownloadPath(const base::FilePath& path); |
| 213 | 218 |
| 214 // Set the kPromptForDownload user preference to |prompt|. | 219 // Set the kPromptForDownload user preference to |prompt|. |
| 215 void SetPromptForDownload(bool prompt); | 220 void SetPromptForDownload(bool prompt); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 delegate_.SetupDefaults(); | 281 delegate_.SetupDefaults(); |
| 277 } | 282 } |
| 278 | 283 |
| 279 void DownloadTargetDeterminerTest::TearDown() { | 284 void DownloadTargetDeterminerTest::TearDown() { |
| 280 download_prefs_.reset(); | 285 download_prefs_.reset(); |
| 281 ChromeRenderViewHostTestHarness::TearDown(); | 286 ChromeRenderViewHostTestHarness::TearDown(); |
| 282 } | 287 } |
| 283 | 288 |
| 284 content::MockDownloadItem* | 289 content::MockDownloadItem* |
| 285 DownloadTargetDeterminerTest::CreateActiveDownloadItem( | 290 DownloadTargetDeterminerTest::CreateActiveDownloadItem( |
| 286 int32 id, | 291 int32_t id, |
| 287 const DownloadTestCase& test_case) { | 292 const DownloadTestCase& test_case) { |
| 288 content::MockDownloadItem* item = | 293 content::MockDownloadItem* item = |
| 289 new ::testing::NiceMock<content::MockDownloadItem>(); | 294 new ::testing::NiceMock<content::MockDownloadItem>(); |
| 290 GURL download_url(test_case.url); | 295 GURL download_url(test_case.url); |
| 291 std::vector<GURL> url_chain; | 296 std::vector<GURL> url_chain; |
| 292 url_chain.push_back(download_url); | 297 url_chain.push_back(download_url); |
| 293 base::FilePath forced_file_path = | 298 base::FilePath forced_file_path = |
| 294 GetPathInDownloadDir(test_case.forced_file_path); | 299 GetPathInDownloadDir(test_case.forced_file_path); |
| 295 DownloadItem::TargetDisposition initial_disposition = | 300 DownloadItem::TargetDisposition initial_disposition = |
| 296 (test_case.test_type == SAVE_AS) ? | 301 (test_case.test_type == SAVE_AS) ? |
| (...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2239 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(npapi_plugin.path())) | 2244 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(npapi_plugin.path())) |
| 2240 .WillRepeatedly(Return(true)); | 2245 .WillRepeatedly(Return(true)); |
| 2241 | 2246 |
| 2242 target_info = RunDownloadTargetDeterminer( | 2247 target_info = RunDownloadTargetDeterminer( |
| 2243 GetPathInDownloadDir(kInitialPath), item.get()); | 2248 GetPathInDownloadDir(kInitialPath), item.get()); |
| 2244 EXPECT_FALSE(target_info->is_filetype_handled_safely); | 2249 EXPECT_FALSE(target_info->is_filetype_handled_safely); |
| 2245 } | 2250 } |
| 2246 #endif // defined(ENABLE_PLUGINS) | 2251 #endif // defined(ENABLE_PLUGINS) |
| 2247 | 2252 |
| 2248 } // namespace | 2253 } // namespace |
| OLD | NEW |