| OLD | NEW |
| 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/common/icon_with_badge_image_source.h" | 5 #include "chrome/common/icon_with_badge_image_source.h" |
| 6 | 6 |
| 7 #include "chrome/common/badge_util.h" | 7 #include "chrome/common/badge_util.h" |
| 8 #include "ui/gfx/canvas.h" | 8 #include "ui/gfx/canvas.h" |
| 9 #include "ui/gfx/rect.h" | 9 #include "ui/gfx/rect.h" |
| 10 | 10 |
| 11 IconWithBadgeImageSource::IconWithBadgeImageSource( | 11 IconWithBadgeImageSource::IconWithBadgeImageSource( |
| 12 const gfx::ImageSkia& icon, | 12 const gfx::ImageSkia& icon, |
| 13 const gfx::Size& icon_size, | 13 const gfx::Size& icon_size, |
| 14 const gfx::Size& spacing, | 14 const gfx::Size& spacing, |
| 15 const std::string& text, | 15 const std::string& text, |
| 16 const SkColor& text_color, | 16 const SkColor& text_color, |
| 17 const SkColor& background_color, | 17 const SkColor& background_color, |
| 18 extensions::Extension::ActionInfo::Type action_type) | 18 extensions::ActionInfo::Type action_type) |
| 19 : gfx::CanvasImageSource(icon_size, false), | 19 : gfx::CanvasImageSource(icon_size, false), |
| 20 icon_(icon), | 20 icon_(icon), |
| 21 spacing_(spacing), | 21 spacing_(spacing), |
| 22 text_(text), | 22 text_(text), |
| 23 text_color_(text_color), | 23 text_color_(text_color), |
| 24 background_color_(background_color), | 24 background_color_(background_color), |
| 25 action_type_(action_type) { | 25 action_type_(action_type) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 IconWithBadgeImageSource::~IconWithBadgeImageSource() {} | 28 IconWithBadgeImageSource::~IconWithBadgeImageSource() {} |
| 29 | 29 |
| 30 void IconWithBadgeImageSource::Draw(gfx::Canvas* canvas) { | 30 void IconWithBadgeImageSource::Draw(gfx::Canvas* canvas) { |
| 31 canvas->DrawImageInt(icon_, 0, 0, SkPaint()); | 31 canvas->DrawImageInt(icon_, 0, 0, SkPaint()); |
| 32 gfx::Rect bounds(size_.width() + spacing_.width(), | 32 gfx::Rect bounds(size_.width() + spacing_.width(), |
| 33 size_.height() + spacing_.height()); | 33 size_.height() + spacing_.height()); |
| 34 | 34 |
| 35 // Draw a badge on the provided browser action icon's canvas. | 35 // Draw a badge on the provided browser action icon's canvas. |
| 36 badge_util::PaintBadge(canvas, bounds, text_, text_color_, | 36 badge_util::PaintBadge(canvas, bounds, text_, text_color_, |
| 37 background_color_, size_.width(), | 37 background_color_, size_.width(), |
| 38 action_type_); | 38 action_type_); |
| 39 } | 39 } |
| OLD | NEW |