diff options
Diffstat (limited to 'chrome/browser/download')
4 files changed, 15 insertions, 14 deletions
diff --git a/chrome/browser/download/download_request_infobar_delegate.cc b/chrome/browser/download/download_request_infobar_delegate.cc index 1601b9f..4d39ad3 100644 --- a/chrome/browser/download/download_request_infobar_delegate.cc +++ b/chrome/browser/download/download_request_infobar_delegate.cc @@ -15,15 +15,14 @@ DownloadRequestInfoBarDelegate::DownloadRequestInfoBarDelegate( DownloadRequestLimiter::TabDownloadState* host) : ConfirmInfoBarDelegate(tab), host_(host) { - if (tab) - tab->AddInfoBar(this); } DownloadRequestInfoBarDelegate::~DownloadRequestInfoBarDelegate() { } void DownloadRequestInfoBarDelegate::InfoBarClosed() { - Cancel(); + if (host_) + host_->Cancel(); // This will delete us. ConfirmInfoBarDelegate::InfoBarClosed(); } @@ -51,11 +50,3 @@ bool DownloadRequestInfoBarDelegate::Accept() { return !host_; } - -bool DownloadRequestInfoBarDelegate::Cancel() { - if (host_) { - host_->Cancel(); - host_ = NULL; - } - return true; -} diff --git a/chrome/browser/download/download_request_infobar_delegate.h b/chrome/browser/download/download_request_infobar_delegate.h index 60d2132..16d3f4b 100644 --- a/chrome/browser/download/download_request_infobar_delegate.h +++ b/chrome/browser/download/download_request_infobar_delegate.h @@ -35,7 +35,6 @@ class DownloadRequestInfoBarDelegate : public ConfirmInfoBarDelegate { virtual string16 GetMessageText() const; virtual string16 GetButtonLabel(InfoBarButton button) const; virtual bool Accept(); - virtual bool Cancel(); DownloadRequestLimiter::TabDownloadState* host_; diff --git a/chrome/browser/download/download_request_infobar_delegate_unittest.cc b/chrome/browser/download/download_request_infobar_delegate_unittest.cc index 90ec2af..5a8b251 100644 --- a/chrome/browser/download/download_request_infobar_delegate_unittest.cc +++ b/chrome/browser/download/download_request_infobar_delegate_unittest.cc @@ -20,6 +20,14 @@ class MockTabDownloadState : public DownloadRequestLimiter::TabDownloadState { ConfirmInfoBarDelegate* infobar() { return infobar_->AsConfirmInfoBarDelegate(); } + void close_infobar() { + // TODO(pkasting): Right now InfoBarDelegates delete themselves via + // InfoBarClosed(); once InfoBars own their delegates, this can become a + // simple reset() call and ~MockTabDownloadState() will no longer need to + // call it. + if (infobar_ != NULL) + infobar_.release()->InfoBarClosed(); + } bool responded() const { return responded_; } bool accepted() const { return accepted_; } @@ -41,6 +49,7 @@ MockTabDownloadState::MockTabDownloadState() } MockTabDownloadState::~MockTabDownloadState() { + close_infobar(); EXPECT_TRUE(responded_); } @@ -54,6 +63,7 @@ void MockTabDownloadState::Accept() { EXPECT_FALSE(responded_); responded_ = true; accepted_ = true; + static_cast<DownloadRequestInfoBarDelegate*>(infobar_.get())->set_host(NULL); } @@ -73,6 +83,6 @@ TEST(DownloadRequestInfobarDelegate, CancelTest) { TEST(DownloadRequestInfobarDelegate, CloseTest) { MockTabDownloadState state; - state.infobar()->InfoBarClosed(); + state.close_infobar(); EXPECT_FALSE(state.accepted()); } diff --git a/chrome/browser/download/download_request_limiter.cc b/chrome/browser/download/download_request_limiter.cc index fae07c9..075d103 100644 --- a/chrome/browser/download/download_request_limiter.cc +++ b/chrome/browser/download/download_request_limiter.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -71,6 +71,7 @@ void DownloadRequestLimiter::TabDownloadState::PromptUserForDownload( NotifyCallbacks(DownloadRequestLimiter::delegate_->ShouldAllowDownload()); } else { infobar_ = new DownloadRequestInfoBarDelegate(tab, this); + tab->AddInfoBar(infobar_); } } |