summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-08 04:20:40 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-08 04:20:40 +0000
commitec8f51164d477d8d83726fe61c68977d17b03149 (patch)
treede1ea01984caab5a5841c8a7c1593805157ce60d /chrome/browser/download
parentef47ded033e48098e83bb94e63b6e44ca6b511b4 (diff)
downloadchromium_src-ec8f51164d477d8d83726fe61c68977d17b03149.zip
chromium_src-ec8f51164d477d8d83726fe61c68977d17b03149.tar.gz
chromium_src-ec8f51164d477d8d83726fe61c68977d17b03149.tar.bz2
Cleanup:
* Change int to size_t in a few APIs. * Rename infobar_delegate_count() to infobar_count() in preparation for TabContents owning InfoBars rather than InfoBarDelegates. * Move some code from PluginInstallerInfoBarDelegate to PluginObserver since it's more related to who's instantiating the infobar(delegate)s. * Unify InfoBarDelegate behavior by making no delegates auto-add themselves to tabs (callers now all do this explicitly). * Eliminate unused member TabContentsSSLHelper::SSLAddCertData::handler_. * De-inline a couple classes. * Make more functions private. * Add some consts. * Change DCHECK() to DCHECK_EQ() where possible. * Rename the delegates in plugin_observer.cc to have "Delegate" in the names. * Remove unnecessary qualifiers. * Simplify. * Misc. style issues, naming issues, etc. BUG=none TEST=none Review URL: http://codereview.chromium.org/6250172 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74086 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download')
-rw-r--r--chrome/browser/download/download_request_infobar_delegate.cc13
-rw-r--r--chrome/browser/download/download_request_infobar_delegate.h1
-rw-r--r--chrome/browser/download/download_request_infobar_delegate_unittest.cc12
-rw-r--r--chrome/browser/download/download_request_limiter.cc3
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_);
}
}