| 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/display/display_util.h" | 5 #include "ash/display/display_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/common/new_window_controller.h" | 10 #include "ash/common/new_window_controller.h" |
| 11 #include "ash/common/system/system_notifier.h" | 11 #include "ash/common/system/system_notifier.h" |
| 12 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
| 13 #include "ash/display/extended_mouse_warp_controller.h" | 13 #include "ash/display/extended_mouse_warp_controller.h" |
| 14 #include "ash/display/null_mouse_warp_controller.h" | 14 #include "ash/display/null_mouse_warp_controller.h" |
| 15 #include "ash/display/unified_mouse_warp_controller.h" | 15 #include "ash/display/unified_mouse_warp_controller.h" |
| 16 #include "ash/host/ash_window_tree_host.h" | 16 #include "ash/host/ash_window_tree_host.h" |
| 17 #include "ash/resources/vector_icons/vector_icons.h" | |
| 18 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| 19 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
| 20 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/sys_info.h" | |
| 23 #include "grit/ash_strings.h" | 21 #include "grit/ash_strings.h" |
| 24 #include "ui/aura/env.h" | 22 #include "ui/aura/env.h" |
| 25 #include "ui/aura/window_tree_host.h" | 23 #include "ui/aura/window_tree_host.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/display/display.h" | 25 #include "ui/display/display.h" |
| 28 #include "ui/display/manager/display_manager.h" | 26 #include "ui/display/manager/display_manager.h" |
| 29 #include "ui/display/manager/managed_display_info.h" | 27 #include "ui/display/manager/managed_display_info.h" |
| 30 #include "ui/gfx/geometry/point.h" | 28 #include "ui/gfx/geometry/point.h" |
| 31 #include "ui/gfx/geometry/rect.h" | 29 #include "ui/gfx/geometry/rect.h" |
| 32 #include "ui/gfx/geometry/size_conversions.h" | 30 #include "ui/gfx/geometry/size_conversions.h" |
| 33 #include "ui/gfx/paint_vector_icon.h" | |
| 34 #include "ui/message_center/message_center.h" | 31 #include "ui/message_center/message_center.h" |
| 35 #include "ui/message_center/notification.h" | 32 #include "ui/message_center/notification.h" |
| 36 #include "ui/message_center/notification_delegate.h" | 33 #include "ui/message_center/notification_delegate.h" |
| 37 #include "ui/message_center/notification_list.h" | 34 #include "ui/message_center/notification_list.h" |
| 38 #include "ui/wm/core/coordinate_conversion.h" | 35 #include "ui/wm/core/coordinate_conversion.h" |
| 39 | 36 |
| 37 #if defined(OS_CHROMEOS) |
| 38 #include "ash/resources/vector_icons/vector_icons.h" |
| 39 #include "base/sys_info.h" |
| 40 #include "ui/gfx/paint_vector_icon.h" |
| 41 #endif |
| 42 |
| 40 namespace ash { | 43 namespace ash { |
| 41 namespace { | 44 namespace { |
| 42 | 45 |
| 43 const char kDisplayErrorNotificationId[] = "chrome://settings/display/error"; | 46 const char kDisplayErrorNotificationId[] = "chrome://settings/display/error"; |
| 44 | 47 |
| 48 #if defined(OS_CHROMEOS) |
| 45 // TODO(glevin): These are for new MD vector icons, but are using pre-MD color | 49 // TODO(glevin): These are for new MD vector icons, but are using pre-MD color |
| 46 // scheme. When we switch to all MD icons for notifications, these should be | 50 // scheme. When we switch to all MD icons for notifications, these should be |
| 47 // updated to use MD color scheme. | 51 // updated to use MD color scheme. |
| 48 const SkColor kDisplayIconColor = SkColorSetRGB(0xBD, 0xBD, 0xBD); | 52 const SkColor kDisplayIconColor = SkColorSetRGB(0xBD, 0xBD, 0xBD); |
| 49 const SkColor kFeedbackIconColor = SkColorSetRGB(0x96, 0x96, 0x98); | 53 const SkColor kFeedbackIconColor = SkColorSetRGB(0x96, 0x96, 0x98); |
| 54 #endif |
| 50 | 55 |
| 51 // A notification delegate that will start the feedback app when the notication | 56 // A notification delegate that will start the feedback app when the notication |
| 52 // is clicked. | 57 // is clicked. |
| 53 class DisplayErrorNotificationDelegate | 58 class DisplayErrorNotificationDelegate |
| 54 : public message_center::NotificationDelegate { | 59 : public message_center::NotificationDelegate { |
| 55 public: | 60 public: |
| 56 DisplayErrorNotificationDelegate() = default; | 61 DisplayErrorNotificationDelegate() = default; |
| 57 | 62 |
| 58 // message_center::NotificationDelegate: | 63 // message_center::NotificationDelegate: |
| 59 void ButtonClick(int index) override { | 64 void ButtonClick(int index) override { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } else { | 165 } else { |
| 161 new_point_in_screen = point_in_native; | 166 new_point_in_screen = point_in_native; |
| 162 host->ConvertScreenInPixelsToDIP(&new_point_in_screen); | 167 host->ConvertScreenInPixelsToDIP(&new_point_in_screen); |
| 163 ::wm::ConvertPointToScreen(host->window(), &new_point_in_screen); | 168 ::wm::ConvertPointToScreen(host->window(), &new_point_in_screen); |
| 164 } | 169 } |
| 165 aura::Env::GetInstance()->set_last_mouse_location(new_point_in_screen); | 170 aura::Env::GetInstance()->set_last_mouse_location(new_point_in_screen); |
| 166 } | 171 } |
| 167 } | 172 } |
| 168 | 173 |
| 169 | 174 |
| 175 #if defined(OS_CHROMEOS) |
| 170 void ShowDisplayErrorNotification(const base::string16& message, | 176 void ShowDisplayErrorNotification(const base::string16& message, |
| 171 bool allow_feedback) { | 177 bool allow_feedback) { |
| 172 // Always remove the notification to make sure the notification appears | 178 // Always remove the notification to make sure the notification appears |
| 173 // as a popup in any situation. | 179 // as a popup in any situation. |
| 174 message_center::MessageCenter::Get()->RemoveNotification( | 180 message_center::MessageCenter::Get()->RemoveNotification( |
| 175 kDisplayErrorNotificationId, false /* by_user */); | 181 kDisplayErrorNotificationId, false /* by_user */); |
| 176 | 182 |
| 177 message_center::RichNotificationData data; | 183 message_center::RichNotificationData data; |
| 178 if (allow_feedback) { | 184 if (allow_feedback) { |
| 179 message_center::ButtonInfo send_button( | 185 message_center::ButtonInfo send_button( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 190 message, gfx::Image(CreateVectorIcon(kNotificationDisplayErrorIcon, | 196 message, gfx::Image(CreateVectorIcon(kNotificationDisplayErrorIcon, |
| 191 kDisplayIconColor)), | 197 kDisplayIconColor)), |
| 192 base::string16(), // display_source | 198 base::string16(), // display_source |
| 193 GURL(), message_center::NotifierId( | 199 GURL(), message_center::NotifierId( |
| 194 message_center::NotifierId::SYSTEM_COMPONENT, | 200 message_center::NotifierId::SYSTEM_COMPONENT, |
| 195 system_notifier::kNotifierDisplayError), | 201 system_notifier::kNotifierDisplayError), |
| 196 data, new DisplayErrorNotificationDelegate)); | 202 data, new DisplayErrorNotificationDelegate)); |
| 197 message_center::MessageCenter::Get()->AddNotification( | 203 message_center::MessageCenter::Get()->AddNotification( |
| 198 std::move(notification)); | 204 std::move(notification)); |
| 199 } | 205 } |
| 206 #endif |
| 200 | 207 |
| 201 base::string16 GetDisplayErrorNotificationMessageForTest() { | 208 base::string16 GetDisplayErrorNotificationMessageForTest() { |
| 202 message_center::NotificationList::Notifications notifications = | 209 message_center::NotificationList::Notifications notifications = |
| 203 message_center::MessageCenter::Get()->GetVisibleNotifications(); | 210 message_center::MessageCenter::Get()->GetVisibleNotifications(); |
| 204 for (auto* const notification : notifications) { | 211 for (auto* const notification : notifications) { |
| 205 if (notification->id() == kDisplayErrorNotificationId) | 212 if (notification->id() == kDisplayErrorNotificationId) |
| 206 return notification->message(); | 213 return notification->message(); |
| 207 } | 214 } |
| 208 return base::string16(); | 215 return base::string16(); |
| 209 } | 216 } |
| 210 | 217 |
| 211 } // namespace ash | 218 } // namespace ash |
| OLD | NEW |