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

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

Issue 2761063002: Move more from WmShell to Shell (Closed)
Patch Set: merge 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
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/common/system/chromeos/session/tray_session_length_limit.h" 5 #include "ash/common/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/system_notifier.h" 11 #include "ash/common/system/system_notifier.h"
12 #include "ash/common/system/tray/label_tray_view.h" 12 #include "ash/common/system/tray/label_tray_view.h"
13 #include "ash/common/system/tray/system_tray.h" 13 #include "ash/common/system/tray/system_tray.h"
14 #include "ash/common/system/tray/system_tray_delegate.h" 14 #include "ash/common/system/tray/system_tray_delegate.h"
15 #include "ash/common/system/tray/system_tray_notifier.h" 15 #include "ash/common/system/tray/system_tray_notifier.h"
16 #include "ash/common/wm_shell.h" 16 #include "ash/common/wm_shell.h"
17 #include "ash/resources/grit/ash_resources.h" 17 #include "ash/resources/grit/ash_resources.h"
18 #include "ash/shell.h"
18 #include "ash/strings/grit/ash_strings.h" 19 #include "ash/strings/grit/ash_strings.h"
19 #include "base/logging.h" 20 #include "base/logging.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
21 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/base/l10n/time_format.h" 23 #include "ui/base/l10n/time_format.h"
23 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
24 #include "ui/message_center/message_center.h" 25 #include "ui/message_center/message_center.h"
25 #include "ui/message_center/notification.h" 26 #include "ui/message_center/notification.h"
26 #include "ui/views/view.h" 27 #include "ui/views/view.h"
27 28
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 Update(); 84 Update();
84 } 85 }
85 86
86 void TraySessionLengthLimit::Update() { 87 void TraySessionLengthLimit::Update() {
87 UpdateState(); 88 UpdateState();
88 UpdateNotification(); 89 UpdateNotification();
89 UpdateTrayBubbleView(); 90 UpdateTrayBubbleView();
90 } 91 }
91 92
92 void TraySessionLengthLimit::UpdateState() { 93 void TraySessionLengthLimit::UpdateState() {
93 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); 94 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate();
94 if (delegate->GetSessionStartTime(&session_start_time_) && 95 if (delegate->GetSessionStartTime(&session_start_time_) &&
95 delegate->GetSessionLengthLimit(&time_limit_)) { 96 delegate->GetSessionLengthLimit(&time_limit_)) {
96 const base::TimeDelta expiring_soon_threshold( 97 const base::TimeDelta expiring_soon_threshold(
97 base::TimeDelta::FromMinutes(kExpiringSoonThresholdInMinutes)); 98 base::TimeDelta::FromMinutes(kExpiringSoonThresholdInMinutes));
98 remaining_session_time_ = 99 remaining_session_time_ =
99 std::max(time_limit_ - (base::TimeTicks::Now() - session_start_time_), 100 std::max(time_limit_ - (base::TimeTicks::Now() - session_start_time_),
100 base::TimeDelta()); 101 base::TimeDelta());
101 limit_state_ = remaining_session_time_ <= expiring_soon_threshold 102 limit_state_ = remaining_session_time_ <= expiring_soon_threshold
102 ? LIMIT_EXPIRING_SOON 103 ? LIMIT_EXPIRING_SOON
103 : LIMIT_SET; 104 : LIMIT_SET;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 188
188 base::string16 TraySessionLengthLimit::ComposeTrayBubbleMessage() const { 189 base::string16 TraySessionLengthLimit::ComposeTrayBubbleMessage() const {
189 return l10n_util::GetStringFUTF16( 190 return l10n_util::GetStringFUTF16(
190 IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT, 191 IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT,
191 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION, 192 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION,
192 ui::TimeFormat::LENGTH_LONG, 10, 193 ui::TimeFormat::LENGTH_LONG, 10,
193 remaining_session_time_)); 194 remaining_session_time_));
194 } 195 }
195 196
196 } // namespace ash 197 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698