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

Unified Diff: chrome/browser/ui/views/infobars/infobar_background.cc

Issue 6609047: [linux_views][Win] spoof proof redesign infobar extension with tab. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: renames, don't const_cast, ditch InfoBarView::VerticalOffset. Created 9 years, 9 months 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
Index: chrome/browser/ui/views/infobars/infobar_background.cc
diff --git a/chrome/browser/ui/views/infobars/infobar_background.cc b/chrome/browser/ui/views/infobars/infobar_background.cc
index 71fa45c835e02c4ce91b8bed2bedef6562335e62..43dff3a3ca7959e674389f1c7ba201eedfdfdc42 100644
--- a/chrome/browser/ui/views/infobars/infobar_background.cc
+++ b/chrome/browser/ui/views/infobars/infobar_background.cc
@@ -4,18 +4,19 @@
#include "chrome/browser/ui/views/infobars/infobar_background.h"
+#include "chrome/browser/ui/views/infobars/infobar_view.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/canvas_skia_paint.h"
+#include "third_party/skia/include/effects/SkGradientShader.h"
#include "views/view.h"
// static
const int InfoBarBackground::kSeparatorLineHeight = 1;
-InfoBarBackground::InfoBarBackground(InfoBarDelegate::Type infobar_type) {
- gradient_background_.reset(
- views::Background::CreateVerticalGradientBackground(
- GetTopColor(infobar_type),
- GetBottomColor(infobar_type)));
+InfoBarBackground::InfoBarBackground(InfoBarDelegate::Type infobar_type)
+ : top_color_(GetTopColor(infobar_type)),
+ bottom_color_(GetBottomColor(infobar_type)) {
}
InfoBarBackground::~InfoBarBackground() {
@@ -42,7 +43,34 @@ SkColor InfoBarBackground::GetBottomColor(InfoBarDelegate::Type infobar_type) {
}
void InfoBarBackground::Paint(gfx::Canvas* canvas, views::View* view) const {
- gradient_background_->Paint(canvas, view);
+ SkPoint gradient_points[2] = {
+ {SkIntToScalar(0), SkIntToScalar(0)},
+ {SkIntToScalar(0), SkIntToScalar(view->height())}
+ };
+ SkColor gradient_colors[2] = {
+ top_color_,
+ bottom_color_
+ };
+ SkShader* gradient_shader = SkGradientShader::CreateLinear(
+ gradient_points, gradient_colors, NULL, 2, SkShader::kClamp_TileMode);
+ SkPaint paint;
+ paint.setStrokeWidth(1.0);
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setShader(gradient_shader);
+ paint.setAntiAlias(true);
+ gradient_shader->unref();
+
+ InfoBarView* infobar = static_cast<InfoBarView*>(view);
+ gfx::CanvasSkia* canvas_skia = canvas->AsCanvasSkia();
+ canvas_skia->drawPath(*infobar->fill_path(), paint);
+
+ paint.setShader(NULL);
+ paint.setColor(SkColorSetA(ResourceBundle::toolbar_separator_color,
+ SkColorGetA(gradient_colors[0])));
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas_skia->drawPath(*infobar->stroke_path(), paint);
+
+ // Now draw at the bottom.
canvas->FillRectInt(ResourceBundle::toolbar_separator_color, 0,
view->height() - kSeparatorLineHeight, view->width(),
kSeparatorLineHeight);

Powered by Google App Engine
This is Rietveld 408576698