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 #include "ash/system/chromeos/session/tray_session_length_limit.h" | 5 #include "ash/system/chromeos/session/tray_session_length_limit.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/system/chromeos/label_tray_view.h" | 10 #include "ash/system/chromeos/label_tray_view.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 if (delegate->GetSessionStartTime(&session_start_time_) && | 94 if (delegate->GetSessionStartTime(&session_start_time_) && |
95 delegate->GetSessionLengthLimit(&time_limit_)) { | 95 delegate->GetSessionLengthLimit(&time_limit_)) { |
96 const base::TimeDelta expiring_soon_threshold( | 96 const base::TimeDelta expiring_soon_threshold( |
97 base::TimeDelta::FromMinutes(kExpiringSoonThresholdInMinutes)); | 97 base::TimeDelta::FromMinutes(kExpiringSoonThresholdInMinutes)); |
98 remaining_session_time_ = std::max( | 98 remaining_session_time_ = std::max( |
99 time_limit_ - (base::TimeTicks::Now() - session_start_time_), | 99 time_limit_ - (base::TimeTicks::Now() - session_start_time_), |
100 base::TimeDelta()); | 100 base::TimeDelta()); |
101 limit_state_ = remaining_session_time_ <= expiring_soon_threshold ? | 101 limit_state_ = remaining_session_time_ <= expiring_soon_threshold ? |
102 LIMIT_EXPIRING_SOON : LIMIT_SET; | 102 LIMIT_EXPIRING_SOON : LIMIT_SET; |
103 if (!timer_) | 103 if (!timer_) |
104 timer_.reset(new base::RepeatingTimer<TraySessionLengthLimit>); | 104 timer_.reset(new base::RepeatingTimer); |
105 if (!timer_->IsRunning()) { | 105 if (!timer_->IsRunning()) { |
106 timer_->Start(FROM_HERE, | 106 timer_->Start(FROM_HERE, |
107 base::TimeDelta::FromMilliseconds( | 107 base::TimeDelta::FromMilliseconds( |
108 kTimerIntervalInMilliseconds), | 108 kTimerIntervalInMilliseconds), |
109 this, | 109 this, |
110 &TraySessionLengthLimit::Update); | 110 &TraySessionLengthLimit::Update); |
111 } | 111 } |
112 } else { | 112 } else { |
113 remaining_session_time_ = base::TimeDelta(); | 113 remaining_session_time_ = base::TimeDelta(); |
114 limit_state_ = LIMIT_NONE; | 114 limit_state_ = LIMIT_NONE; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 base::string16 TraySessionLengthLimit::ComposeTrayBubbleMessage() const { | 189 base::string16 TraySessionLengthLimit::ComposeTrayBubbleMessage() const { |
190 return l10n_util::GetStringFUTF16( | 190 return l10n_util::GetStringFUTF16( |
191 IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT, | 191 IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT, |
192 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION, | 192 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION, |
193 ui::TimeFormat::LENGTH_LONG, | 193 ui::TimeFormat::LENGTH_LONG, |
194 10, | 194 10, |
195 remaining_session_time_)); | 195 remaining_session_time_)); |
196 } | 196 } |
197 | 197 |
198 } // namespace ash | 198 } // namespace ash |
OLD | NEW |