Chromium Code Reviews| Index: chrome/browser/views/browser_actions_container.cc |
| =================================================================== |
| --- chrome/browser/views/browser_actions_container.cc (revision 38137) |
| +++ chrome/browser/views/browser_actions_container.cc (working copy) |
| @@ -31,6 +31,7 @@ |
| #include "third_party/skia/include/effects/SkGradientShader.h" |
| #include "views/controls/button/menu_button.h" |
| #include "views/controls/button/text_button.h" |
| +#include "views/drag_utils.h" |
| #include "views/window/window.h" |
| #include "grit/theme_resources.h" |
| @@ -274,6 +275,25 @@ |
| button_->UpdateState(); |
| } |
| +gfx::Canvas* BrowserActionView::GetIconWithBadge() { |
| + int tab_id = panel_->GetCurrentTabId(); |
| + |
| + SkBitmap icon = button_->extension()->browser_action()->GetIcon(tab_id); |
| + if (icon.isNull()) |
| + icon = button_->default_icon(); |
| + |
| + gfx::Canvas* canvas = new gfx::Canvas(icon.width(), icon.height(), false); |
| + canvas->DrawBitmapInt(icon, 0, 0); |
| + |
| + if (tab_id >= 0) { |
| + gfx::Rect bounds = |
| + gfx::Rect(icon.width(), icon.height() + kControlVertOffset); |
| + button_->extension()->browser_action()->PaintBadge(canvas, bounds, tab_id); |
| + } |
| + |
| + return canvas; |
| +} |
| + |
| void BrowserActionView::Layout() { |
| button_->SetBounds(0, kControlVertOffset, width(), kButtonSize); |
| } |
| @@ -832,7 +852,14 @@ |
| DCHECK(data); |
| for (size_t i = 0; i < browser_action_views_.size(); ++i) { |
| - if (browser_action_views_[i]->button() == sender) { |
| + BrowserActionButton* button = browser_action_views_[i]->button(); |
| + if (button == sender) { |
| + // Set the dragging image for the icon. |
| + scoped_ptr<gfx::Canvas> canvas( |
| + browser_action_views_[i]->GetIconWithBadge()); |
| + drag_utils::SetDragImageOnDataObject(*canvas, button->width(), |
| + button->height(), press_x, press_y, data); |
| + // Fill in the remaining info. |
|
Erik does not do reviews
2010/02/05 01:16:24
nit: newline above comment
|
| BrowserActionDragData drag_data( |
| browser_action_views_[i]->button()->extension()->id(), i); |
| drag_data.Write(profile_, data); |