| 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 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "ash/common/system/tray/system_tray_delegate.h" | 11 #include "ash/common/system/tray/system_tray_delegate.h" |
| 12 #include "ash/common/wm_shell.h" |
| 12 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 13 #include "ash/system/chromeos/label_tray_view.h" | 14 #include "ash/system/chromeos/label_tray_view.h" |
| 14 #include "ash/system/system_notifier.h" | 15 #include "ash/system/system_notifier.h" |
| 15 #include "ash/system/tray/system_tray.h" | 16 #include "ash/system/tray/system_tray.h" |
| 16 #include "ash/system/tray/system_tray_notifier.h" | 17 #include "ash/system/tray/system_tray_notifier.h" |
| 17 #include "base/logging.h" | 18 #include "base/logging.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 19 #include "grit/ash_resources.h" | 20 #include "grit/ash_resources.h" |
| 20 #include "grit/ash_strings.h" | 21 #include "grit/ash_strings.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 Update(); | 85 Update(); |
| 85 } | 86 } |
| 86 | 87 |
| 87 void TraySessionLengthLimit::Update() { | 88 void TraySessionLengthLimit::Update() { |
| 88 UpdateState(); | 89 UpdateState(); |
| 89 UpdateNotification(); | 90 UpdateNotification(); |
| 90 UpdateTrayBubbleView(); | 91 UpdateTrayBubbleView(); |
| 91 } | 92 } |
| 92 | 93 |
| 93 void TraySessionLengthLimit::UpdateState() { | 94 void TraySessionLengthLimit::UpdateState() { |
| 94 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 95 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); |
| 95 if (delegate->GetSessionStartTime(&session_start_time_) && | 96 if (delegate->GetSessionStartTime(&session_start_time_) && |
| 96 delegate->GetSessionLengthLimit(&time_limit_)) { | 97 delegate->GetSessionLengthLimit(&time_limit_)) { |
| 97 const base::TimeDelta expiring_soon_threshold( | 98 const base::TimeDelta expiring_soon_threshold( |
| 98 base::TimeDelta::FromMinutes(kExpiringSoonThresholdInMinutes)); | 99 base::TimeDelta::FromMinutes(kExpiringSoonThresholdInMinutes)); |
| 99 remaining_session_time_ = std::max( | 100 remaining_session_time_ = std::max( |
| 100 time_limit_ - (base::TimeTicks::Now() - session_start_time_), | 101 time_limit_ - (base::TimeTicks::Now() - session_start_time_), |
| 101 base::TimeDelta()); | 102 base::TimeDelta()); |
| 102 limit_state_ = remaining_session_time_ <= expiring_soon_threshold ? | 103 limit_state_ = remaining_session_time_ <= expiring_soon_threshold ? |
| 103 LIMIT_EXPIRING_SOON : LIMIT_SET; | 104 LIMIT_EXPIRING_SOON : LIMIT_SET; |
| 104 if (!timer_) | 105 if (!timer_) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 base::string16 TraySessionLengthLimit::ComposeTrayBubbleMessage() const { | 192 base::string16 TraySessionLengthLimit::ComposeTrayBubbleMessage() const { |
| 192 return l10n_util::GetStringFUTF16( | 193 return l10n_util::GetStringFUTF16( |
| 193 IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT, | 194 IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT, |
| 194 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION, | 195 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION, |
| 195 ui::TimeFormat::LENGTH_LONG, | 196 ui::TimeFormat::LENGTH_LONG, |
| 196 10, | 197 10, |
| 197 remaining_session_time_)); | 198 remaining_session_time_)); |
| 198 } | 199 } |
| 199 | 200 |
| 200 } // namespace ash | 201 } // namespace ash |
| OLD | NEW |