| 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/download_browsertest.h" | 5 #include "chrome/browser/download/download_browsertest.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "base/strings/utf_string_conversions.h" | 31 #include "base/strings/utf_string_conversions.h" |
| 32 #include "base/sys_info.h" | 32 #include "base/sys_info.h" |
| 33 #include "base/test/test_file_util.h" | 33 #include "base/test/test_file_util.h" |
| 34 #include "base/threading/thread_restrictions.h" | 34 #include "base/threading/thread_restrictions.h" |
| 35 #include "build/build_config.h" | 35 #include "build/build_config.h" |
| 36 #include "chrome/app/chrome_command_ids.h" | 36 #include "chrome/app/chrome_command_ids.h" |
| 37 #include "chrome/browser/browser_process.h" | 37 #include "chrome/browser/browser_process.h" |
| 38 #include "chrome/browser/chrome_notification_types.h" | 38 #include "chrome/browser/chrome_notification_types.h" |
| 39 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 39 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 40 #include "chrome/browser/download/download_commands.h" | 40 #include "chrome/browser/download/download_commands.h" |
| 41 #include "chrome/browser/download/download_core_service.h" |
| 42 #include "chrome/browser/download/download_core_service_factory.h" |
| 41 #include "chrome/browser/download/download_crx_util.h" | 43 #include "chrome/browser/download/download_crx_util.h" |
| 42 #include "chrome/browser/download/download_history.h" | 44 #include "chrome/browser/download/download_history.h" |
| 43 #include "chrome/browser/download/download_item_model.h" | 45 #include "chrome/browser/download/download_item_model.h" |
| 44 #include "chrome/browser/download/download_prefs.h" | 46 #include "chrome/browser/download/download_prefs.h" |
| 45 #include "chrome/browser/download/download_request_limiter.h" | 47 #include "chrome/browser/download/download_request_limiter.h" |
| 46 #include "chrome/browser/download/download_service.h" | |
| 47 #include "chrome/browser/download/download_service_factory.h" | |
| 48 #include "chrome/browser/download/download_shelf.h" | 48 #include "chrome/browser/download/download_shelf.h" |
| 49 #include "chrome/browser/download/download_target_determiner.h" | 49 #include "chrome/browser/download/download_target_determiner.h" |
| 50 #include "chrome/browser/download/download_test_file_activity_observer.h" | 50 #include "chrome/browser/download/download_test_file_activity_observer.h" |
| 51 #include "chrome/browser/extensions/extension_service.h" | 51 #include "chrome/browser/extensions/extension_service.h" |
| 52 #include "chrome/browser/history/history_service_factory.h" | 52 #include "chrome/browser/history/history_service_factory.h" |
| 53 #include "chrome/browser/infobars/infobar_service.h" | 53 #include "chrome/browser/infobars/infobar_service.h" |
| 54 #include "chrome/browser/net/url_request_mock_util.h" | 54 #include "chrome/browser/net/url_request_mock_util.h" |
| 55 #include "chrome/browser/notifications/notification_ui_manager.h" | 55 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 56 #include "chrome/browser/permissions/permission_request_manager.h" | 56 #include "chrome/browser/permissions/permission_request_manager.h" |
| 57 #include "chrome/browser/profiles/profile.h" | 57 #include "chrome/browser/profiles/profile.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } | 343 } |
| 344 | 344 |
| 345 class HistoryObserver : public DownloadHistory::Observer { | 345 class HistoryObserver : public DownloadHistory::Observer { |
| 346 public: | 346 public: |
| 347 typedef base::Callback<bool(const history::DownloadRow&)> FilterCallback; | 347 typedef base::Callback<bool(const history::DownloadRow&)> FilterCallback; |
| 348 | 348 |
| 349 explicit HistoryObserver(Profile* profile) | 349 explicit HistoryObserver(Profile* profile) |
| 350 : profile_(profile), | 350 : profile_(profile), |
| 351 waiting_(false), | 351 waiting_(false), |
| 352 seen_stored_(false) { | 352 seen_stored_(false) { |
| 353 DownloadServiceFactory::GetForBrowserContext(profile_)-> | 353 DownloadCoreServiceFactory::GetForBrowserContext(profile_) |
| 354 GetDownloadHistory()->AddObserver(this); | 354 ->GetDownloadHistory() |
| 355 ->AddObserver(this); |
| 355 } | 356 } |
| 356 | 357 |
| 357 ~HistoryObserver() override { | 358 ~HistoryObserver() override { |
| 358 DownloadService* service = DownloadServiceFactory::GetForBrowserContext( | 359 DownloadCoreService* service = |
| 359 profile_); | 360 DownloadCoreServiceFactory::GetForBrowserContext(profile_); |
| 360 if (service && service->GetDownloadHistory()) | 361 if (service && service->GetDownloadHistory()) |
| 361 service->GetDownloadHistory()->RemoveObserver(this); | 362 service->GetDownloadHistory()->RemoveObserver(this); |
| 362 } | 363 } |
| 363 | 364 |
| 364 void SetFilterCallback(const FilterCallback& callback) { | 365 void SetFilterCallback(const FilterCallback& callback) { |
| 365 callback_ = callback; | 366 callback_ = callback; |
| 366 } | 367 } |
| 367 | 368 |
| 368 void OnDownloadStored(content::DownloadItem* item, | 369 void OnDownloadStored(content::DownloadItem* item, |
| 369 const history::DownloadRow& info) override { | 370 const history::DownloadRow& info) override { |
| 370 if (!callback_.is_null() && (!callback_.Run(info))) | 371 if (!callback_.is_null() && (!callback_.Run(info))) |
| 371 return; | 372 return; |
| 372 | 373 |
| 373 seen_stored_ = true; | 374 seen_stored_ = true; |
| 374 if (waiting_) | 375 if (waiting_) |
| 375 base::MessageLoopForUI::current()->QuitWhenIdle(); | 376 base::MessageLoopForUI::current()->QuitWhenIdle(); |
| 376 } | 377 } |
| 377 | 378 |
| 378 void OnDownloadHistoryDestroyed() override { | 379 void OnDownloadHistoryDestroyed() override { |
| 379 DownloadServiceFactory::GetForBrowserContext(profile_)-> | 380 DownloadCoreServiceFactory::GetForBrowserContext(profile_) |
| 380 GetDownloadHistory()->RemoveObserver(this); | 381 ->GetDownloadHistory() |
| 382 ->RemoveObserver(this); |
| 381 } | 383 } |
| 382 | 384 |
| 383 void WaitForStored() { | 385 void WaitForStored() { |
| 384 if (seen_stored_) | 386 if (seen_stored_) |
| 385 return; | 387 return; |
| 386 waiting_ = true; | 388 waiting_ = true; |
| 387 content::RunMessageLoop(); | 389 content::RunMessageLoop(); |
| 388 waiting_ = false; | 390 waiting_ = false; |
| 389 } | 391 } |
| 390 | 392 |
| (...skipping 3474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3865 browser(), 1, | 3867 browser(), 1, |
| 3866 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 3868 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
| 3867 ui_test_utils::NavigateToURL(browser(), extension_url); | 3869 ui_test_utils::NavigateToURL(browser(), extension_url); |
| 3868 | 3870 |
| 3869 observer->WaitForFinished(); | 3871 observer->WaitForFinished(); |
| 3870 | 3872 |
| 3871 // Download shelf should close. | 3873 // Download shelf should close. |
| 3872 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 3874 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| 3873 } | 3875 } |
| 3874 #endif // defined(OS_CHROMEOS) | 3876 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |