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_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ | |
6 #define ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ | |
7 | |
8 #include <map> | |
9 #include <memory> | |
10 #include <vector> | |
11 | |
12 #include "ash/common/login_status.h" | |
13 #include "ash/common/system/tray/system_tray_item.h" | |
14 #include "base/macros.h" | |
15 #include "base/timer/timer.h" | |
16 #include "ui/views/bubble/tray_bubble_view.h" | |
17 | |
18 namespace ash { | |
19 class SystemTray; | |
20 class SystemTrayItem; | |
21 | |
22 class SystemTrayBubble { | |
23 public: | |
24 enum BubbleType { BUBBLE_TYPE_DEFAULT, BUBBLE_TYPE_DETAILED }; | |
25 | |
26 SystemTrayBubble(ash::SystemTray* tray, | |
27 const std::vector<ash::SystemTrayItem*>& items, | |
28 BubbleType bubble_type); | |
29 virtual ~SystemTrayBubble(); | |
30 | |
31 // Change the items displayed in the bubble. | |
32 void UpdateView(const std::vector<ash::SystemTrayItem*>& items, | |
33 BubbleType bubble_type); | |
34 | |
35 // Creates |bubble_view_| and a child views for each member of |items_|. | |
36 // Also creates |bubble_wrapper_|. |init_params| may be modified. | |
37 void InitView(views::View* anchor, | |
38 LoginStatus login_status, | |
39 views::TrayBubbleView::InitParams* init_params); | |
40 | |
41 // Focus the default item if no item is focused. Othewise, do nothing. | |
42 void FocusDefaultIfNeeded(); | |
43 | |
44 BubbleType bubble_type() const { return bubble_type_; } | |
45 views::TrayBubbleView* bubble_view() const { return bubble_view_; } | |
46 | |
47 void DestroyItemViews(); | |
48 void BubbleViewDestroyed(); | |
49 void StartAutoCloseTimer(int seconds); | |
50 void StopAutoCloseTimer(); | |
51 void RestartAutoCloseTimer(); | |
52 void Close(); | |
53 void SetVisible(bool is_visible); | |
54 bool IsVisible(); | |
55 | |
56 // Returns true if any of the SystemTrayItems return true from | |
57 // ShouldShowShelf(). | |
58 bool ShouldShowShelf() const; | |
59 | |
60 // Records metrics for visible system menu rows. Only implemented for the | |
61 // BUBBLE_TYPE_DEFAULT BubbleType. | |
62 void RecordVisibleRowMetrics(); | |
63 | |
64 private: | |
65 // Updates the bottom padding of the |bubble_view_| based on the | |
66 // |bubble_type_|. | |
67 void UpdateBottomPadding(); | |
68 void CreateItemViews(LoginStatus login_status); | |
69 | |
70 ash::SystemTray* tray_; | |
71 views::TrayBubbleView* bubble_view_; | |
72 std::vector<ash::SystemTrayItem*> items_; | |
73 BubbleType bubble_type_; | |
74 | |
75 // Tracks the views created in the last call to CreateItemViews(). | |
76 std::map<SystemTrayItem::UmaType, views::View*> tray_item_view_map_; | |
77 | |
78 int autoclose_delay_; | |
79 base::OneShotTimer autoclose_; | |
80 | |
81 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubble); | |
82 }; | |
83 | |
84 } // namespace ash | |
85 | |
86 #endif // ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ | |
OLD | NEW |