Chromium Code Reviews| 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 b94e7227364fc4e08c9259a98ee2d3b2a5f8a983..72701394c5f5d89c907413d6b462c5c13ec0ee94 100644 |
| --- a/ui/message_center/views/custom_notification_view.cc |
| +++ b/ui/message_center/views/custom_notification_view.cc |
| @@ -11,6 +11,7 @@ |
| #include "ui/views/background.h" |
| #include "ui/views/controls/button/image_button.h" |
| #include "ui/views/controls/image_view.h" |
| +#include "ui/views/painter.h" |
| namespace message_center { |
| @@ -35,10 +36,21 @@ CustomNotificationView::CustomNotificationView( |
| } |
| AddChildView(small_image()); |
| + |
| + focus_painter_ = views::Painter::CreateSolidFocusPainter( |
| + kFocusBorderColor, gfx::Insets(0, 1, 3, 2)); |
| } |
| CustomNotificationView::~CustomNotificationView() {} |
| +void CustomNotificationView::OnContentFocused() { |
| + SchedulePaint(); |
| +} |
| + |
| +void CustomNotificationView::OnContentBlured() { |
| + SchedulePaint(); |
| +} |
| + |
| void CustomNotificationView::SetDrawBackgroundAsActive(bool active) { |
| // Do nothing if |contents_view_| has a background. |
| if (contents_view_->background()) |
| @@ -81,6 +93,34 @@ void CustomNotificationView::Layout() { |
| MessageView::Layout(); |
| contents_view_->SetBoundsRect(GetContentsBounds()); |
| + |
| + // If the content view claims focus, defer focus handling to the content view. |
| + if (contents_view_->IsFocusable()) { |
|
yoshiki
2017/01/05 07:12:39
nit: no braces for one line block.
yhanada
2017/01/05 13:12:44
Done.
|
| + SetFocusBehavior(FocusBehavior::NEVER); |
| + } |
| +} |
| + |
| +bool CustomNotificationView::HasFocus() const { |
| + // In case that focus handling is defered to the content view, asking the |
| + // content view about focus. |
| + if (contents_view_ && contents_view_->IsFocusable()) |
| + return contents_view_->HasFocus(); |
| + else |
| + return MessageView::HasFocus(); |
| +} |
| + |
| +void CustomNotificationView::RequestFocus() { |
| + if (contents_view_ && contents_view_->IsFocusable()) |
| + contents_view_->RequestFocus(); |
| + else |
| + MessageView::RequestFocus(); |
| +} |
| + |
| +void CustomNotificationView::OnPaint(gfx::Canvas* canvas) { |
| + MessageView::OnPaint(canvas); |
| + if (contents_view_ && contents_view_->IsFocusable()) |
| + views::Painter::PaintFocusPainter(contents_view_, canvas, |
| + focus_painter_.get()); |
| } |
| } // namespace message_center |