Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ash / system / tray / actionable_view.h
blobc5ccbe31c1eacd724ad26c343726bb655432c705
1 // Copyright 2013 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 #ifndef ASH_SYSTEM_TRAY_ACTIONABLE_VIEW_H_
6 #define ASH_SYSTEM_TRAY_ACTIONABLE_VIEW_H_
8 #include "ash/ash_export.h"
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "ui/views/view.h"
13 namespace ash {
15 // A focusable view that performs an action when user clicks on it, or presses
16 // enter or space when focused. Note that the action is triggered on mouse-up,
17 // instead of on mouse-down. So if user presses the mouse on the view, then
18 // moves the mouse out of the view and then releases, then the action will not
19 // be performed.
20 // Exported for SystemTray.
21 class ASH_EXPORT ActionableView : public views::View {
22 public:
23 static const char kViewClassName[];
25 ActionableView();
27 virtual ~ActionableView();
29 void SetAccessibleName(const base::string16& name);
30 const base::string16& accessible_name() const { return accessible_name_; }
32 protected:
33 void OnPaintFocus(gfx::Canvas* canvas);
35 // Returns the bounds to paint the focus rectangle in.
36 virtual gfx::Rect GetFocusBounds();
38 // Performs an action when user clicks on the view (on mouse-press event), or
39 // presses a key when this view is in focus. Returns true if the event has
40 // been handled and an action was performed. Returns false otherwise.
41 virtual bool PerformAction(const ui::Event& event) = 0;
43 // Overridden from views::View.
44 virtual const char* GetClassName() const OVERRIDE;
45 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
46 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
47 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
48 virtual void OnMouseCaptureLost() OVERRIDE;
49 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
50 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
51 virtual void OnFocus() OVERRIDE;
52 virtual void OnBlur() OVERRIDE;
54 // Overridden from ui::EventHandler.
55 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
57 private:
58 base::string16 accessible_name_;
59 bool has_capture_;
61 DISALLOW_COPY_AND_ASSIGN(ActionableView);
64 } // namespace ash
66 #endif // ASH_SYSTEM_TRAY_ACTIONABLE_VIEW_H_