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

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

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_SESSION_TRAY_SESSION_LENGTH_LIMIT_H_
6 #define ASH_COMMON_SYSTEM_CHROMEOS_SESSION_TRAY_SESSION_LENGTH_LIMIT_H_
7
8 #include <memory>
9
10 #include "ash/common/system/chromeos/session/session_length_limit_observer.h"
11 #include "ash/common/system/tray/system_tray_item.h"
12 #include "base/macros.h"
13 #include "base/strings/string16.h"
14 #include "base/time/time.h"
15 #include "base/timer/timer.h"
16
17 namespace ash {
18 namespace test {
19 class TraySessionLengthLimitTest;
20 }
21
22 class LabelTrayView;
23
24 // Adds a countdown timer to the system tray if the session length is limited.
25 class ASH_EXPORT TraySessionLengthLimit : public SystemTrayItem,
26 public SessionLengthLimitObserver {
27 public:
28 enum LimitState { LIMIT_NONE, LIMIT_SET, LIMIT_EXPIRING_SOON };
29
30 explicit TraySessionLengthLimit(SystemTray* system_tray);
31 ~TraySessionLengthLimit() override;
32
33 // SystemTrayItem:
34 views::View* CreateDefaultView(LoginStatus status) override;
35 void DestroyDefaultView() override;
36
37 // SessionLengthLimitObserver:
38 void OnSessionStartTimeChanged() override;
39 void OnSessionLengthLimitChanged() override;
40
41 private:
42 friend class test::TraySessionLengthLimitTest;
43
44 static const char kNotificationId[];
45
46 // Update state, notification and tray bubble view. Called by the
47 // RepeatingTimer in regular intervals and also by OnSession*Changed().
48 void Update();
49
50 // Recalculate |limit_state_| and |remaining_session_time_|.
51 void UpdateState();
52
53 void UpdateNotification();
54 void UpdateTrayBubbleView() const;
55
56 // These require that the state has been updated before.
57 base::string16 ComposeNotificationMessage() const;
58 base::string16 ComposeTrayBubbleMessage() const;
59
60 base::TimeTicks session_start_time_;
61 base::TimeDelta time_limit_;
62 base::TimeDelta remaining_session_time_;
63
64 LimitState limit_state_; // Current state.
65 LimitState last_limit_state_; // State of last notification update.
66
67 LabelTrayView* tray_bubble_view_;
68 std::unique_ptr<base::RepeatingTimer> timer_;
69
70 DISALLOW_COPY_AND_ASSIGN(TraySessionLengthLimit);
71 };
72
73 } // namespace ash
74
75 #endif // ASH_COMMON_SYSTEM_CHROMEOS_SESSION_TRAY_SESSION_LENGTH_LIMIT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698