| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/browser/download/download_service.h" | 27 #include "chrome/browser/download/download_service.h" |
| 28 #include "chrome/browser/download/download_service_factory.h" | 28 #include "chrome/browser/download/download_service_factory.h" |
| 29 #include "chrome/browser/download/download_target_determiner.h" | 29 #include "chrome/browser/download/download_target_determiner.h" |
| 30 #include "chrome/browser/download/download_util.h" | 30 #include "chrome/browser/download/download_util.h" |
| 31 #include "chrome/browser/download/save_package_file_picker.h" | 31 #include "chrome/browser/download/save_package_file_picker.h" |
| 32 #include "chrome/browser/extensions/api/downloads/downloads_api.h" | 32 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
| 33 #include "chrome/browser/extensions/crx_installer.h" | 33 #include "chrome/browser/extensions/crx_installer.h" |
| 34 #include "chrome/browser/platform_util.h" | 34 #include "chrome/browser/platform_util.h" |
| 35 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 36 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 37 #include "chrome/common/extensions/extension.h" | |
| 38 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
| 39 #include "components/user_prefs/pref_registry_syncable.h" | 38 #include "components/user_prefs/pref_registry_syncable.h" |
| 40 #include "content/public/browser/download_item.h" | 39 #include "content/public/browser/download_item.h" |
| 41 #include "content/public/browser/download_manager.h" | 40 #include "content/public/browser/download_manager.h" |
| 42 #include "content/public/browser/notification_source.h" | 41 #include "content/public/browser/notification_source.h" |
| 42 #include "extensions/common/constants.h" |
| 43 | 43 |
| 44 #if defined(OS_CHROMEOS) | 44 #if defined(OS_CHROMEOS) |
| 45 #include "chrome/browser/chromeos/drive/download_handler.h" | 45 #include "chrome/browser/chromeos/drive/download_handler.h" |
| 46 #include "chrome/browser/chromeos/drive/file_system_util.h" | 46 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 using content::BrowserThread; | 49 using content::BrowserThread; |
| 50 using content::DownloadItem; | 50 using content::DownloadItem; |
| 51 using content::DownloadManager; | 51 using content::DownloadManager; |
| 52 using safe_browsing::DownloadProtectionService; | 52 using safe_browsing::DownloadProtectionService; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 224 } |
| 225 | 225 |
| 226 bool ChromeDownloadManagerDelegate::ShouldOpenFileBasedOnExtension( | 226 bool ChromeDownloadManagerDelegate::ShouldOpenFileBasedOnExtension( |
| 227 const base::FilePath& path) { | 227 const base::FilePath& path) { |
| 228 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 228 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 229 if (path.Extension().empty()) | 229 if (path.Extension().empty()) |
| 230 return false; | 230 return false; |
| 231 // TODO(asanka): This determination is done based on |path|, while | 231 // TODO(asanka): This determination is done based on |path|, while |
| 232 // ShouldOpenDownload() detects extension downloads based on the | 232 // ShouldOpenDownload() detects extension downloads based on the |
| 233 // characteristics of the download. Reconcile this. http://crbug.com/167702 | 233 // characteristics of the download. Reconcile this. http://crbug.com/167702 |
| 234 if (extensions::Extension::IsExtension(path)) | 234 if (path.MatchesExtension(extensions::kExtensionFileExtension)) |
| 235 return false; | 235 return false; |
| 236 return download_prefs_->IsAutoOpenEnabledBasedOnExtension(path); | 236 return download_prefs_->IsAutoOpenEnabledBasedOnExtension(path); |
| 237 } | 237 } |
| 238 | 238 |
| 239 // static | 239 // static |
| 240 void ChromeDownloadManagerDelegate::DisableSafeBrowsing(DownloadItem* item) { | 240 void ChromeDownloadManagerDelegate::DisableSafeBrowsing(DownloadItem* item) { |
| 241 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 241 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 242 #if defined(FULL_SAFE_BROWSING) | 242 #if defined(FULL_SAFE_BROWSING) |
| 243 SafeBrowsingState* state = static_cast<SafeBrowsingState*>( | 243 SafeBrowsingState* state = static_cast<SafeBrowsingState*>( |
| 244 item->GetUserData(&safe_browsing_id)); | 244 item->GetUserData(&safe_browsing_id)); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 560 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 561 source); | 561 source); |
| 562 | 562 |
| 563 scoped_refptr<extensions::CrxInstaller> installer = | 563 scoped_refptr<extensions::CrxInstaller> installer = |
| 564 content::Source<extensions::CrxInstaller>(source).ptr(); | 564 content::Source<extensions::CrxInstaller>(source).ptr(); |
| 565 content::DownloadOpenDelayedCallback callback = | 565 content::DownloadOpenDelayedCallback callback = |
| 566 crx_installers_[installer.get()]; | 566 crx_installers_[installer.get()]; |
| 567 crx_installers_.erase(installer.get()); | 567 crx_installers_.erase(installer.get()); |
| 568 callback.Run(installer->did_handle_successfully()); | 568 callback.Run(installer->did_handle_successfully()); |
| 569 } | 569 } |
| OLD | NEW |