| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ | 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 namespace content { | 37 namespace content { |
| 38 | 38 |
| 39 class AudioFocusDelegate; | 39 class AudioFocusDelegate; |
| 40 class AudioFocusManagerTest; | 40 class AudioFocusManagerTest; |
| 41 class MediaSessionImplServiceRoutingTest; | 41 class MediaSessionImplServiceRoutingTest; |
| 42 class MediaSessionImplStateObserver; | 42 class MediaSessionImplStateObserver; |
| 43 class MediaSessionImplVisibilityBrowserTest; | 43 class MediaSessionImplVisibilityBrowserTest; |
| 44 class MediaSessionObserver; | 44 class MediaSessionObserver; |
| 45 class MediaSessionPlayerObserver; | 45 class MediaSessionPlayerObserver; |
| 46 class MediaSessionServiceImpl; | 46 class MediaSessionServiceImpl; |
| 47 class MediaSessionServiceImplBrowserTest; |
| 47 | 48 |
| 48 #if defined(OS_ANDROID) | 49 #if defined(OS_ANDROID) |
| 49 class MediaSessionAndroid; | 50 class MediaSessionAndroid; |
| 50 #endif // defined(OS_ANDROID) | 51 #endif // defined(OS_ANDROID) |
| 51 | 52 |
| 52 // MediaSessionImpl is the implementation of MediaSession. It manages the media | 53 // MediaSessionImpl is the implementation of MediaSession. It manages the media |
| 53 // session and audio focus for a given WebContents. It is requesting the audio | 54 // session and audio focus for a given WebContents. It is requesting the audio |
| 54 // focus, pausing when requested by the system and dropping it on demand. The | 55 // focus, pausing when requested by the system and dropping it on demand. The |
| 55 // audio focus can be of two types: Transient or Content. A Transient audio | 56 // audio focus can be of two types: Transient or Content. A Transient audio |
| 56 // focus will allow other players to duck instead of pausing and will be | 57 // focus will allow other players to duck instead of pausing and will be |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 CONTENT_EXPORT AudioFocusManager::AudioFocusType audio_focus_type() const { | 161 CONTENT_EXPORT AudioFocusManager::AudioFocusType audio_focus_type() const { |
| 161 return audio_focus_type_; | 162 return audio_focus_type_; |
| 162 } | 163 } |
| 163 | 164 |
| 164 // Returns whether the session has Pepper instances. | 165 // Returns whether the session has Pepper instances. |
| 165 bool HasPepper() const; | 166 bool HasPepper() const; |
| 166 | 167 |
| 167 // WebContentsObserver implementation | 168 // WebContentsObserver implementation |
| 168 void WebContentsDestroyed() override; | 169 void WebContentsDestroyed() override; |
| 169 void RenderFrameDeleted(RenderFrameHost* rfh) override; | 170 void RenderFrameDeleted(RenderFrameHost* rfh) override; |
| 171 void DidFinishNavigation(NavigationHandle* navigation_handle) override; |
| 170 | 172 |
| 171 // MediaSessionService-related methods | 173 // MediaSessionService-related methods |
| 172 | 174 |
| 173 // Called when a MediaSessionService is created, which registers itself to | 175 // Called when a MediaSessionService is created, which registers itself to |
| 174 // this session. | 176 // this session. |
| 175 void OnServiceCreated(MediaSessionServiceImpl* service); | 177 void OnServiceCreated(MediaSessionServiceImpl* service); |
| 176 // Called when a MediaSessionService is destroyed, which unregisters itself | 178 // Called when a MediaSessionService is destroyed, which unregisters itself |
| 177 // from this session. | 179 // from this session. |
| 178 void OnServiceDestroyed(MediaSessionServiceImpl* service); | 180 void OnServiceDestroyed(MediaSessionServiceImpl* service); |
| 179 | 181 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 192 // to blink::MediaSession corresponding to the current routed service. | 194 // to blink::MediaSession corresponding to the current routed service. |
| 193 void DidReceiveAction(blink::mojom::MediaSessionAction action) override; | 195 void DidReceiveAction(blink::mojom::MediaSessionAction action) override; |
| 194 | 196 |
| 195 private: | 197 private: |
| 196 friend class content::WebContentsUserData<MediaSessionImpl>; | 198 friend class content::WebContentsUserData<MediaSessionImpl>; |
| 197 friend class ::MediaSessionImplBrowserTest; | 199 friend class ::MediaSessionImplBrowserTest; |
| 198 friend class content::MediaSessionImplVisibilityBrowserTest; | 200 friend class content::MediaSessionImplVisibilityBrowserTest; |
| 199 friend class content::AudioFocusManagerTest; | 201 friend class content::AudioFocusManagerTest; |
| 200 friend class content::MediaSessionImplServiceRoutingTest; | 202 friend class content::MediaSessionImplServiceRoutingTest; |
| 201 friend class content::MediaSessionImplStateObserver; | 203 friend class content::MediaSessionImplStateObserver; |
| 204 friend class content::MediaSessionServiceImplBrowserTest; |
| 202 | 205 |
| 203 CONTENT_EXPORT void SetDelegateForTests( | 206 CONTENT_EXPORT void SetDelegateForTests( |
| 204 std::unique_ptr<AudioFocusDelegate> delegate); | 207 std::unique_ptr<AudioFocusDelegate> delegate); |
| 205 CONTENT_EXPORT bool IsActiveForTest() const; | 208 CONTENT_EXPORT bool IsActiveForTest() const; |
| 206 CONTENT_EXPORT void RemoveAllPlayersForTest(); | 209 CONTENT_EXPORT void RemoveAllPlayersForTest(); |
| 207 CONTENT_EXPORT MediaSessionUmaHelper* uma_helper_for_test(); | 210 CONTENT_EXPORT MediaSessionUmaHelper* uma_helper_for_test(); |
| 208 | 211 |
| 209 // Representation of a player for the MediaSessionImpl. | 212 // Representation of a player for the MediaSessionImpl. |
| 210 struct PlayerIdentifier { | 213 struct PlayerIdentifier { |
| 211 PlayerIdentifier(MediaSessionPlayerObserver* observer, int player_id); | 214 PlayerIdentifier(MediaSessionPlayerObserver* observer, int player_id); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 ServicesMap services_; | 315 ServicesMap services_; |
| 313 // The currently routed service (non-owned pointer). | 316 // The currently routed service (non-owned pointer). |
| 314 MediaSessionServiceImpl* routed_service_; | 317 MediaSessionServiceImpl* routed_service_; |
| 315 | 318 |
| 316 DISALLOW_COPY_AND_ASSIGN(MediaSessionImpl); | 319 DISALLOW_COPY_AND_ASSIGN(MediaSessionImpl); |
| 317 }; | 320 }; |
| 318 | 321 |
| 319 } // namespace content | 322 } // namespace content |
| 320 | 323 |
| 321 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ | 324 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ |
| OLD | NEW |