| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/infobars/infobar_tab_helper.h" | 5 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/infobars/infobar.h" | 7 #include "chrome/browser/infobars/infobar.h" |
| 8 #include "chrome/browser/infobars/infobar_delegate.h" | 8 #include "chrome/browser/infobars/infobar_delegate.h" |
| 9 #include "chrome/browser/tab_contents/insecure_content_infobar_delegate.h" | 9 #include "chrome/browser/tab_contents/insecure_content_infobar_delegate.h" |
| 10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // we guarantee that we'll delete all delegates before we do anything else. | 23 // we guarantee that we'll delete all delegates before we do anything else. |
| 24 // | 24 // |
| 25 // TODO(pkasting): If there is no InfoBarContainer, this leaks all the | 25 // TODO(pkasting): If there is no InfoBarContainer, this leaks all the |
| 26 // InfoBarDelegates. This will be fixed once we call CloseSoon() directly on | 26 // InfoBarDelegates. This will be fixed once we call CloseSoon() directly on |
| 27 // Infobars. | 27 // Infobars. |
| 28 RemoveAllInfoBars(false); | 28 RemoveAllInfoBars(false); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void InfoBarTabHelper::AddInfoBar(InfoBarDelegate* delegate) { | 31 void InfoBarTabHelper::AddInfoBar(InfoBarDelegate* delegate) { |
| 32 if (!infobars_enabled_) { | 32 if (!infobars_enabled_) { |
| 33 delegate->InfoBarClosed(); | 33 delete delegate; |
| 34 return; | 34 return; |
| 35 } | 35 } |
| 36 | 36 |
| 37 for (size_t i = 0; i < infobars_.size(); ++i) { | 37 for (size_t i = 0; i < infobars_.size(); ++i) { |
| 38 if (GetInfoBarDelegateAt(i)->EqualsDelegate(delegate)) { | 38 if (GetInfoBarDelegateAt(i)->EqualsDelegate(delegate)) { |
| 39 delegate->InfoBarClosed(); | 39 delete delegate; |
| 40 return; | 40 return; |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 // TODO(pkasting): Consider removing InfoBarTabHelper arg from delegate | 44 // TODO(pkasting): Consider removing InfoBarTabHelper arg from delegate |
| 45 // constructors and instead using a setter from here. | 45 // constructors and instead using a setter from here. |
| 46 infobars_.push_back(delegate); | 46 infobars_.push_back(delegate); |
| 47 content::NotificationService::current()->Notify( | 47 content::NotificationService::current()->Notify( |
| 48 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | 48 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
| 49 content::Source<InfoBarTabHelper>(this), | 49 content::Source<InfoBarTabHelper>(this), |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 if (delegate->ShouldExpire(committed_details)) | 190 if (delegate->ShouldExpire(committed_details)) |
| 191 RemoveInfoBar(delegate); | 191 RemoveInfoBar(delegate); |
| 192 } | 192 } |
| 193 | 193 |
| 194 break; | 194 break; |
| 195 } | 195 } |
| 196 default: | 196 default: |
| 197 NOTREACHED(); | 197 NOTREACHED(); |
| 198 } | 198 } |
| 199 } | 199 } |
| OLD | NEW |