OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 21 matching lines...) Expand all Loading... | |
32 RemoveAllInfoBars(false); | 32 RemoveAllInfoBars(false); |
33 } | 33 } |
34 | 34 |
35 void InfoBarTabHelper::AddInfoBar(InfoBarDelegate* delegate) { | 35 void InfoBarTabHelper::AddInfoBar(InfoBarDelegate* delegate) { |
36 if (!infobars_enabled_) { | 36 if (!infobars_enabled_) { |
37 delegate->InfoBarClosed(); | 37 delegate->InfoBarClosed(); |
38 return; | 38 return; |
39 } | 39 } |
40 | 40 |
41 for (size_t i = 0; i < infobars_.size(); ++i) { | 41 for (size_t i = 0; i < infobars_.size(); ++i) { |
42 if (GetInfoBarDelegateAt(i)->EqualsDelegate(delegate)) { | 42 InfoBarDelegate* delegate_at_i = GetInfoBarDelegateAt(i); |
Ilya Sherman
2012/05/02 03:52:43
nit: Perhaps use an iterator instead of creating t
| |
43 if (delegate_at_i->EqualsDelegate(delegate)) { | |
44 DCHECK_NE(delegate_at_i, delegate); | |
43 delegate->InfoBarClosed(); | 45 delegate->InfoBarClosed(); |
44 return; | 46 return; |
45 } | 47 } |
46 } | 48 } |
47 | 49 |
48 // TODO(pkasting): Consider removing InfoBarTabHelper arg from delegate | 50 // TODO(pkasting): Consider removing InfoBarTabHelper arg from delegate |
49 // constructors and instead using a setter from here. | 51 // constructors and instead using a setter from here. |
50 infobars_.push_back(delegate); | 52 infobars_.push_back(delegate); |
51 // Add ourselves as an observer for navigations the first time a delegate is | 53 // Add ourselves as an observer for navigations the first time a delegate is |
52 // added. We use this notification to expire InfoBars that need to expire on | 54 // added. We use this notification to expire InfoBars that need to expire on |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 if (delegate->ShouldExpire(committed_details)) | 202 if (delegate->ShouldExpire(committed_details)) |
201 RemoveInfoBar(delegate); | 203 RemoveInfoBar(delegate); |
202 } | 204 } |
203 | 205 |
204 break; | 206 break; |
205 } | 207 } |
206 default: | 208 default: |
207 NOTREACHED(); | 209 NOTREACHED(); |
208 } | 210 } |
209 } | 211 } |
OLD | NEW |