Commit 6ced321b authored by Noah Rose Ledesma's avatar Noah Rose Ledesma Committed by Commit Bot

GMC: Remove MediaNotificationService dependency from device picker UI

This change removes the need for communication between the audio device
picker UI and the MediaNotificationService. This communication is now
done via the UI's delegate class.

Bug: 1121367
Change-Id: Ie541b1a3c65a8035fbbdb736bd9c4b9a3cbb89c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2373270
Commit-Queue: Noah Rose Ledesma <noahrose@google.com>
Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801814}
parent 6f457768
......@@ -7,7 +7,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/util/ranges/algorithm.h"
#include "chrome/browser/ui/global_media_controls/media_notification_container_impl.h"
#include "chrome/browser/ui/global_media_controls/media_notification_service.h"
#include "chrome/browser/ui/views/global_media_controls/media_notification_audio_device_selector_view_delegate.h"
#include "chrome/grit/chromium_strings.h"
#include "components/vector_icons/vector_icons.h"
......@@ -165,7 +164,6 @@ void AudioDeviceEntryView::OnColorsChanged(const SkColor& foreground_color,
MediaNotificationAudioDeviceSelectorView::
MediaNotificationAudioDeviceSelectorView(
MediaNotificationAudioDeviceSelectorViewDelegate* delegate,
MediaNotificationService* service,
const std::string& current_device_id,
const SkColor& foreground_color,
const SkColor& background_color)
......@@ -218,7 +216,7 @@ MediaNotificationAudioDeviceSelectorView::
// Get a list of the connected audio output devices
audio_device_subscription_ =
service->RegisterAudioOutputDeviceDescriptionsCallback(
delegate->RegisterAudioOutputDeviceDescriptionsCallback(
base::BindRepeating(&MediaNotificationAudioDeviceSelectorView::
UpdateAvailableAudioDevices,
weak_ptr_factory_.GetWeakPtr()));
......
......@@ -16,14 +16,12 @@ class AudioDeviceEntryView;
} // anonymous namespace
class MediaNotificationAudioDeviceSelectorViewDelegate;
class MediaNotificationService;
class MediaNotificationAudioDeviceSelectorView : public views::View,
public views::ButtonListener {
public:
MediaNotificationAudioDeviceSelectorView(
MediaNotificationAudioDeviceSelectorViewDelegate* delegate,
MediaNotificationService* service,
const std::string& current_device_id,
const SkColor& foreground_color,
const SkColor& background_color);
......
......@@ -4,10 +4,17 @@
#ifndef CHROME_BROWSER_UI_VIEWS_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_AUDIO_DEVICE_SELECTOR_VIEW_DELEGATE_H_
#define CHROME_BROWSER_UI_VIEWS_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_AUDIO_DEVICE_SELECTOR_VIEW_DELEGATE_H_
#include "chrome/browser/ui/global_media_controls/media_notification_device_provider.h"
class MediaNotificationAudioDeviceSelectorViewDelegate {
public:
virtual void OnAudioSinkChosen(const std::string& sink_id) = 0;
virtual void OnAudioDeviceSelectorViewSizeChanged() = 0;
virtual std::unique_ptr<MediaNotificationDeviceProvider::
GetOutputDevicesCallbackList::Subscription>
RegisterAudioOutputDeviceDescriptionsCallback(
MediaNotificationDeviceProvider::GetOutputDevicesCallbackList::
CallbackType callback) = 0;
};
#endif // CHROME_BROWSER_UI_VIEWS_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_AUDIO_DEVICE_SELECTOR_VIEW_DELEGATE_H_
......@@ -125,8 +125,7 @@ MediaNotificationContainerImplView::MediaNotificationContainerImplView(
!is_cast_notification) {
auto audio_device_selector_view =
std::make_unique<MediaNotificationAudioDeviceSelectorView>(
this, service_, audio_sink_id_, foreground_color_,
background_color_);
this, audio_sink_id_, foreground_color_, background_color_);
audio_device_selector_view_ =
AddChildView(std::move(audio_device_selector_view));
view_->UpdateCornerRadius(message_center::kNotificationCornerRadius, 0);
......@@ -354,6 +353,16 @@ void MediaNotificationContainerImplView::
OnSizeChanged();
}
std::unique_ptr<
MediaNotificationDeviceProvider::GetOutputDevicesCallbackList::Subscription>
MediaNotificationContainerImplView::
RegisterAudioOutputDeviceDescriptionsCallback(
MediaNotificationDeviceProvider::GetOutputDevicesCallbackList::
CallbackType callback) {
return service_->RegisterAudioOutputDeviceDescriptionsCallback(
std::move(callback));
}
ui::Layer* MediaNotificationContainerImplView::GetSlideOutLayer() {
return swipeable_container_->layer();
}
......
......@@ -96,6 +96,11 @@ class MediaNotificationContainerImplView
// Called when an audio device has been selected for output.
void OnAudioSinkChosen(const std::string& sink_id) override;
void OnAudioDeviceSelectorViewSizeChanged() override;
std::unique_ptr<MediaNotificationDeviceProvider::
GetOutputDevicesCallbackList::Subscription>
RegisterAudioOutputDeviceDescriptionsCallback(
MediaNotificationDeviceProvider::GetOutputDevicesCallbackList::
CallbackType callback) override;
// Sets up the notification to be ready to display in an overlay instead of
// the dialog.
......
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