| OLD | NEW |
| 1 // Copyright (c) 2011 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/extensions/browser_action_overflow_menu_contro
ller.h" | 5 #include "chrome/browser/ui/views/extensions/browser_action_overflow_menu_contro
ller.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_context_menu_model.h" | 9 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/browser_list.h" | 11 #include "chrome/browser/ui/browser_list.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 36 menu_runner_.reset(new views::MenuRunner(menu_)); | 36 menu_runner_.reset(new views::MenuRunner(menu_)); |
| 37 menu_->set_has_icons(true); | 37 menu_->set_has_icons(true); |
| 38 | 38 |
| 39 size_t command_id = 1; // Menu id 0 is reserved, start with 1. | 39 size_t command_id = 1; // Menu id 0 is reserved, start with 1. |
| 40 for (size_t i = start_index; i < views_->size(); ++i) { | 40 for (size_t i = start_index; i < views_->size(); ++i) { |
| 41 BrowserActionView* view = (*views_)[i]; | 41 BrowserActionView* view = (*views_)[i]; |
| 42 scoped_ptr<gfx::Canvas> canvas(view->GetIconWithBadge()); | 42 scoped_ptr<gfx::Canvas> canvas(view->GetIconWithBadge()); |
| 43 menu_->AppendMenuItemWithIcon( | 43 menu_->AppendMenuItemWithIcon( |
| 44 command_id, | 44 command_id, |
| 45 UTF8ToUTF16(view->button()->extension()->name()), | 45 UTF8ToUTF16(view->button()->extension()->name()), |
| 46 canvas->AsCanvasSkia()->ExtractBitmap()); | 46 canvas->ExtractBitmap()); |
| 47 | 47 |
| 48 // Set the tooltip for this item. | 48 // Set the tooltip for this item. |
| 49 string16 tooltip = UTF8ToUTF16( | 49 string16 tooltip = UTF8ToUTF16( |
| 50 view->button()->extension()->browser_action()->GetTitle( | 50 view->button()->extension()->browser_action()->GetTitle( |
| 51 owner_->GetCurrentTabId())); | 51 owner_->GetCurrentTabId())); |
| 52 menu_->SetTooltip(tooltip, command_id); | 52 menu_->SetTooltip(tooltip, command_id); |
| 53 | 53 |
| 54 ++command_id; | 54 ++command_id; |
| 55 } | 55 } |
| 56 } | 56 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( | 214 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( |
| 215 int id, size_t* index) { | 215 int id, size_t* index) { |
| 216 // The index of the view being dragged (GetCommand gives a 1-based index into | 216 // The index of the view being dragged (GetCommand gives a 1-based index into |
| 217 // the overflow menu). | 217 // the overflow menu). |
| 218 size_t view_index = owner_->VisibleBrowserActions() + id - 1; | 218 size_t view_index = owner_->VisibleBrowserActions() + id - 1; |
| 219 if (index) | 219 if (index) |
| 220 *index = view_index; | 220 *index = view_index; |
| 221 return owner_->GetBrowserActionViewAt(view_index); | 221 return owner_->GetBrowserActionViewAt(view_index); |
| 222 } | 222 } |
| OLD | NEW |