| 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" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 SkColor color) { | 88 SkColor color) { |
| 89 return views::Border::CreateSolidSidedBorder(top, left, 0, 0, color); | 89 return views::Border::CreateSolidSidedBorder(top, left, 0, 0, color); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // ItemView //////////////////////////////////////////////////////////////////// | 92 // ItemView //////////////////////////////////////////////////////////////////// |
| 93 | 93 |
| 94 // ItemViews are responsible for drawing each list notification item's title and | 94 // ItemViews are responsible for drawing each list notification item's title and |
| 95 // message next to each other within a single column. | 95 // message next to each other within a single column. |
| 96 class ItemView : public views::View { | 96 class ItemView : public views::View { |
| 97 public: | 97 public: |
| 98 ItemView(const message_center::NotificationItem& item); | 98 explicit ItemView(const message_center::NotificationItem& item); |
| 99 ~ItemView() override; | 99 ~ItemView() override; |
| 100 | 100 |
| 101 // Overridden from views::View: | 101 // Overridden from views::View: |
| 102 void SetVisible(bool visible) override; | 102 void SetVisible(bool visible) override; |
| 103 | 103 |
| 104 private: | 104 private: |
| 105 DISALLOW_COPY_AND_ASSIGN(ItemView); | 105 DISALLOW_COPY_AND_ASSIGN(ItemView); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 ItemView::ItemView(const message_center::NotificationItem& item) { | 108 ItemView::ItemView(const message_center::NotificationItem& item) { |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 message_view_ = new BoundedLabel(text); | 428 message_view_ = new BoundedLabel(text); |
| 429 message_view_->SetLineHeight(kMessageLineHeight); | 429 message_view_->SetLineHeight(kMessageLineHeight); |
| 430 message_view_->SetColors(message_center::kRegularTextColor, | 430 message_view_->SetColors(message_center::kRegularTextColor, |
| 431 kDimTextBackgroundColor); | 431 kDimTextBackgroundColor); |
| 432 message_view_->SetBorder(MakeTextBorder(padding, 4, 0)); | 432 message_view_->SetBorder(MakeTextBorder(padding, 4, 0)); |
| 433 top_view_->AddChildView(message_view_); | 433 top_view_->AddChildView(message_view_); |
| 434 } else { | 434 } else { |
| 435 message_view_->SetText(text); | 435 message_view_->SetText(text); |
| 436 } | 436 } |
| 437 | 437 |
| 438 message_view_->SetVisible(!notification.items().size()); | 438 message_view_->SetVisible(notification.items().empty()); |
| 439 } | 439 } |
| 440 | 440 |
| 441 base::string16 NotificationView::FormatContextMessage( | 441 base::string16 NotificationView::FormatContextMessage( |
| 442 const Notification& notification) const { | 442 const Notification& notification) const { |
| 443 if (notification.UseOriginAsContextMessage()) { | 443 if (notification.UseOriginAsContextMessage()) { |
| 444 const GURL url = notification.origin_url(); | 444 const GURL url = notification.origin_url(); |
| 445 DCHECK(url.is_valid()); | 445 DCHECK(url.is_valid()); |
| 446 return gfx::ElideText( | 446 return gfx::ElideText( |
| 447 url_formatter::FormatUrlForSecurityDisplay( | 447 url_formatter::FormatUrlForSecurityDisplay( |
| 448 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS), | 448 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS), |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 progress_bar_view_ = new NotificationIndeterminateProgressBar(); | 538 progress_bar_view_ = new NotificationIndeterminateProgressBar(); |
| 539 | 539 |
| 540 progress_bar_view_->SetBorder(MakeProgressBarBorder( | 540 progress_bar_view_->SetBorder(MakeProgressBarBorder( |
| 541 message_center::kProgressBarTopPadding, kProgressBarBottomPadding)); | 541 message_center::kProgressBarTopPadding, kProgressBarBottomPadding)); |
| 542 top_view_->AddChildView(progress_bar_view_); | 542 top_view_->AddChildView(progress_bar_view_); |
| 543 } | 543 } |
| 544 | 544 |
| 545 if (!is_indeterminate) | 545 if (!is_indeterminate) |
| 546 progress_bar_view_->SetValue(notification.progress() / 100.0); | 546 progress_bar_view_->SetValue(notification.progress() / 100.0); |
| 547 | 547 |
| 548 progress_bar_view_->SetVisible(!notification.items().size()); | 548 progress_bar_view_->SetVisible(notification.items().empty()); |
| 549 } | 549 } |
| 550 | 550 |
| 551 void NotificationView::CreateOrUpdateListItemViews( | 551 void NotificationView::CreateOrUpdateListItemViews( |
| 552 const Notification& notification) { | 552 const Notification& notification) { |
| 553 for (size_t i = 0; i < item_views_.size(); ++i) | 553 for (size_t i = 0; i < item_views_.size(); ++i) |
| 554 delete item_views_[i]; | 554 delete item_views_[i]; |
| 555 item_views_.clear(); | 555 item_views_.clear(); |
| 556 | 556 |
| 557 int padding = kMessageLineHeight - views::Label().font_list().GetHeight(); | 557 int padding = kMessageLineHeight - views::Label().font_list().GetHeight(); |
| 558 std::vector<NotificationItem> items = notification.items(); | 558 std::vector<NotificationItem> items = notification.items(); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 | 711 |
| 712 return message_line_limit; | 712 return message_line_limit; |
| 713 } | 713 } |
| 714 | 714 |
| 715 int NotificationView::GetMessageHeight(int width, int limit) const { | 715 int NotificationView::GetMessageHeight(int width, int limit) const { |
| 716 return message_view_ ? | 716 return message_view_ ? |
| 717 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; | 717 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; |
| 718 } | 718 } |
| 719 | 719 |
| 720 } // namespace message_center | 720 } // namespace message_center |
| OLD | NEW |