| 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 "base/base_export.h" | 10 #include "base/base_export.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/timer.h" | 12 #include "base/timer.h" |
| 12 #include "ui/views/widget/widget_observer.h" | |
| 13 | 13 |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 namespace ash { | 16 namespace ash { |
| 17 | 17 |
| 18 class SystemTray; | 18 class SystemTray; |
| 19 class SystemTrayItem; | 19 class SystemTrayItem; |
| 20 | 20 |
| 21 namespace internal { | 21 namespace internal { |
| 22 | 22 |
| 23 class SystemTrayBubble : public TrayBubbleView::Host, | 23 class TrayBubbleWrapper; |
| 24 public views::WidgetObserver { | 24 |
| 25 class SystemTrayBubble : public TrayBubbleView::Delegate { |
| 25 public: | 26 public: |
| 26 enum BubbleType { | 27 enum BubbleType { |
| 27 BUBBLE_TYPE_DEFAULT, | 28 BUBBLE_TYPE_DEFAULT, |
| 28 BUBBLE_TYPE_DETAILED, | 29 BUBBLE_TYPE_DETAILED, |
| 29 BUBBLE_TYPE_NOTIFICATION | 30 BUBBLE_TYPE_NOTIFICATION |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 SystemTrayBubble(ash::SystemTray* tray, | 33 SystemTrayBubble(ash::SystemTray* tray, |
| 33 const std::vector<ash::SystemTrayItem*>& items, | 34 const std::vector<ash::SystemTrayItem*>& items, |
| 34 BubbleType bubble_type); | 35 BubbleType bubble_type); |
| 35 virtual ~SystemTrayBubble(); | 36 virtual ~SystemTrayBubble(); |
| 36 | 37 |
| 37 // Change the items displayed in the bubble. | 38 // Change the items displayed in the bubble. |
| 38 void UpdateView(const std::vector<ash::SystemTrayItem*>& items, | 39 void UpdateView(const std::vector<ash::SystemTrayItem*>& items, |
| 39 BubbleType bubble_type); | 40 BubbleType bubble_type); |
| 40 | 41 |
| 41 // Creates |bubble_view_| and a child views for each member of |items_|. | 42 // Creates |bubble_view_| and a child views for each member of |items_|. |
| 42 // Also creates |bubble_widget_| and sets up animations. | 43 // Also creates |bubble_wrapper_|. |init_params| may be modified. |
| 43 void InitView(views::View* anchor, | 44 void InitView(views::View* anchor, |
| 44 TrayBubbleView::InitParams init_params, | 45 user::LoginStatus login_status, |
| 45 user::LoginStatus login_status); | 46 TrayBubbleView::InitParams* init_params); |
| 46 | 47 |
| 47 // Overridden from TrayBubbleView::Host. | 48 // Overridden from TrayBubbleView::Delegate. |
| 48 virtual void BubbleViewDestroyed() OVERRIDE; | 49 virtual void BubbleViewDestroyed() OVERRIDE; |
| 49 virtual void OnMouseEnteredView() OVERRIDE; | 50 virtual void OnMouseEnteredView() OVERRIDE; |
| 50 virtual void OnMouseExitedView() OVERRIDE; | 51 virtual void OnMouseExitedView() OVERRIDE; |
| 51 virtual void OnClickedOutsideView() OVERRIDE; | |
| 52 virtual string16 GetAccessibleName() OVERRIDE; | 52 virtual string16 GetAccessibleName() OVERRIDE; |
| 53 virtual gfx::Rect GetAnchorRect(views::Widget* anchor_widget, |
| 54 AnchorType anchor_type, |
| 55 AnchorAlignment anchor_alignment) OVERRIDE; |
| 53 | 56 |
| 54 BubbleType bubble_type() const { return bubble_type_; } | 57 BubbleType bubble_type() const { return bubble_type_; } |
| 55 TrayBubbleView* bubble_view() const { return bubble_view_; } | 58 TrayBubbleView* bubble_view() const { return bubble_view_; } |
| 56 | 59 |
| 57 void DestroyItemViews(); | 60 void DestroyItemViews(); |
| 58 void StartAutoCloseTimer(int seconds); | 61 void StartAutoCloseTimer(int seconds); |
| 59 void StopAutoCloseTimer(); | 62 void StopAutoCloseTimer(); |
| 60 void RestartAutoCloseTimer(); | 63 void RestartAutoCloseTimer(); |
| 61 void Close(); | 64 void Close(); |
| 62 void SetVisible(bool is_visible); | 65 void SetVisible(bool is_visible); |
| 63 bool IsVisible(); | 66 bool IsVisible(); |
| 64 | 67 |
| 65 private: | 68 private: |
| 66 void CreateItemViews(user::LoginStatus login_status); | 69 void CreateItemViews(user::LoginStatus login_status); |
| 67 | 70 |
| 68 // Overridden from views::WidgetObserver: | |
| 69 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; | |
| 70 | |
| 71 ash::SystemTray* tray_; | 71 ash::SystemTray* tray_; |
| 72 TrayBubbleView* bubble_view_; | 72 TrayBubbleView* bubble_view_; |
| 73 views::Widget* bubble_widget_; | 73 scoped_ptr<TrayBubbleWrapper> bubble_wrapper_; |
| 74 std::vector<ash::SystemTrayItem*> items_; | 74 std::vector<ash::SystemTrayItem*> items_; |
| 75 BubbleType bubble_type_; | 75 BubbleType bubble_type_; |
| 76 | 76 |
| 77 int autoclose_delay_; | 77 int autoclose_delay_; |
| 78 base::OneShotTimer<SystemTrayBubble> autoclose_; | 78 base::OneShotTimer<SystemTrayBubble> autoclose_; |
| 79 | 79 |
| 80 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubble); | 80 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubble); |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 } // namespace internal | 83 } // namespace internal |
| 84 } // namespace ash | 84 } // namespace ash |
| 85 | 85 |
| 86 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ | 86 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ |
| OLD | NEW |