| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_manager.h" | 5 #include "chrome/browser/download/download_manager.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 14 #include "base/stl_util-inl.h" | 14 #include "base/stl_util-inl.h" |
| 15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
| 16 #include "base/sys_string_conversions.h" | 16 #include "base/sys_string_conversions.h" |
| 17 #include "base/task.h" | 17 #include "base/task.h" |
| 18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "chrome/browser/browser_list.h" | 20 #include "chrome/browser/browser_list.h" |
| 21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/browser_thread.h" | 22 #include "chrome/browser/browser_thread.h" |
| 23 #include "chrome/browser/download/download_extensions.h" |
| 23 #include "chrome/browser/download/download_file_manager.h" | 24 #include "chrome/browser/download/download_file_manager.h" |
| 24 #include "chrome/browser/download/download_history.h" | 25 #include "chrome/browser/download/download_history.h" |
| 25 #include "chrome/browser/download/download_item.h" | 26 #include "chrome/browser/download/download_item.h" |
| 26 #include "chrome/browser/download/download_prefs.h" | 27 #include "chrome/browser/download/download_prefs.h" |
| 27 #include "chrome/browser/download/download_status_updater.h" | 28 #include "chrome/browser/download/download_status_updater.h" |
| 28 #include "chrome/browser/download/download_util.h" | 29 #include "chrome/browser/download/download_util.h" |
| 29 #include "chrome/browser/extensions/extensions_service.h" | 30 #include "chrome/browser/extensions/extensions_service.h" |
| 30 #include "chrome/browser/history/download_create_info.h" | 31 #include "chrome/browser/history/download_create_info.h" |
| 31 #include "chrome/browser/net/chrome_url_request_context.h" | 32 #include "chrome/browser/net/chrome_url_request_context.h" |
| 32 #include "chrome/browser/platform_util.h" | 33 #include "chrome/browser/platform_util.h" |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 | 797 |
| 797 void DownloadManager::RemoveObserver(Observer* observer) { | 798 void DownloadManager::RemoveObserver(Observer* observer) { |
| 798 observers_.RemoveObserver(observer); | 799 observers_.RemoveObserver(observer); |
| 799 } | 800 } |
| 800 | 801 |
| 801 bool DownloadManager::ShouldOpenFileBasedOnExtension( | 802 bool DownloadManager::ShouldOpenFileBasedOnExtension( |
| 802 const FilePath& path) const { | 803 const FilePath& path) const { |
| 803 FilePath::StringType extension = path.Extension(); | 804 FilePath::StringType extension = path.Extension(); |
| 804 if (extension.empty()) | 805 if (extension.empty()) |
| 805 return false; | 806 return false; |
| 806 if (download_util::IsExecutableExtension(extension)) | 807 if (!download_util::IsFileExtensionSafe(extension)) |
| 807 return false; | 808 return false; |
| 808 if (Extension::IsExtension(path)) | 809 if (Extension::IsExtension(path)) |
| 809 return false; | 810 return false; |
| 810 DCHECK(extension[0] == FilePath::kExtensionSeparator); | 811 DCHECK(extension[0] == FilePath::kExtensionSeparator); |
| 811 extension.erase(0, 1); | 812 extension.erase(0, 1); |
| 812 return download_prefs_->IsAutoOpenEnabledForExtension(extension); | 813 return download_prefs_->IsAutoOpenEnabledForExtension(extension); |
| 813 } | 814 } |
| 814 | 815 |
| 815 bool DownloadManager::IsDownloadProgressKnown() { | 816 bool DownloadManager::IsDownloadProgressKnown() { |
| 816 for (DownloadMap::iterator i = in_progress_.begin(); | 817 for (DownloadMap::iterator i = in_progress_.begin(); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 observed_download_manager_->RemoveObserver(this); | 1002 observed_download_manager_->RemoveObserver(this); |
| 1002 } | 1003 } |
| 1003 | 1004 |
| 1004 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { | 1005 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { |
| 1005 observing_download_manager_->NotifyModelChanged(); | 1006 observing_download_manager_->NotifyModelChanged(); |
| 1006 } | 1007 } |
| 1007 | 1008 |
| 1008 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { | 1009 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { |
| 1009 observed_download_manager_ = NULL; | 1010 observed_download_manager_ = NULL; |
| 1010 } | 1011 } |
| OLD | NEW |