OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 // IO threads. | 327 // IO threads. |
328 // This almost certainly means that a Download cancel has propagated through | 328 // This almost certainly means that a Download cancel has propagated through |
329 // the system. | 329 // the system. |
330 class DownloadsFlushObserver | 330 class DownloadsFlushObserver |
331 : public DownloadManager::Observer, | 331 : public DownloadManager::Observer, |
332 public DownloadItem::Observer, | 332 public DownloadItem::Observer, |
333 public base::RefCountedThreadSafe<DownloadsFlushObserver> { | 333 public base::RefCountedThreadSafe<DownloadsFlushObserver> { |
334 public: | 334 public: |
335 explicit DownloadsFlushObserver(DownloadManager* download_manager) | 335 explicit DownloadsFlushObserver(DownloadManager* download_manager) |
336 : download_manager_(download_manager), | 336 : download_manager_(download_manager), |
337 waiting_for_zero_inprogress_(true) { } | 337 waiting_for_zero_inprogress_(true) {} |
338 | 338 |
339 void WaitForFlush() { | 339 void WaitForFlush() { |
340 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 340 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
341 download_manager_->AddObserver(this); | 341 download_manager_->AddObserver(this); |
342 ui_test_utils::RunMessageLoop(); | 342 ui_test_utils::RunMessageLoop(); |
343 } | 343 } |
344 | 344 |
345 // DownloadsManager observer methods. | 345 // DownloadsManager observer methods. |
346 virtual void ModelChanged() { | 346 virtual void ModelChanged() { |
347 // Model has changed, so there may be more DownloadItems to observe. | 347 // Model has changed, so there may be more DownloadItems to observe. |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 // Location of the test data. | 819 // Location of the test data. |
820 FilePath test_dir_; | 820 FilePath test_dir_; |
821 | 821 |
822 // Location of the downloads directory for these tests | 822 // Location of the downloads directory for these tests |
823 ScopedTempDir downloads_directory_; | 823 ScopedTempDir downloads_directory_; |
824 }; | 824 }; |
825 | 825 |
826 // Get History Information. | 826 // Get History Information. |
827 class DownloadsHistoryDataCollector { | 827 class DownloadsHistoryDataCollector { |
828 public: | 828 public: |
829 explicit DownloadsHistoryDataCollector(int64 download_db_handle, | 829 DownloadsHistoryDataCollector(int64 download_db_handle, |
830 DownloadManager* manager) | 830 DownloadManager* manager) |
831 : result_valid_(false), | 831 : result_valid_(false), |
832 download_db_handle_(download_db_handle) { | 832 download_db_handle_(download_db_handle) { |
833 HistoryService* hs = | 833 HistoryService* hs = |
834 manager->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); | 834 manager->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); |
835 DCHECK(hs); | 835 DCHECK(hs); |
836 hs->QueryDownloads( | 836 hs->QueryDownloads( |
837 &callback_consumer_, | 837 &callback_consumer_, |
838 NewCallback(this, | 838 NewCallback(this, |
839 &DownloadsHistoryDataCollector::OnQueryDownloadsComplete)); | 839 &DownloadsHistoryDataCollector::OnQueryDownloadsComplete)); |
840 | 840 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 } | 886 } |
887 | 887 |
888 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} | 888 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} |
889 virtual void OnInstallFailure(const std::string& error) {} | 889 virtual void OnInstallFailure(const std::string& error) {} |
890 }; | 890 }; |
891 | 891 |
892 // Mock that simulates a permissions dialog where the user allows | 892 // Mock that simulates a permissions dialog where the user allows |
893 // installation. | 893 // installation. |
894 class MockAutoConfirmExtensionInstallUI : public ExtensionInstallUI { | 894 class MockAutoConfirmExtensionInstallUI : public ExtensionInstallUI { |
895 public: | 895 public: |
896 explicit MockAutoConfirmExtensionInstallUI(Profile* profile) : | 896 explicit MockAutoConfirmExtensionInstallUI(Profile* profile) |
897 ExtensionInstallUI(profile) {} | 897 : ExtensionInstallUI(profile) {} |
898 | 898 |
899 // Proceed without confirmation prompt. | 899 // Proceed without confirmation prompt. |
900 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 900 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { |
901 delegate->InstallUIProceed(); | 901 delegate->InstallUIProceed(); |
902 } | 902 } |
903 | 903 |
904 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} | 904 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} |
905 virtual void OnInstallFailure(const std::string& error) {} | 905 virtual void OnInstallFailure(const std::string& error) {} |
906 }; | 906 }; |
907 | 907 |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1711 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); | 1711 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
1712 | 1712 |
1713 // Download shelf should close. Download panel stays open on ChromeOS. | 1713 // Download shelf should close. Download panel stays open on ChromeOS. |
1714 CheckDownloadUI(browser(), false, true, FilePath()); | 1714 CheckDownloadUI(browser(), false, true, FilePath()); |
1715 | 1715 |
1716 // Check that the extension was installed. | 1716 // Check that the extension was installed. |
1717 ExtensionService* extension_service = | 1717 ExtensionService* extension_service = |
1718 browser()->profile()->GetExtensionService(); | 1718 browser()->profile()->GetExtensionService(); |
1719 ASSERT_TRUE(extension_service->GetExtensionById(kLargeThemeCrxId, false)); | 1719 ASSERT_TRUE(extension_service->GetExtensionById(kLargeThemeCrxId, false)); |
1720 } | 1720 } |
OLD | NEW |