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/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
13 #include "chrome/browser/browser_thread.h" | 13 #include "chrome/browser/browser_thread.h" |
| 14 #include "chrome/browser/download/download_extensions.h" |
14 #include "chrome/browser/download/download_file_manager.h" | 15 #include "chrome/browser/download/download_file_manager.h" |
15 #include "chrome/browser/download/download_history.h" | 16 #include "chrome/browser/download/download_history.h" |
16 #include "chrome/browser/download/download_manager.h" | 17 #include "chrome/browser/download/download_manager.h" |
17 #include "chrome/browser/download/download_prefs.h" | 18 #include "chrome/browser/download/download_prefs.h" |
18 #include "chrome/browser/download/download_util.h" | 19 #include "chrome/browser/download/download_util.h" |
19 #include "chrome/browser/history/download_create_info.h" | 20 #include "chrome/browser/history/download_create_info.h" |
20 #include "chrome/browser/platform_util.h" | 21 #include "chrome/browser/platform_util.h" |
21 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
22 #include "chrome/browser/profile.h" | 23 #include "chrome/browser/profile.h" |
23 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 void DownloadItem::UpdateObservers() { | 158 void DownloadItem::UpdateObservers() { |
158 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadUpdated(this)); | 159 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadUpdated(this)); |
159 } | 160 } |
160 | 161 |
161 void DownloadItem::NotifyObserversDownloadFileCompleted() { | 162 void DownloadItem::NotifyObserversDownloadFileCompleted() { |
162 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadFileCompleted(this)); | 163 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadFileCompleted(this)); |
163 } | 164 } |
164 | 165 |
165 bool DownloadItem::CanOpenDownload() { | 166 bool DownloadItem::CanOpenDownload() { |
166 return !Extension::IsExtension(target_name_) && | 167 return !Extension::IsExtension(target_name_) && |
167 !download_util::IsExecutableFile(target_name_); | 168 download_util::IsFileSafe(target_name_); |
168 } | 169 } |
169 | 170 |
170 bool DownloadItem::ShouldOpenFileBasedOnExtension() { | 171 bool DownloadItem::ShouldOpenFileBasedOnExtension() { |
171 return download_manager_->ShouldOpenFileBasedOnExtension( | 172 return download_manager_->ShouldOpenFileBasedOnExtension( |
172 GetUserVerifiedFilePath()); | 173 GetUserVerifiedFilePath()); |
173 } | 174 } |
174 | 175 |
175 void DownloadItem::OpenFilesBasedOnExtension(bool open) { | 176 void DownloadItem::OpenFilesBasedOnExtension(bool open) { |
176 DownloadPrefs* prefs = download_manager_->download_prefs(); | 177 DownloadPrefs* prefs = download_manager_->download_prefs(); |
177 if (open) | 178 if (open) |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 return GetTargetFilePath(); | 437 return GetTargetFilePath(); |
437 return full_path_; | 438 return full_path_; |
438 } | 439 } |
439 | 440 |
440 void DownloadItem::Init(bool start_timer) { | 441 void DownloadItem::Init(bool start_timer) { |
441 if (target_name_.value().empty()) | 442 if (target_name_.value().empty()) |
442 target_name_ = full_path_.BaseName(); | 443 target_name_ = full_path_.BaseName(); |
443 if (start_timer) | 444 if (start_timer) |
444 StartProgressTimer(); | 445 StartProgressTimer(); |
445 } | 446 } |
OLD | NEW |