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_item.h" | 5 #include "chrome/browser/download/download_item.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "base/timer.h" | 12 #include "base/timer.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
15 #include "chrome/browser/browser_thread.h" | 15 #include "chrome/browser/browser_thread.h" |
| 16 #include "chrome/browser/download/download_extensions.h" |
16 #include "chrome/browser/download/download_file_manager.h" | 17 #include "chrome/browser/download/download_file_manager.h" |
17 #include "chrome/browser/download/download_history.h" | 18 #include "chrome/browser/download/download_history.h" |
18 #include "chrome/browser/download/download_manager.h" | 19 #include "chrome/browser/download/download_manager.h" |
19 #include "chrome/browser/download/download_prefs.h" | 20 #include "chrome/browser/download/download_prefs.h" |
20 #include "chrome/browser/download/download_util.h" | 21 #include "chrome/browser/download/download_util.h" |
21 #include "chrome/browser/history/download_create_info.h" | 22 #include "chrome/browser/history/download_create_info.h" |
22 #include "chrome/browser/platform_util.h" | 23 #include "chrome/browser/platform_util.h" |
23 #include "chrome/browser/prefs/pref_service.h" | 24 #include "chrome/browser/prefs/pref_service.h" |
24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 void DownloadItem::UpdateObservers() { | 190 void DownloadItem::UpdateObservers() { |
190 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadUpdated(this)); | 191 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadUpdated(this)); |
191 } | 192 } |
192 | 193 |
193 void DownloadItem::NotifyObserversDownloadFileCompleted() { | 194 void DownloadItem::NotifyObserversDownloadFileCompleted() { |
194 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadFileCompleted(this)); | 195 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadFileCompleted(this)); |
195 } | 196 } |
196 | 197 |
197 bool DownloadItem::CanOpenDownload() { | 198 bool DownloadItem::CanOpenDownload() { |
198 return !Extension::IsExtension(target_name_) && | 199 return !Extension::IsExtension(target_name_) && |
199 !download_util::IsExecutableFile(target_name_); | 200 download_util::IsFileSafe(target_name_); |
200 } | 201 } |
201 | 202 |
202 bool DownloadItem::ShouldOpenFileBasedOnExtension() { | 203 bool DownloadItem::ShouldOpenFileBasedOnExtension() { |
203 return download_manager_->ShouldOpenFileBasedOnExtension( | 204 return download_manager_->ShouldOpenFileBasedOnExtension( |
204 GetUserVerifiedFilePath()); | 205 GetUserVerifiedFilePath()); |
205 } | 206 } |
206 | 207 |
207 void DownloadItem::OpenFilesBasedOnExtension(bool open) { | 208 void DownloadItem::OpenFilesBasedOnExtension(bool open) { |
208 DownloadPrefs* prefs = download_manager_->download_prefs(); | 209 DownloadPrefs* prefs = download_manager_->download_prefs(); |
209 if (open) | 210 if (open) |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 target_name_.value().c_str(), | 490 target_name_.value().c_str(), |
490 full_path().value().c_str(), | 491 full_path().value().c_str(), |
491 DebugSafetyStateString(safety_state())); | 492 DebugSafetyStateString(safety_state())); |
492 } | 493 } |
493 | 494 |
494 description += base::StringPrintf(" state = %s }", | 495 description += base::StringPrintf(" state = %s }", |
495 DebugDownloadStateString(state())); | 496 DebugDownloadStateString(state())); |
496 | 497 |
497 return description; | 498 return description; |
498 } | 499 } |
OLD | NEW |