Commit 735437bf authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

views: open context menus on extension actions on down arrow

These buttons have two modes: a context menu and an "activation", which usually
shows a popup but may also take an action on the page or similar. They
subclass MenuButton, so down-arrow is wired to activation instead of to opening
the menu by default. This change causes extension actions to always open their
context menu on down-arrow instead of activating, since otherwise the context
menu is keyboard-inaccessible.

Bug: 696268
Change-Id: If0f12c3ac5b1168cc74ea5df848ecf30d0662e09
Reviewed-on: https://chromium-review.googlesource.com/c/1286738Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600736}
parent 43116fdd
......@@ -144,6 +144,14 @@ ToolbarActionView::CreateInkDropHighlight() const {
return CreateToolbarInkDropHighlight(this);
}
bool ToolbarActionView::OnKeyPressed(const ui::KeyEvent& event) {
if (event.key_code() == ui::VKEY_DOWN) {
ShowContextMenuForView(this, gfx::Point(), ui::MENU_SOURCE_KEYBOARD);
return true;
}
return MenuButton::OnKeyPressed(event);
}
content::WebContents* ToolbarActionView::GetCurrentWebContents() const {
return delegate_->GetCurrentWebContents();
}
......
......@@ -73,6 +73,7 @@ class ToolbarActionView : public views::MenuButton,
std::unique_ptr<views::InkDrop> CreateInkDrop() override;
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
const override;
bool OnKeyPressed(const ui::KeyEvent& event) override;
// ToolbarActionViewDelegateViews:
content::WebContents* GetCurrentWebContents() const override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment