Page action extension icons should handle tap events

Handle ui::ET_GESTURE_TAP events in PageImageActionView
by showing the extension popup (the same action
taken on a mouse click). This achieves consistency
between touch and mouse input.

BUG=399748
TEST=none

Review URL: https://codereview.chromium.org/430093003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287780 0039d316-1c4b-4281-b951-d872f2087c98
parent 49e41a17
......@@ -33,6 +33,9 @@ using content::WebContents;
using extensions::LocationBarController;
using extensions::Extension;
// static
const char PageActionImageView::kViewClassName[] = "PageActionImageView";
PageActionImageView::PageActionImageView(LocationBarView* owner,
ExtensionAction* page_action,
Browser* browser)
......@@ -113,6 +116,10 @@ void PageActionImageView::ExecuteAction(
}
}
const char* PageActionImageView::GetClassName() const {
return kViewClassName;
}
void PageActionImageView::GetAccessibleState(ui::AXViewState* state) {
state->role = ui::AX_ROLE_BUTTON;
state->name = base::UTF8ToUTF16(tooltip_);
......@@ -147,6 +154,13 @@ bool PageActionImageView::OnKeyPressed(const ui::KeyEvent& event) {
return false;
}
void PageActionImageView::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() == ui::ET_GESTURE_TAP) {
ExecuteAction(ExtensionPopup::SHOW);
event->SetHandled();
}
}
void PageActionImageView::ShowContextMenuForView(
View* source,
const gfx::Point& point,
......
......@@ -49,10 +49,12 @@ class PageActionImageView : public views::ImageView,
}
// Overridden from views::View:
virtual const char* GetClassName() const OVERRIDE;
virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
// Overridden from ExtensionContextMenuModel::Delegate
virtual void InspectPopup() OVERRIDE;
......@@ -81,6 +83,8 @@ class PageActionImageView : public views::ImageView,
void ExecuteAction(ExtensionPopup::ShowAction show_action);
private:
static const char kViewClassName[];
// Overridden from View.
virtual void PaintChildren(gfx::Canvas* canvas,
const views::CullSet& cull_set) 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