@@ -34,9 +34,9 @@ const char MenuBarView::kViewClassName[] = "BookmarkBarView";
34
34
class MenuBarButton : public views ::MenuButton {
35
35
public:
36
36
MenuBarButton (const base::string16& title,
37
- views::ButtonListener* menu_button_listener ,
37
+ PressedCallback callback ,
38
38
bool show_menu_marker)
39
- : MenuButton(PressedCallback(menu_button_listener, this ), title) {
39
+ : MenuButton(std::move(callback ), title) {
40
40
SetElideBehavior (kElideBehavior );
41
41
}
42
42
@@ -72,7 +72,10 @@ void MenuBarView::UpdateMenu(ui::MenuModel* model) {
72
72
void MenuBarView::InitView (ui::MenuModel* model) {
73
73
model_ = model;
74
74
for (int i = 0 ; i < model_->GetItemCount (); i++) {
75
- AddChildView (new MenuBarButton (model_->GetLabelAt (i), this , false ));
75
+ AddChildView (new MenuBarButton (model_->GetLabelAt (i),
76
+ base::BindRepeating (&MenuBarView::ButtonPressed,
77
+ base::Unretained (this ), i),
78
+ false ));
76
79
}
77
80
}
78
81
@@ -93,9 +96,9 @@ bool MenuBarView::GetMenuButtonAtLocation(const gfx::Point& loc, ui::MenuModel**
93
96
return false ;
94
97
}
95
98
96
- void MenuBarView::ButtonPressed (views::Button* view ,
99
+ void MenuBarView::ButtonPressed (int button_index ,
97
100
const ui::Event& event) {
98
- int button_index = GetIndexOf (view) ;
101
+ views::View* view = children ()[button_index] ;
99
102
DCHECK_NE (-1 , button_index);
100
103
ui::MenuModel::ItemType type = model_->GetTypeAt (button_index);
101
104
if (type == ui::MenuModel::TYPE_SUBMENU) {
0 commit comments