OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_contents/infobar.h" |
7 #include "chrome/browser/ui/views/infobars/infobar_view.h" | 8 #include "chrome/browser/ui/views/infobars/infobar_view.h" |
8 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
9 #include "ui/gfx/canvas_skia_paint.h" | 10 #include "ui/gfx/canvas_skia_paint.h" |
10 #include "third_party/skia/include/effects/SkGradientShader.h" | 11 #include "third_party/skia/include/effects/SkGradientShader.h" |
11 #include "views/view.h" | 12 #include "views/view.h" |
12 | 13 |
13 InfoBarBackground::InfoBarBackground(InfoBarDelegate::Type infobar_type) | 14 InfoBarBackground::InfoBarBackground(InfoBarDelegate::Type infobar_type) |
14 : separator_color_(SK_ColorBLACK), | 15 : separator_color_(SK_ColorBLACK), |
15 top_color_(GetTopColor(infobar_type)), | 16 top_color_(GetInfoBarTopColor(infobar_type)), |
16 bottom_color_(GetBottomColor(infobar_type)) { | 17 bottom_color_(GetInfoBarBottomColor(infobar_type)) { |
17 } | 18 } |
18 | 19 |
19 InfoBarBackground::~InfoBarBackground() { | 20 InfoBarBackground::~InfoBarBackground() { |
20 } | 21 } |
21 | 22 |
22 SkColor InfoBarBackground::GetTopColor(InfoBarDelegate::Type infobar_type) { | |
23 static const SkColor kWarningBackgroundColorTop = | |
24 SkColorSetRGB(255, 242, 183); | |
25 static const SkColor kPageActionBackgroundColorTop = | |
26 SkColorSetRGB(218, 231, 249); | |
27 | |
28 return (infobar_type == InfoBarDelegate::WARNING_TYPE) ? | |
29 kWarningBackgroundColorTop : kPageActionBackgroundColorTop; | |
30 } | |
31 | |
32 SkColor InfoBarBackground::GetBottomColor(InfoBarDelegate::Type infobar_type) { | |
33 static const SkColor kWarningBackgroundColorBottom = | |
34 SkColorSetRGB(250, 230, 145); | |
35 static const SkColor kPageActionBackgroundColorBottom = | |
36 SkColorSetRGB(179, 202, 231); | |
37 | |
38 return (infobar_type == InfoBarDelegate::WARNING_TYPE) ? | |
39 kWarningBackgroundColorBottom : kPageActionBackgroundColorBottom; | |
40 } | |
41 | |
42 void InfoBarBackground::Paint(gfx::Canvas* canvas, views::View* view) const { | 23 void InfoBarBackground::Paint(gfx::Canvas* canvas, views::View* view) const { |
43 SkPoint gradient_points[2] = { | 24 SkPoint gradient_points[2] = { |
44 {SkIntToScalar(0), SkIntToScalar(0)}, | 25 {SkIntToScalar(0), SkIntToScalar(0)}, |
45 {SkIntToScalar(0), SkIntToScalar(view->height())} | 26 {SkIntToScalar(0), SkIntToScalar(view->height())} |
46 }; | 27 }; |
47 SkColor gradient_colors[2] = { | 28 SkColor gradient_colors[2] = { |
48 top_color_, | 29 top_color_, |
49 bottom_color_ | 30 bottom_color_ |
50 }; | 31 }; |
51 SkShader* gradient_shader = SkGradientShader::CreateLinear( | 32 SkShader* gradient_shader = SkGradientShader::CreateLinear( |
(...skipping 18 matching lines...) Expand all Loading... |
70 // lest we get weird color bleeding problems. | 51 // lest we get weird color bleeding problems. |
71 paint.setAntiAlias(true); | 52 paint.setAntiAlias(true); |
72 canvas_skia->drawPath(*infobar->stroke_path(), paint); | 53 canvas_skia->drawPath(*infobar->stroke_path(), paint); |
73 paint.setAntiAlias(false); | 54 paint.setAntiAlias(false); |
74 | 55 |
75 // Now draw the separator at the bottom. | 56 // Now draw the separator at the bottom. |
76 canvas->FillRectInt(separator_color_, 0, | 57 canvas->FillRectInt(separator_color_, 0, |
77 view->height() - InfoBar::kSeparatorLineHeight, | 58 view->height() - InfoBar::kSeparatorLineHeight, |
78 view->width(), InfoBar::kSeparatorLineHeight); | 59 view->width(), InfoBar::kSeparatorLineHeight); |
79 } | 60 } |
OLD | NEW |