// Copyright 2020 The Chromium Authors // 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_PRESENTATION_REQUEST_NOTIFICATION_PRODUCER_H_ #define CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_PRESENTATION_REQUEST_NOTIFICATION_PRODUCER_H_ #include <memory> #include <optional> #include <string> #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "base/unguessable_token.h" #include "chrome/browser/ui/global_media_controls/presentation_request_notification_item.h" #include "components/global_media_controls/public/mojom/device_service.mojom.h" #include "components/media_router/browser/presentation/web_contents_presentation_manager.h" #include "content/public/browser/presentation_observer.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/remote.h" // An object that creates and manages media notifications related to // presentation requests by delegating to the implementer of // global_media_controls::mojom::DevicePickerProvider that handles the UI. // On Chrome OS, this object lives on the browser-side of the crosapi split. // On other platforms, both this and DevicePickerProvider live within the same // browser process. // // The purpose of this class is somewhat subtle. When a page uses the Cast API // or Presentation API to make itself castable, we want there to be a // notification for it in the global media controls dialog. Most of the time, // there will already be a notification because the active tab will be playing // media that causes a notification to be created, but in some circumstances // (e.g. a YouTube page loaded with the audio muted), this class is the only // mechanism that will cause a notification to be shown. // // This class can only ever manage one notification at a time. The notification // correponds either to the default presentation request created in the active // tab, or to a non-default presentation request being started (typically by the // user clicking a Cast button in the active tab). // // The notification managed by this object only exists when the media control // dialog is showing. This is to prevent presentation requests from causing the // media control button to become visible when it would otherwise be hidden. // // Once a Cast/Presentation session has been created, this class is no longer // involved; at that point CastMediaNotificationProducer become responsible for // managing the notification for an active session. class PresentationRequestNotificationProducer final : public content::PresentationObserver, public global_media_controls::mojom::DevicePickerObserver { … }; #endif // CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_PRESENTATION_REQUEST_NOTIFICATION_PRODUCER_H_