| 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 "content/browser/download/download_item.h" | 5 #include "content/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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 download_stats::RecordOpen(end_time(), !opened()); | 289 download_stats::RecordOpen(end_time(), !opened()); |
| 290 opened_ = true; | 290 opened_ = true; |
| 291 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadOpened(this)); | 291 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadOpened(this)); |
| 292 download_manager_->MarkDownloadOpened(this); | 292 download_manager_->MarkDownloadOpened(this); |
| 293 | 293 |
| 294 // For testing: If download opening is disabled on this item, | 294 // For testing: If download opening is disabled on this item, |
| 295 // make the rest of the routine a no-op. | 295 // make the rest of the routine a no-op. |
| 296 if (!open_enabled_) | 296 if (!open_enabled_) |
| 297 return; | 297 return; |
| 298 | 298 |
| 299 if (download_manager_->delegate()->ShouldOpenDownload(this)) | 299 content::GetContentClient()->browser()->OpenItem(full_path()); |
| 300 content::GetContentClient()->browser()->OpenItem(full_path()); | |
| 301 } | 300 } |
| 302 | 301 |
| 303 void DownloadItem::ShowDownloadInShell() { | 302 void DownloadItem::ShowDownloadInShell() { |
| 304 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 303 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
| 305 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 304 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 306 | 305 |
| 307 content::GetContentClient()->browser()->ShowItemInFolder(full_path()); | 306 content::GetContentClient()->browser()->ShowItemInFolder(full_path()); |
| 308 } | 307 } |
| 309 | 308 |
| 310 void DownloadItem::DangerousDownloadValidated() { | 309 void DownloadItem::DangerousDownloadValidated() { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 389 |
| 391 void DownloadItem::MarkAsComplete() { | 390 void DownloadItem::MarkAsComplete() { |
| 392 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 391 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
| 393 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 392 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 394 | 393 |
| 395 DCHECK(all_data_saved_); | 394 DCHECK(all_data_saved_); |
| 396 end_time_ = base::Time::Now(); | 395 end_time_ = base::Time::Now(); |
| 397 TransitionTo(COMPLETE); | 396 TransitionTo(COMPLETE); |
| 398 } | 397 } |
| 399 | 398 |
| 400 void DownloadItem::CompleteDelayedDownload() { | 399 void DownloadItem::DelayedDownloadOpened() { |
| 401 auto_opened_ = true; | 400 auto_opened_ = true; |
| 402 Completed(); | 401 Completed(); |
| 403 } | 402 } |
| 404 | 403 |
| 405 void DownloadItem::OnAllDataSaved(int64 size) { | 404 void DownloadItem::OnAllDataSaved(int64 size) { |
| 406 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 405 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
| 407 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 406 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 408 | 407 |
| 409 DCHECK(!all_data_saved_); | 408 DCHECK(!all_data_saved_); |
| 410 all_data_saved_ = true; | 409 all_data_saved_ = true; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 610 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 612 | 611 |
| 613 VLOG(20) << __FUNCTION__ << "()" | 612 VLOG(20) << __FUNCTION__ << "()" |
| 614 << " full_path = \"" << full_path.value() << "\"" | 613 << " full_path = \"" << full_path.value() << "\"" |
| 615 << " needed rename = " << NeedsRename() | 614 << " needed rename = " << NeedsRename() |
| 616 << " " << DebugString(false); | 615 << " " << DebugString(false); |
| 617 DCHECK(NeedsRename()); | 616 DCHECK(NeedsRename()); |
| 618 | 617 |
| 619 Rename(full_path); | 618 Rename(full_path); |
| 620 | 619 |
| 621 if (download_manager_->delegate()->ShouldCompleteDownload(this)) { | 620 if (download_manager_->delegate()->ShouldOpenDownload(this)) { |
| 622 Completed(); | 621 Completed(); |
| 623 } else { | 622 } else { |
| 624 delegate_delayed_complete_ = true; | 623 delegate_delayed_complete_ = true; |
| 625 } | 624 } |
| 626 } | 625 } |
| 627 | 626 |
| 628 bool DownloadItem::MatchesQuery(const string16& query) const { | 627 bool DownloadItem::MatchesQuery(const string16& query) const { |
| 629 if (query.empty()) | 628 if (query.empty()) |
| 630 return true; | 629 return true; |
| 631 | 630 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 state_info_.target_name.value().c_str(), | 810 state_info_.target_name.value().c_str(), |
| 812 full_path().value().c_str()); | 811 full_path().value().c_str()); |
| 813 } else { | 812 } else { |
| 814 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); | 813 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); |
| 815 } | 814 } |
| 816 | 815 |
| 817 description += " }"; | 816 description += " }"; |
| 818 | 817 |
| 819 return description; | 818 return description; |
| 820 } | 819 } |
| OLD | NEW |