| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_SERVICE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_SERVICE_IMPL_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_SERVICE_IMPL_H_ | 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/optional.h" | 8 #include "base/optional.h" |
| 9 #include "content/public/common/media_metadata.h" | 9 #include "content/public/common/media_metadata.h" |
| 10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
| 11 #include "third_party/WebKit/public/platform/modules/mediasession/media_session.
mojom.h" | 11 #include "third_party/WebKit/public/platform/modules/mediasession/media_session.
mojom.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 class RenderFrameHost; |
| 15 class MediaSessionImpl; | 16 class MediaSessionImpl; |
| 16 class RenderFrameHost; | |
| 17 | 17 |
| 18 // There is one MediaSessionService per frame. | 18 // There is one MediaSessionService per frame. The class is owned by |
| 19 // RenderFrameHost and should register/unregister itself to/from |
| 20 // MediaSessionImpl when RenderFrameHost is created/destroyed. |
| 19 class MediaSessionServiceImpl : public blink::mojom::MediaSessionService { | 21 class MediaSessionServiceImpl : public blink::mojom::MediaSessionService { |
| 20 public: | 22 public: |
| 21 ~MediaSessionServiceImpl() override; | 23 ~MediaSessionServiceImpl() override; |
| 22 | 24 |
| 23 static void Create(RenderFrameHost* render_frame_host, | 25 static void Create(RenderFrameHost* render_frame_host, |
| 24 blink::mojom::MediaSessionServiceRequest request); | 26 blink::mojom::MediaSessionServiceRequest request); |
| 25 const blink::mojom::MediaSessionClientPtr& GetClient() { return client_; } | 27 const blink::mojom::MediaSessionClientPtr& GetClient() { return client_; } |
| 28 RenderFrameHost* GetRenderFrameHost() { return render_frame_host_; } |
| 29 |
| 30 const base::Optional<MediaMetadata>& metadata() const { return metadata_; } |
| 31 const std::set<blink::mojom::MediaSessionAction>& actions() const { |
| 32 return actions_; |
| 33 } |
| 26 | 34 |
| 27 private: | 35 private: |
| 28 explicit MediaSessionServiceImpl(RenderFrameHost* render_frame_host); | 36 explicit MediaSessionServiceImpl(RenderFrameHost* render_frame_host); |
| 29 | 37 |
| 30 // blink::mojom::MediaSessionService implementation. | 38 // blink::mojom::MediaSessionService implementation. |
| 31 void SetClient(blink::mojom::MediaSessionClientPtr client) override; | 39 void SetClient(blink::mojom::MediaSessionClientPtr client) override; |
| 32 | 40 |
| 33 void SetMetadata( | 41 void SetMetadata(const base::Optional<MediaMetadata>& metadata) override; |
| 34 const base::Optional<content::MediaMetadata>& metadata) override; | |
| 35 | 42 |
| 36 void EnableAction(blink::mojom::MediaSessionAction action) override; | 43 void EnableAction(blink::mojom::MediaSessionAction action) override; |
| 37 void DisableAction(blink::mojom::MediaSessionAction action) override; | 44 void DisableAction(blink::mojom::MediaSessionAction action) override; |
| 38 | 45 |
| 39 // Returns the content::MediaSession this service is associated with. Only | |
| 40 // returns non-null when this service is in the top-level frame. | |
| 41 MediaSessionImpl* GetMediaSession(); | 46 MediaSessionImpl* GetMediaSession(); |
| 42 | 47 |
| 43 void Bind(blink::mojom::MediaSessionServiceRequest request); | 48 void Bind(blink::mojom::MediaSessionServiceRequest request); |
| 44 | 49 |
| 45 RenderFrameHost* render_frame_host_; | 50 RenderFrameHost* render_frame_host_; |
| 46 | 51 |
| 47 // RAII binding of |this| to an MediaSessionService interface request. | 52 // RAII binding of |this| to an MediaSessionService interface request. |
| 48 // The binding is removed when binding_ is cleared or goes out of scope. | 53 // The binding is removed when binding_ is cleared or goes out of scope. |
| 49 std::unique_ptr<mojo::Binding<blink::mojom::MediaSessionService>> binding_; | 54 std::unique_ptr<mojo::Binding<blink::mojom::MediaSessionService>> binding_; |
| 50 blink::mojom::MediaSessionClientPtr client_; | 55 blink::mojom::MediaSessionClientPtr client_; |
| 56 base::Optional<MediaMetadata> metadata_; |
| 57 std::set<blink::mojom::MediaSessionAction> actions_; |
| 51 | 58 |
| 52 DISALLOW_COPY_AND_ASSIGN(MediaSessionServiceImpl); | 59 DISALLOW_COPY_AND_ASSIGN(MediaSessionServiceImpl); |
| 53 }; | 60 }; |
| 54 | 61 |
| 55 } // namespace content | 62 } // namespace content |
| 56 | 63 |
| 57 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_SERVICE_IMPL_H_ | 64 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_SERVICE_IMPL_H_ |
| OLD | NEW |