Index: components/infobars/core/infobar_container.cc |
diff --git a/components/infobars/core/infobar_container.cc b/components/infobars/core/infobar_container.cc |
index b6831129e69a830c970b632e9baed4c66a298b86..39ab047b556fc48ee7ab1920b09a05bdfc820676 100644 |
--- a/components/infobars/core/infobar_container.cc |
+++ b/components/infobars/core/infobar_container.cc |
@@ -19,8 +19,8 @@ InfoBarContainer::Delegate::~Delegate() { |
InfoBarContainer::InfoBarContainer(Delegate* delegate) |
: delegate_(delegate), |
- infobar_manager_(NULL), |
- top_arrow_target_height_(InfoBar::kDefaultArrowTargetHeight) { |
+ infobar_manager_(nullptr), |
+ top_arrow_target_height_(0) { |
} |
InfoBarContainer::~InfoBarContainer() { |
@@ -46,6 +46,8 @@ void InfoBarContainer::ChangeInfoBarManager(InfoBarManager* infobar_manager) { |
infobar_manager_ = infobar_manager; |
if (infobar_manager_) { |
infobar_manager_->AddObserver(this); |
+ const InfoBarConstants& constants = infobar_manager_->GetInfoBarConstants(); |
+ top_arrow_target_height_ = constants.default_arrow_target_height; |
for (size_t i = 0; i < infobar_manager_->infobar_count(); ++i) { |
// As when we removed the infobars above, we prevent callbacks to |
@@ -64,9 +66,7 @@ int InfoBarContainer::GetVerticalOverlap(int* total_height) const { |
int vertical_overlap = 0; |
int next_infobar_y = 0; |
- for (InfoBars::const_iterator i(infobars_.begin()); i != infobars_.end(); |
- ++i) { |
- InfoBar* infobar = *i; |
+ for (InfoBar* infobar : infobars_) { |
next_infobar_y -= infobar->arrow_height(); |
vertical_overlap = std::max(vertical_overlap, -next_infobar_y); |
next_infobar_y += infobar->total_height(); |
@@ -80,9 +80,11 @@ int InfoBarContainer::GetVerticalOverlap(int* total_height) const { |
void InfoBarContainer::SetMaxTopArrowHeight(int height) { |
// Decrease the height by the arrow stroke thickness, which is the separator |
// line height, because the infobar arrow target heights are without-stroke. |
- top_arrow_target_height_ = std::min( |
- std::max(height - InfoBar::kSeparatorLineHeight, 0), |
- InfoBar::kMaximumArrowTargetHeight); |
+ DCHECK(infobar_manager_); |
+ const InfoBarConstants constants = infobar_manager_->GetInfoBarConstants(); |
+ top_arrow_target_height_ = |
+ std::min(std::max(height - constants.separator_line_height, 0), |
+ constants.maximum_arrow_target_height); |
UpdateInfoBarArrowTargetHeights(); |
} |
@@ -94,7 +96,7 @@ void InfoBarContainer::OnInfoBarStateChanged(bool is_animating) { |
} |
void InfoBarContainer::RemoveInfoBar(InfoBar* infobar) { |
- infobar->set_container(NULL); |
+ infobar->set_container(nullptr); |
InfoBars::iterator i(std::find(infobars_.begin(), infobars_.end(), infobar)); |
DCHECK(i != infobars_.end()); |
PlatformSpecificRemoveInfoBar(infobar); |
@@ -107,8 +109,8 @@ void InfoBarContainer::RemoveAllInfoBarsForDestruction() { |
// delegate_->InfoBarContainerStateChanged(). This is important because at |
// this point |delegate_| may be shutting down, and it's at best unimportant |
// and at worst disastrous to call that. |
- delegate_ = NULL; |
- ChangeInfoBarManager(NULL); |
+ delegate_ = nullptr; |
+ ChangeInfoBarManager(nullptr); |
} |
void InfoBarContainer::OnInfoBarAdded(InfoBar* infobar) { |
@@ -134,7 +136,7 @@ void InfoBarContainer::OnInfoBarReplaced(InfoBar* old_infobar, |
void InfoBarContainer::OnManagerShuttingDown(InfoBarManager* manager) { |
DCHECK_EQ(infobar_manager_, manager); |
infobar_manager_->RemoveObserver(this); |
- infobar_manager_ = NULL; |
+ infobar_manager_ = nullptr; |
} |
void InfoBarContainer::AddInfoBar(InfoBar* infobar, |
@@ -160,20 +162,23 @@ void InfoBarContainer::UpdateInfoBarArrowTargetHeights() { |
} |
int InfoBarContainer::ArrowTargetHeightForInfoBar(size_t infobar_index) const { |
- if (!delegate_ || !delegate_->DrawInfoBarArrows(NULL)) |
+ if (!delegate_ || !delegate_->DrawInfoBarArrows(nullptr)) |
return 0; |
if (infobar_index == 0) |
return top_arrow_target_height_; |
+ DCHECK(infobar_manager_); |
+ const InfoBarConstants& constants = infobar_manager_->GetInfoBarConstants(); |
const gfx::SlideAnimation& first_infobar_animation = |
const_cast<const InfoBar*>(infobars_.front())->animation(); |
if ((infobar_index > 1) || first_infobar_animation.IsShowing()) |
- return InfoBar::kDefaultArrowTargetHeight; |
+ return constants.default_arrow_target_height; |
// When the first infobar is animating closed, we animate the second infobar's |
// arrow target height from the default to the top target height. Note that |
// the animation values here are going from 1.0 -> 0.0 as the top bar closes. |
- return top_arrow_target_height_ + static_cast<int>( |
- (InfoBar::kDefaultArrowTargetHeight - top_arrow_target_height_) * |
- first_infobar_animation.GetCurrentValue()); |
+ return top_arrow_target_height_ + |
+ static_cast<int>((constants.default_arrow_target_height - |
+ top_arrow_target_height_) * |
+ first_infobar_animation.GetCurrentValue()); |
} |
} // namespace infobars |