Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Unified Diff: chrome/browser/extensions/theme_installed_infobar_delegate.cc

Issue 5326011: Check that TabContents is valid (not null) before removing theme change InfoBar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update comment Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..088e732d69418d63bb84e7ea19315572b164dbb0 100644
--- a/chrome/browser/extensions/theme_installed_infobar_delegate.cc
+++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc
@@ -98,8 +98,22 @@ 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 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.
+ }
+ }
}
bool ThemeInstalledInfoBarDelegate::MatchesTheme(const Extension* theme) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698