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

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

Issue 2581703003: Defer focus handling to the content if it claims to have focus. (Closed)
Patch Set: 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
« no previous file with comments | « ui/message_center/views/custom_notification_view.h ('k') | ui/message_center/views/message_center_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/message_center/views/custom_notification_view.h ('k') | ui/message_center/views/message_center_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698