Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_md.h" | 5 #include "ui/message_center/views/notification_view_md.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | |
| 9 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | |
| 10 #include "ui/base/cursor/cursor.h" | 12 #include "ui/base/cursor/cursor.h" |
| 11 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 12 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
| 13 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
| 14 #include "ui/gfx/image/image_skia_operations.h" | 16 #include "ui/gfx/image/image_skia_operations.h" |
| 15 #include "ui/gfx/paint_vector_icon.h" | 17 #include "ui/gfx/paint_vector_icon.h" |
| 16 #include "ui/gfx/skia_util.h" | 18 #include "ui/gfx/skia_util.h" |
| 17 #include "ui/gfx/text_elider.h" | 19 #include "ui/gfx/text_elider.h" |
| 18 #include "ui/message_center/message_center.h" | 20 #include "ui/message_center/message_center.h" |
| 19 #include "ui/message_center/message_center_style.h" | 21 #include "ui/message_center/message_center_style.h" |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 compact_title_message_view_->set_title(notification.title()); | 491 compact_title_message_view_->set_title(notification.title()); |
| 490 compact_title_message_view_->set_message(notification.message()); | 492 compact_title_message_view_->set_message(notification.message()); |
| 491 left_content_->InvalidateLayout(); | 493 left_content_->InvalidateLayout(); |
| 492 } | 494 } |
| 493 | 495 |
| 494 void NotificationViewMD::CreateOrUpdateProgressBarView( | 496 void NotificationViewMD::CreateOrUpdateProgressBarView( |
| 495 const Notification& notification) { | 497 const Notification& notification) { |
| 496 if (notification.type() != NOTIFICATION_TYPE_PROGRESS) { | 498 if (notification.type() != NOTIFICATION_TYPE_PROGRESS) { |
| 497 left_content_->RemoveChildView(progress_bar_view_); | 499 left_content_->RemoveChildView(progress_bar_view_); |
| 498 progress_bar_view_ = nullptr; | 500 progress_bar_view_ = nullptr; |
| 501 header_row_->SetSummaryText(base::string16()); | |
| 499 return; | 502 return; |
| 500 } | 503 } |
| 501 | 504 |
| 502 DCHECK(left_content_); | 505 DCHECK(left_content_); |
| 503 | 506 |
| 504 if (!progress_bar_view_) { | 507 if (!progress_bar_view_) { |
| 505 progress_bar_view_ = new views::ProgressBar(kProgressBarHeight, | 508 progress_bar_view_ = new views::ProgressBar(kProgressBarHeight, |
| 506 /* allow_round_corner */ false); | 509 /* allow_round_corner */ false); |
| 507 progress_bar_view_->SetBorder(views::CreateEmptyBorder( | 510 progress_bar_view_->SetBorder(views::CreateEmptyBorder( |
| 508 message_center::kProgressBarTopPadding, 0, 0, 0)); | 511 message_center::kProgressBarTopPadding, 0, 0, 0)); |
| 509 left_content_->AddChildView(progress_bar_view_); | 512 left_content_->AddChildView(progress_bar_view_); |
| 510 } | 513 } |
| 511 | 514 |
| 512 progress_bar_view_->SetValue(notification.progress() / 100.0); | 515 progress_bar_view_->SetValue(notification.progress() / 100.0); |
| 513 progress_bar_view_->SetVisible(notification.items().empty()); | 516 progress_bar_view_->SetVisible(notification.items().empty()); |
| 517 | |
| 518 header_row_->SetSummaryText(base::IntToString16(notification.progress()) + | |
|
yoshiki
2017/06/22 13:27:37
Could you make this a localized string?
| |
| 519 base::ASCIIToUTF16("%")); | |
| 514 } | 520 } |
| 515 | 521 |
| 516 void NotificationViewMD::CreateOrUpdateListItemViews( | 522 void NotificationViewMD::CreateOrUpdateListItemViews( |
| 517 const Notification& notification) { | 523 const Notification& notification) { |
| 518 for (auto* item_view : item_views_) | 524 for (auto* item_view : item_views_) |
| 519 delete item_view; | 525 delete item_view; |
| 520 item_views_.clear(); | 526 item_views_.clear(); |
| 521 | 527 |
| 522 const std::vector<NotificationItem>& items = notification.items(); | 528 const std::vector<NotificationItem>& items = notification.items(); |
| 523 | 529 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 709 header_row_->expand_button()->HasFocus()) || | 715 header_row_->expand_button()->HasFocus()) || |
| 710 (header_row_->IsCloseButtonEnabled() && | 716 (header_row_->IsCloseButtonEnabled() && |
| 711 header_row_->close_button()->HasFocus()) || | 717 header_row_->close_button()->HasFocus()) || |
| 712 (header_row_->IsSettingsButtonEnabled() && | 718 (header_row_->IsSettingsButtonEnabled() && |
| 713 header_row_->settings_button()->HasFocus()); | 719 header_row_->settings_button()->HasFocus()); |
| 714 | 720 |
| 715 header_row_->SetControlButtonsVisible(target_visibility); | 721 header_row_->SetControlButtonsVisible(target_visibility); |
| 716 } | 722 } |
| 717 | 723 |
| 718 } // namespace message_center | 724 } // namespace message_center |
| OLD | NEW |