Skip to content

Commit 09b304e

Browse files
committed
1 parent 2450418 commit 09b304e

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/browser/menubar_view.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ const char MenuBarView::kViewClassName[] = "BookmarkBarView";
3434
class MenuBarButton : public views::MenuButton {
3535
public:
3636
MenuBarButton(const base::string16& title,
37-
views::ButtonListener* menu_button_listener,
37+
PressedCallback callback,
3838
bool show_menu_marker)
39-
: MenuButton(PressedCallback(menu_button_listener, this), title) {
39+
: MenuButton(std::move(callback), title) {
4040
SetElideBehavior(kElideBehavior);
4141
}
4242

@@ -72,7 +72,10 @@ void MenuBarView::UpdateMenu(ui::MenuModel* model) {
7272
void MenuBarView::InitView(ui::MenuModel* model) {
7373
model_ = model;
7474
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));
7679
}
7780
}
7881

@@ -93,9 +96,9 @@ bool MenuBarView::GetMenuButtonAtLocation(const gfx::Point& loc, ui::MenuModel**
9396
return false;
9497
}
9598

96-
void MenuBarView::ButtonPressed(views::Button* view,
99+
void MenuBarView::ButtonPressed(int button_index,
97100
const ui::Event& event) {
98-
int button_index = GetIndexOf(view);
101+
views::View* view = children()[button_index];
99102
DCHECK_NE(-1, button_index);
100103
ui::MenuModel::ItemType type = model_->GetTypeAt(button_index);
101104
if (type == ui::MenuModel::TYPE_SUBMENU) {

src/browser/menubar_view.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ namespace nw {
2626
//
2727
///////////////////////////////////////////////////////////////////////////////
2828

29-
class MenuBarView :
30-
public views::AccessiblePaneView,
31-
public views::ButtonListener {
29+
class MenuBarView : public views::AccessiblePaneView {
3230

3331
public:
3432
// The internal view class name.
@@ -46,9 +44,7 @@ class MenuBarView :
4644

4745
bool GetMenuButtonAtLocation(const gfx::Point& loc, ui::MenuModel** model, views::MenuButton** button);
4846

49-
// views::ButtonListener:
50-
void ButtonPressed(views::Button* sender,
51-
const ui::Event& event) override;
47+
void ButtonPressed(int index, const ui::Event& event);
5248

5349
private:
5450
ui::MenuModel* model_;

0 commit comments

Comments
 (0)