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/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" |
(...skipping 24 matching lines...) Expand all Loading... |
35 views_(&views), | 35 views_(&views), |
36 start_index_(start_index), | 36 start_index_(start_index), |
37 for_drop_(false) { | 37 for_drop_(false) { |
38 menu_ = new views::MenuItemView(this); | 38 menu_ = new views::MenuItemView(this); |
39 menu_runner_.reset(new views::MenuRunner(menu_)); | 39 menu_runner_.reset(new views::MenuRunner(menu_)); |
40 menu_->set_has_icons(true); | 40 menu_->set_has_icons(true); |
41 | 41 |
42 size_t command_id = 1; // Menu id 0 is reserved, start with 1. | 42 size_t command_id = 1; // Menu id 0 is reserved, start with 1. |
43 for (size_t i = start_index; i < views_->size(); ++i) { | 43 for (size_t i = start_index; i < views_->size(); ++i) { |
44 BrowserActionView* view = (*views_)[i]; | 44 BrowserActionView* view = (*views_)[i]; |
45 scoped_ptr<gfx::Canvas> canvas(view->GetIconWithBadge()); | |
46 menu_->AppendMenuItemWithIcon( | 45 menu_->AppendMenuItemWithIcon( |
47 command_id, | 46 command_id, |
48 UTF8ToUTF16(view->button()->extension()->name()), | 47 UTF8ToUTF16(view->button()->extension()->name()), |
49 canvas->ExtractImageRep()); | 48 view->GetIconWithBadge()); |
50 | 49 |
51 // Set the tooltip for this item. | 50 // Set the tooltip for this item. |
52 string16 tooltip = UTF8ToUTF16( | 51 string16 tooltip = UTF8ToUTF16( |
53 view->button()->extension()->browser_action()->GetTitle( | 52 view->button()->extension()->browser_action()->GetTitle( |
54 owner_->GetCurrentTabId())); | 53 owner_->GetCurrentTabId())); |
55 menu_->SetTooltip(tooltip, command_id); | 54 menu_->SetTooltip(tooltip, command_id); |
56 | 55 |
57 ++command_id; | 56 ++command_id; |
58 } | 57 } |
59 } | 58 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 219 |
221 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( | 220 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( |
222 int id, size_t* index) { | 221 int id, size_t* index) { |
223 // The index of the view being dragged (GetCommand gives a 1-based index into | 222 // The index of the view being dragged (GetCommand gives a 1-based index into |
224 // the overflow menu). | 223 // the overflow menu). |
225 size_t view_index = owner_->VisibleBrowserActions() + id - 1; | 224 size_t view_index = owner_->VisibleBrowserActions() + id - 1; |
226 if (index) | 225 if (index) |
227 *index = view_index; | 226 *index = view_index; |
228 return owner_->GetBrowserActionViewAt(view_index); | 227 return owner_->GetBrowserActionViewAt(view_index); |
229 } | 228 } |
OLD | NEW |