OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/display/display_error_observer_chromeos.h" | 5 #include "ash/display/display_error_observer_chromeos.h" |
6 | 6 |
7 #include <cinttypes> | 7 #include <cinttypes> |
| 8 #include <memory> |
8 #include <utility> | 9 #include <utility> |
9 | 10 |
10 #include "ash/new_window_delegate.h" | 11 #include "ash/new_window_delegate.h" |
11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
12 #include "ash/system/system_notifier.h" | 13 #include "ash/system/system_notifier.h" |
13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
14 #include "grit/ash_resources.h" | 15 #include "grit/ash_resources.h" |
15 #include "grit/ash_strings.h" | 16 #include "grit/ash_strings.h" |
16 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
17 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // Always remove the notification to make sure the notification appears | 71 // Always remove the notification to make sure the notification appears |
71 // as a popup in any situation. | 72 // as a popup in any situation. |
72 message_center::MessageCenter::Get()->RemoveNotification( | 73 message_center::MessageCenter::Get()->RemoveNotification( |
73 kDisplayErrorNotificationId, false /* by_user */); | 74 kDisplayErrorNotificationId, false /* by_user */); |
74 | 75 |
75 int message_id = (new_state == ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) ? | 76 int message_id = (new_state == ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) ? |
76 IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING : | 77 IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING : |
77 IDS_ASH_DISPLAY_FAILURE_ON_NON_MIRRORING; | 78 IDS_ASH_DISPLAY_FAILURE_ON_NON_MIRRORING; |
78 | 79 |
79 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 80 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
80 scoped_ptr<Notification> notification(new Notification( | 81 std::unique_ptr<Notification> notification(new Notification( |
81 message_center::NOTIFICATION_TYPE_SIMPLE, kDisplayErrorNotificationId, | 82 message_center::NOTIFICATION_TYPE_SIMPLE, kDisplayErrorNotificationId, |
82 base::string16(), // title | 83 base::string16(), // title |
83 l10n_util::GetStringUTF16(message_id), | 84 l10n_util::GetStringUTF16(message_id), |
84 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_DISPLAY), | 85 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_DISPLAY), |
85 base::string16(), // display_source | 86 base::string16(), // display_source |
86 GURL(), | 87 GURL(), |
87 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, | 88 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
88 system_notifier::kNotifierDisplayError), | 89 system_notifier::kNotifierDisplayError), |
89 message_center::RichNotificationData(), | 90 message_center::RichNotificationData(), |
90 new DisplayErrorNotificationDelegate)); | 91 new DisplayErrorNotificationDelegate)); |
91 message_center::MessageCenter::Get()->AddNotification( | 92 message_center::MessageCenter::Get()->AddNotification( |
92 std::move(notification)); | 93 std::move(notification)); |
93 } | 94 } |
94 | 95 |
95 base::string16 | 96 base::string16 |
96 DisplayErrorObserver::GetDisplayErrorNotificationMessageForTest() { | 97 DisplayErrorObserver::GetDisplayErrorNotificationMessageForTest() { |
97 message_center::NotificationList::Notifications notifications = | 98 message_center::NotificationList::Notifications notifications = |
98 message_center::MessageCenter::Get()->GetVisibleNotifications(); | 99 message_center::MessageCenter::Get()->GetVisibleNotifications(); |
99 for (message_center::NotificationList::Notifications::const_iterator iter = | 100 for (message_center::NotificationList::Notifications::const_iterator iter = |
100 notifications.begin(); iter != notifications.end(); ++iter) { | 101 notifications.begin(); iter != notifications.end(); ++iter) { |
101 if ((*iter)->id() == kDisplayErrorNotificationId) | 102 if ((*iter)->id() == kDisplayErrorNotificationId) |
102 return (*iter)->message(); | 103 return (*iter)->message(); |
103 } | 104 } |
104 | 105 |
105 return base::string16(); | 106 return base::string16(); |
106 } | 107 } |
107 | 108 |
108 } // namespace ash | 109 } // namespace ash |
OLD | NEW |