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

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

Issue 2715463004: Remove non-MD code from LabelTrayView (Closed)
Patch Set: estade comments Created 3 years, 8 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
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } // namespace 42 } // namespace
43 43
44 // static 44 // static
45 const char TraySessionLengthLimit::kNotificationId[] = 45 const char TraySessionLengthLimit::kNotificationId[] =
46 "chrome://session/timeout"; 46 "chrome://session/timeout";
47 47
48 TraySessionLengthLimit::TraySessionLengthLimit(SystemTray* system_tray) 48 TraySessionLengthLimit::TraySessionLengthLimit(SystemTray* system_tray)
49 : SystemTrayItem(system_tray, UMA_SESSION_LENGTH_LIMIT), 49 : SystemTrayItem(system_tray, UMA_SESSION_LENGTH_LIMIT),
50 limit_state_(LIMIT_NONE), 50 limit_state_(LIMIT_NONE),
51 last_limit_state_(LIMIT_NONE), 51 last_limit_state_(LIMIT_NONE),
52 tray_bubble_view_(NULL) { 52 tray_bubble_view_(nullptr) {
53 Shell::Get()->system_tray_notifier()->AddSessionLengthLimitObserver(this); 53 Shell::Get()->system_tray_notifier()->AddSessionLengthLimitObserver(this);
54 Update(); 54 Update();
55 } 55 }
56 56
57 TraySessionLengthLimit::~TraySessionLengthLimit() { 57 TraySessionLengthLimit::~TraySessionLengthLimit() {
58 Shell::Get()->system_tray_notifier()->RemoveSessionLengthLimitObserver(this); 58 Shell::Get()->system_tray_notifier()->RemoveSessionLengthLimitObserver(this);
59 } 59 }
60 60
61 // Add view to tray bubble. 61 // Add view to tray bubble.
62 views::View* TraySessionLengthLimit::CreateDefaultView(LoginStatus status) { 62 views::View* TraySessionLengthLimit::CreateDefaultView(LoginStatus status) {
63 CHECK(!tray_bubble_view_); 63 CHECK(!tray_bubble_view_);
64 UpdateState(); 64 UpdateState();
65 if (limit_state_ == LIMIT_NONE) 65 if (limit_state_ == LIMIT_NONE)
66 return NULL; 66 return nullptr;
67 tray_bubble_view_ = 67 tray_bubble_view_ = new LabelTrayView(nullptr, kSystemMenuTimerIcon);
68 new LabelTrayView(NULL /* click_listener */,
69 IDR_AURA_UBER_TRAY_BUBBLE_SESSION_LENGTH_LIMIT);
70 tray_bubble_view_->SetMessage(ComposeTrayBubbleMessage()); 68 tray_bubble_view_->SetMessage(ComposeTrayBubbleMessage());
71 return tray_bubble_view_; 69 return tray_bubble_view_;
72 } 70 }
73 71
74 // View has been removed from tray bubble. 72 // View has been removed from tray bubble.
75 void TraySessionLengthLimit::DestroyDefaultView() { 73 void TraySessionLengthLimit::DestroyDefaultView() {
76 tray_bubble_view_ = NULL; 74 tray_bubble_view_ = nullptr;
77 } 75 }
78 76
79 void TraySessionLengthLimit::OnSessionStartTimeChanged() { 77 void TraySessionLengthLimit::OnSessionStartTimeChanged() {
80 Update(); 78 Update();
81 } 79 }
82 80
83 void TraySessionLengthLimit::OnSessionLengthLimitChanged() { 81 void TraySessionLengthLimit::OnSessionLengthLimitChanged() {
84 Update(); 82 Update();
85 } 83 }
86 84
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 new message_center::Notification( 148 new message_center::Notification(
151 message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId, 149 message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId,
152 base::string16() /* title */, 150 base::string16() /* title */,
153 ComposeNotificationMessage() /* message */, 151 ComposeNotificationMessage() /* message */,
154 gfx::Image( 152 gfx::Image(
155 gfx::CreateVectorIcon(kSystemMenuTimerIcon, kMenuIconColor)), 153 gfx::CreateVectorIcon(kSystemMenuTimerIcon, kMenuIconColor)),
156 base::string16() /* display_source */, GURL(), 154 base::string16() /* display_source */, GURL(),
157 message_center::NotifierId( 155 message_center::NotifierId(
158 message_center::NotifierId::SYSTEM_COMPONENT, 156 message_center::NotifierId::SYSTEM_COMPONENT,
159 system_notifier::kNotifierSessionLengthTimeout), 157 system_notifier::kNotifierSessionLengthTimeout),
160 data, NULL /* delegate */)); 158 data, nullptr /* delegate */));
161 notification->SetSystemPriority(); 159 notification->SetSystemPriority();
162 if (message_center->FindVisibleNotificationById(kNotificationId)) 160 if (message_center->FindVisibleNotificationById(kNotificationId))
163 message_center->UpdateNotification(kNotificationId, 161 message_center->UpdateNotification(kNotificationId,
164 std::move(notification)); 162 std::move(notification));
165 else 163 else
166 message_center->AddNotification(std::move(notification)); 164 message_center->AddNotification(std::move(notification));
167 last_limit_state_ = limit_state_; 165 last_limit_state_ = limit_state_;
168 } 166 }
169 167
170 void TraySessionLengthLimit::UpdateTrayBubbleView() const { 168 void TraySessionLengthLimit::UpdateTrayBubbleView() const {
(...skipping 16 matching lines...) Expand all
187 185
188 base::string16 TraySessionLengthLimit::ComposeTrayBubbleMessage() const { 186 base::string16 TraySessionLengthLimit::ComposeTrayBubbleMessage() const {
189 return l10n_util::GetStringFUTF16( 187 return l10n_util::GetStringFUTF16(
190 IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT, 188 IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT,
191 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION, 189 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION,
192 ui::TimeFormat::LENGTH_LONG, 10, 190 ui::TimeFormat::LENGTH_LONG, 10,
193 remaining_session_time_)); 191 remaining_session_time_));
194 } 192 }
195 193
196 } // namespace ash 194 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/enterprise/tray_enterprise.cc ('k') | ash/common/system/chromeos/supervised/tray_supervised_user.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698