OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_ANDROID_MEDIA_PLAYERS_OBSERVER_H_ |
| 6 #define CONTENT_BROWSER_ANDROID_MEDIA_PLAYERS_OBSERVER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "content/browser/media/audio_state_provider.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 class RenderFrameHost; |
| 16 |
| 17 // On Android the MediaPlayerAndroid objects report |
| 18 // the audible state to us. |
| 19 class MediaPlayersObserver : public AudioStateProvider { |
| 20 public: |
| 21 explicit MediaPlayersObserver(WebContents* web_contents); |
| 22 ~MediaPlayersObserver() override; |
| 23 |
| 24 bool IsAudioStateAvailable() const override; |
| 25 |
| 26 // This audio state provider does not have a monitor, |
| 27 // the method returns nullptr. |
| 28 AudioStreamMonitor* audio_stream_monitor() override; |
| 29 |
| 30 // These methods constitute the observer pattern, should |
| 31 // be called when corresponding event happens. They will notify |
| 32 // WebContents whenever its audible state as a whole changes. |
| 33 void OnAudibleStateChanged(RenderFrameHost* rfh, int player_id, |
| 34 bool is_audible); |
| 35 void RemovePlayer(RenderFrameHost* rfh, int player_id); |
| 36 void RenderFrameDeleted(RenderFrameHost* rfh); |
| 37 |
| 38 private: |
| 39 void UpdateStatusAndNotify(); |
| 40 |
| 41 // Audible status per player ID and frame |
| 42 typedef std::pair<RenderFrameHost*, int> Key; |
| 43 typedef std::map<Key, bool> StatusMap; |
| 44 StatusMap audio_status_map_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(MediaPlayersObserver); |
| 47 }; |
| 48 |
| 49 } // namespace content |
| 50 |
| 51 #endif // CONTENT_BROWSER_ANDROID_MEDIA_PLAYERS_OBSERVER_H_ |
OLD | NEW |