| 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 "base/command_line.h" |
| 8 #include "ui/message_center/message_center_switches.h" |
| 7 #include "ui/message_center/notification_types.h" | 9 #include "ui/message_center/notification_types.h" |
| 8 #include "ui/message_center/views/notification_view.h" | 10 #include "ui/message_center/views/notification_view.h" |
| 11 #include "ui/message_center/views/notification_view_md.h" |
| 9 | 12 |
| 10 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
| 11 #include "ui/base/win/shell.h" | 14 #include "ui/base/win/shell.h" |
| 12 #endif | 15 #endif |
| 13 | 16 |
| 14 namespace message_center { | 17 namespace message_center { |
| 15 | 18 |
| 16 // static | 19 // static |
| 17 MessageView* MessageViewFactory::Create(MessageCenterController* controller, | 20 MessageView* MessageViewFactory::Create(MessageCenterController* controller, |
| 18 const Notification& notification, | 21 const Notification& notification, |
| 19 bool top_level) { | 22 bool top_level) { |
| 20 MessageView* notification_view = nullptr; | 23 MessageView* notification_view = nullptr; |
| 21 switch (notification.type()) { | 24 switch (notification.type()) { |
| 22 case NOTIFICATION_TYPE_BASE_FORMAT: | 25 case NOTIFICATION_TYPE_BASE_FORMAT: |
| 23 case NOTIFICATION_TYPE_IMAGE: | 26 case NOTIFICATION_TYPE_IMAGE: |
| 24 case NOTIFICATION_TYPE_MULTIPLE: | 27 case NOTIFICATION_TYPE_MULTIPLE: |
| 25 case NOTIFICATION_TYPE_SIMPLE: | 28 case NOTIFICATION_TYPE_SIMPLE: |
| 26 case NOTIFICATION_TYPE_PROGRESS: | 29 case NOTIFICATION_TYPE_PROGRESS: { |
| 30 bool new_style_notification_enabled = false; // default value |
| 31 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 32 switches::kEnableMessageCenterNewStyleNotification)) { |
| 33 new_style_notification_enabled = true; |
| 34 } else if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 35 switches::kDisableMessageCenterNewStyleNotification)) { |
| 36 new_style_notification_enabled = false; |
| 37 } |
| 38 |
| 27 // All above roads lead to the generic NotificationView. | 39 // All above roads lead to the generic NotificationView. |
| 28 notification_view = new NotificationView(controller, notification); | 40 if (new_style_notification_enabled) |
| 41 notification_view = new NotificationViewMD(controller, notification); |
| 42 else |
| 43 notification_view = new NotificationView(controller, notification); |
| 29 break; | 44 break; |
| 45 } |
| 30 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) | 46 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) |
| 31 case NOTIFICATION_TYPE_CUSTOM: | 47 case NOTIFICATION_TYPE_CUSTOM: |
| 32 notification_view = | 48 notification_view = |
| 33 notification.delegate() | 49 notification.delegate() |
| 34 ->CreateCustomMessageView(controller, notification) | 50 ->CreateCustomMessageView(controller, notification) |
| 35 .release(); | 51 .release(); |
| 36 break; | 52 break; |
| 37 #endif | 53 #endif |
| 38 default: | 54 default: |
| 39 // If the caller asks for an unrecognized kind of view (entirely possible | 55 // If the caller asks for an unrecognized kind of view (entirely possible |
| (...skipping 18 matching lines...) Expand all Loading... |
| 58 if (top_level && !ui::win::IsAeroGlassEnabled()) { | 74 if (top_level && !ui::win::IsAeroGlassEnabled()) { |
| 59 return notification_view; | 75 return notification_view; |
| 60 } | 76 } |
| 61 #endif // OS_WIN | 77 #endif // OS_WIN |
| 62 | 78 |
| 63 notification_view->SetIsNested(); | 79 notification_view->SetIsNested(); |
| 64 return notification_view; | 80 return notification_view; |
| 65 } | 81 } |
| 66 | 82 |
| 67 } // namespace message_center | 83 } // namespace message_center |
| OLD | NEW |