| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/logging.h" | |
| 6 #include "content/browser/download/download_item_impl_delegate.h" | 5 #include "content/browser/download/download_item_impl_delegate.h" |
| 7 | 6 |
| 8 class DownloadItemImpl; | 7 #include "base/logging.h" |
| 8 #include "content/browser/download/download_item_impl.h" |
| 9 | 9 |
| 10 // Infrastructure in DownloadItemImplDelegate to assert invariant that | 10 // Infrastructure in DownloadItemImplDelegate to assert invariant that |
| 11 // delegate always outlives all attached DownloadItemImpls. | 11 // delegate always outlives all attached DownloadItemImpls. |
| 12 DownloadItemImplDelegate::DownloadItemImplDelegate() | 12 DownloadItemImplDelegate::DownloadItemImplDelegate() |
| 13 : count_(0) {} | 13 : count_(0) {} |
| 14 | 14 |
| 15 DownloadItemImplDelegate::~DownloadItemImplDelegate() { | 15 DownloadItemImplDelegate::~DownloadItemImplDelegate() { |
| 16 DCHECK_EQ(0, count_); | 16 DCHECK_EQ(0, count_); |
| 17 } | 17 } |
| 18 | 18 |
| 19 void DownloadItemImplDelegate::Attach() { | 19 void DownloadItemImplDelegate::Attach() { |
| 20 ++count_; | 20 ++count_; |
| 21 } | 21 } |
| 22 | 22 |
| 23 void DownloadItemImplDelegate::Detach() { | 23 void DownloadItemImplDelegate::Detach() { |
| 24 DCHECK_LT(0, count_); | 24 DCHECK_LT(0, count_); |
| 25 --count_; | 25 --count_; |
| 26 } | 26 } |
| 27 | 27 |
| 28 void DownloadItemImplDelegate::DetermineDownloadTarget( |
| 29 DownloadItemImpl* download, const DownloadTargetCallback& callback) { |
| 30 // TODO(rdsmith/asanka): Do something useful if forced file path is null. |
| 31 FilePath target_path(download->GetForcedFilePath()); |
| 32 callback.Run(target_path, |
| 33 content::DownloadItem::TARGET_DISPOSITION_OVERWRITE, |
| 34 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, |
| 35 target_path); |
| 36 } |
| 37 |
| 28 void DownloadItemImplDelegate::ReadyForDownloadCompletion( | 38 void DownloadItemImplDelegate::ReadyForDownloadCompletion( |
| 29 DownloadItemImpl* download, | 39 DownloadItemImpl* download, |
| 30 const base::Closure& complete_callback) { | 40 const base::Closure& complete_callback) { |
| 31 complete_callback.Run(); | 41 complete_callback.Run(); |
| 32 } | 42 } |
| 33 | 43 |
| 44 bool DownloadItemImplDelegate::ShouldOpenDownload(DownloadItemImpl* download) { |
| 45 return false; |
| 46 } |
| 47 |
| 34 bool DownloadItemImplDelegate::ShouldOpenFileBasedOnExtension( | 48 bool DownloadItemImplDelegate::ShouldOpenFileBasedOnExtension( |
| 35 const FilePath& path) { | 49 const FilePath& path) { |
| 36 return false; | 50 return false; |
| 37 } | 51 } |
| 38 | 52 |
| 39 bool DownloadItemImplDelegate::ShouldOpenDownload(DownloadItemImpl* download) { | |
| 40 return false; | |
| 41 } | |
| 42 | |
| 43 void DownloadItemImplDelegate::CheckForFileRemoval( | 53 void DownloadItemImplDelegate::CheckForFileRemoval( |
| 44 DownloadItemImpl* download_item) {} | 54 DownloadItemImpl* download_item) {} |
| 45 | 55 |
| 46 content::BrowserContext* DownloadItemImplDelegate::GetBrowserContext() const { | 56 content::BrowserContext* DownloadItemImplDelegate::GetBrowserContext() const { |
| 47 return NULL; | 57 return NULL; |
| 48 } | 58 } |
| 49 | 59 |
| 50 DownloadFileManager* DownloadItemImplDelegate::GetDownloadFileManager() { | 60 DownloadFileManager* DownloadItemImplDelegate::GetDownloadFileManager() { |
| 51 return NULL; | 61 return NULL; |
| 52 } | 62 } |
| 53 | 63 |
| 54 void DownloadItemImplDelegate::UpdatePersistence(DownloadItemImpl* download) {} | 64 void DownloadItemImplDelegate::UpdatePersistence(DownloadItemImpl* download) {} |
| 55 | 65 |
| 56 void DownloadItemImplDelegate::DownloadStopped(DownloadItemImpl* download) {} | 66 void DownloadItemImplDelegate::DownloadStopped(DownloadItemImpl* download) {} |
| 57 | 67 |
| 58 void DownloadItemImplDelegate::DownloadCompleted(DownloadItemImpl* download) {} | 68 void DownloadItemImplDelegate::DownloadCompleted(DownloadItemImpl* download) {} |
| 59 | 69 |
| 60 void DownloadItemImplDelegate::DownloadOpened(DownloadItemImpl* download) {} | 70 void DownloadItemImplDelegate::DownloadOpened(DownloadItemImpl* download) {} |
| 61 | 71 |
| 62 void DownloadItemImplDelegate::DownloadRemoved(DownloadItemImpl* download) {} | 72 void DownloadItemImplDelegate::DownloadRemoved(DownloadItemImpl* download) {} |
| 63 | 73 |
| 64 void DownloadItemImplDelegate::DownloadRenamedToIntermediateName( | 74 void DownloadItemImplDelegate::DownloadRenamedToIntermediateName( |
| 65 DownloadItemImpl* download) {} | 75 DownloadItemImpl* download) {} |
| 66 | 76 |
| 67 void DownloadItemImplDelegate::DownloadRenamedToFinalName( | 77 void DownloadItemImplDelegate::DownloadRenamedToFinalName( |
| 68 DownloadItemImpl* download) {} | 78 DownloadItemImpl* download) {} |
| 69 | 79 |
| 70 void DownloadItemImplDelegate::AssertStateConsistent( | 80 void DownloadItemImplDelegate::AssertStateConsistent( |
| 71 DownloadItemImpl* download) const {} | 81 DownloadItemImpl* download) const {} |
| OLD | NEW |