| OLD | NEW |
| 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/notification_view.h" | 5 #include "ui/message_center/notification_view.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
| 9 #include "ui/base/accessibility/accessible_view_state.h" | 9 #include "ui/base/accessibility/accessible_view_state.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 title_->SetBackgroundColor(kTitleBackgroundColor); | 183 title_->SetBackgroundColor(kTitleBackgroundColor); |
| 184 title_->set_border(MakePadding(kActionButtonTitleTopPadding, 0, 0, 0)); | 184 title_->set_border(MakePadding(kActionButtonTitleTopPadding, 0, 0, 0)); |
| 185 AddChildView(title_); | 185 AddChildView(title_); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 | 188 |
| 189 } // namespace | 189 } // namespace |
| 190 | 190 |
| 191 namespace message_center { | 191 namespace message_center { |
| 192 | 192 |
| 193 // static |
| 194 MessageView* NotificationView::ViewForNotification( |
| 195 const NotificationList::Notification& notification, |
| 196 NotificationList::Delegate* list_delegate) { |
| 197 switch (notification.type) { |
| 198 case ui::notifications::NOTIFICATION_TYPE_BASE_FORMAT: |
| 199 case ui::notifications::NOTIFICATION_TYPE_IMAGE: |
| 200 case ui::notifications::NOTIFICATION_TYPE_MULTIPLE: |
| 201 case ui::notifications::NOTIFICATION_TYPE_SIMPLE: |
| 202 break; |
| 203 default: |
| 204 // If the caller asks for an unrecognized kind of view (entirely possible |
| 205 // if an application is running on an older version of this code that |
| 206 // doesn't have the requested kind of notification template), we'll fall |
| 207 // back to a notification instance that will provide at least basic |
| 208 // functionality. |
| 209 LOG(WARNING) << "Unable to fulfill request for unrecognized " |
| 210 << "notification type " << notification.type << ". " |
| 211 << "Falling back to simple notification type."; |
| 212 } |
| 213 |
| 214 // Currently all roads lead to the generic NotificationView. |
| 215 return new NotificationView(list_delegate, notification); |
| 216 } |
| 217 |
| 193 NotificationView::NotificationView( | 218 NotificationView::NotificationView( |
| 194 NotificationList::Delegate* list_delegate, | 219 NotificationList::Delegate* list_delegate, |
| 195 const NotificationList::Notification& notification) | 220 const NotificationList::Notification& notification) |
| 196 : MessageView(list_delegate, notification) { | 221 : MessageView(list_delegate, notification) { |
| 197 } | 222 } |
| 198 | 223 |
| 199 NotificationView::~NotificationView() { | 224 NotificationView::~NotificationView() { |
| 200 } | 225 } |
| 201 | 226 |
| 202 void NotificationView::Layout() { | 227 void NotificationView::Layout() { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 action_buttons_.push_back(button); | 377 action_buttons_.push_back(button); |
| 353 layout->StartRow(0, 0); | 378 layout->StartRow(0, 0); |
| 354 layout->AddView(button, 2, 1, | 379 layout->AddView(button, 2, 1, |
| 355 views::GridLayout::FILL, views::GridLayout::FILL, 0, 40); | 380 views::GridLayout::FILL, views::GridLayout::FILL, 0, 40); |
| 356 } | 381 } |
| 357 | 382 |
| 358 return content_view_; | 383 return content_view_; |
| 359 } | 384 } |
| 360 | 385 |
| 361 } // namespace message_center | 386 } // namespace message_center |
| OLD | NEW |