Chromium Code Reviews| Index: ui/message_center/views/notification_view_md.cc |
| diff --git a/ui/message_center/views/notification_view_md.cc b/ui/message_center/views/notification_view_md.cc |
| index 7a86c5bc7e9e7e2414f81900eaea6e48f5110a06..00f8776a1e046a9466d2226cce85fbf802f96cce 100644 |
| --- a/ui/message_center/views/notification_view_md.cc |
| +++ b/ui/message_center/views/notification_view_md.cc |
| @@ -116,6 +116,8 @@ class ItemView : public views::View { |
| explicit ItemView(const message_center::NotificationItem& item); |
| ~ItemView() override; |
| + const char* GetClassName() const override; |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(ItemView); |
| }; |
| @@ -142,6 +144,10 @@ ItemView::ItemView(const message_center::NotificationItem& item) { |
| ItemView::~ItemView() = default; |
| +const char* ItemView::GetClassName() const { |
| + return "ItemView"; |
| +} |
| + |
| // CompactTitleMessageView ///////////////////////////////////////////////////// |
| // CompactTitleMessageView shows notification title and message in a single |
| @@ -151,6 +157,8 @@ class CompactTitleMessageView : public views::View { |
| explicit CompactTitleMessageView(); |
| ~CompactTitleMessageView() override; |
| + const char* GetClassName() const override; |
| + |
| void OnPaint(gfx::Canvas* canvas) override; |
| void set_title(const base::string16& title) { title_ = title; } |
| @@ -166,7 +174,11 @@ class CompactTitleMessageView : public views::View { |
| views::Label* message_view_ = nullptr; |
| }; |
| -CompactTitleMessageView::~CompactTitleMessageView() {} |
| +CompactTitleMessageView::~CompactTitleMessageView() = default; |
| + |
| +const char* CompactTitleMessageView::GetClassName() const { |
| + return "CompactTitleMessageView"; |
| +} |
| CompactTitleMessageView::CompactTitleMessageView() { |
| SetLayoutManager(new views::FillLayout()); |
| @@ -227,6 +239,8 @@ class NotificationButtonMD : public views::LabelButton { |
| const base::string16& text); |
| ~NotificationButtonMD() override; |
| + const char* GetClassName() const override; |
| + |
| std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() |
| const override; |
| @@ -249,6 +263,10 @@ NotificationButtonMD::NotificationButtonMD(views::ButtonListener* listener, |
| NotificationButtonMD::~NotificationButtonMD() = default; |
| +const char* NotificationButtonMD::GetClassName() const { |
| + return "NotificationButtonMD"; |
| +} |
| + |
| std::unique_ptr<views::InkDropHighlight> |
| NotificationButtonMD::CreateInkDropHighlight() const { |
| std::unique_ptr<views::InkDropHighlight> highlight = |
| @@ -304,10 +322,12 @@ void NotificationViewMD::CreateOrUpdateViews(const Notification& notification) { |
| CreateOrUpdateIconView(notification); |
| CreateOrUpdateSmallIconView(notification); |
| CreateOrUpdateImageView(notification); |
| - CreateOrUpdateActionButtonViews(notification); |
| CreateOrUpdateCloseButtonView(notification); |
| CreateOrUpdateSettingsButtonView(notification); |
| UpdateViewForExpandedState(expanded_); |
| + // Should be called at the last because SynthesizeMouseMoveEvent() requires |
| + // everything is in the right location when called. |
| + CreateOrUpdateActionButtonViews(notification); |
| } |
| NotificationViewMD::NotificationViewMD(MessageCenterController* controller, |
| @@ -472,8 +492,10 @@ void NotificationViewMD::CreateOrUpdateContextTitleView( |
| void NotificationViewMD::CreateOrUpdateTitleView( |
| const Notification& notification) { |
| - if (notification.type() == NOTIFICATION_TYPE_PROGRESS) { |
| - left_content_->RemoveChildView(title_view_); |
| + if (notification.title().empty() || |
| + notification.type() == NOTIFICATION_TYPE_PROGRESS) { |
| + if (title_view_ != nullptr) |
|
fukino
2017/07/06 12:44:10
nit: "if (title_view_)" is sufficient and consiste
tetsui
2017/07/07 01:52:41
Done.
|
| + left_content_->RemoveChildView(title_view_); |
| title_view_ = nullptr; |
| return; |
| } |
| @@ -528,7 +550,8 @@ void NotificationViewMD::CreateOrUpdateMessageView( |
| void NotificationViewMD::CreateOrUpdateCompactTitleMessageView( |
| const Notification& notification) { |
| if (notification.type() != NOTIFICATION_TYPE_PROGRESS) { |
| - left_content_->RemoveChildView(compact_title_message_view_); |
| + if (compact_title_message_view_ != nullptr) |
|
fukino
2017/07/06 12:44:11
ditto
tetsui
2017/07/07 01:52:41
Done.
|
| + left_content_->RemoveChildView(compact_title_message_view_); |
| compact_title_message_view_ = nullptr; |
| return; |
| } |
| @@ -545,7 +568,8 @@ void NotificationViewMD::CreateOrUpdateCompactTitleMessageView( |
| void NotificationViewMD::CreateOrUpdateProgressBarView( |
| const Notification& notification) { |
| if (notification.type() != NOTIFICATION_TYPE_PROGRESS) { |
| - left_content_->RemoveChildView(progress_bar_view_); |
| + if (progress_bar_view_ != nullptr) |
|
fukino
2017/07/06 12:44:10
ditto
tetsui
2017/07/07 01:52:41
Done.
|
| + left_content_->RemoveChildView(progress_bar_view_); |
| progress_bar_view_ = nullptr; |
| header_row_->ClearProgress(); |
| return; |
| @@ -593,7 +617,8 @@ void NotificationViewMD::CreateOrUpdateIconView( |
| const Notification& notification) { |
| if (notification.type() == NOTIFICATION_TYPE_PROGRESS || |
| notification.type() == NOTIFICATION_TYPE_MULTIPLE) { |
| - right_content_->RemoveChildView(icon_view_); |
| + if (icon_view_ != nullptr) |
|
fukino
2017/07/06 12:44:11
ditto
tetsui
2017/07/07 01:52:41
Done.
|
| + right_content_->RemoveChildView(icon_view_); |
| icon_view_ = nullptr; |
| return; |
| } |
| @@ -685,11 +710,14 @@ void NotificationViewMD::CreateOrUpdateActionButtonViews( |
| } |
| } |
| - if (new_buttons) { |
| - // TODO(fukino): Investigate if this Layout() is necessary. |
| - Layout(); |
| + // Inherit mouse hover state when action button views reset. |
| + // If the view is not expanded, there should be no hover state. |
| + if (new_buttons && expanded_) { |
| views::Widget* widget = GetWidget(); |
| - if (widget != NULL) { |
| + if (widget != nullptr) { |
|
fukino
2017/07/06 12:44:11
ditto
tetsui
2017/07/07 01:52:41
Done.
|
| + // This Layout() is needed because button should be in the right location |
| + // in the view hierarchy when SynthesizeMouseMoveEvent() is called. |
| + Layout(); |
| widget->SetSize(widget->GetContentsView()->GetPreferredSize()); |
| GetWidget()->SynthesizeMouseMoveEvent(); |
| } |