| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/message_center/views/message_view_factory.h" |
| 6 |
| 7 #include "ui/message_center/notification_types.h" |
| 8 #include "ui/message_center/views/custom_notification_view.h" |
| 9 #include "ui/message_center/views/notification_view.h" |
| 10 |
| 11 #if defined(OS_WIN) |
| 12 #include "ui/base/win/shell.h" |
| 13 #endif |
| 14 |
| 15 namespace message_center { |
| 16 |
| 17 // static |
| 18 MessageView* MessageViewFactory::Create(MessageCenterController* controller, |
| 19 const Notification& notification, |
| 20 bool top_level) { |
| 21 MessageView* notification_view = nullptr; |
| 22 switch (notification.type()) { |
| 23 case NOTIFICATION_TYPE_BASE_FORMAT: |
| 24 case NOTIFICATION_TYPE_IMAGE: |
| 25 case NOTIFICATION_TYPE_MULTIPLE: |
| 26 case NOTIFICATION_TYPE_SIMPLE: |
| 27 case NOTIFICATION_TYPE_PROGRESS: |
| 28 // All above roads lead to the generic NotificationView. |
| 29 notification_view = new NotificationView(controller, notification); |
| 30 break; |
| 31 case NOTIFICATION_TYPE_CUSTOM: |
| 32 notification_view = new CustomNotificationView(controller, notification); |
| 33 break; |
| 34 default: |
| 35 // If the caller asks for an unrecognized kind of view (entirely possible |
| 36 // if an application is running on an older version of this code that |
| 37 // doesn't have the requested kind of notification template), we'll fall |
| 38 // back to a notification instance that will provide at least basic |
| 39 // functionality. |
| 40 LOG(WARNING) << "Unable to fulfill request for unrecognized " |
| 41 << "notification type " << notification.type() << ". " |
| 42 << "Falling back to simple notification type."; |
| 43 notification_view = new NotificationView(controller, notification); |
| 44 } |
| 45 |
| 46 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 47 // Don't create shadows for notification toasts on linux wih aura. |
| 48 if (top_level) |
| 49 return notification_view; |
| 50 #endif |
| 51 |
| 52 #if defined(OS_WIN) |
| 53 // Don't create shadows for notifications on Windows under classic theme. |
| 54 if (top_level && !ui::win::IsAeroGlassEnabled()) { |
| 55 return notification_view; |
| 56 } |
| 57 #endif // OS_WIN |
| 58 |
| 59 notification_view->CreateShadowBorder(); |
| 60 return notification_view; |
| 61 } |
| 62 |
| 63 } // namespace message_center |
| OLD | NEW |