summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ssl
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-03 03:16:26 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-03 03:16:26 +0000
commit42b0ecedf7eb4beea125ac17ffc0cd373f4b420c (patch)
tree8c2026442208c18ec14613f0f6132b24acd1e7de /chrome/browser/ssl
parent37a241c6f22e761a07d9ff70aff1b15674eb8bf6 (diff)
downloadchromium_src-42b0ecedf7eb4beea125ac17ffc0cd373f4b420c.zip
chromium_src-42b0ecedf7eb4beea125ac17ffc0cd373f4b420c.tar.gz
chromium_src-42b0ecedf7eb4beea125ac17ffc0cd373f4b420c.tar.bz2
Infobar system refactor.
This changes the ownership model of infobars so that InfoBars are long-lived and own their InfoBarDelegates directly. The InfoBarService pseudo-owns the InfoBars (instead of deleting them directly, it tells them when they're unowned and expects them to delete themselves). This fixes leaks when infobars are closed while not visible (e.g. in a background tab) and in general makes the system clearer and easier to reason about. BUG=62154 TEST=none R=erg@chromium.org, sail@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/22694006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238283 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ssl')
-rw-r--r--chrome/browser/ssl/ssl_tab_helper.cc32
1 files changed, 15 insertions, 17 deletions
diff --git a/chrome/browser/ssl/ssl_tab_helper.cc b/chrome/browser/ssl/ssl_tab_helper.cc
index ece2ea6..1048e3c 100644
--- a/chrome/browser/ssl/ssl_tab_helper.cc
+++ b/chrome/browser/ssl/ssl_tab_helper.cc
@@ -42,18 +42,17 @@ namespace {
class SSLCertResultInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- // Creates an SSL cert result infobar delegate. If |previous_infobar| is
+ // Creates an SSL cert result infobar and delegate. If |previous_infobar| is
// NULL, adds the infobar to |infobar_service|; otherwise, replaces
// |previous_infobar|. Returns the new infobar if it was successfully added.
// |cert| is valid iff cert addition was successful.
- static InfoBarDelegate* Create(InfoBarService* infobar_service,
- InfoBarDelegate* previous_infobar,
- const string16& message,
- net::X509Certificate* cert);
+ static InfoBar* Create(InfoBarService* infobar_service,
+ InfoBar* previous_infobar,
+ const string16& message,
+ net::X509Certificate* cert);
private:
- SSLCertResultInfoBarDelegate(InfoBarService* infobar_service,
- const string16& message,
+ SSLCertResultInfoBarDelegate(const string16& message,
net::X509Certificate* cert);
virtual ~SSLCertResultInfoBarDelegate();
@@ -72,23 +71,22 @@ class SSLCertResultInfoBarDelegate : public ConfirmInfoBarDelegate {
};
// static
-InfoBarDelegate* SSLCertResultInfoBarDelegate::Create(
- InfoBarService* infobar_service,
- InfoBarDelegate* previous_infobar,
- const string16& message,
- net::X509Certificate* cert) {
- scoped_ptr<InfoBarDelegate> infobar(
- new SSLCertResultInfoBarDelegate(infobar_service, message, cert));
+InfoBar* SSLCertResultInfoBarDelegate::Create(InfoBarService* infobar_service,
+ InfoBar* previous_infobar,
+ const string16& message,
+ net::X509Certificate* cert) {
+ scoped_ptr<InfoBar> infobar(ConfirmInfoBarDelegate::CreateInfoBar(
+ scoped_ptr<ConfirmInfoBarDelegate>(
+ new SSLCertResultInfoBarDelegate(message, cert))));
return previous_infobar ?
infobar_service->ReplaceInfoBar(previous_infobar, infobar.Pass()) :
infobar_service->AddInfoBar(infobar.Pass());
}
SSLCertResultInfoBarDelegate::SSLCertResultInfoBarDelegate(
- InfoBarService* infobar_service,
const string16& message,
net::X509Certificate* cert)
- : ConfirmInfoBarDelegate(infobar_service),
+ : ConfirmInfoBarDelegate(),
message_(message),
cert_(cert) {
}
@@ -147,7 +145,7 @@ class SSLTabHelper::SSLAddCertData
const content::NotificationDetails& details) OVERRIDE;
InfoBarService* infobar_service_;
- InfoBarDelegate* infobar_;
+ InfoBar* infobar_;
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(SSLAddCertData);