| 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), |
| 224 opened_(false) { | 227 opened_(false) { |
| 225 Init(true /* start progress timer */); | 228 Init(true /* start progress timer */); |
| 226 } | 229 } |
| 227 | 230 |
| 228 DownloadItem::~DownloadItem() { | 231 DownloadItem::~DownloadItem() { |
| 229 state_ = REMOVING; | 232 state_ = REMOVING; |
| 230 UpdateObservers(); | 233 UpdateObservers(); |
| 231 } | 234 } |
| 232 | 235 |
| 233 void DownloadItem::AddObserver(Observer* observer) { | 236 void DownloadItem::AddObserver(Observer* observer) { |
| 234 observers_.AddObserver(observer); | 237 observers_.AddObserver(observer); |
| 235 } | 238 } |
| 236 | 239 |
| 240 bool DownloadItem::HasObserver(Observer* observer) { |
| 241 return observers_.HasObserver(observer); |
| 242 } |
| 243 |
| 237 void DownloadItem::RemoveObserver(Observer* observer) { | 244 void DownloadItem::RemoveObserver(Observer* observer) { |
| 238 observers_.RemoveObserver(observer); | 245 observers_.RemoveObserver(observer); |
| 239 } | 246 } |
| 240 | 247 |
| 241 void DownloadItem::UpdateObservers() { | 248 void DownloadItem::UpdateObservers() { |
| 242 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadUpdated(this)); | 249 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadUpdated(this)); |
| 243 } | 250 } |
| 244 | 251 |
| 245 bool DownloadItem::CanOpenDownload() { | 252 bool DownloadItem::CanOpenDownload() { |
| 246 return !Extension::IsExtension(target_name_); | 253 return !Extension::IsExtension(target_name_); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 target_name_.value().c_str(), | 660 target_name_.value().c_str(), |
| 654 full_path().value().c_str()); | 661 full_path().value().c_str()); |
| 655 } else { | 662 } else { |
| 656 description += base::StringPrintf(" url = \"%s\"", url().spec().c_str()); | 663 description += base::StringPrintf(" url = \"%s\"", url().spec().c_str()); |
| 657 } | 664 } |
| 658 | 665 |
| 659 description += " }"; | 666 description += " }"; |
| 660 | 667 |
| 661 return description; | 668 return description; |
| 662 } | 669 } |
| OLD | NEW |