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