download_item_impl_delegate.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
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 10namespace content { 11 12// Infrastructure in DownloadItemImplDelegate to assert invariant that 13// delegate always outlives all attached DownloadItemImpls. 14DownloadItemImplDelegate::DownloadItemImplDelegate() 15 : count_(0) {} 16 17DownloadItemImplDelegate::~DownloadItemImplDelegate() { 18 DCHECK_EQ(0, count_); 19} 20 21void DownloadItemImplDelegate::Attach() { 22 ++count_; 23} 24 25void DownloadItemImplDelegate::Detach() { 26 DCHECK_LT(0, count_); 27 --count_; 28} 29 30void DownloadItemImplDelegate::DetermineDownloadTarget( 31 DownloadItemImpl* download, const DownloadTargetCallback& callback) { 32 // TODO(rdsmith/asanka): Do something useful if forced file path is null. 33 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 40void DownloadItemImplDelegate::ReadyForDownloadCompletion( 41 DownloadItemImpl* download, 42 const base::Closure& complete_callback) { 43 complete_callback.Run(); 44} 45 46bool DownloadItemImplDelegate::ShouldOpenDownload( 47 DownloadItemImpl* download, const ShouldOpenDownloadCallback& callback) { 48 return false; 49} 50 51bool DownloadItemImplDelegate::ShouldOpenFileBasedOnExtension( 52 const FilePath& path) { 53 return false; 54} 55 56void DownloadItemImplDelegate::CheckForFileRemoval( 57 DownloadItemImpl* download_item) {} 58 59BrowserContext* DownloadItemImplDelegate::GetBrowserContext() const { 60 return NULL; 61} 62 63void DownloadItemImplDelegate::UpdatePersistence(DownloadItemImpl* download) {} 64 65void DownloadItemImplDelegate::DownloadStopped(DownloadItemImpl* download) {} 66 67void DownloadItemImplDelegate::DownloadCompleted(DownloadItemImpl* download) {} 68 69void DownloadItemImplDelegate::DownloadOpened(DownloadItemImpl* download) {} 70 71void DownloadItemImplDelegate::DownloadRemoved(DownloadItemImpl* download) {} 72 73void DownloadItemImplDelegate::DownloadRenamedToIntermediateName( 74 DownloadItemImpl* download) {} 75 76void DownloadItemImplDelegate::DownloadRenamedToFinalName( 77 DownloadItemImpl* download) {} 78 79void DownloadItemImplDelegate::AssertStateConsistent( 80 DownloadItemImpl* download) const {} 81 82} // namespace content 83