cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / ash / system / tray / actionable_view.cc
blobdc26cde928da8d473876362597d568829251b19e
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/system/tray/actionable_view.h"
7 #include "ash/ash_constants.h"
8 #include "ui/accessibility/ax_view_state.h"
9 #include "ui/gfx/canvas.h"
11 namespace ash {
13 // static
14 const char ActionableView::kViewClassName[] = "tray/ActionableView";
16 ActionableView::ActionableView()
17 : has_capture_(false) {
18 SetFocusable(true);
21 ActionableView::~ActionableView() {
24 void ActionableView::OnPaintFocus(gfx::Canvas* canvas) {
25 gfx::Rect rect(GetFocusBounds());
26 rect.Inset(1, 1, 3, 2);
27 canvas->DrawSolidFocusRect(rect, kFocusBorderColor);
30 gfx::Rect ActionableView::GetFocusBounds() {
31 return GetLocalBounds();
34 const char* ActionableView::GetClassName() const {
35 return kViewClassName;
38 bool ActionableView::OnKeyPressed(const ui::KeyEvent& event) {
39 if (event.key_code() == ui::VKEY_SPACE ||
40 event.key_code() == ui::VKEY_RETURN) {
41 return PerformAction(event);
43 return false;
46 bool ActionableView::OnMousePressed(const ui::MouseEvent& event) {
47 // Return true so that this view starts capturing the events.
48 has_capture_ = true;
49 return true;
52 void ActionableView::OnMouseReleased(const ui::MouseEvent& event) {
53 if (has_capture_ && GetLocalBounds().Contains(event.location()))
54 PerformAction(event);
57 void ActionableView::OnMouseCaptureLost() {
58 has_capture_ = false;
61 void ActionableView::SetAccessibleName(const base::string16& name) {
62 accessible_name_ = name;
65 void ActionableView::GetAccessibleState(ui::AXViewState* state) {
66 state->role = ui::AX_ROLE_BUTTON;
67 state->name = accessible_name_;
70 void ActionableView::OnPaint(gfx::Canvas* canvas) {
71 View::OnPaint(canvas);
72 if (HasFocus())
73 OnPaintFocus(canvas);
76 void ActionableView::OnFocus() {
77 View::OnFocus();
78 // We render differently when focused.
79 SchedulePaint();
82 void ActionableView::OnBlur() {
83 View::OnBlur();
84 // We render differently when focused.
85 SchedulePaint();
88 void ActionableView::OnGestureEvent(ui::GestureEvent* event) {
89 if (event->type() == ui::ET_GESTURE_TAP && PerformAction(*event))
90 event->SetHandled();
93 } // namespace ash