diff options
25 files changed, 101 insertions, 121 deletions
diff --git a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc index 14f8a80..bdcdfbd 100644 --- a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc +++ b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc @@ -167,7 +167,7 @@ void ExtensionDisabledInfobarDelegate::Observe( extension = info->extension; } if (extension == extension_) - tab_contents_->RemoveInfoBar(this); + RemoveSelf(); } diff --git a/chrome/browser/extensions/extension_infobar_delegate.cc b/chrome/browser/extensions/extension_infobar_delegate.cc index b52154f..130421b 100644 --- a/chrome/browser/extensions/extension_infobar_delegate.cc +++ b/chrome/browser/extensions/extension_infobar_delegate.cc @@ -8,7 +8,6 @@ #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/extensions/extension.h" #include "content/common/notification_details.h" @@ -21,7 +20,6 @@ ExtensionInfoBarDelegate::ExtensionInfoBarDelegate(Browser* browser, : InfoBarDelegate(tab_contents), observer_(NULL), extension_(extension), - tab_contents_(tab_contents), closing_(false) { ExtensionProcessManager* manager = browser->profile()->GetExtensionProcessManager(); @@ -71,25 +69,12 @@ ExtensionInfoBarDelegate* void ExtensionInfoBarDelegate::Observe(int type, const NotificationSource& source, const NotificationDetails& details) { - TabContentsWrapper* wrapper = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_); - switch (type) { - case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: { - const ExtensionHost* result = Details<ExtensionHost>(details).ptr(); - if (extension_host_.get() == result) - wrapper->RemoveInfoBar(this); - break; - } - case chrome::NOTIFICATION_EXTENSION_UNLOADED: { - const Extension* extension = - Details<UnloadedExtensionInfo>(details)->extension; - if (extension_ == extension) - wrapper->RemoveInfoBar(this); - break; - } - default: { - NOTREACHED() << "Unknown message"; - break; - } + if (type == chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE) { + if (extension_host_.get() == Details<ExtensionHost>(details).ptr()) + RemoveSelf(); + } else { + DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); + if (extension_ == Details<UnloadedExtensionInfo>(details)->extension) + RemoveSelf(); } } diff --git a/chrome/browser/extensions/extension_infobar_delegate.h b/chrome/browser/extensions/extension_infobar_delegate.h index 815618a..6337258 100644 --- a/chrome/browser/extensions/extension_infobar_delegate.h +++ b/chrome/browser/extensions/extension_infobar_delegate.h @@ -15,7 +15,6 @@ class Browser; class Extension; class ExtensionHost; class GURL; -class TabContentsWrapper; // The InfobarDelegate for creating and managing state for the ExtensionInfobar // plus monitor when the extension goes away. @@ -68,7 +67,6 @@ class ExtensionInfoBarDelegate : public InfoBarDelegate, DelegateObserver* observer_; const Extension* extension_; - TabContents* tab_contents_; NotificationRegistrar registrar_; // Whether we are currently animating to close. This is used to ignore diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.cc b/chrome/browser/extensions/theme_installed_infobar_delegate.cc index ed8462b..0d0b66c 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.cc +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc @@ -11,9 +11,9 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/extensions/extension.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/common/notification_service.h" #include "grit/generated_resources.h" #include "grit/theme_resources_standard.h" @@ -31,8 +31,7 @@ ThemeInstalledInfoBarDelegate::ThemeInstalledInfoBarDelegate( name_(new_theme->name()), theme_id_(new_theme->id()), previous_theme_id_(previous_theme_id), - previous_using_native_theme_(previous_using_native_theme), - tab_contents_(tab_contents) { + previous_using_native_theme_(previous_using_native_theme) { theme_service_->OnInfobarDisplayed(); registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, Source<ThemeService>(theme_service_)); @@ -102,23 +101,8 @@ void ThemeInstalledInfoBarDelegate::Observe( const NotificationSource& source, const NotificationDetails& details) { DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); - // If the new theme is different from what this info bar is associated - // with, close this info bar since it is no longer relevant. - if (theme_id_ != theme_service_->GetThemeID()) { - if (tab_contents_ && !tab_contents_->is_being_destroyed()) { - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)-> - RemoveInfoBar(this); - // The infobar is gone so there is no reason for this delegate to keep - // a pointer to the TabContents (the TabContents has deleted its - // reference to this delegate and a new delegate will be created if - // a new infobar is created). - tab_contents_ = NULL; - // Although it's not being used anymore, this delegate is never deleted. - // It can not be deleted now because it is still needed if we - // "undo" the theme change that triggered this notification - // (when InfoBar::OnBackgroundExpose() is called). This will likely - // be fixed when infobar delegate deletion is cleaned up for - // http://crbug.com/62154. - } - } + // If the new theme is different from what this info bar is associated with, + // close this info bar since it is no longer relevant. + if (theme_id_ != theme_service_->GetThemeID()) + RemoveSelf(); } diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.h b/chrome/browser/extensions/theme_installed_infobar_delegate.h index 581b143..d34526d 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.h +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.h @@ -14,7 +14,6 @@ class ThemeService; class Extension; class Profile; class SkBitmap; -class TabContents; // When a user installs a theme, we display it immediately, but provide an // infobar allowing them to cancel. @@ -65,9 +64,6 @@ class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate, std::string previous_theme_id_; bool previous_using_native_theme_; - // Tab to which this info bar is associated. - TabContents* tab_contents_; - // Registers and unregisters us for notifications. NotificationRegistrar registrar_; }; diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context.cc index 6e8ed8e..4d90689 100644 --- a/chrome/browser/geolocation/chrome_geolocation_permission_context.cc +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context.cc @@ -398,7 +398,7 @@ void GeolocationInfoBarQueueController::OnPermissionSet( // either synchronously or asynchronously, which will then pump the queue // via OnInfoBarClosed(). PendingInfoBarRequest copied_request = *i; - // Don't let CancelInfoBarRequestInternal() call RemoveInfoBar() on the + // Don't let CancelInfoBarRequestInternal() call RemoveInfoBar() with the // delegate that's currently calling us. That delegate is in either // Accept() or Cancel(), so its owning InfoBar will call RemoveInfoBar() // later on in this callstack anyway; and if we do it here, and it causes diff --git a/chrome/browser/tab_contents/infobar.cc b/chrome/browser/tab_contents/infobar.cc index 67d9e91..d8dacb2 100644 --- a/chrome/browser/tab_contents/infobar.cc +++ b/chrome/browser/tab_contents/infobar.cc @@ -49,8 +49,8 @@ InfoBar::InfoBar(TabContentsWrapper* owner, InfoBarDelegate* delegate) arrow_half_width_(0), bar_height_(0), bar_target_height_(kDefaultBarTargetHeight) { - DCHECK(owner != NULL); - DCHECK(delegate != NULL); + DCHECK(owner_ != NULL); + DCHECK(delegate_ != NULL); animation_.SetTweenType(ui::Tween::LINEAR); } @@ -100,7 +100,7 @@ void InfoBar::AnimationProgressed(const ui::Animation* animation) { RecalculateHeights(false); } -void InfoBar::RemoveInfoBar() { +void InfoBar::RemoveSelf() { // |owner_| can be NULL here, e.g. because the user clicks the close button // when the infobar is already closing. if (delegate_ && owner_) diff --git a/chrome/browser/tab_contents/infobar.h b/chrome/browser/tab_contents/infobar.h index 09c224b..3d2f703 100644 --- a/chrome/browser/tab_contents/infobar.h +++ b/chrome/browser/tab_contents/infobar.h @@ -80,9 +80,8 @@ class InfoBar : public ui::AnimationDelegate { // ui::AnimationDelegate: virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; - // Called when the user closes the infobar, forwards a removal request to our - // owner. - void RemoveInfoBar(); + // Forwards a close request to our owner. + void RemoveSelf(); // Changes the target height of the main ("bar") portion of the infobar. void SetBarTargetHeight(int height); diff --git a/chrome/browser/tab_contents/infobar_container.cc b/chrome/browser/tab_contents/infobar_container.cc index 63b7a61..cfd66e6 100644 --- a/chrome/browser/tab_contents/infobar_container.cc +++ b/chrome/browser/tab_contents/infobar_container.cc @@ -134,7 +134,7 @@ void InfoBarContainer::Observe(int type, case chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED: { InfoBarRemovedDetails* removed_details = Details<InfoBarRemovedDetails>(details).ptr(); - RemoveInfoBar(removed_details->first, removed_details->second); + HideInfoBar(removed_details->first, removed_details->second); break; } @@ -142,7 +142,7 @@ void InfoBarContainer::Observe(int type, InfoBarReplacedDetails* replaced_details = Details<InfoBarReplacedDetails>(details).ptr(); AddInfoBar(replaced_details->second->CreateInfoBar(tab_contents_), - RemoveInfoBar(replaced_details->first, false), false, WANT_CALLBACK); + HideInfoBar(replaced_details->first, false), false, WANT_CALLBACK); break; } @@ -152,8 +152,8 @@ void InfoBarContainer::Observe(int type, } } -size_t InfoBarContainer::RemoveInfoBar(InfoBarDelegate* delegate, - bool use_animation) { +size_t InfoBarContainer::HideInfoBar(InfoBarDelegate* delegate, + bool use_animation) { // Search for the infobar associated with |delegate|. We cannot search for // |delegate| in |tab_contents_|, because an InfoBar remains alive until its // close animation completes, while the delegate is removed from the tab diff --git a/chrome/browser/tab_contents/infobar_container.h b/chrome/browser/tab_contents/infobar_container.h index a9bee62..01d310c 100644 --- a/chrome/browser/tab_contents/infobar_container.h +++ b/chrome/browser/tab_contents/infobar_container.h @@ -100,11 +100,13 @@ class InfoBarContainer : public NotificationObserver { const NotificationSource& source, const NotificationDetails& details) OVERRIDE; - // Removes an InfoBar for the specified delegate, in response to a - // notification from the selected TabContentsWrapper. The InfoBar's - // disappearance will be animated if |use_animation| is true. Returns the - // position within |infobars_| the infobar was previously at. - size_t RemoveInfoBar(InfoBarDelegate* delegate, bool use_animation); + // Hides an InfoBar for the specified delegate, in response to a notification + // from the selected TabContentsWrapper. The InfoBar's disappearance will be + // animated if |use_animation| is true. The InfoBar will call back to + // RemoveInfoBar() to remove itself once it's hidden (which may mean + // synchronously). Returns the position within |infobars_| the infobar was + // previously at. + size_t HideInfoBar(InfoBarDelegate* delegate, bool use_animation); // Adds |infobar| to this container before the existing infobar at position // |position| and calls Show() on it. |animate| is passed along to diff --git a/chrome/browser/tab_contents/infobar_delegate.cc b/chrome/browser/tab_contents/infobar_delegate.cc index 9d0c77e..f6d88a8 100644 --- a/chrome/browser/tab_contents/infobar_delegate.cc +++ b/chrome/browser/tab_contents/infobar_delegate.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "build/build_config.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "content/browser/tab_contents/navigation_details.h" #include "content/browser/tab_contents/navigation_entry.h" #include "content/browser/tab_contents/tab_contents.h" @@ -27,13 +28,6 @@ bool InfoBarDelegate::ShouldExpire( return ShouldExpireInternal(details); } -bool InfoBarDelegate::ShouldExpireInternal( - const content::LoadCommittedDetails& details) const { - return (contents_unique_id_ != details.entry->unique_id()) || - (PageTransition::StripQualifier(details.entry->transition_type()) == - PageTransition::RELOAD); -} - void InfoBarDelegate::InfoBarDismissed() { } @@ -81,7 +75,8 @@ TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() { } InfoBarDelegate::InfoBarDelegate(TabContents* contents) - : contents_unique_id_(0) { + : contents_unique_id_(0), + owner_(contents) { if (contents) StoreActiveEntryUniqueID(contents); } @@ -90,3 +85,17 @@ void InfoBarDelegate::StoreActiveEntryUniqueID(TabContents* contents) { NavigationEntry* active_entry = contents->controller().GetActiveEntry(); contents_unique_id_ = active_entry ? active_entry->unique_id() : 0; } + +bool InfoBarDelegate::ShouldExpireInternal( + const content::LoadCommittedDetails& details) const { + return (contents_unique_id_ != details.entry->unique_id()) || + (PageTransition::StripQualifier(details.entry->transition_type()) == + PageTransition::RELOAD); +} + +void InfoBarDelegate::RemoveSelf() { + if (owner_) { + TabContentsWrapper::GetCurrentWrapperForContents(owner_)-> + RemoveInfoBar(this); // Clears |owner_|. + } +} diff --git a/chrome/browser/tab_contents/infobar_delegate.h b/chrome/browser/tab_contents/infobar_delegate.h index 7ab8c42..29faba8 100644 --- a/chrome/browser/tab_contents/infobar_delegate.h +++ b/chrome/browser/tab_contents/infobar_delegate.h @@ -48,6 +48,9 @@ class InfoBarDelegate { // platform-specific. virtual InfoBar* CreateInfoBar(TabContentsWrapper* owner) = 0; + // Called by the TabContentsWrapper when it removes us. + void clear_owner() { owner_ = NULL; } + // Returns true if the supplied |delegate| is equal to this one. Equality is // left to the implementation to define. This function is called by the // TabContentsWrapper when determining whether or not a delegate should be @@ -87,9 +90,8 @@ class InfoBarDelegate { virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); protected: - // Provided to subclasses as a convenience to initialize the state of this - // object. If |contents| is non-NULL, its active entry's unique ID will be - // stored using StoreActiveEntryUniqueID automatically. + // If |contents| is non-NULL, its active entry's unique ID will be stored + // using StoreActiveEntryUniqueID automatically. explicit InfoBarDelegate(TabContents* contents); // Store the unique id for the active entry in the specified TabContents, to @@ -101,11 +103,18 @@ class InfoBarDelegate { bool ShouldExpireInternal( const content::LoadCommittedDetails& details) const; + // Removes ourself from |owner_| if we haven't already been removed. + // TODO(pkasting): Move to InfoBar. + void RemoveSelf(); + private: // The unique id of the active NavigationEntry of the TabContents that we were // opened for. Used to help expire on navigations. int contents_unique_id_; + // TODO(pkasting): Remove. + TabContents* owner_; + DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); }; diff --git a/chrome/browser/translate/translate_infobar_delegate.cc b/chrome/browser/translate/translate_infobar_delegate.cc index 5d1e140..3677693 100644 --- a/chrome/browser/translate/translate_infobar_delegate.cc +++ b/chrome/browser/translate/translate_infobar_delegate.cc @@ -111,8 +111,7 @@ void TranslateInfoBarDelegate::Translate() { void TranslateInfoBarDelegate::RevertTranslation() { TranslateManager::GetInstance()->RevertTranslation(tab_contents_); - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)-> - RemoveInfoBar(this); + RemoveSelf(); } void TranslateInfoBarDelegate::ReportLanguageDetectionError() { @@ -146,8 +145,7 @@ void TranslateInfoBarDelegate::ToggleLanguageBlacklist() { prefs_.RemoveLanguageFromBlacklist(original_lang); } else { prefs_.BlacklistLanguage(original_lang); - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)-> - RemoveInfoBar(this); + RemoveSelf(); } } @@ -165,8 +163,7 @@ void TranslateInfoBarDelegate::ToggleSiteBlacklist() { prefs_.RemoveSiteFromBlacklist(host); } else { prefs_.BlacklistSite(host); - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)-> - RemoveInfoBar(this); + RemoveSelf(); } } @@ -196,8 +193,7 @@ void TranslateInfoBarDelegate::NeverTranslatePageLanguage() { std::string original_lang = GetOriginalLanguageCode(); DCHECK(!prefs_.IsLanguageBlacklisted(original_lang)); prefs_.BlacklistLanguage(original_lang); - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)-> - RemoveInfoBar(this); + RemoveSelf(); } string16 TranslateInfoBarDelegate::GetMessageInfoBarText() { diff --git a/chrome/browser/ui/cocoa/extensions/extension_infobar_controller.mm b/chrome/browser/ui/cocoa/extensions/extension_infobar_controller.mm index a107ee6..b245a67 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/extensions/extension_infobar_controller.mm @@ -13,6 +13,7 @@ #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" #import "chrome/browser/ui/cocoa/menu_button.h" #include "chrome/browser/ui/cocoa/infobars/infobar.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_icon_set.h" #include "chrome/common/extensions/extension_resource.h" @@ -261,7 +262,8 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver, @end InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { - NSWindow* window = [(NSView*)tab_contents_->GetContentNativeView() window]; + NSWindow* window = + [(NSView*)owner->tab_contents()->GetContentNativeView() window]; ExtensionInfoBarController* controller = [[ExtensionInfoBarController alloc] initWithDelegate:this owner:owner diff --git a/chrome/browser/ui/cocoa/infobars/infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/infobar_controller.mm index 2edf458..aaa1cdc 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_controller.mm @@ -82,7 +82,7 @@ const float kAnimateCloseDuration = 0.12; // Asks the container controller to remove the infobar for this delegate. This // call will trigger a notification that starts the infobar animating closed. -- (void)removeInfoBar; +- (void)removeSelf; // Performs final cleanup after an animation is finished or stopped, including // notifying the InfoBarDelegate that the infobar was closed and removing the @@ -161,7 +161,7 @@ const float kAnimateCloseDuration = 0.12; if (delegate_) delegate_->InfoBarDismissed(); - [self removeInfoBar]; + [self removeSelf]; } - (AnimatableView*)animatableView { @@ -263,7 +263,7 @@ const float kAnimateCloseDuration = 0.12; [label_.get() setVerticallyResizable:NO]; } -- (void)removeInfoBar { +- (void)removeSelf { // TODO(rohitrao): This method can be called even if the infobar has already // been removed and |delegate_| is NULL. Is there a way to rewrite the code // so that inner event loops don't cause us to try and remove the infobar @@ -388,13 +388,13 @@ const float kAnimateCloseDuration = 0.12; event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); if (delegate_ && delegate_->AsLinkInfoBarDelegate()->LinkClicked(disposition)) { - // Call |-removeInfoBar| on the outermost runloop to force a delay. As shown - // in <http://crbug.com/87201>, the second click event can be delivered - // after the animation finishes (and this gets released and deallocated), - // which leads to zombie messaging. Unfortnately, the order between the - // animation finishing and the click event being delivered is - // nondeterministic, so this hack is the best that can be done. - [self performSelector:@selector(removeInfoBar) + // Call |-removeSelf| on the outermost runloop to force a delay. As shown in + // <http://crbug.com/87201>, the second click event can be delivered after + // the animation finishes (and this gets released and deallocated), which + // leads to zombie messaging. Unfortunately, the order between the animation + // finishing and the click event being delivered is nondeterministic, so + // this hack is the best that can be done. + [self performSelector:@selector(removeSelf) withObject:nil afterDelay:0.0]; } @@ -411,13 +411,13 @@ const float kAnimateCloseDuration = 0.12; // Called when someone clicks on the "OK" button. - (IBAction)ok:(id)sender { if (delegate_ && delegate_->AsConfirmInfoBarDelegate()->Accept()) - [self removeInfoBar]; + [self removeSelf]; } // Called when someone clicks on the "Cancel" button. - (IBAction)cancel:(id)sender { if (delegate_ && delegate_->AsConfirmInfoBarDelegate()->Cancel()) - [self removeInfoBar]; + [self removeSelf]; } // Confirm infobars can have OK and/or cancel buttons, depending on @@ -519,7 +519,7 @@ const float kAnimateCloseDuration = 0.12; event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); if (delegate_ && delegate_->AsConfirmInfoBarDelegate()->LinkClicked(disposition)) - [self removeInfoBar]; + [self removeSelf]; } @end diff --git a/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm b/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm index f3a4c8b..93a9dd1 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm @@ -56,25 +56,25 @@ } @end -// Calls to removeInfoBar normally start an animation, which removes the infobar +// Calls to removeSelf normally start an animation, which removes the infobar // completely when finished. For testing purposes, we create a mock controller // which calls close: immediately, rather than kicking off an animation. @interface TestLinkInfoBarController : LinkInfoBarController -- (void)removeInfoBar; +- (void)removeSelf; @end @implementation TestLinkInfoBarController -- (void)removeInfoBar { +- (void)removeSelf { [self close]; } @end @interface TestConfirmInfoBarController : ConfirmInfoBarController -- (void)removeInfoBar; +- (void)removeSelf; @end @implementation TestConfirmInfoBarController -- (void)removeInfoBar { +- (void)removeSelf { [self close]; } @end diff --git a/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.cc index 49cc927..8bfb29c 100644 --- a/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.cc @@ -94,7 +94,7 @@ void BeforeTranslateInfoBar::OnAcceptPressed(GtkWidget* sender) { void BeforeTranslateInfoBar::OnDenyPressed(GtkWidget* sender) { GetDelegate()->TranslationDeclined(); - RemoveInfoBar(); + RemoveSelf(); } void BeforeTranslateInfoBar::OnNeverTranslatePressed(GtkWidget* sender) { diff --git a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc index 5249a1d..aea0b49 100644 --- a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc @@ -83,17 +83,16 @@ void ConfirmInfoBarGtk::AddButton(ConfirmInfoBarDelegate::InfoBarButton type) { void ConfirmInfoBarGtk::OnOkButton(GtkWidget* widget) { if (delegate()->AsConfirmInfoBarDelegate()->Accept()) - RemoveInfoBar(); + RemoveSelf(); } void ConfirmInfoBarGtk::OnCancelButton(GtkWidget* widget) { if (delegate()->AsConfirmInfoBarDelegate()->Cancel()) - RemoveInfoBar(); + RemoveSelf(); } void ConfirmInfoBarGtk::OnLinkClicked(GtkWidget* widget) { if (delegate()->AsConfirmInfoBarDelegate()->LinkClicked( - gtk_util::DispositionForCurrentButtonPressEvent())) { - RemoveInfoBar(); - } + gtk_util::DispositionForCurrentButtonPressEvent())) + RemoveSelf(); } diff --git a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc index d0e9223..846d817 100644 --- a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc @@ -192,7 +192,7 @@ void InfoBarGtk::OnCloseButton(GtkWidget* button) { // InfoBarDismissed(), since this can lead to us double-recording dismissals. if (delegate() && owned()) delegate()->InfoBarDismissed(); - RemoveInfoBar(); + RemoveSelf(); } gboolean InfoBarGtk::OnBackgroundExpose(GtkWidget* sender, diff --git a/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc index 7b538d6..f3a7c2c 100644 --- a/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/link_infobar_gtk.cc @@ -30,9 +30,8 @@ LinkInfoBarGtk::~LinkInfoBarGtk() { void LinkInfoBarGtk::OnLinkClicked(GtkWidget* button) { if (GetDelegate()->LinkClicked( - gtk_util::DispositionForCurrentButtonPressEvent())) { - RemoveInfoBar(); - } + gtk_util::DispositionForCurrentButtonPressEvent())) + RemoveSelf(); } LinkInfoBarDelegate* LinkInfoBarGtk::GetDelegate() { diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc index 94f39fbe..6d4d418 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc @@ -536,6 +536,7 @@ void TabContentsWrapper::ReplaceInfoBar(InfoBarDelegate* old_delegate, Details<InfoBarReplacedDetails>(&replaced_details)); infobars_.erase(infobars_.begin() + i + 1); + old_delegate->clear_owner(); } InfoBarDelegate* TabContentsWrapper::GetInfoBarDelegateAt(size_t index) { @@ -686,6 +687,7 @@ void TabContentsWrapper::RemoveInfoBarInternal(InfoBarDelegate* delegate, Details<InfoBarRemovedDetails>(&removed_details)); infobars_.erase(infobars_.begin() + i); + delegate->clear_owner(); // Remove ourselves as an observer if we are tracking no more InfoBars. if (infobars_.empty()) { registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, diff --git a/chrome/browser/ui/views/infobars/before_translate_infobar.cc b/chrome/browser/ui/views/infobars/before_translate_infobar.cc index b1f2909..9a0f66e 100644 --- a/chrome/browser/ui/views/infobars/before_translate_infobar.cc +++ b/chrome/browser/ui/views/infobars/before_translate_infobar.cc @@ -168,7 +168,7 @@ void BeforeTranslateInfoBar::ButtonPressed(views::Button* sender, delegate->Translate(); } else if (sender == deny_button_) { delegate->TranslationDeclined(); - RemoveInfoBar(); + RemoveSelf(); } else if (sender == never_translate_button_) { delegate->NeverTranslatePageLanguage(); } else if (sender == always_translate_button_) { diff --git a/chrome/browser/ui/views/infobars/confirm_infobar.cc b/chrome/browser/ui/views/infobars/confirm_infobar.cc index ab20bcc..d1decd0 100644 --- a/chrome/browser/ui/views/infobars/confirm_infobar.cc +++ b/chrome/browser/ui/views/infobars/confirm_infobar.cc @@ -101,10 +101,10 @@ void ConfirmInfoBar::ButtonPressed(views::Button* sender, ConfirmInfoBarDelegate* delegate = GetDelegate(); if ((ok_button_ != NULL) && sender == ok_button_) { if (delegate->Accept()) - RemoveInfoBar(); + RemoveSelf(); } else if ((cancel_button_ != NULL) && (sender == cancel_button_)) { if (delegate->Cancel()) - RemoveInfoBar(); + RemoveSelf(); } else { InfoBarView::ButtonPressed(sender, event); } @@ -126,7 +126,7 @@ void ConfirmInfoBar::LinkClicked(views::Link* source, int event_flags) { DCHECK_EQ(link_, source); if (GetDelegate()->LinkClicked( event_utils::DispositionFromEventFlags(event_flags))) - RemoveInfoBar(); + RemoveSelf(); } ConfirmInfoBarDelegate* ConfirmInfoBar::GetDelegate() { diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc index bfeda15..22950a5 100644 --- a/chrome/browser/ui/views/infobars/infobar_view.cc +++ b/chrome/browser/ui/views/infobars/infobar_view.cc @@ -261,7 +261,7 @@ void InfoBarView::ButtonPressed(views::Button* sender, // dismissals. if (delegate() && owned()) delegate()->InfoBarDismissed(); - RemoveInfoBar(); + RemoveSelf(); } } diff --git a/chrome/browser/ui/views/infobars/link_infobar.cc b/chrome/browser/ui/views/infobars/link_infobar.cc index ed27b5d..3844722 100644 --- a/chrome/browser/ui/views/infobars/link_infobar.cc +++ b/chrome/browser/ui/views/infobars/link_infobar.cc @@ -77,7 +77,7 @@ void LinkInfoBar::LinkClicked(views::Link* source, int event_flags) { DCHECK_EQ(link_, source); if (GetDelegate()->LinkClicked( event_utils::DispositionFromEventFlags(event_flags))) - RemoveInfoBar(); + RemoveSelf(); } LinkInfoBarDelegate* LinkInfoBar::GetDelegate() { |