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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 // TODO(pkasting): Port Mac to use this. | 7 // TODO(pkasting): Port Mac to use this. |
8 #if defined(TOOLKIT_VIEWS) || defined(TOOLKIT_GTK) | 8 #if defined(TOOLKIT_VIEWS) || defined(TOOLKIT_GTK) |
9 | 9 |
10 #include "chrome/browser/tab_contents/infobar_container.h" | 10 #include "chrome/browser/tab_contents/infobar_container.h" |
11 | 11 |
| 12 #include "chrome/browser/infobars/infobar_tab_helper.h" |
12 #include "chrome/browser/tab_contents/infobar.h" | 13 #include "chrome/browser/tab_contents/infobar.h" |
13 #include "chrome/browser/tab_contents/infobar_delegate.h" | 14 #include "chrome/browser/tab_contents/infobar_delegate.h" |
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
15 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
16 #include "content/common/notification_details.h" | 17 #include "content/common/notification_details.h" |
17 #include "content/common/notification_source.h" | 18 #include "content/common/notification_source.h" |
18 #include "ui/base/animation/slide_animation.h" | 19 #include "ui/base/animation/slide_animation.h" |
19 | 20 |
20 InfoBarContainer::Delegate::~Delegate() { | 21 InfoBarContainer::Delegate::~Delegate() { |
21 } | 22 } |
(...skipping 22 matching lines...) Expand all Loading... |
44 tab_contents_ = contents; | 45 tab_contents_ = contents; |
45 if (tab_contents_) { | 46 if (tab_contents_) { |
46 Source<TabContentsWrapper> tc_source(tab_contents_); | 47 Source<TabContentsWrapper> tc_source(tab_contents_); |
47 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | 48 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
48 tc_source); | 49 tc_source); |
49 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, | 50 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
50 tc_source); | 51 tc_source); |
51 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, | 52 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, |
52 tc_source); | 53 tc_source); |
53 | 54 |
54 for (size_t i = 0; i < tab_contents_->infobar_count(); ++i) { | 55 for (size_t i = 0; |
| 56 i < tab_contents_->infobar_tab_helper()->infobar_count(); |
| 57 ++i) { |
55 // As when we removed the infobars above, we prevent callbacks to | 58 // As when we removed the infobars above, we prevent callbacks to |
56 // OnInfoBarAnimated() for each infobar. | 59 // OnInfoBarAnimated() for each infobar. |
57 AddInfoBar( | 60 AddInfoBar( |
58 tab_contents_->GetInfoBarDelegateAt(i)->CreateInfoBar(tab_contents_), | 61 tab_contents_->infobar_tab_helper()->GetInfoBarDelegateAt(i)-> |
| 62 CreateInfoBar(tab_contents_), |
59 i, false, NO_CALLBACK); | 63 i, false, NO_CALLBACK); |
60 } | 64 } |
61 } | 65 } |
62 | 66 |
63 // Now that everything is up to date, signal the delegate to re-layout. | 67 // Now that everything is up to date, signal the delegate to re-layout. |
64 OnInfoBarStateChanged(false); | 68 OnInfoBarStateChanged(false); |
65 } | 69 } |
66 | 70 |
67 int InfoBarContainer::GetVerticalOverlap(int* total_height) { | 71 int InfoBarContainer::GetVerticalOverlap(int* total_height) { |
68 // Our |total_height| is the sum of the preferred heights of the InfoBars | 72 // Our |total_height| is the sum of the preferred heights of the InfoBars |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 return InfoBar::kDefaultArrowTargetHeight; | 211 return InfoBar::kDefaultArrowTargetHeight; |
208 // When the first infobar is animating closed, we animate the second infobar's | 212 // When the first infobar is animating closed, we animate the second infobar's |
209 // arrow target height from the default to the top target height. Note that | 213 // arrow target height from the default to the top target height. Note that |
210 // the animation values here are going from 1.0 -> 0.0 as the top bar closes. | 214 // the animation values here are going from 1.0 -> 0.0 as the top bar closes. |
211 return top_arrow_target_height_ + static_cast<int>( | 215 return top_arrow_target_height_ + static_cast<int>( |
212 (InfoBar::kDefaultArrowTargetHeight - top_arrow_target_height_) * | 216 (InfoBar::kDefaultArrowTargetHeight - top_arrow_target_height_) * |
213 first_infobar_animation.GetCurrentValue()); | 217 first_infobar_animation.GetCurrentValue()); |
214 } | 218 } |
215 | 219 |
216 #endif // TOOLKIT_VIEWS || defined(TOOLKIT_GTK) | 220 #endif // TOOLKIT_VIEWS || defined(TOOLKIT_GTK) |
OLD | NEW |