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