Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_COMMON_SYSTEM_TRAY_ACTIONABLE_VIEW_H_ | 5 #ifndef ASH_COMMON_SYSTEM_TRAY_ACTIONABLE_VIEW_H_ |
| 6 #define ASH_COMMON_SYSTEM_TRAY_ACTIONABLE_VIEW_H_ | 6 #define ASH_COMMON_SYSTEM_TRAY_ACTIONABLE_VIEW_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
| 11 | 11 |
| 12 namespace ash { | 12 namespace ash { |
| 13 class SystemTrayItem; | |
| 13 | 14 |
| 14 // A focusable view that performs an action when user clicks on it, or presses | 15 // A focusable view that performs an action when user clicks on it, or presses |
| 15 // enter or space when focused. Note that the action is triggered on mouse-up, | 16 // enter or space when focused. Note that the action is triggered on mouse-up, |
| 16 // instead of on mouse-down. So if user presses the mouse on the view, then | 17 // instead of on mouse-down. So if user presses the mouse on the view, then |
| 17 // moves the mouse out of the view and then releases, then the action will not | 18 // moves the mouse out of the view and then releases, then the action will not |
| 18 // be performed. | 19 // be performed. |
| 19 // Exported for SystemTray. | 20 // Exported for SystemTray. |
| 20 class ASH_EXPORT ActionableView : public views::View { | 21 class ASH_EXPORT ActionableView : public views::View { |
| 21 public: | 22 public: |
| 22 static const char kViewClassName[]; | 23 static const char kViewClassName[]; |
| 23 | 24 |
| 24 ActionableView(); | 25 explicit ActionableView(SystemTrayItem* owner); |
|
James Cook
2016/09/22 21:17:16
nit: document that |owner| can be null, and what t
oshima
2016/09/23 09:37:19
Done.
| |
| 25 | 26 |
| 26 ~ActionableView() override; | 27 ~ActionableView() override; |
| 27 | 28 |
| 28 void SetAccessibleName(const base::string16& name); | 29 void SetAccessibleName(const base::string16& name); |
| 29 const base::string16& accessible_name() const { return accessible_name_; } | 30 const base::string16& accessible_name() const { return accessible_name_; } |
| 30 | 31 |
| 32 void CloseSystemBubble(); | |
|
James Cook
2016/09/22 21:17:16
nit: document
oshima
2016/09/23 09:37:19
Done.
| |
| 33 | |
| 31 protected: | 34 protected: |
| 35 SystemTrayItem* owner() { return owner_; } | |
| 36 | |
| 32 void OnPaintFocus(gfx::Canvas* canvas); | 37 void OnPaintFocus(gfx::Canvas* canvas); |
| 33 | 38 |
| 34 // Returns the bounds to paint the focus rectangle in. | 39 // Returns the bounds to paint the focus rectangle in. |
| 35 virtual gfx::Rect GetFocusBounds(); | 40 virtual gfx::Rect GetFocusBounds(); |
| 36 | 41 |
| 37 // Performs an action when user clicks on the view (on mouse-press event), or | 42 // Performs an action when user clicks on the view (on mouse-press event), or |
| 38 // presses a key when this view is in focus. Returns true if the event has | 43 // presses a key when this view is in focus. Returns true if the event has |
| 39 // been handled and an action was performed. Returns false otherwise. | 44 // been handled and an action was performed. Returns false otherwise. |
| 40 virtual bool PerformAction(const ui::Event& event) = 0; | 45 virtual bool PerformAction(const ui::Event& event) = 0; |
| 41 | 46 |
| 42 // Overridden from views::View. | 47 // Overridden from views::View. |
| 43 const char* GetClassName() const override; | 48 const char* GetClassName() const override; |
| 44 bool OnKeyPressed(const ui::KeyEvent& event) override; | 49 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 45 bool OnMousePressed(const ui::MouseEvent& event) override; | 50 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 46 void OnMouseReleased(const ui::MouseEvent& event) override; | 51 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 47 void OnMouseCaptureLost() override; | 52 void OnMouseCaptureLost() override; |
| 48 void GetAccessibleState(ui::AXViewState* state) override; | 53 void GetAccessibleState(ui::AXViewState* state) override; |
| 49 void OnPaint(gfx::Canvas* canvas) override; | 54 void OnPaint(gfx::Canvas* canvas) override; |
| 50 void OnFocus() override; | 55 void OnFocus() override; |
| 51 void OnBlur() override; | 56 void OnBlur() override; |
| 52 | 57 |
| 53 // Overridden from ui::EventHandler. | 58 // Overridden from ui::EventHandler. |
| 54 void OnGestureEvent(ui::GestureEvent* event) override; | 59 void OnGestureEvent(ui::GestureEvent* event) override; |
| 55 | 60 |
| 56 private: | 61 private: |
| 62 SystemTrayItem* owner_; | |
| 63 | |
| 57 base::string16 accessible_name_; | 64 base::string16 accessible_name_; |
| 58 bool has_capture_; | 65 bool has_capture_; |
| 59 | 66 |
| 60 DISALLOW_COPY_AND_ASSIGN(ActionableView); | 67 DISALLOW_COPY_AND_ASSIGN(ActionableView); |
| 61 }; | 68 }; |
| 62 | 69 |
| 63 } // namespace ash | 70 } // namespace ash |
| 64 | 71 |
| 65 #endif // ASH_COMMON_SYSTEM_TRAY_ACTIONABLE_VIEW_H_ | 72 #endif // ASH_COMMON_SYSTEM_TRAY_ACTIONABLE_VIEW_H_ |
| OLD | NEW |