Chromium Code Reviews| Index: ash/system/session/tray_session_length_limit.cc |
| diff --git a/ash/system/session/tray_session_length_limit.cc b/ash/system/session/tray_session_length_limit.cc |
| index 66ed5079e2232fd2e197b4d8a2885eefef5ea895..185a9ddf54b837e23a2e799afbace65a91686b53 100644 |
| --- a/ash/system/session/tray_session_length_limit.cc |
| +++ b/ash/system/session/tray_session_length_limit.cc |
| @@ -9,12 +9,12 @@ |
| #include <utility> |
| #include "ash/resources/vector_icons/vector_icons.h" |
| +#include "ash/session/session_controller.h" |
| #include "ash/shell.h" |
| #include "ash/strings/grit/ash_strings.h" |
| #include "ash/system/system_notifier.h" |
| #include "ash/system/tray/label_tray_view.h" |
| #include "ash/system/tray/system_tray.h" |
| -#include "ash/system/tray/system_tray_delegate.h" |
| #include "ash/system/tray/system_tray_notifier.h" |
| #include "ash/system/tray/tray_constants.h" |
| #include "base/logging.h" |
| @@ -49,12 +49,12 @@ TraySessionLengthLimit::TraySessionLengthLimit(SystemTray* system_tray) |
| limit_state_(LIMIT_NONE), |
| last_limit_state_(LIMIT_NONE), |
| tray_bubble_view_(nullptr) { |
| - Shell::Get()->system_tray_notifier()->AddSessionLengthLimitObserver(this); |
| + Shell::Get()->session_controller()->AddObserver(this); |
| Update(); |
| } |
| TraySessionLengthLimit::~TraySessionLengthLimit() { |
| - Shell::Get()->system_tray_notifier()->RemoveSessionLengthLimitObserver(this); |
| + Shell::Get()->session_controller()->RemoveObserver(this); |
| } |
| // Add view to tray bubble. |
| @@ -73,10 +73,6 @@ void TraySessionLengthLimit::OnDefaultViewDestroyed() { |
| tray_bubble_view_ = nullptr; |
| } |
| -void TraySessionLengthLimit::OnSessionStartTimeChanged() { |
| - Update(); |
| -} |
| - |
| void TraySessionLengthLimit::OnSessionLengthLimitChanged() { |
| Update(); |
| } |
| @@ -88,13 +84,14 @@ void TraySessionLengthLimit::Update() { |
| } |
| void TraySessionLengthLimit::UpdateState() { |
| - SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); |
| - if (delegate->GetSessionStartTime(&session_start_time_) && |
| - delegate->GetSessionLengthLimit(&time_limit_)) { |
|
James Cook
2017/06/05 23:23:48
As far as I can tell there was never a need for th
msw
2017/06/06 19:01:04
Acknowledged.
|
| + SessionController* session = Shell::Get()->session_controller(); |
| + base::TimeDelta time_limit = session->session_length_limit(); |
| + base::TimeTicks session_start_time = session->session_start_time(); |
| + if (!time_limit.is_zero() && !session_start_time.is_null()) { |
| const base::TimeDelta expiring_soon_threshold( |
| base::TimeDelta::FromMinutes(kExpiringSoonThresholdInMinutes)); |
| remaining_session_time_ = |
| - std::max(time_limit_ - (base::TimeTicks::Now() - session_start_time_), |
| + std::max(time_limit - (base::TimeTicks::Now() - session_start_time), |
| base::TimeDelta()); |
| limit_state_ = remaining_session_time_ <= expiring_soon_threshold |
| ? LIMIT_EXPIRING_SOON |
| @@ -156,11 +153,12 @@ void TraySessionLengthLimit::UpdateNotification() { |
| system_notifier::kNotifierSessionLengthTimeout), |
| data, nullptr /* delegate */)); |
| notification->SetSystemPriority(); |
| - if (message_center->FindVisibleNotificationById(kNotificationId)) |
| + if (message_center->FindVisibleNotificationById(kNotificationId)) { |
| message_center->UpdateNotification(kNotificationId, |
| std::move(notification)); |
| - else |
| + } else { |
| message_center->AddNotification(std::move(notification)); |
| + } |
| last_limit_state_ = limit_state_; |
| } |