Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / content / browser / android / media_players_observer.h
blobb01a3bf916a02555186884fdc6ffccae68edef27
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.
5 #ifndef CONTENT_BROWSER_ANDROID_MEDIA_PLAYERS_OBSERVER_H_
6 #define CONTENT_BROWSER_ANDROID_MEDIA_PLAYERS_OBSERVER_H_
8 #include <map>
10 #include "base/macros.h"
11 #include "content/browser/media/audio_state_provider.h"
13 namespace content {
15 class RenderFrameHost;
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;
24 bool IsAudioStateAvailable() const override;
26 // This audio state provider does not have a monitor,
27 // the method returns nullptr.
28 AudioStreamMonitor* audio_stream_monitor() override;
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);
38 private:
39 void UpdateStatusAndNotify();
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_;
46 DISALLOW_COPY_AND_ASSIGN(MediaPlayersObserver);
49 } // namespace content
51 #endif // CONTENT_BROWSER_ANDROID_MEDIA_PLAYERS_OBSERVER_H_