| 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/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" |
| 11 #include "base/stl_util.h" | |
| 12 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 13 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 14 #include "components/url_formatter/elide_url.h" | 13 #include "components/url_formatter/elide_url.h" |
| 15 #include "third_party/skia/include/core/SkPaint.h" | 14 #include "third_party/skia/include/core/SkPaint.h" |
| 16 #include "third_party/skia/include/core/SkPath.h" | 15 #include "third_party/skia/include/core/SkPath.h" |
| 17 #include "ui/base/cursor/cursor.h" | 16 #include "ui/base/cursor/cursor.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/layout.h" | 18 #include "ui/base/layout.h" |
| 20 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
| 21 #include "ui/gfx/geometry/size.h" | 20 #include "ui/gfx/geometry/size.h" |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 message_center::kProgressBarTopPadding, kProgressBarBottomPadding)); | 501 message_center::kProgressBarTopPadding, kProgressBarBottomPadding)); |
| 503 top_view_->AddChildView(progress_bar_view_); | 502 top_view_->AddChildView(progress_bar_view_); |
| 504 } | 503 } |
| 505 | 504 |
| 506 progress_bar_view_->SetValue(notification.progress() / 100.0); | 505 progress_bar_view_->SetValue(notification.progress() / 100.0); |
| 507 progress_bar_view_->SetVisible(notification.items().empty()); | 506 progress_bar_view_->SetVisible(notification.items().empty()); |
| 508 } | 507 } |
| 509 | 508 |
| 510 void NotificationView::CreateOrUpdateListItemViews( | 509 void NotificationView::CreateOrUpdateListItemViews( |
| 511 const Notification& notification) { | 510 const Notification& notification) { |
| 512 for (size_t i = 0; i < item_views_.size(); ++i) | 511 for (auto item_view : item_views_) |
| 513 delete item_views_[i]; | 512 delete item_view; |
| 514 item_views_.clear(); | 513 item_views_.clear(); |
| 515 | 514 |
| 516 int padding = kMessageLineHeight - views::Label().font_list().GetHeight(); | 515 int padding = kMessageLineHeight - views::Label().font_list().GetHeight(); |
| 517 std::vector<NotificationItem> items = notification.items(); | 516 std::vector<NotificationItem> items = notification.items(); |
| 518 | 517 |
| 519 if (items.size() == 0) | 518 if (items.size() == 0) |
| 520 return; | 519 return; |
| 521 | 520 |
| 522 DCHECK(top_view_); | 521 DCHECK(top_view_); |
| 523 for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) { | 522 for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 SK_ColorTRANSPARENT) | 582 SK_ColorTRANSPARENT) |
| 584 : NULL); | 583 : NULL); |
| 585 } | 584 } |
| 586 | 585 |
| 587 void NotificationView::CreateOrUpdateActionButtonViews( | 586 void NotificationView::CreateOrUpdateActionButtonViews( |
| 588 const Notification& notification) { | 587 const Notification& notification) { |
| 589 std::vector<ButtonInfo> buttons = notification.buttons(); | 588 std::vector<ButtonInfo> buttons = notification.buttons(); |
| 590 bool new_buttons = action_buttons_.size() != buttons.size(); | 589 bool new_buttons = action_buttons_.size() != buttons.size(); |
| 591 | 590 |
| 592 if (new_buttons || buttons.size() == 0) { | 591 if (new_buttons || buttons.size() == 0) { |
| 593 // STLDeleteElements also clears the container. | 592 for (auto item : separators_) |
| 594 base::STLDeleteElements(&separators_); | 593 delete item; |
| 595 base::STLDeleteElements(&action_buttons_); | 594 separators_.clear(); |
| 595 for (auto item : action_buttons_) |
| 596 delete item; |
| 597 action_buttons_.clear(); |
| 596 } | 598 } |
| 597 | 599 |
| 598 DCHECK(bottom_view_); | 600 DCHECK(bottom_view_); |
| 599 DCHECK_EQ(this, bottom_view_->parent()); | 601 DCHECK_EQ(this, bottom_view_->parent()); |
| 600 | 602 |
| 601 for (size_t i = 0; i < buttons.size(); ++i) { | 603 for (size_t i = 0; i < buttons.size(); ++i) { |
| 602 ButtonInfo button_info = buttons[i]; | 604 ButtonInfo button_info = buttons[i]; |
| 603 if (new_buttons) { | 605 if (new_buttons) { |
| 604 views::View* separator = new views::ImageView(); | 606 views::View* separator = new views::ImageView(); |
| 605 separator->SetBorder(MakeSeparatorBorder(1, 0, kButtonSeparatorColor)); | 607 separator->SetBorder(MakeSeparatorBorder(1, 0, kButtonSeparatorColor)); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 | 665 |
| 664 return message_line_limit; | 666 return message_line_limit; |
| 665 } | 667 } |
| 666 | 668 |
| 667 int NotificationView::GetMessageHeight(int width, int limit) const { | 669 int NotificationView::GetMessageHeight(int width, int limit) const { |
| 668 return message_view_ ? | 670 return message_view_ ? |
| 669 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; | 671 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; |
| 670 } | 672 } |
| 671 | 673 |
| 672 } // namespace message_center | 674 } // namespace message_center |
| OLD | NEW |