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