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