| Index: components/infobars/core/infobar.cc
|
| diff --git a/components/infobars/core/infobar.cc b/components/infobars/core/infobar.cc
|
| index 1ddfffde5db3e3873f402d20d8435974f37756f7..36e91740fec77b85144214fe4faeaf390a80c865 100644
|
| --- a/components/infobars/core/infobar.cc
|
| +++ b/components/infobars/core/infobar.cc
|
| @@ -15,16 +15,16 @@
|
| namespace infobars {
|
|
|
| InfoBar::InfoBar(scoped_ptr<InfoBarDelegate> delegate)
|
| - : owner_(NULL),
|
| + : owner_(nullptr),
|
| delegate_(delegate.Pass()),
|
| - container_(NULL),
|
| + container_(nullptr),
|
| animation_(this),
|
| arrow_height_(0),
|
| - arrow_target_height_(kDefaultArrowTargetHeight),
|
| + arrow_target_height_(0),
|
| arrow_half_width_(0),
|
| bar_height_(0),
|
| - bar_target_height_(kDefaultBarTargetHeight) {
|
| - DCHECK(delegate_ != NULL);
|
| + bar_target_height_(0) {
|
| + DCHECK(delegate_ != nullptr);
|
| animation_.SetTweenType(gfx::Tween::LINEAR);
|
| delegate_->set_infobar(this);
|
| }
|
| @@ -56,6 +56,9 @@ SkColor InfoBar::GetBottomColor(InfoBarDelegate::Type infobar_type) {
|
| void InfoBar::SetOwner(InfoBarManager* owner) {
|
| DCHECK(!owner_);
|
| owner_ = owner;
|
| + const InfoBarConstants& constants = owner_->GetInfoBarConstants();
|
| + arrow_target_height_ = constants.default_arrow_target_height;
|
| + bar_target_height_ = constants.default_bar_target_height;
|
| delegate_->StoreActiveEntryUniqueID();
|
| PlatformSpecificSetOwner();
|
| }
|
| @@ -85,7 +88,8 @@ void InfoBar::Hide(bool animate) {
|
| }
|
|
|
| void InfoBar::SetArrowTargetHeight(int height) {
|
| - DCHECK_LE(height, kMaximumArrowTargetHeight);
|
| + DCHECK(owner_);
|
| + DCHECK_LE(height, owner_->GetInfoBarConstants().maximum_arrow_target_height);
|
| // Once the closing animation starts, we ignore further requests to change the
|
| // target height.
|
| if ((arrow_target_height_ != height) && !animation_.IsClosing()) {
|
| @@ -95,7 +99,7 @@ void InfoBar::SetArrowTargetHeight(int height) {
|
| }
|
|
|
| void InfoBar::CloseSoon() {
|
| - owner_ = NULL;
|
| + owner_ = nullptr;
|
| PlatformSpecificOnCloseSoon();
|
| MaybeDelete();
|
| }
|
| @@ -126,6 +130,8 @@ void InfoBar::AnimationEnded(const gfx::Animation* animation) {
|
| }
|
|
|
| void InfoBar::RecalculateHeights(bool force_notify) {
|
| + DCHECK(owner_);
|
| + const InfoBarConstants& constants = owner_->GetInfoBarConstants();
|
| int old_arrow_height = arrow_height_;
|
| int old_bar_height = bar_height_;
|
|
|
| @@ -137,23 +143,28 @@ void InfoBar::RecalculateHeights(bool force_notify) {
|
| double scale_factor = sqrt(animation_.GetCurrentValue());
|
| arrow_height_ = static_cast<int>(arrow_target_height_ * scale_factor);
|
| if (animation_.is_animating()) {
|
| - arrow_half_width_ = static_cast<int>(std::min(arrow_target_height_,
|
| - kMaximumArrowTargetHalfWidth) * scale_factor);
|
| + arrow_half_width_ =
|
| + static_cast<int>(std::min(arrow_target_height_,
|
| + constants.maximum_arrow_target_half_width) *
|
| + scale_factor);
|
| } else {
|
| // When the infobar is not animating (i.e. fully open), we set the
|
| // half-width to be proportionally the same distance between its default and
|
| // maximum values as the height is between its.
|
| - arrow_half_width_ = kDefaultArrowTargetHalfWidth +
|
| - ((kMaximumArrowTargetHalfWidth - kDefaultArrowTargetHalfWidth) *
|
| - ((arrow_height_ - kDefaultArrowTargetHeight) /
|
| - (kMaximumArrowTargetHeight - kDefaultArrowTargetHeight)));
|
| + arrow_half_width_ =
|
| + constants.default_arrow_target_half_width +
|
| + ((constants.maximum_arrow_target_half_width -
|
| + constants.default_arrow_target_half_width) *
|
| + ((arrow_height_ - constants.default_arrow_target_height) /
|
| + (constants.maximum_arrow_target_height -
|
| + constants.default_arrow_target_height)));
|
| }
|
| // Add pixels for the stroke, if the arrow is to be visible at all. Without
|
| - // this, changing the arrow height from 0 to kSeparatorLineHeight would
|
| - // produce no visible effect, because the stroke would paint atop the divider
|
| - // line above the infobar.
|
| + // this, changing the arrow height from 0 to constants.separator_line_height
|
| + // would produce no visible effect, because the stroke would paint atop the
|
| + // divider line above the infobar.
|
| if (arrow_height_)
|
| - arrow_height_ += kSeparatorLineHeight;
|
| + arrow_height_ += constants.separator_line_height;
|
|
|
| bar_height_ = animation_.CurrentValueBetween(0, bar_target_height_);
|
|
|
|
|