| 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/chrome_download_manager_delegate.h" | 5 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/prefs/pref_member.h" | 14 #include "base/prefs/pref_member.h" |
| 15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
| 16 #include "base/rand_util.h" | 16 #include "base/rand_util.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/task_runner.h" | 19 #include "base/task_runner.h" |
| 20 #include "base/task_runner_util.h" | 20 #include "base/task_runner_util.h" |
| 21 #include "base/threading/sequenced_worker_pool.h" | 21 #include "base/threading/sequenced_worker_pool.h" |
| 22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/chrome_notification_types.h" | |
| 25 #include "chrome/browser/download/download_completion_blocker.h" | 24 #include "chrome/browser/download/download_completion_blocker.h" |
| 26 #include "chrome/browser/download/download_crx_util.h" | 25 #include "chrome/browser/download/download_crx_util.h" |
| 27 #include "chrome/browser/download/download_file_picker.h" | 26 #include "chrome/browser/download/download_file_picker.h" |
| 28 #include "chrome/browser/download/download_history.h" | 27 #include "chrome/browser/download/download_history.h" |
| 29 #include "chrome/browser/download/download_item_model.h" | 28 #include "chrome/browser/download/download_item_model.h" |
| 30 #include "chrome/browser/download/download_path_reservation_tracker.h" | 29 #include "chrome/browser/download/download_path_reservation_tracker.h" |
| 31 #include "chrome/browser/download/download_prefs.h" | 30 #include "chrome/browser/download/download_prefs.h" |
| 32 #include "chrome/browser/download/download_service.h" | 31 #include "chrome/browser/download/download_service.h" |
| 33 #include "chrome/browser/download/download_service_factory.h" | 32 #include "chrome/browser/download/download_service_factory.h" |
| 34 #include "chrome/browser/download/download_stats.h" | 33 #include "chrome/browser/download/download_stats.h" |
| 35 #include "chrome/browser/download/download_target_determiner.h" | 34 #include "chrome/browser/download/download_target_determiner.h" |
| 36 #include "chrome/browser/download/save_package_file_picker.h" | 35 #include "chrome/browser/download/save_package_file_picker.h" |
| 37 #include "chrome/browser/platform_util.h" | 36 #include "chrome/browser/platform_util.h" |
| 38 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
| 39 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 38 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 40 #include "chrome/browser/ui/browser.h" | 39 #include "chrome/browser/ui/browser.h" |
| 41 #include "chrome/browser/ui/browser_finder.h" | 40 #include "chrome/browser/ui/browser_finder.h" |
| 42 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 41 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 43 #include "chrome/common/chrome_constants.h" | 42 #include "chrome/common/chrome_constants.h" |
| 44 #include "chrome/common/pref_names.h" | 43 #include "chrome/common/pref_names.h" |
| 45 #include "components/pref_registry/pref_registry_syncable.h" | 44 #include "components/pref_registry/pref_registry_syncable.h" |
| 46 #include "content/public/browser/download_item.h" | 45 #include "content/public/browser/download_item.h" |
| 47 #include "content/public/browser/download_manager.h" | 46 #include "content/public/browser/download_manager.h" |
| 48 #include "content/public/browser/notification_source.h" | 47 #include "content/public/browser/notification_source.h" |
| 49 #include "content/public/browser/page_navigator.h" | 48 #include "content/public/browser/page_navigator.h" |
| 49 #include "extensions/browser/notification_types.h" |
| 50 #include "net/base/filename_util.h" | 50 #include "net/base/filename_util.h" |
| 51 #include "net/base/mime_util.h" | 51 #include "net/base/mime_util.h" |
| 52 | 52 |
| 53 #if defined(OS_CHROMEOS) | 53 #if defined(OS_CHROMEOS) |
| 54 #include "chrome/browser/chromeos/drive/download_handler.h" | 54 #include "chrome/browser/chromeos/drive/download_handler.h" |
| 55 #include "chrome/browser/chromeos/drive/file_system_util.h" | 55 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 #if defined(ENABLE_EXTENSIONS) | 58 #if defined(ENABLE_EXTENSIONS) |
| 59 #include "chrome/browser/extensions/api/downloads/downloads_api.h" | 59 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 #if defined(ENABLE_EXTENSIONS) | 353 #if defined(ENABLE_EXTENSIONS) |
| 354 if (download_crx_util::IsExtensionDownload(*item) && | 354 if (download_crx_util::IsExtensionDownload(*item) && |
| 355 !extensions::WebstoreInstaller::GetAssociatedApproval(*item)) { | 355 !extensions::WebstoreInstaller::GetAssociatedApproval(*item)) { |
| 356 scoped_refptr<extensions::CrxInstaller> crx_installer = | 356 scoped_refptr<extensions::CrxInstaller> crx_installer = |
| 357 download_crx_util::OpenChromeExtension(profile_, *item); | 357 download_crx_util::OpenChromeExtension(profile_, *item); |
| 358 | 358 |
| 359 // CRX_INSTALLER_DONE will fire when the install completes. At that | 359 // CRX_INSTALLER_DONE will fire when the install completes. At that |
| 360 // time, Observe() will call the passed callback. | 360 // time, Observe() will call the passed callback. |
| 361 registrar_.Add( | 361 registrar_.Add( |
| 362 this, | 362 this, |
| 363 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 363 extensions::NOTIFICATION_CRX_INSTALLER_DONE, |
| 364 content::Source<extensions::CrxInstaller>(crx_installer.get())); | 364 content::Source<extensions::CrxInstaller>(crx_installer.get())); |
| 365 | 365 |
| 366 crx_installers_[crx_installer.get()] = callback; | 366 crx_installers_[crx_installer.get()] = callback; |
| 367 // The status text and percent complete indicator will change now | 367 // The status text and percent complete indicator will change now |
| 368 // that we are installing a CRX. Update observers so that they pick | 368 // that we are installing a CRX. Update observers so that they pick |
| 369 // up the change. | 369 // up the change. |
| 370 item->UpdateObservers(); | 370 item->UpdateObservers(); |
| 371 return false; | 371 return false; |
| 372 } | 372 } |
| 373 #endif | 373 #endif |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 state->SetVerdict(result); | 662 state->SetVerdict(result); |
| 663 } | 663 } |
| 664 #endif // FULL_SAFE_BROWSING | 664 #endif // FULL_SAFE_BROWSING |
| 665 | 665 |
| 666 // content::NotificationObserver implementation. | 666 // content::NotificationObserver implementation. |
| 667 void ChromeDownloadManagerDelegate::Observe( | 667 void ChromeDownloadManagerDelegate::Observe( |
| 668 int type, | 668 int type, |
| 669 const content::NotificationSource& source, | 669 const content::NotificationSource& source, |
| 670 const content::NotificationDetails& details) { | 670 const content::NotificationDetails& details) { |
| 671 #if defined(ENABLE_EXTENSIONS) | 671 #if defined(ENABLE_EXTENSIONS) |
| 672 DCHECK(type == chrome::NOTIFICATION_CRX_INSTALLER_DONE); | 672 DCHECK(type == extensions::NOTIFICATION_CRX_INSTALLER_DONE); |
| 673 | 673 |
| 674 registrar_.Remove(this, | 674 registrar_.Remove(this, extensions::NOTIFICATION_CRX_INSTALLER_DONE, source); |
| 675 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | |
| 676 source); | |
| 677 | 675 |
| 678 scoped_refptr<extensions::CrxInstaller> installer = | 676 scoped_refptr<extensions::CrxInstaller> installer = |
| 679 content::Source<extensions::CrxInstaller>(source).ptr(); | 677 content::Source<extensions::CrxInstaller>(source).ptr(); |
| 680 content::DownloadOpenDelayedCallback callback = | 678 content::DownloadOpenDelayedCallback callback = |
| 681 crx_installers_[installer.get()]; | 679 crx_installers_[installer.get()]; |
| 682 crx_installers_.erase(installer.get()); | 680 crx_installers_.erase(installer.get()); |
| 683 callback.Run(installer->did_handle_successfully()); | 681 callback.Run(installer->did_handle_successfully()); |
| 684 #endif | 682 #endif |
| 685 } | 683 } |
| 686 | 684 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || | 722 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || |
| 725 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || | 723 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || |
| 726 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || | 724 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || |
| 727 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || | 725 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || |
| 728 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { | 726 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { |
| 729 return true; | 727 return true; |
| 730 } | 728 } |
| 731 #endif | 729 #endif |
| 732 return false; | 730 return false; |
| 733 } | 731 } |
| OLD | NEW |