| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extension_install_ui.h" | 5 #include "chrome/browser/extensions/extension_install_ui.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return; | 103 return; |
| 104 | 104 |
| 105 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | 105 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); |
| 106 if (!browser) | 106 if (!browser) |
| 107 return; | 107 return; |
| 108 | 108 |
| 109 TabContents* tab_contents = browser->GetSelectedTabContents(); | 109 TabContents* tab_contents = browser->GetSelectedTabContents(); |
| 110 if (!tab_contents) | 110 if (!tab_contents) |
| 111 return; | 111 return; |
| 112 | 112 |
| 113 // First remove any previous theme preview infobar. | 113 // First find any previous theme preview infobars. |
| 114 InfoBarDelegate* old_delegate = NULL; |
| 114 for (int i = 0; i < tab_contents->infobar_delegate_count(); ++i) { | 115 for (int i = 0; i < tab_contents->infobar_delegate_count(); ++i) { |
| 115 InfoBarDelegate* delegate = tab_contents->GetInfoBarDelegateAt(i); | 116 InfoBarDelegate* delegate = tab_contents->GetInfoBarDelegateAt(i); |
| 116 if (delegate->AsThemePreviewInfobarDelegate()) { | 117 if (delegate->AsThemePreviewInfobarDelegate()) { |
| 117 tab_contents->RemoveInfoBar(delegate); | 118 old_delegate = delegate; |
| 118 break; | 119 break; |
| 119 } | 120 } |
| 120 } | 121 } |
| 121 | 122 |
| 122 // Now add the new one. | 123 // Then either replace that old one or add a new one. |
| 123 tab_contents->AddInfoBar(new ThemePreviewInfobarDelegate( | 124 InfoBarDelegate* new_delegate = new ThemePreviewInfobarDelegate(tab_contents, |
| 124 tab_contents, extension->name())); | 125 extension->name()); |
| 126 |
| 127 if (old_delegate) |
| 128 tab_contents->ReplaceInfoBar(old_delegate, new_delegate); |
| 129 else |
| 130 tab_contents->AddInfoBar(new_delegate); |
| 125 } | 131 } |
| OLD | NEW |