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

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: address the comment Created 3 years, 11 months 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..91b894673e90f13db892db6b1a47cf40f8714a49 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,33 @@ 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())
+ 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