| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/toolbar/recent_tabs_menu_model_delegate.h" |
| 6 |
| 7 #include "ui/base/models/menu_model.h" |
| 8 #include "ui/gfx/image/image.h" |
| 9 #include "ui/views/controls/menu/menu_item_view.h" |
| 10 |
| 11 RecentTabsMenuModelDelegate::RecentTabsMenuModelDelegate( |
| 12 ui::MenuModel* model, |
| 13 views::MenuItemView* menu_item) |
| 14 : model_(model), |
| 15 menu_item_(menu_item) { |
| 16 model_->SetMenuModelDelegate(this); |
| 17 } |
| 18 |
| 19 RecentTabsMenuModelDelegate::~RecentTabsMenuModelDelegate() { |
| 20 model_->SetMenuModelDelegate(NULL); |
| 21 } |
| 22 |
| 23 void RecentTabsMenuModelDelegate::OnIconChanged(int index) { |
| 24 // |index| specifies position in children items of |menu_item_| starting at 0, |
| 25 // its corresponding command id as used in the children menu item views |
| 26 // follows that of the parent menu item view |menu_item_|. |
| 27 int command_id = menu_item_->GetCommand() + 1 + index; |
| 28 views::MenuItemView* item = menu_item_->GetMenuItemByID(command_id); |
| 29 DCHECK(item); |
| 30 gfx::Image icon; |
| 31 if (model_->GetIconAt(index, &icon)) |
| 32 item->SetIcon(*icon.ToImageSkia()); |
| 33 } |
| OLD | NEW |