OLD | NEW |
---|---|
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 Loading... | |
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 tab_contents (a new delegate will be created if a new | |
106 // infobar is created). The delegate can not be deleted yet because | |
107 // 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.
| |
108 // this notification. | |
109 tab_contents_ = NULL; | |
110 } | |
111 } | |
103 } | 112 } |
104 | 113 |
105 bool ThemeInstalledInfoBarDelegate::MatchesTheme(const Extension* theme) { | 114 bool ThemeInstalledInfoBarDelegate::MatchesTheme(const Extension* theme) { |
106 return (theme && theme->id() == theme_id_); | 115 return (theme && theme->id() == theme_id_); |
107 } | 116 } |
OLD | NEW |