OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 original_mime_type_(info.original_mime_type), | 125 original_mime_type_(info.original_mime_type), |
126 total_bytes_(info.total_bytes), | 126 total_bytes_(info.total_bytes), |
127 received_bytes_(info.received_bytes), | 127 received_bytes_(info.received_bytes), |
128 start_tick_(base::TimeTicks()), | 128 start_tick_(base::TimeTicks()), |
129 state_(static_cast<DownloadState>(info.state)), | 129 state_(static_cast<DownloadState>(info.state)), |
130 start_time_(info.start_time), | 130 start_time_(info.start_time), |
131 db_handle_(info.db_handle), | 131 db_handle_(info.db_handle), |
132 download_manager_(download_manager), | 132 download_manager_(download_manager), |
133 is_paused_(false), | 133 is_paused_(false), |
134 open_when_complete_(false), | 134 open_when_complete_(false), |
| 135 file_exists_(true), |
135 safety_state_(SAFE), | 136 safety_state_(SAFE), |
136 danger_type_(NOT_DANGEROUS), | 137 danger_type_(NOT_DANGEROUS), |
137 auto_opened_(false), | 138 auto_opened_(false), |
138 target_name_(info.original_name), | 139 target_name_(info.original_name), |
139 render_process_id_(-1), | 140 render_process_id_(-1), |
140 request_id_(-1), | 141 request_id_(-1), |
141 save_as_(false), | 142 save_as_(false), |
142 is_otr_(false), | 143 is_otr_(false), |
143 is_extension_install_(info.is_extension_install), | 144 is_extension_install_(info.is_extension_install), |
144 is_temporary_(false), | 145 is_temporary_(false), |
(...skipping 20 matching lines...) Expand all Loading... |
165 total_bytes_(info.total_bytes), | 166 total_bytes_(info.total_bytes), |
166 received_bytes_(0), | 167 received_bytes_(0), |
167 last_os_error_(0), | 168 last_os_error_(0), |
168 start_tick_(base::TimeTicks::Now()), | 169 start_tick_(base::TimeTicks::Now()), |
169 state_(IN_PROGRESS), | 170 state_(IN_PROGRESS), |
170 start_time_(info.start_time), | 171 start_time_(info.start_time), |
171 db_handle_(DownloadHistory::kUninitializedHandle), | 172 db_handle_(DownloadHistory::kUninitializedHandle), |
172 download_manager_(download_manager), | 173 download_manager_(download_manager), |
173 is_paused_(false), | 174 is_paused_(false), |
174 open_when_complete_(false), | 175 open_when_complete_(false), |
| 176 file_exists_(true), |
175 safety_state_(GetSafetyState(info.is_dangerous_file, | 177 safety_state_(GetSafetyState(info.is_dangerous_file, |
176 info.is_dangerous_url)), | 178 info.is_dangerous_url)), |
177 danger_type_(GetDangerType(info.is_dangerous_file, | 179 danger_type_(GetDangerType(info.is_dangerous_file, |
178 info.is_dangerous_url)), | 180 info.is_dangerous_url)), |
179 auto_opened_(false), | 181 auto_opened_(false), |
180 target_name_(info.original_name), | 182 target_name_(info.original_name), |
181 render_process_id_(info.child_id), | 183 render_process_id_(info.child_id), |
182 request_id_(info.request_id), | 184 request_id_(info.request_id), |
183 save_as_(info.prompt_user_for_save_location), | 185 save_as_(info.prompt_user_for_save_location), |
184 is_otr_(is_otr), | 186 is_otr_(is_otr), |
(...skipping 19 matching lines...) Expand all Loading... |
204 total_bytes_(0), | 206 total_bytes_(0), |
205 received_bytes_(0), | 207 received_bytes_(0), |
206 last_os_error_(0), | 208 last_os_error_(0), |
207 start_tick_(base::TimeTicks::Now()), | 209 start_tick_(base::TimeTicks::Now()), |
208 state_(IN_PROGRESS), | 210 state_(IN_PROGRESS), |
209 start_time_(base::Time::Now()), | 211 start_time_(base::Time::Now()), |
210 db_handle_(DownloadHistory::kUninitializedHandle), | 212 db_handle_(DownloadHistory::kUninitializedHandle), |
211 download_manager_(download_manager), | 213 download_manager_(download_manager), |
212 is_paused_(false), | 214 is_paused_(false), |
213 open_when_complete_(false), | 215 open_when_complete_(false), |
| 216 file_exists_(true), |
214 safety_state_(SAFE), | 217 safety_state_(SAFE), |
215 danger_type_(NOT_DANGEROUS), | 218 danger_type_(NOT_DANGEROUS), |
216 auto_opened_(false), | 219 auto_opened_(false), |
217 render_process_id_(-1), | 220 render_process_id_(-1), |
218 request_id_(-1), | 221 request_id_(-1), |
219 save_as_(false), | 222 save_as_(false), |
220 is_otr_(is_otr), | 223 is_otr_(is_otr), |
221 is_extension_install_(false), | 224 is_extension_install_(false), |
222 is_temporary_(false), | 225 is_temporary_(false), |
223 all_data_saved_(false), | 226 all_data_saved_(false), |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 UpdateObservers(); | 358 UpdateObservers(); |
356 } | 359 } |
357 | 360 |
358 void DownloadItem::OnAllDataSaved(int64 size) { | 361 void DownloadItem::OnAllDataSaved(int64 size) { |
359 DCHECK(!all_data_saved_); | 362 DCHECK(!all_data_saved_); |
360 all_data_saved_ = true; | 363 all_data_saved_ = true; |
361 UpdateSize(size); | 364 UpdateSize(size); |
362 StopProgressTimer(); | 365 StopProgressTimer(); |
363 } | 366 } |
364 | 367 |
| 368 void DownloadItem::OnDownloadedFileRemoved() { |
| 369 file_exists_ = false; |
| 370 UpdateObservers(); |
| 371 } |
| 372 |
365 void DownloadItem::Completed() { | 373 void DownloadItem::Completed() { |
366 VLOG(20) << " " << __FUNCTION__ << "() " | 374 VLOG(20) << " " << __FUNCTION__ << "() " |
367 << DebugString(false); | 375 << DebugString(false); |
368 | 376 |
369 download_util::RecordDownloadCount(download_util::COMPLETED_COUNT); | 377 download_util::RecordDownloadCount(download_util::COMPLETED_COUNT); |
370 | 378 |
371 // Handle chrome extensions explicitly and skip the shell execute. | 379 // Handle chrome extensions explicitly and skip the shell execute. |
372 if (is_extension_install()) { | 380 if (is_extension_install()) { |
373 download_util::OpenChromeExtension(download_manager_->profile(), | 381 download_util::OpenChromeExtension(download_manager_->profile(), |
374 download_manager_, | 382 download_manager_, |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 target_name_.value().c_str(), | 661 target_name_.value().c_str(), |
654 full_path().value().c_str()); | 662 full_path().value().c_str()); |
655 } else { | 663 } else { |
656 description += base::StringPrintf(" url = \"%s\"", url().spec().c_str()); | 664 description += base::StringPrintf(" url = \"%s\"", url().spec().c_str()); |
657 } | 665 } |
658 | 666 |
659 description += " }"; | 667 description += " }"; |
660 | 668 |
661 return description; | 669 return description; |
662 } | 670 } |
OLD | NEW |