• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "content/browser/download/download_item_impl_delegate.h"
6 
7 #include "base/logging.h"
8 #include "content/browser/download/download_item_impl.h"
9 
10 namespace content {
11 
12 // Infrastructure in DownloadItemImplDelegate to assert invariant that
13 // delegate always outlives all attached DownloadItemImpls.
DownloadItemImplDelegate()14 DownloadItemImplDelegate::DownloadItemImplDelegate()
15     : count_(0) {}
16 
~DownloadItemImplDelegate()17 DownloadItemImplDelegate::~DownloadItemImplDelegate() {
18   DCHECK_EQ(0, count_);
19 }
20 
Attach()21 void DownloadItemImplDelegate::Attach() {
22   ++count_;
23 }
24 
Detach()25 void DownloadItemImplDelegate::Detach() {
26   DCHECK_LT(0, count_);
27   --count_;
28 }
29 
DetermineDownloadTarget(DownloadItemImpl * download,const DownloadTargetCallback & callback)30 void DownloadItemImplDelegate::DetermineDownloadTarget(
31     DownloadItemImpl* download, const DownloadTargetCallback& callback) {
32   // TODO(rdsmith/asanka): Do something useful if forced file path is null.
33   base::FilePath target_path(download->GetForcedFilePath());
34   callback.Run(target_path,
35                DownloadItem::TARGET_DISPOSITION_OVERWRITE,
36                DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
37                target_path);
38 }
39 
ShouldCompleteDownload(DownloadItemImpl * download,const base::Closure & complete_callback)40 bool DownloadItemImplDelegate::ShouldCompleteDownload(
41     DownloadItemImpl* download,
42     const base::Closure& complete_callback) {
43   return true;
44 }
45 
ShouldOpenDownload(DownloadItemImpl * download,const ShouldOpenDownloadCallback & callback)46 bool DownloadItemImplDelegate::ShouldOpenDownload(
47     DownloadItemImpl* download, const ShouldOpenDownloadCallback& callback) {
48   return false;
49 }
50 
ShouldOpenFileBasedOnExtension(const base::FilePath & path)51 bool DownloadItemImplDelegate::ShouldOpenFileBasedOnExtension(
52     const base::FilePath& path) {
53   return false;
54 }
55 
CheckForFileRemoval(DownloadItemImpl * download_item)56 void DownloadItemImplDelegate::CheckForFileRemoval(
57     DownloadItemImpl* download_item) {}
58 
ResumeInterruptedDownload(scoped_ptr<DownloadUrlParameters> params,uint32 id)59 void DownloadItemImplDelegate::ResumeInterruptedDownload(
60     scoped_ptr<DownloadUrlParameters> params, uint32 id) {}
61 
GetBrowserContext() const62 BrowserContext* DownloadItemImplDelegate::GetBrowserContext() const {
63   return NULL;
64 }
65 
UpdatePersistence(DownloadItemImpl * download)66 void DownloadItemImplDelegate::UpdatePersistence(DownloadItemImpl* download) {}
67 
OpenDownload(DownloadItemImpl * download)68 void DownloadItemImplDelegate::OpenDownload(DownloadItemImpl* download) {}
69 
ShowDownloadInShell(DownloadItemImpl * download)70 void DownloadItemImplDelegate::ShowDownloadInShell(DownloadItemImpl* download) {
71 }
72 
DownloadRemoved(DownloadItemImpl * download)73 void DownloadItemImplDelegate::DownloadRemoved(DownloadItemImpl* download) {}
74 
AssertStateConsistent(DownloadItemImpl * download) const75 void DownloadItemImplDelegate::AssertStateConsistent(
76     DownloadItemImpl* download) const {}
77 
78 }  // namespace content
79