Index: components/infobars/core/infobar.cc |
diff --git a/components/infobars/core/infobar.cc b/components/infobars/core/infobar.cc |
index 1ddfffde5db3e3873f402d20d8435974f37756f7..2617a46677aac389e9a271dfe25daa115bd7c0a1 100644 |
--- a/components/infobars/core/infobar.cc |
+++ b/components/infobars/core/infobar.cc |
@@ -14,16 +14,24 @@ |
namespace infobars { |
+// static |
+int InfoBar::gSeparatorLineHeight = 1; |
+int InfoBar::gDefaultArrowTargetHeight = 9; |
+int InfoBar::gMaximumArrowTargetHeight = 24; |
+int InfoBar::gDefaultArrowTargetHalfWidth = gDefaultArrowTargetHeight; |
+int InfoBar::gMaximumArrowTargetHalfWidth = 14; |
+int InfoBar::gDefaultBarTargetHeight = 36; |
+ |
InfoBar::InfoBar(scoped_ptr<InfoBarDelegate> delegate) |
: owner_(NULL), |
delegate_(delegate.Pass()), |
container_(NULL), |
animation_(this), |
arrow_height_(0), |
- arrow_target_height_(kDefaultArrowTargetHeight), |
+ arrow_target_height_(gDefaultArrowTargetHeight), |
arrow_half_width_(0), |
bar_height_(0), |
- bar_target_height_(kDefaultBarTargetHeight) { |
+ bar_target_height_(gDefaultBarTargetHeight) { |
DCHECK(delegate_ != NULL); |
animation_.SetTweenType(gfx::Tween::LINEAR); |
delegate_->set_infobar(this); |
@@ -34,6 +42,21 @@ InfoBar::~InfoBar() { |
} |
// static |
+void InfoBar::Initialize(int defaultBarTargetHeight, |
+ int separatorLineHeight, |
+ int defaultArrowTargetHeight, |
+ int maximumArrowTargetHeight, |
+ int defaultArrowTargetHalfWidth, |
+ int maximumArrowTargetHalfWidth) { |
+ gDefaultBarTargetHeight = defaultBarTargetHeight; |
+ gSeparatorLineHeight = separatorLineHeight; |
+ gDefaultArrowTargetHeight = defaultArrowTargetHeight; |
+ gMaximumArrowTargetHeight = maximumArrowTargetHeight; |
+ gDefaultArrowTargetHalfWidth = defaultArrowTargetHalfWidth; |
+ gMaximumArrowTargetHalfWidth = maximumArrowTargetHalfWidth; |
+} |
+ |
+// static |
SkColor InfoBar::GetTopColor(InfoBarDelegate::Type infobar_type) { |
static const SkColor kWarningBackgroundColorTop = |
SkColorSetRGB(255, 242, 183); // Yellow |
@@ -85,7 +108,7 @@ void InfoBar::Hide(bool animate) { |
} |
void InfoBar::SetArrowTargetHeight(int height) { |
- DCHECK_LE(height, kMaximumArrowTargetHeight); |
+ DCHECK_LE(height, gMaximumArrowTargetHeight); |
// Once the closing animation starts, we ignore further requests to change the |
// target height. |
if ((arrow_target_height_ != height) && !animation_.IsClosing()) { |
@@ -138,22 +161,22 @@ void InfoBar::RecalculateHeights(bool force_notify) { |
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); |
+ gMaximumArrowTargetHalfWidth) * 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_ = gDefaultArrowTargetHalfWidth + |
+ ((gMaximumArrowTargetHalfWidth - gDefaultArrowTargetHalfWidth) * |
+ ((arrow_height_ - gDefaultArrowTargetHeight) / |
+ (gMaximumArrowTargetHeight - gDefaultArrowTargetHeight))); |
} |
// 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 |
+ // this, changing the arrow height from 0 to gSeparatorLineHeight 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_ += gSeparatorLineHeight; |
bar_height_ = animation_.CurrentValueBetween(0, bar_target_height_); |