| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_ | |
| 6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_ | |
| 7 | |
| 8 #include "ash/ash_export.h" | |
| 9 #include "ash/common/shelf/shelf_types.h" | |
| 10 #include "ash/system/user/login_status.h" | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/macros.h" | |
| 13 | |
| 14 namespace views { | |
| 15 class View; | |
| 16 } | |
| 17 | |
| 18 namespace ash { | |
| 19 class SystemTray; | |
| 20 class TrayItemView; | |
| 21 | |
| 22 class ASH_EXPORT SystemTrayItem { | |
| 23 public: | |
| 24 explicit SystemTrayItem(SystemTray* system_tray); | |
| 25 virtual ~SystemTrayItem(); | |
| 26 | |
| 27 // Create* functions may return NULL if nothing should be displayed for the | |
| 28 // type of view. The default implementations return NULL. | |
| 29 | |
| 30 // Returns a view to be displayed in the system tray. If this returns NULL, | |
| 31 // then this item is not displayed in the tray. | |
| 32 // NOTE: The returned view should almost always be a TrayItemView, which | |
| 33 // automatically resizes the widget when the size of the view changes, and | |
| 34 // adds animation when the visibility of the view changes. If a view wants to | |
| 35 // avoid this behavior, then it should not be a TrayItemView. | |
| 36 virtual views::View* CreateTrayView(LoginStatus status); | |
| 37 | |
| 38 // Returns a view for the item to be displayed in the list. This view can be | |
| 39 // displayed with a number of other tray items, so this should not be too | |
| 40 // big. | |
| 41 virtual views::View* CreateDefaultView(LoginStatus status); | |
| 42 | |
| 43 // Returns a detailed view for the item. This view is displayed standalone. | |
| 44 virtual views::View* CreateDetailedView(LoginStatus status); | |
| 45 | |
| 46 // Returns a notification view for the item. This view is displayed with | |
| 47 // other notifications and should be the same size as default views. | |
| 48 virtual views::View* CreateNotificationView(LoginStatus status); | |
| 49 | |
| 50 // These functions are called when the corresponding view item is about to be | |
| 51 // removed. An item should do appropriate cleanup in these functions. | |
| 52 // The default implementation does nothing. | |
| 53 virtual void DestroyTrayView(); | |
| 54 virtual void DestroyDefaultView(); | |
| 55 virtual void DestroyDetailedView(); | |
| 56 virtual void DestroyNotificationView(); | |
| 57 | |
| 58 // Updates the tray view (if applicable) when the user's login status changes. | |
| 59 // It is not necessary the update the default or detailed view, since the | |
| 60 // default/detailed popup is closed when login status changes. The default | |
| 61 // implementation does nothing. | |
| 62 virtual void UpdateAfterLoginStatusChange(LoginStatus status); | |
| 63 | |
| 64 // Updates the tray view (if applicable) when shelf's alignment changes. | |
| 65 // The default implementation does nothing. | |
| 66 virtual void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment); | |
| 67 | |
| 68 // Shows the detailed view for this item. If the main popup for the tray is | |
| 69 // currently visible, then making this call would use the existing window to | |
| 70 // display the detailed item. The detailed item will inherit the bounds of the | |
| 71 // existing window. | |
| 72 // If there is no existing view, then this is equivalent to calling | |
| 73 // PopupDetailedView(0, true). | |
| 74 void TransitionDetailedView(); | |
| 75 | |
| 76 // Pops up the detailed view for this item. An item can request to show its | |
| 77 // detailed view using this function (e.g. from an observer callback when | |
| 78 // something, e.g. volume, network availability etc. changes). If | |
| 79 // |for_seconds| is non-zero, then the popup is closed after the specified | |
| 80 // time. | |
| 81 void PopupDetailedView(int for_seconds, bool activate); | |
| 82 | |
| 83 // Continue showing the currently-shown detailed view, if any, for | |
| 84 // |for_seconds| seconds. The caller is responsible for checking that the | |
| 85 // currently-shown view is for this item. | |
| 86 void SetDetailedViewCloseDelay(int for_seconds); | |
| 87 | |
| 88 // Hides the detailed view for this item. | |
| 89 void HideDetailedView(); | |
| 90 | |
| 91 // Shows a notification for this item. | |
| 92 void ShowNotificationView(); | |
| 93 | |
| 94 // Hides the notification for this item. | |
| 95 void HideNotificationView(); | |
| 96 | |
| 97 // Returns true if item should hide the arrow. | |
| 98 virtual bool ShouldHideArrow() const; | |
| 99 | |
| 100 // Returns true if this item needs to force the shelf to be visible when | |
| 101 // the shelf is in the auto-hide state. Default is true. | |
| 102 virtual bool ShouldShowShelf() const; | |
| 103 | |
| 104 // Returns the system tray that this item belongs to. | |
| 105 SystemTray* system_tray() const { return system_tray_; } | |
| 106 | |
| 107 bool restore_focus() const { return restore_focus_; } | |
| 108 void set_restore_focus(bool restore_focus) { | |
| 109 restore_focus_ = restore_focus; | |
| 110 } | |
| 111 | |
| 112 private: | |
| 113 SystemTray* system_tray_; | |
| 114 bool restore_focus_; | |
| 115 | |
| 116 DISALLOW_COPY_AND_ASSIGN(SystemTrayItem); | |
| 117 }; | |
| 118 | |
| 119 } // namespace ash | |
| 120 | |
| 121 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_ | |
| OLD | NEW |