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

Unified 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: Reduce memory footprint and address Bartosz' other comments. 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 side-by-side diff with in-line comments
Download patch
Index: ash/system/chromeos/session/tray_session_length_limit.h
diff --git a/ash/system/chromeos/session/tray_session_length_limit.h b/ash/system/chromeos/session/tray_session_length_limit.h
index 1c9da1713659256d007e540081e98424c79af473..b89a92fb169db0fd75683a319ecde6bf133f2212 100644
--- a/ash/system/chromeos/session/tray_session_length_limit.h
+++ b/ash/system/chromeos/session/tray_session_length_limit.h
@@ -7,9 +7,11 @@
#include "ash/system/chromeos/session/session_length_limit_observer.h"
#include "ash/system/tray/system_tray_item.h"
+#include "ash/system/tray/view_click_listener.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "base/strings/string16.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
@@ -18,14 +20,13 @@ namespace test {
class TraySessionLengthLimitTest;
}
-namespace tray {
-class RemainingSessionTimeTrayView;
-}
+class LabelTrayView;
// Adds a countdown timer to the system tray if the session length is limited.
class ASH_EXPORT TraySessionLengthLimit : public SystemTrayItem,
- public SessionLengthLimitObserver {
- public:
+ public SessionLengthLimitObserver,
+ public ViewClickListener {
+public:
enum LimitState {
LIMIT_NONE,
LIMIT_SET,
@@ -36,33 +37,43 @@ class ASH_EXPORT TraySessionLengthLimit : public SystemTrayItem,
virtual ~TraySessionLengthLimit();
// SystemTrayItem:
- virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE;
- virtual void DestroyTrayView() OVERRIDE;
- virtual void UpdateAfterShelfAlignmentChange(
- ShelfAlignment alignment) OVERRIDE;
+ virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE;
+ virtual void DestroyDefaultView() OVERRIDE;
// SessionLengthLimitObserver:
virtual void OnSessionStartTimeChanged() OVERRIDE;
virtual void OnSessionLengthLimitChanged() OVERRIDE;
- LimitState GetLimitState() const;
- base::TimeDelta GetRemainingSessionTime() const;
+ // ViewClickListener:
+ virtual void OnViewClicked(views::View* sender) OVERRIDE;
private:
friend class test::TraySessionLengthLimitTest;
static const char kNotificationId[];
+ // Update state, notification and tray bubble view. Called by the Timer in
bartfab (slow) 2014/05/06 17:57:00 Nit: Why is Timer capitalized? It sounds like a re
Thiemo Nagel 2014/05/06 18:49:06 Thanks, you're right. I'm using a RepeatingTimer.
+ // regular intervals and also by OnSession*Changed().
void Update();
- bool IsTrayViewVisibleForTest();
+ // Recalculate |limit_state_| and |remaining_session_time_|.
+ void UpdateState();
+
+ void UpdateNotification();
+ void UpdateTrayBubbleView() const;
- tray::RemainingSessionTimeTrayView* tray_view_;
+ // These require that the state has been updated before.
+ base::string16 ComposeNotificationMessage() const;
+ base::string16 ComposeTrayBubbleMessage() const;
- LimitState limit_state_;
base::TimeTicks session_start_time_;
- base::TimeDelta limit_;
+ base::TimeDelta time_limit_;
base::TimeDelta remaining_session_time_;
+
+ LimitState limit_state_; // Current state.
bartfab (slow) 2014/05/06 17:57:00 Nit: Style guide says: Two spaces before //, do no
Thiemo Nagel 2014/05/06 18:49:06 Where does it say that? There is ample evidence o
bartfab (slow) 2014/05/07 12:30:53 I think you are right. I read the JavaScript style
+ LimitState last_limit_state_; // State of last notification update.
+
+ LabelTrayView* tray_bubble_view_;
scoped_ptr<base::RepeatingTimer<TraySessionLengthLimit> > timer_;
DISALLOW_COPY_AND_ASSIGN(TraySessionLengthLimit);

Powered by Google App Engine
This is Rietveld 408576698