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