Chromium Code Reviews| Index: ui/message_center/views/message_view_factory.cc |
| diff --git a/ui/message_center/views/message_view_factory.cc b/ui/message_center/views/message_view_factory.cc |
| index df5f6d923f7e8b9a8b313a6504974aa19d0beeeb..d554111422ebc1dd62e945439e1a0de851e7d9d1 100644 |
| --- a/ui/message_center/views/message_view_factory.cc |
| +++ b/ui/message_center/views/message_view_factory.cc |
| @@ -4,20 +4,40 @@ |
| #include "ui/message_center/views/message_view_factory.h" |
| +#include "base/command_line.h" |
| +#include "ui/message_center/message_center_switches.h" |
| #include "ui/message_center/notification_types.h" |
| #include "ui/message_center/views/custom_notification_view.h" |
| #include "ui/message_center/views/notification_view.h" |
| +#include "ui/message_center/views/notification_view_md.h" |
| #if defined(OS_WIN) |
| #include "ui/base/win/shell.h" |
| #endif |
| +namespace { |
| +static base::Optional<bool> new_style_notification_enabled; |
|
fukino
2017/05/25 07:35:10
This seems to be forbidden by coding style.
https:
yoshiki
2017/05/29 03:52:38
Ok, Done.
|
| +} // anonymous namespace |
| + |
| namespace message_center { |
| // static |
| MessageView* MessageViewFactory::Create(MessageCenterController* controller, |
| const Notification& notification, |
| bool top_level) { |
| + // One-time lazy initialization of |new_style_notification_enabled|. |
| + if (!new_style_notification_enabled) { |
| + new_style_notification_enabled = false; // default value |
| + std::string arg = |
| + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| + switches::kMessageCenterNewStyleNotification); |
| + if (arg == switches::kMessageCenterNewStyleNotificationEnabled) { |
| + new_style_notification_enabled = true; |
| + } else if (arg == switches::kMessageCenterNewStyleNotificationDisabled) { |
| + new_style_notification_enabled = false; |
| + } |
| + } |
| + |
| MessageView* notification_view = nullptr; |
| switch (notification.type()) { |
| case NOTIFICATION_TYPE_BASE_FORMAT: |
| @@ -26,7 +46,10 @@ MessageView* MessageViewFactory::Create(MessageCenterController* controller, |
| case NOTIFICATION_TYPE_SIMPLE: |
| case NOTIFICATION_TYPE_PROGRESS: |
| // All above roads lead to the generic NotificationView. |
| - notification_view = new NotificationView(controller, notification); |
| + if (*new_style_notification_enabled) |
| + notification_view = new NotificationViewMD(controller, notification); |
| + else |
| + notification_view = new NotificationView(controller, notification); |
| break; |
| case NOTIFICATION_TYPE_CUSTOM: |
| notification_view = new CustomNotificationView(controller, notification); |