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_AUDIO_MONITOR_ANDROID_H_ | |
6 #define CONTENT_BROWSER_ANDROID_AUDIO_MONITOR_ANDROID_H_ | |
7 | |
8 #include <map> | |
9 #include "base/macros.h" | |
10 | |
11 namespace content { | |
12 | |
13 class WebContents; | |
14 class RenderFrameHost; | |
15 | |
16 // This class maintains the audible state of many players | |
no sievers
2015/02/10 01:33:03
You should say that this class is associated with
Tima Vaisburd
2015/02/11 03:34:05
Changed the wording, please verify.
| |
17 // together. That state is accociated with a WebContents that might have | |
18 // several players. | |
19 // The audible state is true if at least one player is playing a sound. | |
20 // Whenever the audible state of the WebContents as a whole changes, this | |
21 // class sends notification to it. | |
22 class AudioMonitorAndroid { | |
23 public: | |
24 // Constructor, web_contents represents the tab. | |
no sievers
2015/02/10 01:33:03
Let's avoid talking about 'tabs' here and below wh
Tima Vaisburd
2015/02/11 03:34:05
Done.
| |
25 explicit AudioMonitorAndroid(WebContents* web_contents); | |
26 ~AudioMonitorAndroid(); | |
27 | |
28 // Returns the audible state of the whole tab. | |
29 bool is_audible() const { return is_audible_; } | |
30 | |
31 // These methods constitute the observer pattern, should | |
32 // be called when corresponding event happens. They will notify | |
33 // WebContents whenever the whole tab audible state changes. | |
34 void OnAudibleStateChanged(RenderFrameHost* rfh, int player_id, | |
35 bool is_audible); | |
36 void RemovePlayer(RenderFrameHost* rfh, int player_id); | |
37 void RenderFrameDeleted(RenderFrameHost* rfh); | |
38 | |
39 private: | |
40 void UpdateStatusAndNotify(); | |
41 | |
42 // Contents of the tab this monitor is associated with | |
43 WebContents* web_contents_; | |
44 | |
45 // Audible status per player ID and frame | |
46 typedef std::pair<RenderFrameHost*, int> Key; | |
47 typedef std::map<Key, bool> StatusMap; | |
48 StatusMap audio_status_map_; | |
49 | |
50 // The audible state of the whole tab | |
51 bool is_audible_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(AudioMonitorAndroid); | |
54 }; | |
55 | |
56 } // namespace content | |
57 | |
58 #endif // CONTENT_BROWSER_ANDROID_AUDIO_MONITOR_ANDROID_H_ | |
OLD | NEW |