| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "ui/message_center/views/message_view_factory.h" | 5 #include "ui/message_center/views/message_view_factory.h" |
| 6 | 6 |
| 7 #include "ui/message_center/notification_types.h" | 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" | 8 #include "ui/message_center/views/notification_view.h" |
| 10 | 9 |
| 11 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| 12 #include "ui/base/win/shell.h" | 11 #include "ui/base/win/shell.h" |
| 13 #endif | 12 #endif |
| 14 | 13 |
| 15 namespace message_center { | 14 namespace message_center { |
| 16 | 15 |
| 17 // static | 16 // static |
| 18 MessageView* MessageViewFactory::Create(MessageCenterController* controller, | 17 MessageView* MessageViewFactory::Create(MessageCenterController* controller, |
| 19 const Notification& notification, | 18 const Notification& notification, |
| 20 bool top_level) { | 19 bool top_level) { |
| 21 MessageView* notification_view = nullptr; | 20 MessageView* notification_view = nullptr; |
| 22 switch (notification.type()) { | 21 switch (notification.type()) { |
| 23 case NOTIFICATION_TYPE_BASE_FORMAT: | 22 case NOTIFICATION_TYPE_BASE_FORMAT: |
| 24 case NOTIFICATION_TYPE_IMAGE: | 23 case NOTIFICATION_TYPE_IMAGE: |
| 25 case NOTIFICATION_TYPE_MULTIPLE: | 24 case NOTIFICATION_TYPE_MULTIPLE: |
| 26 case NOTIFICATION_TYPE_SIMPLE: | 25 case NOTIFICATION_TYPE_SIMPLE: |
| 27 case NOTIFICATION_TYPE_PROGRESS: | 26 case NOTIFICATION_TYPE_PROGRESS: |
| 28 // All above roads lead to the generic NotificationView. | 27 // All above roads lead to the generic NotificationView. |
| 29 notification_view = new NotificationView(controller, notification); | 28 notification_view = new NotificationView(controller, notification); |
| 30 break; | 29 break; |
| 30 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) |
| 31 case NOTIFICATION_TYPE_CUSTOM: | 31 case NOTIFICATION_TYPE_CUSTOM: |
| 32 notification_view = new CustomNotificationView(controller, notification); | 32 notification_view = |
| 33 notification.delegate() |
| 34 ->CreateCustomMessageView(controller, notification) |
| 35 .release(); |
| 33 break; | 36 break; |
| 37 #endif |
| 34 default: | 38 default: |
| 35 // If the caller asks for an unrecognized kind of view (entirely possible | 39 // 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 | 40 // 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 | 41 // doesn't have the requested kind of notification template), we'll fall |
| 38 // back to a notification instance that will provide at least basic | 42 // back to a notification instance that will provide at least basic |
| 39 // functionality. | 43 // functionality. |
| 40 LOG(WARNING) << "Unable to fulfill request for unrecognized " | 44 LOG(WARNING) << "Unable to fulfill request for unrecognized or" |
| 41 << "notification type " << notification.type() << ". " | 45 << "unsupported notification type " << notification.type() |
| 42 << "Falling back to simple notification type."; | 46 << ". Falling back to simple notification type."; |
| 43 notification_view = new NotificationView(controller, notification); | 47 notification_view = new NotificationView(controller, notification); |
| 44 } | 48 } |
| 45 | 49 |
| 46 #if defined(OS_LINUX) | 50 #if defined(OS_LINUX) |
| 47 // Don't create shadows for notification toasts on Linux or CrOS. | 51 // Don't create shadows for notification toasts on Linux or CrOS. |
| 48 if (top_level) | 52 if (top_level) |
| 49 return notification_view; | 53 return notification_view; |
| 50 #endif | 54 #endif |
| 51 | 55 |
| 52 #if defined(OS_WIN) | 56 #if defined(OS_WIN) |
| 53 // Don't create shadows for notifications on Windows under classic theme. | 57 // Don't create shadows for notifications on Windows under classic theme. |
| 54 if (top_level && !ui::win::IsAeroGlassEnabled()) { | 58 if (top_level && !ui::win::IsAeroGlassEnabled()) { |
| 55 return notification_view; | 59 return notification_view; |
| 56 } | 60 } |
| 57 #endif // OS_WIN | 61 #endif // OS_WIN |
| 58 | 62 |
| 59 notification_view->SetIsNested(); | 63 notification_view->SetIsNested(); |
| 60 return notification_view; | 64 return notification_view; |
| 61 } | 65 } |
| 62 | 66 |
| 63 } // namespace message_center | 67 } // namespace message_center |
| OLD | NEW |