 Chromium Code Reviews
 Chromium Code Reviews Issue 5326011:
  Check that TabContents is valid (not null) before removing theme change InfoBar.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 5326011:
  Check that TabContents is valid (not null) before removing theme change InfoBar.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: chrome/browser/extensions/theme_installed_infobar_delegate.cc | 
| diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.cc b/chrome/browser/extensions/theme_installed_infobar_delegate.cc | 
| index 49f690c65953dacc65a890dbac84df9081e973ce..0e374b6238c2bc39883de8834ebfc2a39fb5d15f 100644 | 
| --- a/chrome/browser/extensions/theme_installed_infobar_delegate.cc | 
| +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc | 
| @@ -98,8 +98,17 @@ void ThemeInstalledInfoBarDelegate::Observe( | 
| // If the new theme is different from what this info bar is associated | 
| // with, close this info bar since it is no longer relevant. | 
| const Extension* extension = Details<const Extension>(details).ptr(); | 
| - if (!extension || theme_id_ != extension->id()) | 
| - tab_contents_->RemoveInfoBar(this); | 
| + if (!extension || theme_id_ != extension->id()) { | 
| + if (tab_contents_ && !tab_contents_->is_being_destroyed()) { | 
| + tab_contents_->RemoveInfoBar(this); | 
| + // The infobar is gone so there is no reason for this delegate to keep | 
| + // a pointer to the tab_contents (a new delegate will be created if a new | 
| + // infobar is created). The delegate can not be deleted yet because | 
| + // it is still needed if we "undo" the theme change that triggered | 
| 
Aaron Boodman
2010/12/01 01:06:06
I think it would probably be good to reference the
 
Tessa MacDuff
2010/12/01 19:16:37
Done.
 | 
| + // this notification. | 
| + tab_contents_ = NULL; | 
| + } | 
| + } | 
| } | 
| bool ThemeInstalledInfoBarDelegate::MatchesTheme(const Extension* theme) { |