| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ | 5 #ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ |
| 6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ | 6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ |
| 7 | 7 |
| 8 #include "ash/system/tray/tray_bubble_view.h" | 8 #include "ash/system/tray/tray_bubble_view.h" |
| 9 #include "ash/system/user/login_status.h" | 9 #include "ash/system/user/login_status.h" |
| 10 #include "ash/wm/shelf_types.h" | |
| 11 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| 12 #include "base/timer.h" | 11 #include "base/timer.h" |
| 13 #include "ui/views/widget/widget.h" | 12 #include "ui/views/widget/widget.h" |
| 14 | 13 |
| 15 #include <vector> | 14 #include <vector> |
| 16 | 15 |
| 17 namespace ash { | 16 namespace ash { |
| 18 | 17 |
| 19 class SystemTray; | 18 class SystemTray; |
| 20 class SystemTrayItem; | 19 class SystemTrayItem; |
| 21 | 20 |
| 22 namespace internal { | 21 namespace internal { |
| 23 | 22 |
| 24 class SystemTrayBubble : public TrayBubbleView::Host, | 23 class SystemTrayBubble : public TrayBubbleView::Host, |
| 25 public views::Widget::Observer { | 24 public views::Widget::Observer { |
| 26 public: | 25 public: |
| 27 enum BubbleType { | 26 enum BubbleType { |
| 28 BUBBLE_TYPE_DEFAULT, | 27 BUBBLE_TYPE_DEFAULT, |
| 29 BUBBLE_TYPE_DETAILED, | 28 BUBBLE_TYPE_DETAILED, |
| 30 BUBBLE_TYPE_NOTIFICATION | 29 BUBBLE_TYPE_NOTIFICATION |
| 31 }; | 30 }; |
| 32 | 31 |
| 33 enum AnchorType { | |
| 34 ANCHOR_TYPE_TRAY, | |
| 35 ANCHOR_TYPE_BUBBLE | |
| 36 }; | |
| 37 | |
| 38 struct InitParams { | |
| 39 InitParams(AnchorType anchor_type, ShelfAlignment shelf_alignmen); | |
| 40 | |
| 41 views::View* anchor; | |
| 42 AnchorType anchor_type; | |
| 43 bool can_activate; | |
| 44 ash::user::LoginStatus login_status; | |
| 45 int arrow_offset; | |
| 46 int max_height; | |
| 47 }; | |
| 48 | |
| 49 SystemTrayBubble(ash::SystemTray* tray, | 32 SystemTrayBubble(ash::SystemTray* tray, |
| 50 const std::vector<ash::SystemTrayItem*>& items, | 33 const std::vector<ash::SystemTrayItem*>& items, |
| 51 BubbleType bubble_type); | 34 BubbleType bubble_type); |
| 52 virtual ~SystemTrayBubble(); | 35 virtual ~SystemTrayBubble(); |
| 53 | 36 |
| 54 // Change the items displayed in the bubble. | 37 // Change the items displayed in the bubble. |
| 55 void UpdateView(const std::vector<ash::SystemTrayItem*>& items, | 38 void UpdateView(const std::vector<ash::SystemTrayItem*>& items, |
| 56 BubbleType bubble_type); | 39 BubbleType bubble_type); |
| 57 | 40 |
| 58 // Creates |bubble_view_| and a child views for each member of |items_|. | 41 // Creates |bubble_view_| and a child views for each member of |items_|. |
| 59 // Also creates |bubble_widget_| and sets up animations. | 42 // Also creates |bubble_widget_| and sets up animations. |
| 60 void InitView(const InitParams& init_params); | 43 void InitView(views::View* anchor, |
| 44 TrayBubbleView::InitParams init_params, |
| 45 user::LoginStatus login_status); |
| 61 | 46 |
| 62 // Overridden from TrayBubbleView::Host. | 47 // Overridden from TrayBubbleView::Host. |
| 63 virtual void BubbleViewDestroyed() OVERRIDE; | 48 virtual void BubbleViewDestroyed() OVERRIDE; |
| 64 virtual gfx::Rect GetAnchorRect() const OVERRIDE; | |
| 65 virtual void OnMouseEnteredView() OVERRIDE; | 49 virtual void OnMouseEnteredView() OVERRIDE; |
| 66 virtual void OnMouseExitedView() OVERRIDE; | 50 virtual void OnMouseExitedView() OVERRIDE; |
| 67 virtual void OnClickedOutsideView() OVERRIDE; | 51 virtual void OnClickedOutsideView() OVERRIDE; |
| 68 | 52 |
| 69 BubbleType bubble_type() const { return bubble_type_; } | 53 BubbleType bubble_type() const { return bubble_type_; } |
| 70 TrayBubbleView* bubble_view() const { return bubble_view_; } | 54 TrayBubbleView* bubble_view() const { return bubble_view_; } |
| 71 | 55 |
| 72 void DestroyItemViews(); | 56 void DestroyItemViews(); |
| 73 void StartAutoCloseTimer(int seconds); | 57 void StartAutoCloseTimer(int seconds); |
| 74 void StopAutoCloseTimer(); | 58 void StopAutoCloseTimer(); |
| 75 void RestartAutoCloseTimer(); | 59 void RestartAutoCloseTimer(); |
| 76 void Close(); | 60 void Close(); |
| 77 void SetVisible(bool is_visible); | 61 void SetVisible(bool is_visible); |
| 78 bool IsVisible(); | 62 bool IsVisible(); |
| 79 | 63 |
| 80 private: | 64 private: |
| 81 void CreateItemViews(user::LoginStatus login_status); | 65 void CreateItemViews(user::LoginStatus login_status); |
| 82 | 66 |
| 83 // Overridden from views::Widget::Observer. | 67 // Overridden from views::Widget::Observer. |
| 84 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; | 68 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; |
| 85 | 69 |
| 86 ash::SystemTray* tray_; | 70 ash::SystemTray* tray_; |
| 87 TrayBubbleView* bubble_view_; | 71 TrayBubbleView* bubble_view_; |
| 88 views::Widget* bubble_widget_; | 72 views::Widget* bubble_widget_; |
| 89 std::vector<ash::SystemTrayItem*> items_; | 73 std::vector<ash::SystemTrayItem*> items_; |
| 90 BubbleType bubble_type_; | 74 BubbleType bubble_type_; |
| 91 AnchorType anchor_type_; | |
| 92 | 75 |
| 93 int autoclose_delay_; | 76 int autoclose_delay_; |
| 94 base::OneShotTimer<SystemTrayBubble> autoclose_; | 77 base::OneShotTimer<SystemTrayBubble> autoclose_; |
| 95 | 78 |
| 96 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubble); | 79 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubble); |
| 97 }; | 80 }; |
| 98 | 81 |
| 99 } // namespace internal | 82 } // namespace internal |
| 100 } // namespace ash | 83 } // namespace ash |
| 101 | 84 |
| 102 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ | 85 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ |
| OLD | NEW |