OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
6 #define CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 6 #define CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <set> | 11 #include <set> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "content/browser/media/session/media_session_controllers_manager.h" | |
16 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
17 #include "content/public/browser/web_contents_observer.h" | 18 #include "content/public/browser/web_contents_observer.h" |
18 | 19 |
19 namespace content { | 20 namespace content { |
21 | |
20 class PowerSaveBlocker; | 22 class PowerSaveBlocker; |
21 | 23 |
22 // This class manages all RenderFrame based media related managers at the | 24 // This class manages all RenderFrame based media related managers at the |
23 // browser side. It receives IPC messages from media RenderFrameObservers and | 25 // browser side. It receives IPC messages from media RenderFrameObservers and |
24 // forwards them to the corresponding managers. The managers are responsible | 26 // forwards them to the corresponding managers. The managers are responsible |
25 // for sending IPCs back to the RenderFrameObservers at the render side. | 27 // for sending IPCs back to the RenderFrameObservers at the render side. |
26 class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver { | 28 class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver { |
27 public: | 29 public: |
28 explicit MediaWebContentsObserver(WebContents* web_contents); | 30 explicit MediaWebContentsObserver(WebContents* web_contents); |
29 ~MediaWebContentsObserver() override; | 31 ~MediaWebContentsObserver() override; |
30 | 32 |
31 // Called by WebContentsImpl when the audible state may have changed. | 33 // Called by WebContentsImpl when the audible state may have changed. |
32 void MaybeUpdateAudibleState(); | 34 void MaybeUpdateAudibleState(); |
33 | 35 |
34 // WebContentsObserver implementation. | 36 // WebContentsObserver implementation. |
35 void WebContentsDestroyed() override; | 37 void WebContentsDestroyed() override; |
36 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; | 38 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; |
37 bool OnMessageReceived(const IPC::Message& message, | 39 bool OnMessageReceived(const IPC::Message& message, |
38 RenderFrameHost* render_frame_host) override; | 40 RenderFrameHost* render_frame_host) override; |
39 void WasShown() override; | 41 void WasShown() override; |
40 void WasHidden() override; | 42 void WasHidden() override; |
41 | 43 |
44 #if defined(OS_ANDROID) | |
DaleCurtis
2016/02/17 20:16:54
Can you keep this on MWCOA? I'd like to avoid rein
mlamouri (slow - plz ping)
2016/02/23 20:27:55
Done.
| |
45 // Initiates a synchronous MediaSession request for browser side players. | |
46 // | |
47 // TODO(dalecurtis): Delete this method once we're no longer using WMPA and | |
48 // the BrowserMediaPlayerManagers. Tracked by http://crbug.com/580626 | |
49 bool RequestPlay(RenderFrameHost* render_frame_host, | |
50 int delegate_id, | |
51 bool has_audio, | |
52 bool is_remote, | |
53 base::TimeDelta duration); | |
54 #endif // OS_ANDROID | |
55 | |
42 bool has_audio_power_save_blocker_for_testing() const { | 56 bool has_audio_power_save_blocker_for_testing() const { |
43 return !!audio_power_save_blocker_; | 57 return !!audio_power_save_blocker_; |
44 } | 58 } |
45 | 59 |
46 bool has_video_power_save_blocker_for_testing() const { | 60 bool has_video_power_save_blocker_for_testing() const { |
47 return !!video_power_save_blocker_; | 61 return !!video_power_save_blocker_; |
48 } | 62 } |
49 | 63 |
50 private: | 64 private: |
51 void OnMediaDestroyed(RenderFrameHost* render_frame_host, int delegate_id); | 65 void OnMediaDestroyed(RenderFrameHost* render_frame_host, int delegate_id); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, | 98 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, |
85 ActiveMediaPlayerMap* player_map, | 99 ActiveMediaPlayerMap* player_map, |
86 std::set<MediaPlayerId>* removed_players); | 100 std::set<MediaPlayerId>* removed_players); |
87 | 101 |
88 // Tracking variables and associated power save blockers for media playback. | 102 // Tracking variables and associated power save blockers for media playback. |
89 ActiveMediaPlayerMap active_audio_players_; | 103 ActiveMediaPlayerMap active_audio_players_; |
90 ActiveMediaPlayerMap active_video_players_; | 104 ActiveMediaPlayerMap active_video_players_; |
91 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_; | 105 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_; |
92 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_; | 106 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_; |
93 | 107 |
108 MediaSessionControllersManager session_controllers_manager_; | |
109 | |
94 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver); | 110 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver); |
95 }; | 111 }; |
96 | 112 |
97 } // namespace content | 113 } // namespace content |
98 | 114 |
99 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ | 115 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ |
OLD | NEW |