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

Side by Side 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 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" 5 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 92
93 void ThemeInstalledInfoBarDelegate::Observe( 93 void ThemeInstalledInfoBarDelegate::Observe(
94 NotificationType type, 94 NotificationType type,
95 const NotificationSource& source, 95 const NotificationSource& source,
96 const NotificationDetails& details) { 96 const NotificationDetails& details) {
97 DCHECK_EQ(NotificationType::BROWSER_THEME_CHANGED, type.value); 97 DCHECK_EQ(NotificationType::BROWSER_THEME_CHANGED, type.value);
98 // If the new theme is different from what this info bar is associated 98 // If the new theme is different from what this info bar is associated
99 // with, close this info bar since it is no longer relevant. 99 // with, close this info bar since it is no longer relevant.
100 const Extension* extension = Details<const Extension>(details).ptr(); 100 const Extension* extension = Details<const Extension>(details).ptr();
101 if (!extension || theme_id_ != extension->id()) 101 if (!extension || theme_id_ != extension->id()) {
102 tab_contents_->RemoveInfoBar(this); 102 if (tab_contents_ && !tab_contents_->is_being_destroyed()) {
103 tab_contents_->RemoveInfoBar(this);
104 // The infobar is gone so there is no reason for this delegate to keep
105 // a pointer to the TabContents (the TabContents has deleted its
106 // reference to this delegate and a new delegate will be created if
107 // a new infobar is created).
108 tab_contents_ = NULL;
109 // Although it's not being used anymore, this delegate is never deleted.
110 // It can not be deleted now because it is still needed if we
111 // "undo" the theme change that triggered this notification
112 // (when InfoBar::OnBackgroundExpose() is called). This will likely
113 // be fixed when infobar delegate deletion is cleaned up for
114 // http://crbug.com/62154.
115 }
116 }
103 } 117 }
104 118
105 bool ThemeInstalledInfoBarDelegate::MatchesTheme(const Extension* theme) { 119 bool ThemeInstalledInfoBarDelegate::MatchesTheme(const Extension* theme) {
106 return (theme && theme->id() == theme_id_); 120 return (theme && theme->id() == theme_id_);
107 } 121 }
OLDNEW
« 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