Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Unified Diff: components/infobars/core/infobar.cc

Issue 752853005: Remove dependency from infobars component to the embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/infobars/core/infobar.h ('k') | components/infobars/core/infobar_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_);
« no previous file with comments | « components/infobars/core/infobar.h ('k') | components/infobars/core/infobar_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698