Commit eda23cfb authored by Abigail Klein's avatar Abigail Klein Committed by Chromium LUCI CQ

[Live Caption] Show Live Caption toggle in bubble volume slider only.

Only show Live Caption toggle in volume slider in bubble, not in
status tray. Also, enable this behavior for the ChromeOS system-
wide launch.

Bug: 1055150
Change-Id: Ibdcee58a86355890154fd35d700862d379830033
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2619944
Commit-Queue: Abigail Klein <abigailbklein@google.com>
Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842701}
parent 5ddf6a5a
......@@ -17,15 +17,16 @@ using chromeos::CrasAudioHandler;
namespace ash {
UnifiedVolumeSliderController::UnifiedVolumeSliderController(
UnifiedVolumeSliderController::Delegate* delegate)
: delegate_(delegate) {
UnifiedVolumeSliderController::Delegate* delegate,
bool in_bubble)
: delegate_(delegate), in_bubble_(in_bubble) {
DCHECK(delegate);
}
UnifiedVolumeSliderController::~UnifiedVolumeSliderController() = default;
views::View* UnifiedVolumeSliderController::CreateView() {
return new UnifiedVolumeView(this, delegate_);
return new UnifiedVolumeView(this, delegate_, in_bubble_);
}
void UnifiedVolumeSliderController::SliderValueChanged(
......
......@@ -18,7 +18,7 @@ class UnifiedVolumeSliderController : public UnifiedSliderListener {
virtual void OnAudioSettingsButtonClicked() = 0;
};
explicit UnifiedVolumeSliderController(Delegate* delegate);
UnifiedVolumeSliderController(Delegate* delegate, bool in_bubble);
~UnifiedVolumeSliderController() override;
// UnifiedSliderListener:
......@@ -33,6 +33,9 @@ class UnifiedVolumeSliderController : public UnifiedSliderListener {
private:
Delegate* const delegate_;
// Whether the volume slider is in the bubble, as opposed to the system tray.
const bool in_bubble_;
DISALLOW_COPY_AND_ASSIGN(UnifiedVolumeSliderController);
};
......
......@@ -228,13 +228,15 @@ class MoreButton : public UnifiedVolumeViewButton<views::Button> {
UnifiedVolumeView::UnifiedVolumeView(
UnifiedVolumeSliderController* controller,
UnifiedVolumeSliderController::Delegate* delegate)
UnifiedVolumeSliderController::Delegate* delegate,
bool in_bubble)
: UnifiedSliderView(base::BindRepeating(
&UnifiedVolumeSliderController::SliderButtonPressed,
base::Unretained(controller)),
controller,
kSystemMenuVolumeHighIcon,
IDS_ASH_STATUS_TRAY_VOLUME_SLIDER_LABEL),
in_bubble_(in_bubble),
live_caption_button_(new LiveCaptionButton(
base::BindRepeating(&UnifiedVolumeView::OnLiveCaptionButtonPressed,
base::Unretained(this)))),
......@@ -277,7 +279,8 @@ void UnifiedVolumeView::Update(bool by_user) {
IDS_ASH_STATUS_TRAY_VOLUME, state_tooltip_text));
live_caption_button_->SetVisible(
base::FeatureList::IsEnabled(media::kLiveCaption));
in_bubble_ &&
base::FeatureList::IsEnabled(media::kLiveCaptionSystemWideOnChromeOS));
live_caption_button_->SetToggled(
Shell::Get()->session_controller()->GetActivePrefService()->GetBoolean(
prefs::kLiveCaptionEnabled));
......
......@@ -16,7 +16,8 @@ class UnifiedVolumeView : public UnifiedSliderView,
public chromeos::CrasAudioHandler::AudioObserver {
public:
UnifiedVolumeView(UnifiedVolumeSliderController* controller,
UnifiedVolumeSliderController::Delegate* delegate);
UnifiedVolumeSliderController::Delegate* delegate,
bool in_bubble);
~UnifiedVolumeView() override;
// views::View:
......@@ -38,6 +39,9 @@ class UnifiedVolumeView : public UnifiedSliderView,
// views::Button::PressedCallback
void OnLiveCaptionButtonPressed();
// Whether the volume slider is in the bubble, as opposed to the system tray.
const bool in_bubble_;
views::ToggleImageButton* const live_caption_button_;
views::Button* const more_button_;
......
......@@ -204,8 +204,8 @@ void UnifiedSliderBubbleController::ShowBubble(SliderType slider_type) {
void UnifiedSliderBubbleController::CreateSliderController() {
switch (slider_type_) {
case SLIDER_TYPE_VOLUME:
slider_controller_ =
std::make_unique<UnifiedVolumeSliderController>(this);
slider_controller_ = std::make_unique<UnifiedVolumeSliderController>(
this, true /* in_bubble */);
return;
case SLIDER_TYPE_DISPLAY_BRIGHTNESS:
slider_controller_ =
......
......@@ -128,8 +128,8 @@ UnifiedSystemTrayView* UnifiedSystemTrayController::CreateView() {
media_controls_controller_->CreateView());
}
volume_slider_controller_ =
std::make_unique<UnifiedVolumeSliderController>(this);
volume_slider_controller_ = std::make_unique<UnifiedVolumeSliderController>(
this, false /* in_bubble */);
unified_view_->AddSliderView(volume_slider_controller_->CreateView());
brightness_slider_controller_ =
......
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