OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROMEOS_SESSION_SESSION_LENGTH_LIMIT_H_ | 5 #ifndef ASH_SYSTEM_CHROMEOS_SESSION_SESSION_LENGTH_LIMIT_H_ |
6 #define ASH_SYSTEM_CHROMEOS_SESSION_SESSION_LENGTH_LIMIT_H_ | 6 #define ASH_SYSTEM_CHROMEOS_SESSION_SESSION_LENGTH_LIMIT_H_ |
7 | 7 |
8 #include "ash/system/chromeos/session/session_length_limit_observer.h" | 8 #include "ash/system/chromeos/session/session_length_limit_observer.h" |
9 #include "ash/system/tray/system_tray_item.h" | 9 #include "ash/system/tray/system_tray_item.h" |
10 #include "ash/system/tray/view_click_listener.h" | |
10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/strings/string16.h" | |
13 #include "base/time/time.h" | 15 #include "base/time/time.h" |
14 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
15 | 17 |
16 namespace ash { | 18 namespace ash { |
17 namespace test { | 19 namespace test { |
18 class TraySessionLengthLimitTest; | 20 class TraySessionLengthLimitTest; |
bartfab (slow)
2014/05/05 13:45:04
Nit: This should not be needed anymore.
Thiemo Nagel
2014/05/05 14:48:41
It's required for kNotificationId.
| |
19 } | 21 } |
20 | 22 |
21 namespace tray { | 23 class LabelTrayView; |
22 class RemainingSessionTimeTrayView; | |
23 } | |
24 | 24 |
25 // Adds a countdown timer to the system tray if the session length is limited. | 25 // Adds a countdown timer to the system tray if the session length is limited. |
26 class ASH_EXPORT TraySessionLengthLimit : public SystemTrayItem, | 26 class ASH_EXPORT TraySessionLengthLimit : public SystemTrayItem, |
27 public SessionLengthLimitObserver { | 27 public SessionLengthLimitObserver, |
28 public: | 28 public ViewClickListener { |
29 public: | |
29 enum LimitState { | 30 enum LimitState { |
30 LIMIT_NONE, | 31 LIMIT_NONE, |
31 LIMIT_SET, | 32 LIMIT_SET, |
32 LIMIT_EXPIRING_SOON | 33 LIMIT_EXPIRING_SOON |
33 }; | 34 }; |
34 | 35 |
35 explicit TraySessionLengthLimit(SystemTray* system_tray); | 36 explicit TraySessionLengthLimit(SystemTray* system_tray); |
36 virtual ~TraySessionLengthLimit(); | 37 virtual ~TraySessionLengthLimit(); |
37 | 38 |
38 // SystemTrayItem: | 39 // SystemTrayItem: |
39 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE; | 40 virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE; |
40 virtual void DestroyTrayView() OVERRIDE; | 41 virtual void DestroyDefaultView() OVERRIDE; |
41 virtual void UpdateAfterShelfAlignmentChange( | |
42 ShelfAlignment alignment) OVERRIDE; | |
43 | 42 |
44 // SessionLengthLimitObserver: | 43 // SessionLengthLimitObserver: |
45 virtual void OnSessionStartTimeChanged() OVERRIDE; | 44 virtual void OnSessionStartTimeChanged() OVERRIDE; |
46 virtual void OnSessionLengthLimitChanged() OVERRIDE; | 45 virtual void OnSessionLengthLimitChanged() OVERRIDE; |
47 | 46 |
47 // ViewClickListener: | |
48 virtual void OnViewClicked(views::View* sender) OVERRIDE; | |
49 | |
48 LimitState GetLimitState() const; | 50 LimitState GetLimitState() const; |
49 base::TimeDelta GetRemainingSessionTime() const; | 51 base::TimeDelta GetRemainingSessionTime() const; |
50 | 52 |
51 private: | 53 private: |
52 friend class test::TraySessionLengthLimitTest; | 54 friend class test::TraySessionLengthLimitTest; |
bartfab (slow)
2014/05/05 13:45:04
Nit: This should not be needed anymore.
Thiemo Nagel
2014/05/05 14:48:41
See above.
| |
53 | 55 |
54 static const char kNotificationId[]; | 56 static const char kNotificationId[]; |
55 | 57 |
58 // Called by the Timer in regular intervals and also by OnSession*Changed(). | |
56 void Update(); | 59 void Update(); |
57 | 60 |
58 bool IsTrayViewVisibleForTest(); | 61 // Recalculate |limit_state_| and the message strings. |
62 void UpdateState(); | |
59 | 63 |
60 tray::RemainingSessionTimeTrayView* tray_view_; | 64 // Update notifications and views using the message strings. |
65 void UpdateUI(); | |
61 | 66 |
62 LimitState limit_state_; | 67 void UpdateNotification(); |
68 void UpdateTrayBubbleView(); | |
69 | |
63 base::TimeTicks session_start_time_; | 70 base::TimeTicks session_start_time_; |
64 base::TimeDelta limit_; | 71 base::TimeDelta limit_; |
65 base::TimeDelta remaining_session_time_; | 72 base::TimeDelta remaining_session_time_; |
73 | |
74 LimitState limit_state_; | |
75 LimitState last_limit_state_; | |
76 base::string16 notification_message_; | |
77 base::string16 last_notification_message_; | |
78 base::string16 tray_bubble_message_; | |
79 base::string16 last_tray_bubble_message_; | |
80 LabelTrayView* tray_bubble_view_; | |
81 | |
66 scoped_ptr<base::RepeatingTimer<TraySessionLengthLimit> > timer_; | 82 scoped_ptr<base::RepeatingTimer<TraySessionLengthLimit> > timer_; |
67 | 83 |
68 DISALLOW_COPY_AND_ASSIGN(TraySessionLengthLimit); | 84 DISALLOW_COPY_AND_ASSIGN(TraySessionLengthLimit); |
69 }; | 85 }; |
70 | 86 |
71 } // namespace ash | 87 } // namespace ash |
72 | 88 |
73 #endif // ASH_SYSTEM_CHROMEOS_SESSION_SESSION_LENGTH_LIMIT_H_ | 89 #endif // ASH_SYSTEM_CHROMEOS_SESSION_SESSION_LENGTH_LIMIT_H_ |
OLD | NEW |