diff --git a/chrome/browser/chrome_notification_types.h b/chrome/browser/chrome_notification_types.h index eb5ed40342d01f..f36ed3e33308ea 100644 --- a/chrome/browser/chrome_notification_types.h +++ b/chrome/browser/chrome_notification_types.h @@ -131,12 +131,6 @@ enum NotificationType { // Details. NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - // This message is sent when an InfoBar is replacing another infobar in an - // InfoBarService. The source is a Source with a pointer to - // the InfoBarService the InfoBar was removed from. The details is a - // Details. - NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, - // Used to fire notifications about how long various events took to // complete. E.g., this is used to get more fine grained timings from the // new tab page. The source is a WebContents and the details is a diff --git a/chrome/browser/infobars/infobar_service.cc b/chrome/browser/infobars/infobar_service.cc index 030035b6a10945..db73ec38b903aa 100644 --- a/chrome/browser/infobars/infobar_service.cc +++ b/chrome/browser/infobars/infobar_service.cc @@ -68,7 +68,7 @@ int InfoBarService::GetActiveEntryID() { void InfoBarService::NotifyInfoBarAdded(InfoBar* infobar) { InfoBarManager::NotifyInfoBarAdded(infobar); // TODO(droger): Remove the notifications and have listeners change to be - // NavigationManager::Observers instead. See http://crbug.com/354380 + // InfoBarManager::Observers instead. See http://crbug.com/354380 content::NotificationService::current()->Notify( chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, content::Source(this), @@ -78,7 +78,7 @@ void InfoBarService::NotifyInfoBarAdded(InfoBar* infobar) { void InfoBarService::NotifyInfoBarRemoved(InfoBar* infobar, bool animate) { InfoBarManager::NotifyInfoBarRemoved(infobar, animate); // TODO(droger): Remove the notifications and have listeners change to be - // NavigationManager::Observers instead. See http://crbug.com/354380 + // InfoBarManager::Observers instead. See http://crbug.com/354380 InfoBar::RemovedDetails removed_details(infobar, animate); content::NotificationService::current()->Notify( chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, @@ -86,18 +86,6 @@ void InfoBarService::NotifyInfoBarRemoved(InfoBar* infobar, bool animate) { content::Details(&removed_details)); } -void InfoBarService::NotifyInfoBarReplaced(InfoBar* old_infobar, - InfoBar* new_infobar) { - InfoBarManager::NotifyInfoBarReplaced(old_infobar, new_infobar); - // TODO(droger): Remove the notifications and have listeners change to be - // NavigationManager::Observers instead. See http://crbug.com/354380 - InfoBar::ReplacedDetails replaced_details(old_infobar, new_infobar); - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, - content::Source(this), - content::Details(&replaced_details)); -} - void InfoBarService::RenderProcessGone(base::TerminationStatus status) { RemoveAllInfoBars(true); } diff --git a/chrome/browser/infobars/infobar_service.h b/chrome/browser/infobars/infobar_service.h index a90305b5b7afa9..7a07de00062eac 100644 --- a/chrome/browser/infobars/infobar_service.h +++ b/chrome/browser/infobars/infobar_service.h @@ -55,8 +55,6 @@ class InfoBarService : public infobars::InfoBarManager, virtual void NotifyInfoBarAdded(infobars::InfoBar* infobar) OVERRIDE; virtual void NotifyInfoBarRemoved(infobars::InfoBar* infobar, bool animate) OVERRIDE; - virtual void NotifyInfoBarReplaced(infobars::InfoBar* old_infobar, - infobars::InfoBar* new_infobar) OVERRIDE; // content::WebContentsObserver: virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; diff --git a/chrome/browser/ssl/ssl_tab_helper.cc b/chrome/browser/ssl/ssl_tab_helper.cc index a1d5a0b88cce0c..f7045928157212 100644 --- a/chrome/browser/ssl/ssl_tab_helper.cc +++ b/chrome/browser/ssl/ssl_tab_helper.cc @@ -23,10 +23,7 @@ #include "chrome/browser/ui/browser_finder.h" #include "chrome/common/chrome_switches.h" #include "components/infobars/core/infobar.h" -#include "content/public/browser/notification_details.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" -#include "content/public/browser/notification_source.h" +#include "components/infobars/core/infobar_manager.h" #include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -132,8 +129,7 @@ bool SSLCertResultInfoBarDelegate::Accept() { // SSLTabHelper::SSLAddCertData ------------------------------------------------ -class SSLTabHelper::SSLAddCertData - : public content::NotificationObserver { +class SSLTabHelper::SSLAddCertData : public infobars::InfoBarManager::Observer { public: explicit SSLAddCertData(InfoBarService* infobar_service); virtual ~SSLAddCertData(); @@ -142,14 +138,14 @@ class SSLTabHelper::SSLAddCertData void ShowInfoBar(const base::string16& message, net::X509Certificate* cert); private: - // content::NotificationObserver: - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; + // infobars::InfoBarManager::Observer: + virtual void OnInfoBarRemoved(infobars::InfoBar* infobar, + bool animate) OVERRIDE; + virtual void OnInfoBarReplaced(infobars::InfoBar* old_infobar, + infobars::InfoBar* new_infobar) OVERRIDE; InfoBarService* infobar_service_; infobars::InfoBar* infobar_; - content::NotificationRegistrar registrar_; DISALLOW_COPY_AND_ASSIGN(SSLAddCertData); }; @@ -157,14 +153,11 @@ class SSLTabHelper::SSLAddCertData SSLTabHelper::SSLAddCertData::SSLAddCertData(InfoBarService* infobar_service) : infobar_service_(infobar_service), infobar_(NULL) { - content::Source source(infobar_service_); - registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, - source); - registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, - source); + infobar_service_->AddObserver(this); } SSLTabHelper::SSLAddCertData::~SSLAddCertData() { + infobar_service_->RemoveObserver(this); } void SSLTabHelper::SSLAddCertData::ShowInfoBar(const base::string16& message, @@ -173,20 +166,17 @@ void SSLTabHelper::SSLAddCertData::ShowInfoBar(const base::string16& message, message, cert); } -void SSLTabHelper::SSLAddCertData::Observe( - int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED || - type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED); - if (infobar_ == - ((type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED) ? - content::Details( - details)->first : - content::Details( - details)->first)) { +void SSLTabHelper::SSLAddCertData::OnInfoBarRemoved(infobars::InfoBar* infobar, + bool animate) { + if (infobar_ == infobar) + infobar_ = NULL; +} + +void SSLTabHelper::SSLAddCertData::OnInfoBarReplaced( + infobars::InfoBar* old_infobar, + infobars::InfoBar* new_infobar) { + if (infobar_ == old_infobar) infobar_ = NULL; - } } diff --git a/components/infobars/core/infobar.h b/components/infobars/core/infobar.h index 9aef299a3f3afb..46e1584c2b8485 100644 --- a/components/infobars/core/infobar.h +++ b/components/infobars/core/infobar.h @@ -39,7 +39,6 @@ class InfoBar : public gfx::AnimationDelegate { // These are the types passed as Details for infobar-related notifications. typedef InfoBar AddedDetails; typedef std::pair RemovedDetails; - typedef std::pair ReplacedDetails; // Platforms must define these. static const int kDefaultBarTargetHeight; diff --git a/components/infobars/core/infobar_manager.cc b/components/infobars/core/infobar_manager.cc index 6afc9c4e51d6b3..d2c699fe3e1ef2 100644 --- a/components/infobars/core/infobar_manager.cc +++ b/components/infobars/core/infobar_manager.cc @@ -80,7 +80,9 @@ InfoBar* InfoBarManager::ReplaceInfoBar(InfoBar* old_infobar, // to AddInfoBar() or similar, we don't dupe-check against this infobar. infobars_.erase(++i); - NotifyInfoBarReplaced(old_infobar, new_infobar_ptr); + FOR_EACH_OBSERVER(Observer, + observer_list_, + OnInfoBarReplaced(old_infobar, new_infobar_ptr)); old_infobar->CloseSoon(); return new_infobar_ptr; @@ -130,13 +132,6 @@ void InfoBarManager::NotifyInfoBarRemoved(InfoBar* infobar, bool animate) { OnInfoBarRemoved(infobar, animate)); } -void InfoBarManager::NotifyInfoBarReplaced(InfoBar* old_infobar, - InfoBar* new_infobar) { - FOR_EACH_OBSERVER(Observer, - observer_list_, - OnInfoBarReplaced(old_infobar, new_infobar)); -} - void InfoBarManager::RemoveInfoBarInternal(InfoBar* infobar, bool animate) { DCHECK(infobar); if (!infobars_enabled_) { diff --git a/components/infobars/core/infobar_manager.h b/components/infobars/core/infobar_manager.h index 845f784dbeba3e..b1353f9e9bb82c 100644 --- a/components/infobars/core/infobar_manager.h +++ b/components/infobars/core/infobar_manager.h @@ -98,8 +98,6 @@ class InfoBarManager { // overrides are removed (see http://crbug.com/354380). virtual void NotifyInfoBarAdded(InfoBar* infobar); virtual void NotifyInfoBarRemoved(InfoBar* infobar, bool animate); - virtual void NotifyInfoBarReplaced(InfoBar* old_infobar, - InfoBar* new_infobar); private: // InfoBars associated with this InfoBarManager. We own these pointers.