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

Side by Side Diff: chrome/browser/ui/views/infobars/infobar_background.cc

Issue 10911169: Setup field trial for one-click signin inforbar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Steve's review comments Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/infobars/infobar_background.h" 5 #include "chrome/browser/ui/views/infobars/infobar_background.h"
6 6
7 #include "chrome/browser/infobars/infobar.h" 7 #include "chrome/browser/infobars/infobar.h"
8 #include "chrome/browser/ui/views/infobars/infobar_view.h" 8 #include "chrome/browser/ui/views/infobars/infobar_view.h"
9 #include "third_party/skia/include/effects/SkGradientShader.h" 9 #include "third_party/skia/include/effects/SkGradientShader.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/color_utils.h" 11 #include "ui/gfx/color_utils.h"
12 #include "ui/views/view.h" 12 #include "ui/views/view.h"
13 13
14 InfoBarBackground::InfoBarBackground(InfoBarDelegate::Type infobar_type) 14 InfoBarBackground::InfoBarBackground(InfoBarDelegate::Type infobar_type)
Peter Kasting 2012/09/11 23:02:07 Nit: I think if you nuke this constructor and make
Roger Tawa OOO till Jul 10th 2012/09/12 15:07:14 I was trying to minimize changes since you didn't
15 : separator_color_(SK_ColorBLACK), 15 : separator_color_(SK_ColorBLACK),
16 top_color_(GetInfoBarTopColor(infobar_type)), 16 top_color_(GetInfoBarTopColor(infobar_type)),
17 bottom_color_(GetInfoBarBottomColor(infobar_type)) { 17 bottom_color_(GetInfoBarBottomColor(infobar_type)) {
18 SetNativeControlColor( 18 Init();
19 color_utils::AlphaBlend(top_color_, bottom_color_, 128)); 19 }
20
21 InfoBarBackground::InfoBarBackground(SkColor top, SkColor bottom)
22 : separator_color_(SK_ColorBLACK), top_color_(top), bottom_color_(bottom) {
23 Init();
20 } 24 }
21 25
22 InfoBarBackground::~InfoBarBackground() { 26 InfoBarBackground::~InfoBarBackground() {
23 } 27 }
24 28
29 void InfoBarBackground::Init() {
30 SetNativeControlColor(
31 color_utils::AlphaBlend(top_color_, bottom_color_, 128));
32 }
33
25 void InfoBarBackground::Paint(gfx::Canvas* canvas, views::View* view) const { 34 void InfoBarBackground::Paint(gfx::Canvas* canvas, views::View* view) const {
26 SkPoint gradient_points[2]; 35 SkPoint gradient_points[2];
27 gradient_points[0].iset(0, 0); 36 gradient_points[0].iset(0, 0);
28 gradient_points[1].iset(0, view->height()); 37 gradient_points[1].iset(0, view->height());
29 SkColor gradient_colors[2] = { top_color_, bottom_color_ }; 38 SkColor gradient_colors[2] = { top_color_, bottom_color_ };
30 SkShader* gradient_shader = SkGradientShader::CreateLinear( 39 SkShader* gradient_shader = SkGradientShader::CreateLinear(
31 gradient_points, gradient_colors, NULL, 2, SkShader::kClamp_TileMode); 40 gradient_points, gradient_colors, NULL, 2, SkShader::kClamp_TileMode);
32 SkPaint paint; 41 SkPaint paint;
33 paint.setStrokeWidth(SkIntToScalar(InfoBar::kSeparatorLineHeight)); 42 paint.setStrokeWidth(SkIntToScalar(InfoBar::kSeparatorLineHeight));
34 paint.setStyle(SkPaint::kFill_Style); 43 paint.setStyle(SkPaint::kFill_Style);
(...skipping 14 matching lines...) Expand all
49 // lest we get weird color bleeding problems. 58 // lest we get weird color bleeding problems.
50 paint.setAntiAlias(true); 59 paint.setAntiAlias(true);
51 canvas_skia->drawPath(infobar->stroke_path(), paint); 60 canvas_skia->drawPath(infobar->stroke_path(), paint);
52 paint.setAntiAlias(false); 61 paint.setAntiAlias(false);
53 62
54 // Now draw the separator at the bottom. 63 // Now draw the separator at the bottom.
55 canvas->FillRect(gfx::Rect(0, view->height() - InfoBar::kSeparatorLineHeight, 64 canvas->FillRect(gfx::Rect(0, view->height() - InfoBar::kSeparatorLineHeight,
56 view->width(), InfoBar::kSeparatorLineHeight), 65 view->width(), InfoBar::kSeparatorLineHeight),
57 separator_color_); 66 separator_color_);
58 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698