Commit 0e9331a2 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Unified: Fix tab focus of notification controls.

Tab focusing to notification control buttons was broken in
UnifiedSystemTray because UnifiedMessageCenterView did not implement the
same OnDidChangeFocus logic as MesageCenterView did.

TEST=manual
BUG=862506

Change-Id: Ide2d9e170ecefcc87db2d43b6d8d3b1042492374
Reviewed-on: https://chromium-review.googlesource.com/1132907Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575940}
parent 18490bcb
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "ui/message_center/message_center_types.h" #include "ui/message_center/message_center_types.h"
#include "ui/message_center/views/message_view.h" #include "ui/message_center/views/message_view.h"
#include "ui/message_center/views/message_view_factory.h" #include "ui/message_center/views/message_view_factory.h"
#include "ui/message_center/views/notification_control_buttons_view.h"
#include "ui/views/controls/scroll_view.h" #include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/scrollbar/overlay_scroll_bar.h" #include "ui/views/controls/scrollbar/overlay_scroll_bar.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
...@@ -87,6 +88,14 @@ UnifiedMessageCenterView::UnifiedMessageCenterView( ...@@ -87,6 +88,14 @@ UnifiedMessageCenterView::UnifiedMessageCenterView(
UnifiedMessageCenterView::~UnifiedMessageCenterView() { UnifiedMessageCenterView::~UnifiedMessageCenterView() {
message_center_->RemoveObserver(this); message_center_->RemoveObserver(this);
if (focus_manager_)
focus_manager_->RemoveFocusChangeListener(this);
}
void UnifiedMessageCenterView::Init() {
focus_manager_ = GetFocusManager();
if (focus_manager_)
focus_manager_->AddFocusChangeListener(this);
} }
void UnifiedMessageCenterView::SetMaxHeight(int max_height) { void UnifiedMessageCenterView::SetMaxHeight(int max_height) {
...@@ -174,6 +183,29 @@ void UnifiedMessageCenterView::ButtonPressed(views::Button* sender, ...@@ -174,6 +183,29 @@ void UnifiedMessageCenterView::ButtonPressed(views::Button* sender,
tray_controller_->HandleClearAllAction(); tray_controller_->HandleClearAllAction();
} }
void UnifiedMessageCenterView::OnWillChangeFocus(views::View* before,
views::View* now) {}
void UnifiedMessageCenterView::OnDidChangeFocus(views::View* before,
views::View* now) {
// Update the button visibility when the focus state is changed.
size_t count = message_list_view_->GetNotificationCount();
for (size_t i = 0; i < count; ++i) {
MessageView* view = message_list_view_->GetNotificationAt(i);
// ControlButtonsView is not in the same view hierarchy on ARC++
// notifications, so check it separately.
if (view->Contains(before) || view->Contains(now) ||
(view->GetControlButtonsView() &&
(view->GetControlButtonsView()->Contains(before) ||
view->GetControlButtonsView()->Contains(now)))) {
view->UpdateControlButtonsVisibility();
}
// Ensure that a notification is not removed or added during iteration.
DCHECK_EQ(count, message_list_view_->GetNotificationCount());
}
}
void UnifiedMessageCenterView::OnAllNotificationsCleared() { void UnifiedMessageCenterView::OnAllNotificationsCleared() {
tray_controller_->OnClearAllAnimationEnded(); tray_controller_->OnClearAllAnimationEnded();
} }
......
...@@ -22,6 +22,12 @@ class MessageCenter; ...@@ -22,6 +22,12 @@ class MessageCenter;
} // namespace message_center } // namespace message_center
namespace views {
class FocusManager;
} // namespace views
namespace ash { namespace ash {
class UnifiedSystemTrayController; class UnifiedSystemTrayController;
...@@ -33,12 +39,16 @@ class ASH_EXPORT UnifiedMessageCenterView ...@@ -33,12 +39,16 @@ class ASH_EXPORT UnifiedMessageCenterView
public message_center::MessageCenterObserver, public message_center::MessageCenterObserver,
public views::ViewObserver, public views::ViewObserver,
public views::ButtonListener, public views::ButtonListener,
public views::FocusChangeListener,
public MessageListView::Observer { public MessageListView::Observer {
public: public:
UnifiedMessageCenterView(UnifiedSystemTrayController* tray_controller, UnifiedMessageCenterView(UnifiedSystemTrayController* tray_controller,
message_center::MessageCenter* message_center); message_center::MessageCenter* message_center);
~UnifiedMessageCenterView() override; ~UnifiedMessageCenterView() override;
// Initialize focus listener.
void Init();
// Set the maximum height that the view can take. // Set the maximum height that the view can take.
void SetMaxHeight(int max_height); void SetMaxHeight(int max_height);
...@@ -66,6 +76,10 @@ class ASH_EXPORT UnifiedMessageCenterView ...@@ -66,6 +76,10 @@ class ASH_EXPORT UnifiedMessageCenterView
// views::ButtonListener: // views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// views::FocusChangeListener:
void OnWillChangeFocus(views::View* before, views::View* now) override;
void OnDidChangeFocus(views::View* before, views::View* now) override;
// MessageListView::Observer: // MessageListView::Observer:
void OnAllNotificationsCleared() override; void OnAllNotificationsCleared() override;
...@@ -84,6 +98,8 @@ class ASH_EXPORT UnifiedMessageCenterView ...@@ -84,6 +98,8 @@ class ASH_EXPORT UnifiedMessageCenterView
views::ScrollView* const scroller_; views::ScrollView* const scroller_;
MessageListView* const message_list_view_; MessageListView* const message_list_view_;
views::FocusManager* focus_manager_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(UnifiedMessageCenterView); DISALLOW_COPY_AND_ASSIGN(UnifiedMessageCenterView);
}; };
......
...@@ -105,6 +105,8 @@ UnifiedSystemTrayBubble::UnifiedSystemTrayBubble(UnifiedSystemTray* tray, ...@@ -105,6 +105,8 @@ UnifiedSystemTrayBubble::UnifiedSystemTrayBubble(UnifiedSystemTray* tray,
TrayBackgroundView::InitializeBubbleAnimations(bubble_widget_); TrayBackgroundView::InitializeBubbleAnimations(bubble_widget_);
bubble_view_->InitializeAndShowBubble(); bubble_view_->InitializeAndShowBubble();
unified_view_->Init();
if (app_list::features::IsBackgroundBlurEnabled()) { if (app_list::features::IsBackgroundBlurEnabled()) {
bubble_widget_->client_view()->layer()->SetBackgroundBlur( bubble_widget_->client_view()->layer()->SetBackgroundBlur(
kUnifiedMenuBackgroundBlur); kUnifiedMenuBackgroundBlur);
......
...@@ -175,6 +175,10 @@ UnifiedSystemTrayView::UnifiedSystemTrayView( ...@@ -175,6 +175,10 @@ UnifiedSystemTrayView::UnifiedSystemTrayView(
UnifiedSystemTrayView::~UnifiedSystemTrayView() = default; UnifiedSystemTrayView::~UnifiedSystemTrayView() = default;
void UnifiedSystemTrayView::Init() {
message_center_view_->Init();
}
void UnifiedSystemTrayView::SetMaxHeight(int max_height) { void UnifiedSystemTrayView::SetMaxHeight(int max_height) {
message_center_view_->SetMaxHeight(max_height); message_center_view_->SetMaxHeight(max_height);
} }
......
...@@ -52,6 +52,9 @@ class ASH_EXPORT UnifiedSystemTrayView : public views::View { ...@@ -52,6 +52,9 @@ class ASH_EXPORT UnifiedSystemTrayView : public views::View {
bool initially_expanded); bool initially_expanded);
~UnifiedSystemTrayView() override; ~UnifiedSystemTrayView() override;
// Initialize after the view is attached to the widget.
void Init();
// Set the maximum height that the view can take. // Set the maximum height that the view can take.
void SetMaxHeight(int max_height); void SetMaxHeight(int max_height);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment