Commit cb9a2f55 authored by Tommy Steimel's avatar Tommy Steimel Committed by Commit Bot

GMC: Refactor to have profile-level session tracking

This CL pulls most of the logic out of MediaToolbarButtonController and
puts it into MediaNotificationService which lives as a profile-keyed
service. This allows the media session tracking to be shared between
windows, and makes the MediaToolbarButtonController make more sense.

Bug: 1021369
Change-Id: I03f302cb8b80099df011fa04e47df389c2d5d8f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1898278Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarTakumi Fujimoto <takumif@chromium.org>
Commit-Queue: Tommy Steimel <steimel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712761}
parent d1ed7671
......@@ -940,6 +940,11 @@ jumbo_static_library("ui") {
"global_media_controls/media_dialog_delegate.h",
"global_media_controls/media_notification_container_impl.h",
"global_media_controls/media_notification_container_observer.h",
"global_media_controls/media_notification_service.cc",
"global_media_controls/media_notification_service.h",
"global_media_controls/media_notification_service_factory.cc",
"global_media_controls/media_notification_service_factory.h",
"global_media_controls/media_notification_service_observer.h",
"global_media_controls/media_toolbar_button_controller.cc",
"global_media_controls/media_toolbar_button_controller.h",
"global_media_controls/media_toolbar_button_controller_delegate.cc",
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_SERVICE_H_
#define CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_SERVICE_H_
#include <map>
#include <string>
#include <vector>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/global_media_controls/cast_media_notification_provider.h"
#include "chrome/browser/ui/global_media_controls/media_notification_container_observer.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/media_message_center/media_notification_controller.h"
#include "content/public/browser/web_contents_observer.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/media_session/public/mojom/audio_focus.mojom.h"
#include "services/media_session/public/mojom/media_controller.mojom.h"
namespace content {
class WebContents;
} // namespace content
namespace media_message_center {
class MediaSessionNotificationItem;
} // namespace media_message_center
namespace service_manager {
class Connector;
} // namespace service_manager
class MediaDialogDelegate;
class MediaNotificationContainerImpl;
class MediaNotificationServiceObserver;
class MediaNotificationService
: public KeyedService,
public media_session::mojom::AudioFocusObserver,
public media_message_center::MediaNotificationController,
public MediaNotificationContainerObserver {
public:
MediaNotificationService(Profile* profile,
service_manager::Connector* connector);
MediaNotificationService(const MediaNotificationService&) = delete;
MediaNotificationService& operator=(const MediaNotificationService&) = delete;
~MediaNotificationService() override;
void AddObserver(MediaNotificationServiceObserver* observer);
void RemoveObserver(MediaNotificationServiceObserver* observer);
// media_session::mojom::AudioFocusObserver implementation.
void OnFocusGained(
media_session::mojom::AudioFocusRequestStatePtr session) override;
void OnFocusLost(
media_session::mojom::AudioFocusRequestStatePtr session) override;
// media_message_center::MediaNotificationController implementation.
void ShowNotification(const std::string& id) override;
void HideNotification(const std::string& id) override;
void RemoveItem(const std::string& id) override;
scoped_refptr<base::SequencedTaskRunner> GetTaskRunner() const override;
void LogMediaSessionActionButtonPressed(const std::string& id) override;
// MediaNotificationContainerObserver implementation.
void OnContainerExpanded(bool expanded) override {}
void OnContainerMetadataChanged() override {}
void OnContainerClicked(const std::string& id) override;
void OnContainerDismissed(const std::string& id) override;
void OnContainerDestroyed(const std::string& id) override;
void OnCastNotificationsChanged();
void SetDialogDelegate(MediaDialogDelegate* delegate);
// True if there are active non-frozen media session notifications or active
// cast notifications.
bool HasActiveNotifications() const;
// True if there are active frozen media session notifications.
bool HasFrozenNotifications() const;
// True if there is an open MediaDialogView associated with this service.
bool HasOpenDialog() const;
private:
friend class MediaNotificationServiceTest;
friend class MediaToolbarButtonControllerTest;
class Session : public content::WebContentsObserver {
public:
Session(MediaNotificationService* owner,
const std::string& id,
std::unique_ptr<media_message_center::MediaSessionNotificationItem>
item,
content::WebContents* web_contents);
Session(const Session&) = delete;
Session& operator=(const Session&) = delete;
~Session() override;
// content::WebContentsObserver implementation.
void WebContentsDestroyed() override;
media_message_center::MediaSessionNotificationItem* item() {
return item_.get();
}
private:
MediaNotificationService* owner_;
const std::string id_;
std::unique_ptr<media_message_center::MediaSessionNotificationItem> item_;
};
void OnReceivedAudioFocusRequests(
std::vector<media_session::mojom::AudioFocusRequestStatePtr> sessions);
base::WeakPtr<media_message_center::MediaNotificationItem>
GetNotificationItem(const std::string& id);
service_manager::Connector* const connector_;
MediaDialogDelegate* dialog_delegate_ = nullptr;
// Used to track whether there are any active controllable media sessions. If
// not, then there's nothing to show in the dialog and we can hide the toolbar
// icon.
std::unordered_set<std::string> active_controllable_session_ids_;
// Tracks the sessions that are currently frozen. If there are only frozen
// sessions, we will disable the toolbar icon and wait to hide it.
std::unordered_set<std::string> frozen_session_ids_;
// Stores a Session for each media session keyed by its |request_id| in string
// format.
std::map<std::string, Session> sessions_;
// A map of all containers we're currently observing.
std::map<std::string, MediaNotificationContainerImpl*> observed_containers_;
// Connections with the media session service to listen for audio focus
// updates and control media sessions.
mojo::Remote<media_session::mojom::AudioFocusManager> audio_focus_remote_;
mojo::Remote<media_session::mojom::MediaControllerManager>
controller_manager_remote_;
mojo::Receiver<media_session::mojom::AudioFocusObserver>
audio_focus_observer_receiver_{this};
std::unique_ptr<CastMediaNotificationProvider> cast_notification_provider_;
base::ObserverList<MediaNotificationServiceObserver> observers_;
base::WeakPtrFactory<MediaNotificationService> weak_ptr_factory_{this};
};
#endif // CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_SERVICE_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/global_media_controls/media_notification_service_factory.h"
#include <memory>
#include "base/memory/singleton.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/global_media_controls/media_notification_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "content/public/browser/system_connector.h"
MediaNotificationServiceFactory::MediaNotificationServiceFactory()
: BrowserContextKeyedServiceFactory(
"MediaNotificationService",
BrowserContextDependencyManager::GetInstance()) {}
MediaNotificationServiceFactory::~MediaNotificationServiceFactory() {}
// static
MediaNotificationServiceFactory*
MediaNotificationServiceFactory::GetInstance() {
return base::Singleton<MediaNotificationServiceFactory>::get();
}
// static
MediaNotificationService* MediaNotificationServiceFactory::GetForProfile(
Profile* profile) {
return static_cast<MediaNotificationService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
KeyedService* MediaNotificationServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
return new MediaNotificationService(Profile::FromBrowserContext(context),
content::GetSystemConnector());
}
content::BrowserContext*
MediaNotificationServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return chrome::GetBrowserContextOwnInstanceInIncognito(context);
}
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_SERVICE_FACTORY_H_
#define CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_SERVICE_FACTORY_H_
#include "base/macros.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
class Profile;
namespace base {
template <typename T>
struct DefaultSingletonTraits;
} // namespace base
namespace content {
class BrowserContext;
} // namespace content
class MediaNotificationService;
class MediaNotificationServiceFactory
: public BrowserContextKeyedServiceFactory {
public:
MediaNotificationServiceFactory(const MediaNotificationServiceFactory&) =
delete;
MediaNotificationServiceFactory& operator=(
const MediaNotificationServiceFactory&) = delete;
static MediaNotificationServiceFactory* GetInstance();
static MediaNotificationService* GetForProfile(Profile* profile);
private:
friend struct base::DefaultSingletonTraits<MediaNotificationServiceFactory>;
MediaNotificationServiceFactory();
~MediaNotificationServiceFactory() override;
// BrowserContextKeyedServiceFactory overrides:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override;
};
#endif // CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_SERVICE_FACTORY_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_SERVICE_OBSERVER_H_
#define CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_SERVICE_OBSERVER_H_
#include "base/observer_list_types.h"
class MediaNotificationServiceObserver : public base::CheckedObserver {
public:
// Called when the list of active, cast, or frozen media notifications
// changes.
virtual void OnNotificationListChanged() = 0;
// Called when a media dialog associated with the service is either opened or
// closed.
virtual void OnMediaDialogOpenedOrClosed() = 0;
protected:
~MediaNotificationServiceObserver() override = default;
};
#endif // CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_SERVICE_OBSERVER_H_
......@@ -5,77 +5,27 @@
#ifndef CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_MEDIA_TOOLBAR_BUTTON_CONTROLLER_H_
#define CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_MEDIA_TOOLBAR_BUTTON_CONTROLLER_H_
#include <map>
#include <string>
#include <vector>
#include "chrome/browser/ui/global_media_controls/media_notification_service_observer.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/media/router/media_routes_observer.h"
#include "chrome/browser/ui/global_media_controls/cast_media_notification_provider.h"
#include "chrome/browser/ui/global_media_controls/media_notification_container_observer.h"
#include "components/media_message_center/media_notification_controller.h"
#include "content/public/browser/web_contents_observer.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/media_session/public/mojom/audio_focus.mojom.h"
#include "services/media_session/public/mojom/media_controller.mojom.h"
namespace content {
class WebContents;
} // namespace content
namespace media_message_center {
class MediaSessionNotificationItem;
} // namespace media_message_center
namespace service_manager {
class Connector;
} // namespace service_manager
class MediaDialogDelegate;
class MediaNotificationContainerImpl;
class MediaNotificationService;
class MediaToolbarButtonControllerDelegate;
// Controller for the MediaToolbarButtonView that decides when to show or hide
// the icon from the toolbar. Also passes MediaNotificationItems to the
// MediaDialogView to display.
class MediaToolbarButtonController
: public media_session::mojom::AudioFocusObserver,
public media_message_center::MediaNotificationController,
public MediaNotificationContainerObserver {
// the icon from the toolbar.
class MediaToolbarButtonController : public MediaNotificationServiceObserver {
public:
MediaToolbarButtonController(const base::UnguessableToken& source_id,
service_manager::Connector* connector,
MediaToolbarButtonControllerDelegate* delegate,
Profile* profile);
MediaToolbarButtonController(MediaToolbarButtonControllerDelegate* delegate,
MediaNotificationService* service);
MediaToolbarButtonController(const MediaToolbarButtonController&) = delete;
MediaToolbarButtonController& operator=(const MediaToolbarButtonController&) =
delete;
~MediaToolbarButtonController() override;
// media_session::mojom::AudioFocusObserver implementation.
void OnFocusGained(
media_session::mojom::AudioFocusRequestStatePtr session) override;
void OnFocusLost(
media_session::mojom::AudioFocusRequestStatePtr session) override;
// media_message_center::MediaNotificationController implementation.
void ShowNotification(const std::string& id) override;
void HideNotification(const std::string& id) override;
void RemoveItem(const std::string& id) override;
scoped_refptr<base::SequencedTaskRunner> GetTaskRunner() const override;
void LogMediaSessionActionButtonPressed(const std::string& id) override;
// MediaNotificationContainerObserver implementation.
void OnContainerExpanded(bool expanded) override {}
void OnContainerMetadataChanged() override {}
void OnContainerClicked(const std::string& id) override;
void OnContainerDismissed(const std::string& id) override;
void OnContainerDestroyed(const std::string& id) override;
void SetDialogDelegate(MediaDialogDelegate* delegate);
// MediaNotificationServiceObserver implementation.
void OnNotificationListChanged() override;
void OnMediaDialogOpenedOrClosed() override;
private:
friend class MediaToolbarButtonControllerTest;
// Tracks the current display state of the toolbar button delegate.
enum class DisplayState {
kShown,
......@@ -83,74 +33,13 @@ class MediaToolbarButtonController
kHidden,
};
class Session : public content::WebContentsObserver {
public:
Session(MediaToolbarButtonController* owner,
const std::string& id,
std::unique_ptr<media_message_center::MediaSessionNotificationItem>
item,
content::WebContents* web_contents);
Session(const Session&) = delete;
Session& operator=(const Session&) = delete;
~Session() override;
// content::WebContentsObserver implementation.
void WebContentsDestroyed() override;
media_message_center::MediaSessionNotificationItem* item() {
return item_.get();
}
private:
MediaToolbarButtonController* owner_;
const std::string id_;
std::unique_ptr<media_message_center::MediaSessionNotificationItem> item_;
};
void OnReceivedAudioFocusRequests(
std::vector<media_session::mojom::AudioFocusRequestStatePtr> sessions);
void UpdateToolbarButtonState();
base::WeakPtr<media_message_center::MediaNotificationItem>
GetNotificationItem(const std::string& id);
service_manager::Connector* const connector_;
MediaToolbarButtonControllerDelegate* const delegate_;
MediaDialogDelegate* dialog_delegate_ = nullptr;
MediaNotificationService* const service_;
// The delegate starts hidden and isn't shown until media playback starts.
DisplayState delegate_display_state_ = DisplayState::kHidden;
// Used to track whether there are any active controllable media sessions. If
// not, then there's nothing to show in the dialog and we can hide the toolbar
// icon.
std::unordered_set<std::string> active_controllable_session_ids_;
// Tracks the sessions that are currently frozen. If there are only frozen
// sessions, we will disable the toolbar icon and wait to hide it.
std::unordered_set<std::string> frozen_session_ids_;
// Stores a Session for each media session keyed by its |request_id| in string
// format.
std::map<std::string, Session> sessions_;
// A map of all containers we're currently observing.
std::map<std::string, MediaNotificationContainerImpl*> observed_containers_;
// Connections with the media session service to listen for audio focus
// updates and control media sessions.
mojo::Remote<media_session::mojom::AudioFocusManager> audio_focus_remote_;
mojo::Remote<media_session::mojom::MediaControllerManager>
controller_manager_remote_;
mojo::Receiver<media_session::mojom::AudioFocusObserver>
audio_focus_observer_receiver_{this};
std::unique_ptr<CastMediaNotificationProvider> cast_notification_provider_;
base::WeakPtrFactory<MediaToolbarButtonController> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(MediaToolbarButtonController);
};
#endif // CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_MEDIA_TOOLBAR_BUTTON_CONTROLLER_H_
......@@ -6,7 +6,7 @@
#include "base/metrics/histogram_functions.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/global_media_controls/media_toolbar_button_controller.h"
#include "chrome/browser/ui/global_media_controls/media_notification_service.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/global_media_controls/media_dialog_view_observer.h"
#include "chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view.h"
......@@ -27,11 +27,10 @@ bool MediaDialogView::has_been_opened_ = false;
// static
void MediaDialogView::ShowDialog(views::View* anchor_view,
MediaToolbarButtonController* controller,
service_manager::Connector* connector) {
MediaNotificationService* service) {
DCHECK(!instance_);
DCHECK(controller);
instance_ = new MediaDialogView(anchor_view, controller, connector);
DCHECK(service);
instance_ = new MediaDialogView(anchor_view, service);
views::Widget* widget =
views::BubbleDialogDelegateView::CreateBubble(instance_);
......@@ -45,7 +44,7 @@ void MediaDialogView::ShowDialog(views::View* anchor_view,
// static
void MediaDialogView::HideDialog() {
if (IsShowing()) {
instance_->controller_->SetDialogDelegate(nullptr);
instance_->service_->SetDialogDelegate(nullptr);
instance_->GetWidget()->Close();
}
......@@ -110,7 +109,7 @@ void MediaDialogView::AddedToWidget() {
SetPaintToLayer();
layer()->SetRoundedCornerRadius(gfx::RoundedCornersF(corner_radius));
controller_->SetDialogDelegate(this);
service_->SetDialogDelegate(this);
}
gfx::Size MediaDialogView::CalculatePreferredSize() const {
......@@ -155,13 +154,12 @@ MediaDialogView::GetNotificationsForTesting() const {
}
MediaDialogView::MediaDialogView(views::View* anchor_view,
MediaToolbarButtonController* controller,
service_manager::Connector* connector)
MediaNotificationService* service)
: BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT),
controller_(controller),
service_(service),
active_sessions_view_(
AddChildView(std::make_unique<MediaNotificationListView>())) {
DCHECK(controller_);
DCHECK(service_);
}
MediaDialogView::~MediaDialogView() {
......@@ -179,6 +177,6 @@ void MediaDialogView::Init() {
void MediaDialogView::WindowClosing() {
if (instance_ == this) {
instance_ = nullptr;
controller_->SetDialogDelegate(nullptr);
service_->SetDialogDelegate(nullptr);
}
}
......@@ -11,14 +11,10 @@
#include "chrome/browser/ui/global_media_controls/media_notification_container_observer.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
namespace service_manager {
class Connector;
} // namespace service_manager
class MediaDialogViewObserver;
class MediaNotificationContainerImplView;
class MediaNotificationListView;
class MediaToolbarButtonController;
class MediaNotificationService;
// Dialog that shows media controls that control the active media session.
class MediaDialogView : public views::BubbleDialogDelegateView,
......@@ -26,8 +22,7 @@ class MediaDialogView : public views::BubbleDialogDelegateView,
public MediaNotificationContainerObserver {
public:
static void ShowDialog(views::View* anchor_view,
MediaToolbarButtonController* controller,
service_manager::Connector* connector);
MediaNotificationService* service);
static void HideDialog();
static bool IsShowing();
......@@ -62,8 +57,7 @@ class MediaDialogView : public views::BubbleDialogDelegateView,
private:
explicit MediaDialogView(views::View* anchor_view,
MediaToolbarButtonController* controller,
service_manager::Connector* connector);
MediaNotificationService* service);
~MediaDialogView() override;
static MediaDialogView* instance_;
......@@ -75,7 +69,7 @@ class MediaDialogView : public views::BubbleDialogDelegateView,
void Init() override;
void WindowClosing() override;
MediaToolbarButtonController* const controller_;
MediaNotificationService* const service_;
MediaNotificationListView* const active_sessions_view_;
......
......@@ -8,6 +8,7 @@
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/global_media_controls/media_notification_service_factory.h"
#include "chrome/browser/ui/global_media_controls/media_toolbar_button_controller.h"
#include "chrome/browser/ui/in_product_help/global_media_controls_in_product_help.h"
#include "chrome/browser/ui/in_product_help/global_media_controls_in_product_help_factory.h"
......@@ -25,17 +26,10 @@
#include "ui/views/animation/ink_drop.h"
#include "ui/views/controls/button/button_controller.h"
MediaToolbarButtonView::MediaToolbarButtonView(
const base::UnguessableToken& source_id,
service_manager::Connector* connector,
const Browser* browser)
MediaToolbarButtonView::MediaToolbarButtonView(const Browser* browser)
: ToolbarButton(this),
connector_(connector),
controller_(
std::make_unique<MediaToolbarButtonController>(source_id,
connector_,
this,
browser->profile())),
service_(
MediaNotificationServiceFactory::GetForProfile(browser->profile())),
browser_(browser) {
GlobalMediaControlsInProductHelp* in_product_help =
GlobalMediaControlsInProductHelpFactory::GetForProfile(
......@@ -54,6 +48,10 @@ MediaToolbarButtonView::MediaToolbarButtonView(
// We start hidden and only show once |controller_| tells us to.
SetVisible(false);
// Wait until we're done with everything else before creating |controller_|
// since it can call |Show()| synchronously.
controller_ = std::make_unique<MediaToolbarButtonController>(this, service_);
}
MediaToolbarButtonView::~MediaToolbarButtonView() {
......@@ -77,7 +75,7 @@ void MediaToolbarButtonView::ButtonPressed(views::Button* sender,
if (MediaDialogView::IsShowing()) {
MediaDialogView::HideDialog();
} else {
MediaDialogView::ShowDialog(this, controller_.get(), connector_);
MediaDialogView::ShowDialog(this, service_);
// Inform observers. Since the promo controller cares about the dialog
// showing, we need to ensure that it's created.
......
......@@ -9,16 +9,9 @@
#include "chrome/browser/ui/global_media_controls/media_toolbar_button_controller_delegate.h"
#include "chrome/browser/ui/views/toolbar/toolbar_button.h"
namespace base {
class UnguessableToken;
} // namespace base
namespace service_manager {
class Connector;
} // namespace service_manager
class Browser;
class GlobalMediaControlsPromoController;
class MediaNotificationService;
class MediaToolbarButtonController;
class MediaToolbarButtonObserver;
......@@ -29,9 +22,7 @@ class MediaToolbarButtonView : public ToolbarButton,
public MediaToolbarButtonControllerDelegate,
public views::ButtonListener {
public:
MediaToolbarButtonView(const base::UnguessableToken& source_id,
service_manager::Connector* connector,
const Browser* browser);
explicit MediaToolbarButtonView(const Browser* browser);
~MediaToolbarButtonView() override;
void AddObserver(MediaToolbarButtonObserver* observer);
......@@ -81,7 +72,7 @@ class MediaToolbarButtonView : public ToolbarButton,
// True if the in-product help bubble is currently showing.
bool is_promo_showing_ = false;
service_manager::Connector* const connector_;
MediaNotificationService* const service_;
std::unique_ptr<MediaToolbarButtonController> controller_;
const Browser* const browser_;
......
......@@ -66,9 +66,7 @@
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
#include "components/vector_icons/vector_icons.h"
#include "content/public/browser/media_session.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/system_connector.h"
#include "content/public/browser/web_contents.h"
#include "media/base/media_switches.h"
#include "ui/accessibility/ax_node_data.h"
......@@ -213,10 +211,7 @@ void ToolbarView::Init() {
std::unique_ptr<MediaToolbarButtonView> media_button;
if (base::FeatureList::IsEnabled(media::kGlobalMediaControls)) {
const base::UnguessableToken& source_id =
content::MediaSession::GetSourceId(browser_->profile());
media_button = std::make_unique<MediaToolbarButtonView>(
source_id, content::GetSystemConnector(), browser_);
media_button = std::make_unique<MediaToolbarButtonView>(browser_);
}
std::unique_ptr<ToolbarAccountIconContainerView>
......
......@@ -3849,6 +3849,7 @@ test("unit_tests") {
"../browser/ui/extensions/extension_message_bubble_bridge_unittest.cc",
"../browser/ui/global_error/global_error_service_unittest.cc",
"../browser/ui/global_media_controls/cast_media_notification_provider_unittest.cc",
"../browser/ui/global_media_controls/media_notification_service_unittest.cc",
"../browser/ui/global_media_controls/media_toolbar_button_controller_unittest.cc",
"../browser/ui/hid/hid_chooser_controller_unittest.cc",
"../browser/ui/in_product_help/active_tab_tracker_unittest.cc",
......
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