Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Unified Diff: ui/message_center/views/custom_notification_view.cc

Issue 2547433002: Transfer responsibility for providing a close button for a notification to each implementation of M… (Closed)
Patch Set: WrapUnique -> MakeUnique Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/message_center/views/custom_notification_view.cc
diff --git a/ui/message_center/views/custom_notification_view.cc b/ui/message_center/views/custom_notification_view.cc
index b3528679e22a823ac5110b4380df567cd9119dce..b94e7227364fc4e08c9259a98ee2d3b2a5f8a983 100644
--- a/ui/message_center/views/custom_notification_view.cc
+++ b/ui/message_center/views/custom_notification_view.cc
@@ -20,18 +20,21 @@ CustomNotificationView::CustomNotificationView(
: MessageView(controller, notification) {
DCHECK_EQ(NOTIFICATION_TYPE_CUSTOM, notification.type());
- contents_view_ = notification.delegate()->CreateCustomContent().release();
+ auto custom_content = notification.delegate()->CreateCustomContent();
+
+ contents_view_ = custom_content->view.release();
DCHECK(contents_view_);
AddChildView(contents_view_);
+ contents_view_delegate_ = std::move(custom_content->delegate);
+ DCHECK(contents_view_delegate_);
+
if (contents_view_->background()) {
background_view()->background()->SetNativeControlColor(
contents_view_->background()->get_color());
}
AddChildView(small_image());
-
- CreateOrUpdateCloseButtonView(notification);
}
CustomNotificationView::~CustomNotificationView() {}
@@ -44,6 +47,23 @@ void CustomNotificationView::SetDrawBackgroundAsActive(bool active) {
MessageView::SetDrawBackgroundAsActive(active);
}
+bool CustomNotificationView::IsCloseButtonFocused() const {
+ if (!contents_view_delegate_)
+ return false;
+ return contents_view_delegate_->IsCloseButtonFocused();
+}
+
+void CustomNotificationView::RequestFocusOnCloseButton() {
+ if (contents_view_delegate_)
+ contents_view_delegate_->RequestFocusOnCloseButton();
+}
+
+bool CustomNotificationView::IsPinned() const {
+ if (!contents_view_delegate_)
+ return false;
+ return contents_view_delegate_->IsPinned();
+}
+
gfx::Size CustomNotificationView::GetPreferredSize() const {
const gfx::Insets insets = GetInsets();
const int contents_width = kNotificationWidth - insets.width();
« no previous file with comments | « ui/message_center/views/custom_notification_view.h ('k') | ui/message_center/views/custom_notification_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698