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

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

Issue 2776973005: Revert of Remove some pre-md code and assets. (Closed)
Patch Set: 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/system/tray/tray_constants.h"
17 #include "ash/resources/grit/ash_resources.h" 16 #include "ash/resources/grit/ash_resources.h"
18 #include "ash/resources/vector_icons/vector_icons.h"
19 #include "ash/shell.h" 17 #include "ash/shell.h"
20 #include "ash/strings/grit/ash_strings.h" 18 #include "ash/strings/grit/ash_strings.h"
21 #include "base/logging.h" 19 #include "base/logging.h"
22 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
23 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/l10n/time_format.h" 22 #include "ui/base/l10n/time_format.h"
25 #include "ui/gfx/paint_vector_icon.h" 23 #include "ui/base/resource/resource_bundle.h"
26 #include "ui/message_center/message_center.h" 24 #include "ui/message_center/message_center.h"
27 #include "ui/message_center/notification.h" 25 #include "ui/message_center/notification.h"
28 #include "ui/views/view.h" 26 #include "ui/views/view.h"
29 27
30 namespace ash { 28 namespace ash {
31 namespace { 29 namespace {
32 30
33 // If the remaining session time falls below this threshold, the user should be 31 // If the remaining session time falls below this threshold, the user should be
34 // informed that the session is about to expire. 32 // informed that the session is about to expire.
35 const int kExpiringSoonThresholdInMinutes = 5; 33 const int kExpiringSoonThresholdInMinutes = 5;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 message_center::MessageCenter::Get()->RemoveNotification( 134 message_center::MessageCenter::Get()->RemoveNotification(
137 kNotificationId, false /* by_user */); 135 kNotificationId, false /* by_user */);
138 } 136 }
139 137
140 // For LIMIT_NONE, there's nothing more to do. 138 // For LIMIT_NONE, there's nothing more to do.
141 if (limit_state_ == LIMIT_NONE) { 139 if (limit_state_ == LIMIT_NONE) {
142 last_limit_state_ = limit_state_; 140 last_limit_state_ = limit_state_;
143 return; 141 return;
144 } 142 }
145 143
144 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
146 message_center::RichNotificationData data; 145 message_center::RichNotificationData data;
147 data.should_make_spoken_feedback_for_popup_updates = 146 data.should_make_spoken_feedback_for_popup_updates =
148 (limit_state_ != last_limit_state_); 147 (limit_state_ != last_limit_state_);
149 std::unique_ptr<message_center::Notification> notification( 148 std::unique_ptr<message_center::Notification> notification(
150 new message_center::Notification( 149 new message_center::Notification(
151 message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId, 150 message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId,
152 base::string16() /* title */, 151 base::string16() /* title */,
153 ComposeNotificationMessage() /* message */, 152 ComposeNotificationMessage() /* message */,
154 gfx::Image( 153 bundle.GetImageNamed(
155 gfx::CreateVectorIcon(kSystemMenuTimerIcon, kMenuIconColor)), 154 IDR_AURA_UBER_TRAY_NOTIFICATION_SESSION_LENGTH_LIMIT),
156 base::string16() /* display_source */, GURL(), 155 base::string16() /* display_source */, GURL(),
157 message_center::NotifierId( 156 message_center::NotifierId(
158 message_center::NotifierId::SYSTEM_COMPONENT, 157 message_center::NotifierId::SYSTEM_COMPONENT,
159 system_notifier::kNotifierSessionLengthTimeout), 158 system_notifier::kNotifierSessionLengthTimeout),
160 data, NULL /* delegate */)); 159 data, NULL /* delegate */));
161 notification->SetSystemPriority(); 160 notification->SetSystemPriority();
162 if (message_center->FindVisibleNotificationById(kNotificationId)) 161 if (message_center->FindVisibleNotificationById(kNotificationId))
163 message_center->UpdateNotification(kNotificationId, 162 message_center->UpdateNotification(kNotificationId,
164 std::move(notification)); 163 std::move(notification));
165 else 164 else
(...skipping 21 matching lines...) Expand all
187 186
188 base::string16 TraySessionLengthLimit::ComposeTrayBubbleMessage() const { 187 base::string16 TraySessionLengthLimit::ComposeTrayBubbleMessage() const {
189 return l10n_util::GetStringFUTF16( 188 return l10n_util::GetStringFUTF16(
190 IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT, 189 IDS_ASH_STATUS_TRAY_BUBBLE_SESSION_LENGTH_LIMIT,
191 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION, 190 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION,
192 ui::TimeFormat::LENGTH_LONG, 10, 191 ui::TimeFormat::LENGTH_LONG, 10,
193 remaining_session_time_)); 192 remaining_session_time_));
194 } 193 }
195 194
196 } // namespace ash 195 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/power/power_status_unittest.cc ('k') | ash/common/system/chromeos/settings/tray_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698