Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: ui/message_center/views/message_view_factory.cc

Issue 2892893002: Initial implementation of new-style notification (Closed)
Patch Set: Fixed build failure Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/custom_notification_view.h" 10 #include "ui/message_center/views/custom_notification_view.h"
9 #include "ui/message_center/views/notification_view.h" 11 #include "ui/message_center/views/notification_view.h"
12 #include "ui/message_center/views/notification_view_md.h"
10 13
11 #if defined(OS_WIN) 14 #if defined(OS_WIN)
12 #include "ui/base/win/shell.h" 15 #include "ui/base/win/shell.h"
13 #endif 16 #endif
14 17
18 namespace {
19 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.
20 } // anonymous namespace
21
15 namespace message_center { 22 namespace message_center {
16 23
17 // static 24 // static
18 MessageView* MessageViewFactory::Create(MessageCenterController* controller, 25 MessageView* MessageViewFactory::Create(MessageCenterController* controller,
19 const Notification& notification, 26 const Notification& notification,
20 bool top_level) { 27 bool top_level) {
28 // One-time lazy initialization of |new_style_notification_enabled|.
29 if (!new_style_notification_enabled) {
30 new_style_notification_enabled = false; // default value
31 std::string arg =
32 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
33 switches::kMessageCenterNewStyleNotification);
34 if (arg == switches::kMessageCenterNewStyleNotificationEnabled) {
35 new_style_notification_enabled = true;
36 } else if (arg == switches::kMessageCenterNewStyleNotificationDisabled) {
37 new_style_notification_enabled = false;
38 }
39 }
40
21 MessageView* notification_view = nullptr; 41 MessageView* notification_view = nullptr;
22 switch (notification.type()) { 42 switch (notification.type()) {
23 case NOTIFICATION_TYPE_BASE_FORMAT: 43 case NOTIFICATION_TYPE_BASE_FORMAT:
24 case NOTIFICATION_TYPE_IMAGE: 44 case NOTIFICATION_TYPE_IMAGE:
25 case NOTIFICATION_TYPE_MULTIPLE: 45 case NOTIFICATION_TYPE_MULTIPLE:
26 case NOTIFICATION_TYPE_SIMPLE: 46 case NOTIFICATION_TYPE_SIMPLE:
27 case NOTIFICATION_TYPE_PROGRESS: 47 case NOTIFICATION_TYPE_PROGRESS:
28 // All above roads lead to the generic NotificationView. 48 // All above roads lead to the generic NotificationView.
29 notification_view = new NotificationView(controller, notification); 49 if (*new_style_notification_enabled)
50 notification_view = new NotificationViewMD(controller, notification);
51 else
52 notification_view = new NotificationView(controller, notification);
30 break; 53 break;
31 case NOTIFICATION_TYPE_CUSTOM: 54 case NOTIFICATION_TYPE_CUSTOM:
32 notification_view = new CustomNotificationView(controller, notification); 55 notification_view = new CustomNotificationView(controller, notification);
33 break; 56 break;
34 default: 57 default:
35 // If the caller asks for an unrecognized kind of view (entirely possible 58 // 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 59 // 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 60 // doesn't have the requested kind of notification template), we'll fall
38 // back to a notification instance that will provide at least basic 61 // back to a notification instance that will provide at least basic
39 // functionality. 62 // functionality.
(...skipping 14 matching lines...) Expand all
54 if (top_level && !ui::win::IsAeroGlassEnabled()) { 77 if (top_level && !ui::win::IsAeroGlassEnabled()) {
55 return notification_view; 78 return notification_view;
56 } 79 }
57 #endif // OS_WIN 80 #endif // OS_WIN
58 81
59 notification_view->SetIsNested(); 82 notification_view->SetIsNested();
60 return notification_view; 83 return notification_view;
61 } 84 }
62 85
63 } // namespace message_center 86 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698