This source file includes following definitions.
- suppress_mouse_released_action_
- GetAccessibleState
- GetTooltipText
- OnMousePressed
- OnMouseReleased
- OnKeyPressed
- OnGestureEvent
#include "chrome/browser/ui/views/location_bar/bubble_icon_view.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "ui/accessibility/ax_view_state.h"
#include "ui/events/event.h"
BubbleIconView::BubbleIconView(CommandUpdater* command_updater, int command_id)
: command_updater_(command_updater),
command_id_(command_id),
suppress_mouse_released_action_(false) {
SetAccessibilityFocusable(true);
LocationBarView::InitTouchableLocationBarChildView(this);
}
BubbleIconView::~BubbleIconView() {
}
void BubbleIconView::GetAccessibleState(ui::AXViewState* state) {
views::ImageView::GetAccessibleState(state);
state->role = ui::AX_ROLE_BUTTON;
}
bool BubbleIconView::GetTooltipText(const gfx::Point& p,
base::string16* tooltip) const {
if (IsBubbleShowing())
return false;
return views::ImageView::GetTooltipText(p, tooltip);
}
bool BubbleIconView::OnMousePressed(const ui::MouseEvent& event) {
suppress_mouse_released_action_ = IsBubbleShowing();
return true;
}
void BubbleIconView::OnMouseReleased(const ui::MouseEvent& event) {
if (suppress_mouse_released_action_) {
suppress_mouse_released_action_ = false;
return;
}
if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) {
OnExecuting(EXECUTE_SOURCE_MOUSE);
command_updater_->ExecuteCommand(command_id_);
}
}
bool BubbleIconView::OnKeyPressed(const ui::KeyEvent& event) {
if (event.key_code() == ui::VKEY_SPACE ||
event.key_code() == ui::VKEY_RETURN) {
OnExecuting(EXECUTE_SOURCE_KEYBOARD);
command_updater_->ExecuteCommand(command_id_);
return true;
}
return false;
}
void BubbleIconView::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() == ui::ET_GESTURE_TAP) {
OnExecuting(EXECUTE_SOURCE_GESTURE);
command_updater_->ExecuteCommand(command_id_);
event->SetHandled();
}
}