Commit 943f66a0 authored by Jazz Xu's avatar Jazz Xu Committed by Commit Bot

CrOS GMC: Allow focus to media dialog and quick setting controls.

This CL fix the issue where user cannot use keyboard to access
global media controls dialog and detailed controls in quick settings.

Change-Id: I909e00e4e55ad0460886eb3ea3e231eaf0d79195
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2503399Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Commit-Queue: Jazz Xu <jazzhsu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821678}
parent 63247c79
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ash/system/media/media_tray.h" #include "ash/system/media/media_tray.h"
#include "ash/focus_cycler.h"
#include "ash/public/cpp/ash_pref_names.h" #include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/media_notification_provider.h" #include "ash/public/cpp/media_notification_provider.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
...@@ -289,6 +290,13 @@ void MediaTray::ShowBubble(bool show_by_click) { ...@@ -289,6 +290,13 @@ void MediaTray::ShowBubble(bool show_by_click) {
false /*is_persistent*/); false /*is_persistent*/);
SetIsActive(true); SetIsActive(true);
// Only focus the widget if it's opened by the keyboard.
if (!show_by_click) {
views::Widget* widget = bubble_->GetBubbleWidget();
widget->widget_delegate()->SetCanActivate(true);
Shell::Get()->focus_cycler()->FocusWidget(widget);
}
base::UmaHistogramBoolean("Media.CrosGlobalMediaControls.RepeatUsageOnShelf", base::UmaHistogramBoolean("Media.CrosGlobalMediaControls.RepeatUsageOnShelf",
bubble_has_shown_); bubble_has_shown_);
bubble_has_shown_ = true; bubble_has_shown_ = true;
......
...@@ -283,6 +283,11 @@ TEST_F(MediaTrayTest, PinToShelfDefaultBehavior) { ...@@ -283,6 +283,11 @@ TEST_F(MediaTrayTest, PinToShelfDefaultBehavior) {
EXPECT_TRUE(MediaTray::IsPinnedToShelf()); EXPECT_TRUE(MediaTray::IsPinnedToShelf());
} }
TEST_F(MediaTrayTest, BubbleGetsFocusWhenOpenWithKeyboard) {
media_tray()->ShowBubble(false /* show_by_click */);
EXPECT_TRUE(GetBubbleWrapper()->GetBubbleWidget()->IsActive());
}
TEST_F(MediaTrayTest, DialogAnchor) { TEST_F(MediaTrayTest, DialogAnchor) {
InsertMockTray(); InsertMockTray();
......
...@@ -105,6 +105,9 @@ UnifiedMediaControlsView::MediaActionButton::MediaActionButton( ...@@ -105,6 +105,9 @@ UnifiedMediaControlsView::MediaActionButton::MediaActionButton(
TrayPopupUtils::ConfigureTrayPopupButton(this); TrayPopupUtils::ConfigureTrayPopupButton(this);
views::InstallCircleHighlightPathGenerator(this); views::InstallCircleHighlightPathGenerator(this);
focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
} }
void UnifiedMediaControlsView::MediaActionButton::SetAction( void UnifiedMediaControlsView::MediaActionButton::SetAction(
...@@ -147,7 +150,9 @@ UnifiedMediaControlsView::MediaActionButton::CreateInkDropRipple() const { ...@@ -147,7 +150,9 @@ UnifiedMediaControlsView::MediaActionButton::CreateInkDropRipple() const {
UnifiedMediaControlsView::UnifiedMediaControlsView( UnifiedMediaControlsView::UnifiedMediaControlsView(
UnifiedMediaControlsController* controller) UnifiedMediaControlsController* controller)
: views::Button(this), controller_(controller) { : views::Button(this), controller_(controller) {
SetFocusBehavior(views::View::FocusBehavior::ACCESSIBLE_ONLY); SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
focus_ring()->SetColor(AshColorProvider::Get()->GetControlsLayerColor(
AshColorProvider::ControlsLayerType::kFocusRingColor));
SetBackground(views::CreateRoundedRectBackground( SetBackground(views::CreateRoundedRectBackground(
AshColorProvider::Get()->GetControlsLayerColor( AshColorProvider::Get()->GetControlsLayerColor(
......
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