| Index: chrome/browser/infobars/infobar_service.cc
|
| diff --git a/chrome/browser/infobars/infobar_service.cc b/chrome/browser/infobars/infobar_service.cc
|
| index 8a2983070097b429190f43784c92e728b50976c8..a6a7d94b1f5189808bc6cf5291b177ee18878a9e 100644
|
| --- a/chrome/browser/infobars/infobar_service.cc
|
| +++ b/chrome/browser/infobars/infobar_service.cc
|
| @@ -17,16 +17,6 @@
|
| DEFINE_WEB_CONTENTS_USER_DATA_KEY(InfoBarService);
|
|
|
| // static
|
| -InfoBarManager* InfoBarService::InfoBarManagerFromWebContents(
|
| - content::WebContents* web_contents) {
|
| - InfoBarService* infobar_service = FromWebContents(web_contents);
|
| - // |infobar_service| may be NULL during shutdown.
|
| - if (!infobar_service)
|
| - return NULL;
|
| - return infobar_service->infobar_manager();
|
| -}
|
| -
|
| -// static
|
| InfoBarDelegate::NavigationDetails
|
| InfoBarService::NavigationDetailsFromLoadCommittedDetails(
|
| const content::LoadCommittedDetails& details) {
|
| @@ -47,37 +37,67 @@ InfoBarDelegate::NavigationDetails
|
| return navigation_details;
|
| }
|
|
|
| -InfoBar* InfoBarService::AddInfoBar(scoped_ptr<InfoBar> infobar) {
|
| - return infobar_manager_.AddInfoBar(infobar.Pass());
|
| -}
|
| -
|
| -InfoBar* InfoBarService::ReplaceInfoBar(InfoBar* old_infobar,
|
| - scoped_ptr<InfoBar> new_infobar) {
|
| - return infobar_manager_.ReplaceInfoBar(old_infobar, new_infobar.Pass());
|
| +// static
|
| +content::WebContents* InfoBarService::WebContentsFromInfoBar(InfoBar* infobar) {
|
| + if (!infobar || !infobar->owner())
|
| + return NULL;
|
| + InfoBarService* infobar_service =
|
| + static_cast<InfoBarService*>(infobar->owner());
|
| + return infobar_service->web_contents();
|
| }
|
|
|
| InfoBarService::InfoBarService(content::WebContents* web_contents)
|
| - : content::WebContentsObserver(web_contents),
|
| - infobar_manager_(web_contents) {
|
| + : content::WebContentsObserver(web_contents) {
|
| DCHECK(web_contents);
|
| - infobar_manager_.AddObserver(this);
|
| }
|
|
|
| -InfoBarService::~InfoBarService() {}
|
| +InfoBarService::~InfoBarService() {
|
| + ShutDown();
|
| +}
|
| +
|
| +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
|
| + content::NotificationService::current()->Notify(
|
| + chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
|
| + content::Source<InfoBarService>(this),
|
| + content::Details<InfoBar::AddedDetails>(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
|
| + InfoBar::RemovedDetails removed_details(infobar, animate);
|
| + content::NotificationService::current()->Notify(
|
| + chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
|
| + content::Source<InfoBarService>(this),
|
| + content::Details<InfoBar::RemovedDetails>(&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<InfoBarService>(this),
|
| + content::Details<InfoBar::ReplacedDetails>(&replaced_details));
|
| +}
|
|
|
| void InfoBarService::RenderProcessGone(base::TerminationStatus status) {
|
| - infobar_manager_.RemoveAllInfoBars(true);
|
| + RemoveAllInfoBars(true);
|
| }
|
|
|
| void InfoBarService::NavigationEntryCommitted(
|
| const content::LoadCommittedDetails& load_details) {
|
| - infobar_manager_.OnNavigation(
|
| - NavigationDetailsFromLoadCommittedDetails(load_details));
|
| + OnNavigation(NavigationDetailsFromLoadCommittedDetails(load_details));
|
| }
|
|
|
| void InfoBarService::WebContentsDestroyed(content::WebContents* web_contents) {
|
| - infobar_manager_.OnWebContentsDestroyed();
|
| -
|
| // The WebContents is going away; be aggressively paranoid and delete
|
| // ourselves lest other parts of the system attempt to add infobars or use
|
| // us otherwise during the destruction.
|
| @@ -98,40 +118,6 @@ bool InfoBarService::OnMessageReceived(const IPC::Message& message) {
|
| return handled;
|
| }
|
|
|
| -void InfoBarService::OnInfoBarAdded(InfoBar* infobar) {
|
| - // TODO(droger): Remove the notifications and have listeners change to be
|
| - // NavigationManager::Observers instead. See http://crbug.com/354380
|
| - content::NotificationService::current()->Notify(
|
| - chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
|
| - content::Source<InfoBarService>(this),
|
| - content::Details<InfoBar::AddedDetails>(infobar));
|
| -}
|
| -
|
| -void InfoBarService::OnInfoBarReplaced(InfoBar* old_infobar,
|
| - 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<InfoBarService>(this),
|
| - content::Details<InfoBar::ReplacedDetails>(&replaced_details));
|
| -}
|
| -
|
| -void InfoBarService::OnInfoBarRemoved(InfoBar* infobar, bool animate) {
|
| - // TODO(droger): Remove the notifications and have listeners change to be
|
| - // NavigationManager::Observers instead. See http://crbug.com/354380
|
| - InfoBar::RemovedDetails removed_details(infobar, animate);
|
| - content::NotificationService::current()->Notify(
|
| - chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
|
| - content::Source<InfoBarService>(this),
|
| - content::Details<InfoBar::RemovedDetails>(&removed_details));
|
| -}
|
| -
|
| -void InfoBarService::OnManagerShuttingDown(InfoBarManager* manager) {
|
| - infobar_manager_.RemoveObserver(this);
|
| -}
|
| -
|
| void InfoBarService::OnDidBlockDisplayingInsecureContent() {
|
| InsecureContentInfoBarDelegate::Create(
|
| this, InsecureContentInfoBarDelegate::DISPLAY);
|
|
|