This source file includes following definitions.
- OnMousePressed
- OnMouseReleased
- OnKeyPressed
- OnGestureEvent
- CanHandleClick
#include "chrome/browser/ui/views/location_bar/location_bar_decoration_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "ui/events/event.h"
LocationBarDecorationView::LocationBarDecorationView()
: could_handle_click_(true) {
SetAccessibilityFocusable(true);
LocationBarView::InitTouchableLocationBarChildView(this);
}
LocationBarDecorationView::~LocationBarDecorationView() {}
bool LocationBarDecorationView::OnMousePressed(const ui::MouseEvent& event) {
if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) {
could_handle_click_ = CanHandleClick();
return true;
}
return false;
}
void LocationBarDecorationView::OnMouseReleased(const ui::MouseEvent& event) {
if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location()) &&
could_handle_click_ && CanHandleClick()) {
OnClick();
}
}
bool LocationBarDecorationView::OnKeyPressed(const ui::KeyEvent& event) {
if (event.key_code() == ui::VKEY_SPACE ||
event.key_code() == ui::VKEY_RETURN) {
OnClick();
return true;
}
return false;
}
void LocationBarDecorationView::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() == ui::ET_GESTURE_TAP) {
OnClick();
event->SetHandled();
}
}
bool LocationBarDecorationView::CanHandleClick() const {
return true;
}