Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Side by Side Diff: ash/system/chromeos/session/tray_session_length_limit.h

Issue 262973004: Move session length timer into tray bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes and improvements, mostly suggested by Bartosz. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
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
48 LimitState GetLimitState() const; 47 // ViewClickListener:
49 base::TimeDelta GetRemainingSessionTime() const; 48 virtual void OnViewClicked(views::View* sender) OVERRIDE;
50 49
51 private: 50 private:
52 friend class test::TraySessionLengthLimitTest; 51 friend class test::TraySessionLengthLimitTest;
53 52
54 static const char kNotificationId[]; 53 static const char kNotificationId[];
55 54
55 // Update state, notifications and tray bubble view. Called by the Timer in
bartfab (slow) 2014/05/05 17:49:58 Nit: s/notifications/notification/
Thiemo Nagel 2014/05/06 14:28:00 Done.
56 // regular intervals and also by OnSession*Changed().
56 void Update(); 57 void Update();
57 58
58 bool IsTrayViewVisibleForTest(); 59 // Recalculate |limit_state_| and the message strings.
60 void UpdateState();
59 61
60 tray::RemainingSessionTimeTrayView* tray_view_; 62 void UpdateNotification();
63 void UpdateTrayBubbleView();
61 64
62 LimitState limit_state_;
63 base::TimeTicks session_start_time_; 65 base::TimeTicks session_start_time_;
64 base::TimeDelta limit_; 66 base::TimeDelta limit_;
65 base::TimeDelta remaining_session_time_; 67 base::TimeDelta remaining_session_time_;
68
69 LimitState limit_state_;
70 LimitState last_limit_state_;
71 base::string16 notification_message_;
72 base::string16 last_notification_message_;
73 base::string16 tray_bubble_message_;
74 base::string16 last_tray_bubble_message_;
75 LabelTrayView* tray_bubble_view_;
76
66 scoped_ptr<base::RepeatingTimer<TraySessionLengthLimit> > timer_; 77 scoped_ptr<base::RepeatingTimer<TraySessionLengthLimit> > timer_;
67 78
68 DISALLOW_COPY_AND_ASSIGN(TraySessionLengthLimit); 79 DISALLOW_COPY_AND_ASSIGN(TraySessionLengthLimit);
69 }; 80 };
70 81
71 } // namespace ash 82 } // namespace ash
72 83
73 #endif // ASH_SYSTEM_CHROMEOS_SESSION_SESSION_LENGTH_LIMIT_H_ 84 #endif // ASH_SYSTEM_CHROMEOS_SESSION_SESSION_LENGTH_LIMIT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698