| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "chrome/browser/download/download_item_model.h" | 28 #include "chrome/browser/download/download_item_model.h" |
| 29 #include "chrome/browser/download/download_path_reservation_tracker.h" | 29 #include "chrome/browser/download/download_path_reservation_tracker.h" |
| 30 #include "chrome/browser/download/download_prefs.h" | 30 #include "chrome/browser/download/download_prefs.h" |
| 31 #include "chrome/browser/download/download_service.h" | 31 #include "chrome/browser/download/download_service.h" |
| 32 #include "chrome/browser/download/download_service_factory.h" | 32 #include "chrome/browser/download/download_service_factory.h" |
| 33 #include "chrome/browser/download/download_stats.h" | 33 #include "chrome/browser/download/download_stats.h" |
| 34 #include "chrome/browser/download/download_target_determiner.h" | 34 #include "chrome/browser/download/download_target_determiner.h" |
| 35 #include "chrome/browser/download/save_package_file_picker.h" | 35 #include "chrome/browser/download/save_package_file_picker.h" |
| 36 #include "chrome/browser/extensions/api/downloads/downloads_api.h" | 36 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
| 37 #include "chrome/browser/extensions/crx_installer.h" | 37 #include "chrome/browser/extensions/crx_installer.h" |
| 38 #include "chrome/browser/extensions/webstore_installer.h" |
| 38 #include "chrome/browser/platform_util.h" | 39 #include "chrome/browser/platform_util.h" |
| 39 #include "chrome/browser/profiles/profile.h" | 40 #include "chrome/browser/profiles/profile.h" |
| 40 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 41 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 41 #include "chrome/browser/ui/browser.h" | 42 #include "chrome/browser/ui/browser.h" |
| 42 #include "chrome/browser/ui/browser_finder.h" | 43 #include "chrome/browser/ui/browser_finder.h" |
| 43 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 44 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 44 #include "chrome/common/chrome_constants.h" | 45 #include "chrome/common/chrome_constants.h" |
| 45 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
| 46 #include "components/user_prefs/pref_registry_syncable.h" | 47 #include "components/user_prefs/pref_registry_syncable.h" |
| 47 #include "content/public/browser/download_item.h" | 48 #include "content/public/browser/download_item.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 bool ChromeDownloadManagerDelegate::ShouldCompleteDownload( | 364 bool ChromeDownloadManagerDelegate::ShouldCompleteDownload( |
| 364 DownloadItem* item, | 365 DownloadItem* item, |
| 365 const base::Closure& user_complete_callback) { | 366 const base::Closure& user_complete_callback) { |
| 366 return IsDownloadReadyForCompletion(item, base::Bind( | 367 return IsDownloadReadyForCompletion(item, base::Bind( |
| 367 &ChromeDownloadManagerDelegate::ShouldCompleteDownloadInternal, | 368 &ChromeDownloadManagerDelegate::ShouldCompleteDownloadInternal, |
| 368 weak_ptr_factory_.GetWeakPtr(), item->GetId(), user_complete_callback)); | 369 weak_ptr_factory_.GetWeakPtr(), item->GetId(), user_complete_callback)); |
| 369 } | 370 } |
| 370 | 371 |
| 371 bool ChromeDownloadManagerDelegate::ShouldOpenDownload( | 372 bool ChromeDownloadManagerDelegate::ShouldOpenDownload( |
| 372 DownloadItem* item, const content::DownloadOpenDelayedCallback& callback) { | 373 DownloadItem* item, const content::DownloadOpenDelayedCallback& callback) { |
| 373 if (download_crx_util::IsExtensionDownload(*item)) { | 374 if (download_crx_util::IsExtensionDownload(*item) && |
| 375 !extensions::WebstoreInstaller::GetAssociatedApproval(*item)) { |
| 374 scoped_refptr<extensions::CrxInstaller> crx_installer = | 376 scoped_refptr<extensions::CrxInstaller> crx_installer = |
| 375 download_crx_util::OpenChromeExtension(profile_, *item); | 377 download_crx_util::OpenChromeExtension(profile_, *item); |
| 376 | 378 |
| 377 // CRX_INSTALLER_DONE will fire when the install completes. At that | 379 // CRX_INSTALLER_DONE will fire when the install completes. At that |
| 378 // time, Observe() will call the passed callback. | 380 // time, Observe() will call the passed callback. |
| 379 registrar_.Add( | 381 registrar_.Add( |
| 380 this, | 382 this, |
| 381 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 383 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 382 content::Source<extensions::CrxInstaller>(crx_installer.get())); | 384 content::Source<extensions::CrxInstaller>(crx_installer.get())); |
| 383 | 385 |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 DownloadItem* item = download_manager_->GetDownload(download_id); | 707 DownloadItem* item = download_manager_->GetDownload(download_id); |
| 706 if (!target_info->target_path.empty() && item && | 708 if (!target_info->target_path.empty() && item && |
| 707 IsOpenInBrowserPreferreredForFile(target_info->target_path) && | 709 IsOpenInBrowserPreferreredForFile(target_info->target_path) && |
| 708 target_info->is_filetype_handled_safely) | 710 target_info->is_filetype_handled_safely) |
| 709 DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true); | 711 DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true); |
| 710 callback.Run(target_info->target_path, | 712 callback.Run(target_info->target_path, |
| 711 target_info->target_disposition, | 713 target_info->target_disposition, |
| 712 target_info->danger_type, | 714 target_info->danger_type, |
| 713 target_info->intermediate_path); | 715 target_info->intermediate_path); |
| 714 } | 716 } |
| OLD | NEW |