Commit e20e15dd authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Focus first notification with ChromeVox shortcut

When Alt+Shift+N is used to open the message center, the first
notification will be focused with this change.
This fix is only available when the "Enable Message Center Redesign"
flag is enabled.

Bug: 1009485
Change-Id: I3509725aa76ad10d2a711c7cd923af4adc6ba31c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1859647Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarTim Song <tengs@chromium.org>
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705748}
parent e5c558f2
...@@ -596,7 +596,7 @@ void HandleTakeScreenshot() { ...@@ -596,7 +596,7 @@ void HandleTakeScreenshot() {
Shell::Get()->screenshot_controller()->TakeScreenshotForAllRootWindows(); Shell::Get()->screenshot_controller()->TakeScreenshotForAllRootWindows();
} }
void HandleToggleSystemTrayBubbleInternal() { void HandleToggleSystemTrayBubbleInternal(bool focus_message_center) {
aura::Window* target_root = Shell::GetRootWindowForNewWindows(); aura::Window* target_root = Shell::GetRootWindowForNewWindows();
UnifiedSystemTray* tray = RootWindowController::ForWindow(target_root) UnifiedSystemTray* tray = RootWindowController::ForWindow(target_root)
->GetStatusAreaWidget() ->GetStatusAreaWidget()
...@@ -606,17 +606,20 @@ void HandleToggleSystemTrayBubbleInternal() { ...@@ -606,17 +606,20 @@ void HandleToggleSystemTrayBubbleInternal() {
} else { } else {
tray->ShowBubble(false /* show_by_click */); tray->ShowBubble(false /* show_by_click */);
tray->ActivateBubble(); tray->ActivateBubble();
if (focus_message_center)
tray->FocusFirstNotification();
} }
} }
void HandleToggleSystemTrayBubble() { void HandleToggleSystemTrayBubble() {
base::RecordAction(UserMetricsAction("Accel_Toggle_System_Tray_Bubble")); base::RecordAction(UserMetricsAction("Accel_Toggle_System_Tray_Bubble"));
HandleToggleSystemTrayBubbleInternal(); HandleToggleSystemTrayBubbleInternal(false /*focus_message_center*/);
} }
void HandleToggleMessageCenterBubble() { void HandleToggleMessageCenterBubble() {
base::RecordAction(UserMetricsAction("Accel_Toggle_Message_Center_Bubble")); base::RecordAction(UserMetricsAction("Accel_Toggle_Message_Center_Bubble"));
HandleToggleSystemTrayBubbleInternal(); HandleToggleSystemTrayBubbleInternal(true /*focus_message_center*/);
} }
void HandleShowTaskManager() { void HandleShowTaskManager() {
......
...@@ -93,6 +93,10 @@ bool UnifiedMessageCenterBubble::FocusOut(bool reverse) { ...@@ -93,6 +93,10 @@ bool UnifiedMessageCenterBubble::FocusOut(bool reverse) {
return tray_->FocusQuickSettings(reverse); return tray_->FocusQuickSettings(reverse);
} }
void UnifiedMessageCenterBubble::FocusFirstNotification() {
message_center_view_->GetFocusManager()->AdvanceFocus(false /*reverse*/);
}
bool UnifiedMessageCenterBubble::IsMessageCenterVisible() { bool UnifiedMessageCenterBubble::IsMessageCenterVisible() {
return message_center_view_->GetVisible(); return message_center_view_->GetVisible();
} }
......
...@@ -38,6 +38,9 @@ class ASH_EXPORT UnifiedMessageCenterBubble : public TrayBubbleBase, ...@@ -38,6 +38,9 @@ class ASH_EXPORT UnifiedMessageCenterBubble : public TrayBubbleBase,
// Relinquish focus and transfer it to the quick settings widget. // Relinquish focus and transfer it to the quick settings widget.
bool FocusOut(bool reverse); bool FocusOut(bool reverse);
// Move focus to the first notification.
void FocusFirstNotification();
// Returns true if notifications are shown. // Returns true if notifications are shown.
bool IsMessageCenterVisible(); bool IsMessageCenterVisible();
......
...@@ -217,6 +217,14 @@ void UnifiedSystemTray::SetTrayBubbleHeight(int height) { ...@@ -217,6 +217,14 @@ void UnifiedSystemTray::SetTrayBubbleHeight(int height) {
ui_delegate_->SetTrayBubbleHeight(height); ui_delegate_->SetTrayBubbleHeight(height);
} }
void UnifiedSystemTray::FocusFirstNotification() {
if (!features::IsUnifiedMessageCenterRefactorEnabled())
return;
FocusMessageCenter(false /*reverse*/);
message_center_bubble()->FocusFirstNotification();
}
bool UnifiedSystemTray::FocusMessageCenter(bool reverse) { bool UnifiedSystemTray::FocusMessageCenter(bool reverse) {
if (!IsMessageCenterBubbleShown()) if (!IsMessageCenterBubbleShown())
return false; return false;
......
...@@ -100,6 +100,9 @@ class ASH_EXPORT UnifiedSystemTray : public TrayBackgroundView, ...@@ -100,6 +100,9 @@ class ASH_EXPORT UnifiedSystemTray : public TrayBackgroundView,
// bubble is shown. // bubble is shown.
void SetTrayBubbleHeight(int height); void SetTrayBubbleHeight(int height);
// Focus the first notification in the message center.
void FocusFirstNotification();
bool FocusMessageCenter(bool reverse); bool FocusMessageCenter(bool reverse);
bool FocusQuickSettings(bool reverse); bool FocusQuickSettings(bool reverse);
......
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