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

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

Issue 1979583003: Support notifications with custom content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@messageview-close-button
Patch Set: Created 4 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/notification_view.h" 5 #include "ui/message_center/views/notification_view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 10 matching lines...) Expand all
21 #include "ui/gfx/canvas.h" 21 #include "ui/gfx/canvas.h"
22 #include "ui/gfx/geometry/size.h" 22 #include "ui/gfx/geometry/size.h"
23 #include "ui/gfx/skia_util.h" 23 #include "ui/gfx/skia_util.h"
24 #include "ui/gfx/text_elider.h" 24 #include "ui/gfx/text_elider.h"
25 #include "ui/message_center/message_center.h" 25 #include "ui/message_center/message_center.h"
26 #include "ui/message_center/message_center_style.h" 26 #include "ui/message_center/message_center_style.h"
27 #include "ui/message_center/notification.h" 27 #include "ui/message_center/notification.h"
28 #include "ui/message_center/notification_types.h" 28 #include "ui/message_center/notification_types.h"
29 #include "ui/message_center/views/bounded_label.h" 29 #include "ui/message_center/views/bounded_label.h"
30 #include "ui/message_center/views/constants.h" 30 #include "ui/message_center/views/constants.h"
31 #include "ui/message_center/views/custom_notification_view.h"
31 #include "ui/message_center/views/message_center_controller.h" 32 #include "ui/message_center/views/message_center_controller.h"
32 #include "ui/message_center/views/notification_button.h" 33 #include "ui/message_center/views/notification_button.h"
33 #include "ui/message_center/views/notification_progress_bar.h" 34 #include "ui/message_center/views/notification_progress_bar.h"
34 #include "ui/message_center/views/padded_button.h" 35 #include "ui/message_center/views/padded_button.h"
35 #include "ui/message_center/views/proportional_image_view.h" 36 #include "ui/message_center/views/proportional_image_view.h"
36 #include "ui/native_theme/native_theme.h" 37 #include "ui/native_theme/native_theme.h"
37 #include "ui/resources/grit/ui_resources.h" 38 #include "ui/resources/grit/ui_resources.h"
38 #include "ui/strings/grit/ui_strings.h" 39 #include "ui/strings/grit/ui_strings.h"
39 #include "ui/views/background.h" 40 #include "ui/views/background.h"
40 #include "ui/views/border.h" 41 #include "ui/views/border.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 child_at(i)->SetVisible(visible); 141 child_at(i)->SetVisible(visible);
141 } 142 }
142 143
143 } // namespace 144 } // namespace
144 145
145 namespace message_center { 146 namespace message_center {
146 147
147 // NotificationView //////////////////////////////////////////////////////////// 148 // NotificationView ////////////////////////////////////////////////////////////
148 149
149 // static 150 // static
150 MessageView* NotificationView::Create(MessageCenterController* controller, 151 MessageView* NotificationView::Create(MessageCenterController* controller,
dewittj 2016/05/16 16:19:28 Seems weird that this function might return a Cust
xiyuan 2016/05/16 16:31:05 Makes sense. How about bring back MessageViewFacto
151 const Notification& notification, 152 const Notification& notification,
152 bool top_level) { 153 bool top_level) {
154 MessageView* notification_view = nullptr;
153 switch (notification.type()) { 155 switch (notification.type()) {
154 case NOTIFICATION_TYPE_BASE_FORMAT: 156 case NOTIFICATION_TYPE_BASE_FORMAT:
155 case NOTIFICATION_TYPE_IMAGE: 157 case NOTIFICATION_TYPE_IMAGE:
156 case NOTIFICATION_TYPE_MULTIPLE: 158 case NOTIFICATION_TYPE_MULTIPLE:
157 case NOTIFICATION_TYPE_SIMPLE: 159 case NOTIFICATION_TYPE_SIMPLE:
158 case NOTIFICATION_TYPE_PROGRESS: 160 case NOTIFICATION_TYPE_PROGRESS:
161 // All above roads lead to the generic NotificationView.
162 notification_view = new NotificationView(controller, notification);
163 break;
164 case NOTIFICATION_TYPE_CUSTOM:
165 notification_view = new CustomNotificationView(controller, notification);
159 break; 166 break;
160 default: 167 default:
161 // If the caller asks for an unrecognized kind of view (entirely possible 168 // If the caller asks for an unrecognized kind of view (entirely possible
162 // if an application is running on an older version of this code that 169 // if an application is running on an older version of this code that
163 // doesn't have the requested kind of notification template), we'll fall 170 // doesn't have the requested kind of notification template), we'll fall
164 // back to a notification instance that will provide at least basic 171 // back to a notification instance that will provide at least basic
165 // functionality. 172 // functionality.
166 LOG(WARNING) << "Unable to fulfill request for unrecognized " 173 LOG(WARNING) << "Unable to fulfill request for unrecognized "
167 << "notification type " << notification.type() << ". " 174 << "notification type " << notification.type() << ". "
168 << "Falling back to simple notification type."; 175 << "Falling back to simple notification type.";
176 notification_view = new NotificationView(controller, notification);
169 } 177 }
170 178
171 // Currently all roads lead to the generic NotificationView.
172 NotificationView* notification_view =
173 new NotificationView(controller, notification);
174
175 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 179 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
176 // Don't create shadows for notification toasts on linux wih aura. 180 // Don't create shadows for notification toasts on linux wih aura.
177 if (top_level) 181 if (top_level)
178 return notification_view; 182 return notification_view;
179 #endif 183 #endif
180 184
181 #if defined(OS_WIN) 185 #if defined(OS_WIN)
182 // Don't create shadows for notifications on Windows under classic theme. 186 // Don't create shadows for notifications on Windows under classic theme.
183 if (top_level && !ui::win::IsAeroGlassEnabled()) { 187 if (top_level && !ui::win::IsAeroGlassEnabled()) {
184 return notification_view; 188 return notification_view;
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 762
759 return message_line_limit; 763 return message_line_limit;
760 } 764 }
761 765
762 int NotificationView::GetMessageHeight(int width, int limit) const { 766 int NotificationView::GetMessageHeight(int width, int limit) const {
763 return message_view_ ? 767 return message_view_ ?
764 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; 768 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0;
765 } 769 }
766 770
767 } // namespace message_center 771 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698