| 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_ITEM_H_ | 5 #ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_ |
| 6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_ | 6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
| 10 #include "ash/system/user/login_status.h" | 10 #include "ash/system/user/login_status.h" |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 | 13 |
| 14 namespace views { | 14 namespace views { |
| 15 class View; | 15 class View; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace ash { | 18 namespace ash { |
| 19 | 19 |
| 20 class ASH_EXPORT SystemTrayItem { | 20 class ASH_EXPORT SystemTrayItem { |
| 21 public: | 21 public: |
| 22 SystemTrayItem(); | 22 SystemTrayItem(); |
| 23 virtual ~SystemTrayItem(); | 23 virtual ~SystemTrayItem(); |
| 24 | 24 |
| 25 // Create* functions may return NULL if nothing should be displayed for the |
| 26 // type of view. The default implementations return NULL. |
| 27 |
| 25 // Returns a view to be displayed in the system tray. If this returns NULL, | 28 // Returns a view to be displayed in the system tray. If this returns NULL, |
| 26 // then this item is not displayed in the tray. | 29 // then this item is not displayed in the tray. |
| 27 // NOTE: The returned view should almost always be a TrayItemView, which | 30 // NOTE: The returned view should almost always be a TrayItemView, which |
| 28 // automatically resizes the widget when the size of the view changes, and | 31 // automatically resizes the widget when the size of the view changes, and |
| 29 // adds animation when the visibility of the view changes. If a view wants to | 32 // adds animation when the visibility of the view changes. If a view wants to |
| 30 // avoid these behaviour, then it should not be a TrayItemView. | 33 // avoid these behaviour, then it should not be a TrayItemView. |
| 31 virtual views::View* CreateTrayView(user::LoginStatus status) = 0; | 34 virtual views::View* CreateTrayView(user::LoginStatus status); |
| 32 | 35 |
| 33 // Returns a view for the item to be displayed in the list. This view can be | 36 // Returns a view for the item to be displayed in the list. This view can be |
| 34 // displayed with a number of other tray items, so this should not be too | 37 // displayed with a number of other tray items, so this should not be too |
| 35 // big. | 38 // big. |
| 36 virtual views::View* CreateDefaultView(user::LoginStatus status) = 0; | 39 virtual views::View* CreateDefaultView(user::LoginStatus status); |
| 37 | 40 |
| 38 // Returns a detailed view for the item. This view is displayed standalone. | 41 // Returns a detailed view for the item. This view is displayed standalone. |
| 39 virtual views::View* CreateDetailedView(user::LoginStatus status) = 0; | 42 virtual views::View* CreateDetailedView(user::LoginStatus status); |
| 43 |
| 44 // Returns a notification view for the item. This view is displayed with |
| 45 // other notifications and should be the same size as default views. |
| 46 virtual views::View* CreateNotificationView(user::LoginStatus status); |
| 40 | 47 |
| 41 // These functions are called when the corresponding view item is about to be | 48 // These functions are called when the corresponding view item is about to be |
| 42 // removed. An item should do appropriate cleanup in these functions. | 49 // removed. An item should do appropriate cleanup in these functions. |
| 43 virtual void DestroyTrayView() = 0; | 50 // The default implementation does nothing. |
| 44 virtual void DestroyDefaultView() = 0; | 51 virtual void DestroyTrayView(); |
| 45 virtual void DestroyDetailedView() = 0; | 52 virtual void DestroyDefaultView(); |
| 53 virtual void DestroyDetailedView(); |
| 54 virtual void DestroyNotificationView(); |
| 46 | 55 |
| 47 // Updates the tray view (if applicable) when the user's login status changes. | 56 // Updates the tray view (if applicable) when the user's login status changes. |
| 48 // It is not necessary the update the default or detailed view, since the | 57 // It is not necessary the update the default or detailed view, since the |
| 49 // default/detailed popup is closed when login status changes. | 58 // default/detailed popup is closed when login status changes. |
| 50 virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) = 0; | 59 virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) = 0; |
| 51 | 60 |
| 52 // Pops up the detailed view for this item. An item can request to show its | 61 // Pops up the detailed view for this item. An item can request to show its |
| 53 // detailed view using this function (e.g. from an observer callback when | 62 // detailed view using this function (e.g. from an observer callback when |
| 54 // something, e.g. volume, network availability etc. changes). If | 63 // something, e.g. volume, network availability etc. changes). If |
| 55 // |for_seconds| is non-zero, then the popup is closed after the specified | 64 // |for_seconds| is non-zero, then the popup is closed after the specified |
| 56 // time. | 65 // time. |
| 57 void PopupDetailedView(int for_seconds, bool activate); | 66 void PopupDetailedView(int for_seconds, bool activate); |
| 58 | 67 |
| 59 // Continue showing the currently-shown detailed view, if any, for | 68 // Continue showing the currently-shown detailed view, if any, for |
| 60 // |for_seconds| seconds. The caller is responsible for checking that the | 69 // |for_seconds| seconds. The caller is responsible for checking that the |
| 61 // currently-shown view is for this item. | 70 // currently-shown view is for this item. |
| 62 void SetDetailedViewCloseDelay(int for_seconds); | 71 void SetDetailedViewCloseDelay(int for_seconds); |
| 63 | 72 |
| 73 // Shows a notification for this item. |
| 74 void ShowNotificationView(); |
| 75 |
| 76 // Hides the notification for this item. |
| 77 void HideNotificationView(); |
| 78 |
| 64 private: | 79 private: |
| 65 | 80 |
| 66 DISALLOW_COPY_AND_ASSIGN(SystemTrayItem); | 81 DISALLOW_COPY_AND_ASSIGN(SystemTrayItem); |
| 67 }; | 82 }; |
| 68 | 83 |
| 69 } // namespace ash | 84 } // namespace ash |
| 70 | 85 |
| 71 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_ | 86 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_ |
| OLD | NEW |