| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/custom_notification_view.h" | 5 #include "ui/message_center/views/custom_notification_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ui/base/ime/input_method.h" | 9 #include "ui/base/ime/input_method.h" |
| 10 #include "ui/base/ime/text_input_client.h" | 10 #include "ui/base/ime/text_input_client.h" |
| 11 #include "ui/base/ime/text_input_type.h" | 11 #include "ui/base/ime/text_input_type.h" |
| 12 #include "ui/gfx/geometry/size.h" | 12 #include "ui/gfx/geometry/size.h" |
| 13 #include "ui/message_center/message_center_style.h" | 13 #include "ui/message_center/message_center_style.h" |
| 14 #include "ui/message_center/views/message_center_controller.h" | 14 #include "ui/message_center/views/message_center_controller.h" |
| 15 #include "ui/views/background.h" | 15 #include "ui/views/background.h" |
| 16 #include "ui/views/controls/button/image_button.h" | 16 #include "ui/views/controls/button/image_button.h" |
| 17 #include "ui/views/controls/image_view.h" | 17 #include "ui/views/controls/image_view.h" |
| 18 #include "ui/views/painter.h" | 18 #include "ui/views/painter.h" |
| 19 | 19 |
| 20 namespace message_center { | 20 namespace message_center { |
| 21 | 21 |
| 22 // static |
| 23 const char CustomNotificationView::kViewClassName[] = "CustomNotificationView"; |
| 24 |
| 22 CustomNotificationView::CustomNotificationView( | 25 CustomNotificationView::CustomNotificationView( |
| 23 MessageCenterController* controller, | 26 MessageCenterController* controller, |
| 24 const Notification& notification) | 27 const Notification& notification) |
| 25 : MessageView(controller, notification) { | 28 : MessageView(controller, notification) { |
| 26 DCHECK_EQ(NOTIFICATION_TYPE_CUSTOM, notification.type()); | 29 DCHECK_EQ(NOTIFICATION_TYPE_CUSTOM, notification.type()); |
| 27 | 30 |
| 28 auto custom_content = notification.delegate()->CreateCustomContent(); | 31 auto custom_content = notification.delegate()->CreateCustomContent(); |
| 29 | 32 |
| 30 contents_view_ = custom_content->view.release(); | 33 contents_view_ = custom_content->view.release(); |
| 31 DCHECK(contents_view_); | 34 DCHECK(contents_view_); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 if (contents_view_delegate_) | 74 if (contents_view_delegate_) |
| 72 contents_view_delegate_->RequestFocusOnCloseButton(); | 75 contents_view_delegate_->RequestFocusOnCloseButton(); |
| 73 } | 76 } |
| 74 | 77 |
| 75 bool CustomNotificationView::IsPinned() const { | 78 bool CustomNotificationView::IsPinned() const { |
| 76 if (!contents_view_delegate_) | 79 if (!contents_view_delegate_) |
| 77 return false; | 80 return false; |
| 78 return contents_view_delegate_->IsPinned(); | 81 return contents_view_delegate_->IsPinned(); |
| 79 } | 82 } |
| 80 | 83 |
| 84 const char* CustomNotificationView::GetClassName() const { |
| 85 return kViewClassName; |
| 86 } |
| 87 |
| 81 void CustomNotificationView::UpdateControlButtonsVisibility() { | 88 void CustomNotificationView::UpdateControlButtonsVisibility() { |
| 82 if (contents_view_delegate_) | 89 if (contents_view_delegate_) |
| 83 contents_view_delegate_->UpdateControlButtonsVisibility(); | 90 contents_view_delegate_->UpdateControlButtonsVisibility(); |
| 84 } | 91 } |
| 85 | 92 |
| 86 gfx::Size CustomNotificationView::GetPreferredSize() const { | 93 gfx::Size CustomNotificationView::GetPreferredSize() const { |
| 87 const gfx::Insets insets = GetInsets(); | 94 const gfx::Insets insets = GetInsets(); |
| 88 const int contents_width = kNotificationWidth - insets.width(); | 95 const int contents_width = kNotificationWidth - insets.width(); |
| 89 const int contents_height = contents_view_->GetHeightForWidth(contents_width); | 96 const int contents_height = contents_view_->GetHeightForWidth(contents_width); |
| 90 return gfx::Size(kNotificationWidth, contents_height + insets.height()); | 97 return gfx::Size(kNotificationWidth, contents_height + insets.height()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 150 } |
| 144 | 151 |
| 145 void CustomNotificationView::ChildPreferredSizeChanged(View* child) { | 152 void CustomNotificationView::ChildPreferredSizeChanged(View* child) { |
| 146 // Notify MessageCenterController when the custom content changes size, | 153 // Notify MessageCenterController when the custom content changes size, |
| 147 // as it may need to relayout. | 154 // as it may need to relayout. |
| 148 if (controller()) | 155 if (controller()) |
| 149 controller()->UpdateNotificationSize(notification_id()); | 156 controller()->UpdateNotificationSize(notification_id()); |
| 150 } | 157 } |
| 151 | 158 |
| 152 } // namespace message_center | 159 } // namespace message_center |
| OLD | NEW |