summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/browser_init.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 02:12:10 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 02:12:10 +0000
commite3c31d27e49dd4b795fdca9c290fabee1b117b02 (patch)
treec5b4d960ae0237842d77324542b205e80d4dfcbf /chrome/browser/ui/browser_init.cc
parentf9486289464b51ffedba0541bf0fbeefc5d53f39 (diff)
downloadchromium_src-e3c31d27e49dd4b795fdca9c290fabee1b117b02.zip
chromium_src-e3c31d27e49dd4b795fdca9c290fabee1b117b02.tar.gz
chromium_src-e3c31d27e49dd4b795fdca9c290fabee1b117b02.tar.bz2
Replace the virtual InfoBarDelegate::InfoBarClosed() function with a non-virtual one. This is a step along the way to killing it entirely. This also adds a lot of OVERRIDE markers and does some other cleanup in a few places.
The original (stupid) design for the delegate class left subclasses great flexibility in how they mapped infobars to delegates. In practice, no one ever wanted multiple infobars driven off a single delegate, so the mapping was always one-to-one. As a result, it was always correct for InfoBarClosed() to "delete this", but because the base class did not do so, every subclass needed to. Most did; the others leaked memory and failed to run their destructors. This change forces the base class to delete itself. This fixes the delegate leaks in the couple subclasses that failed to do this. It also eliminates a lot of copy-and-pasted "delete this" implementations. Ultimately, we'll be moving to a model where the InfoBar "view" class owns the delegate and deletes it directly, which will eliminate InfoBarClosed() completely. BUG=62154 TEST=none Review URL: http://codereview.chromium.org/6926001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84195 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/browser_init.cc')
-rw-r--r--chrome/browser/ui/browser_init.cc71
1 files changed, 37 insertions, 34 deletions
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index 86bb2ec..6700377 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -144,7 +144,6 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
// ConfirmInfoBarDelegate:
virtual bool ShouldExpire(
const NavigationController::LoadCommittedDetails& details) const OVERRIDE;
- virtual void InfoBarClosed() OVERRIDE;
virtual gfx::Image* GetIcon() const OVERRIDE;
virtual string16 GetMessageText() const OVERRIDE;
virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
@@ -182,6 +181,8 @@ DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate(
}
DefaultBrowserInfoBarDelegate::~DefaultBrowserInfoBarDelegate() {
+ if (!action_taken_)
+ UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.Ignored", 1);
}
bool DefaultBrowserInfoBarDelegate::ShouldExpire(
@@ -189,12 +190,6 @@ bool DefaultBrowserInfoBarDelegate::ShouldExpire(
return should_expire_;
}
-void DefaultBrowserInfoBarDelegate::InfoBarClosed() {
- if (!action_taken_)
- UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.Ignored", 1);
- delete this;
-}
-
gfx::Image* DefaultBrowserInfoBarDelegate::GetIcon() const {
return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
IDR_PRODUCT_ICON_32);
@@ -305,7 +300,6 @@ class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate {
virtual ~SessionCrashedInfoBarDelegate();
// ConfirmInfoBarDelegate:
- virtual void InfoBarClosed() OVERRIDE;
virtual gfx::Image* GetIcon() const OVERRIDE;
virtual string16 GetMessageText() const OVERRIDE;
virtual int GetButtons() const OVERRIDE;
@@ -327,10 +321,6 @@ SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate(
SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() {
}
-void SessionCrashedInfoBarDelegate::InfoBarClosed() {
- delete this;
-}
-
gfx::Image* SessionCrashedInfoBarDelegate::GetIcon() const {
return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
IDR_INFOBAR_RESTORE_SESSION);
@@ -1081,29 +1071,13 @@ void BrowserInit::LaunchWithProfile::AddBadFlagsInfoBarIfNecessary(
class DNSCertProvenanceCheckingInfoBar : public ConfirmInfoBarDelegate {
public:
- explicit DNSCertProvenanceCheckingInfoBar(TabContents* tab_contents)
- : ConfirmInfoBarDelegate(tab_contents),
- tab_contents_(tab_contents) {
- }
+ explicit DNSCertProvenanceCheckingInfoBar(TabContents* tab_contents);
+ virtual ~DNSCertProvenanceCheckingInfoBar();
- virtual string16 GetMessageText() const {
- return l10n_util::GetStringUTF16(
- IDS_DNS_CERT_PROVENANCE_CHECKING_WARNING_MESSAGE);
- }
-
- virtual int GetButtons() const {
- return BUTTON_OK;
- }
-
- virtual string16 GetButtonLabel(InfoBarButton button) const {
- return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
- }
-
- virtual bool Accept() {
- tab_contents_->OpenURL(GURL(kLearnMoreURL), GURL(), NEW_FOREGROUND_TAB,
- PageTransition::AUTO_BOOKMARK);
- return true;
- }
+ virtual string16 GetMessageText() const OVERRIDE;
+ virtual int GetButtons() const OVERRIDE;
+ virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
+ virtual bool Accept() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(DNSCertProvenanceCheckingInfoBar);
@@ -1112,6 +1086,35 @@ class DNSCertProvenanceCheckingInfoBar : public ConfirmInfoBarDelegate {
TabContents* const tab_contents_;
};
+DNSCertProvenanceCheckingInfoBar::DNSCertProvenanceCheckingInfoBar(
+ TabContents* tab_contents)
+ : ConfirmInfoBarDelegate(tab_contents),
+ tab_contents_(tab_contents) {
+}
+
+DNSCertProvenanceCheckingInfoBar::~DNSCertProvenanceCheckingInfoBar() {
+}
+
+string16 DNSCertProvenanceCheckingInfoBar::GetMessageText() const {
+ return l10n_util::GetStringUTF16(
+ IDS_DNS_CERT_PROVENANCE_CHECKING_WARNING_MESSAGE);
+}
+
+int DNSCertProvenanceCheckingInfoBar::GetButtons() const {
+ return BUTTON_OK;
+}
+
+string16 DNSCertProvenanceCheckingInfoBar::GetButtonLabel(
+ InfoBarButton button) const {
+ return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
+}
+
+bool DNSCertProvenanceCheckingInfoBar::Accept() {
+ tab_contents_->OpenURL(GURL(kLearnMoreURL), GURL(), NEW_FOREGROUND_TAB,
+ PageTransition::AUTO_BOOKMARK);
+ return true;
+}
+
// This is the page which provides information on DNS certificate provenance
// checking.
const char DNSCertProvenanceCheckingInfoBar::kLearnMoreURL[] =