Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: content/browser/media/media_web_contents_observer.h

Issue 2693203002: Provide a WebContents API to discover the playback of a fullscreen video. (Closed)
Patch Set: review comments and compile fix Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 24 matching lines...) Expand all
35 // forwards them to the corresponding managers. The managers are responsible 35 // forwards them to the corresponding managers. The managers are responsible
36 // for sending IPCs back to the RenderFrameObservers at the render side. 36 // for sending IPCs back to the RenderFrameObservers at the render side.
37 class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver { 37 class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver {
38 public: 38 public:
39 explicit MediaWebContentsObserver(WebContents* web_contents); 39 explicit MediaWebContentsObserver(WebContents* web_contents);
40 ~MediaWebContentsObserver() override; 40 ~MediaWebContentsObserver() override;
41 41
42 // Called by WebContentsImpl when the audible state may have changed. 42 // Called by WebContentsImpl when the audible state may have changed.
43 void MaybeUpdateAudibleState(); 43 void MaybeUpdateAudibleState();
44 44
45 // Called by WebContentsImpl to know if an active player is effectively
46 // fullscreen. That means that the video is either fullscreen or it is the
47 // content of a fullscreen page (in other words, a fullscreen video with
48 // custom controls).
49 // It should only be called while the WebContents is fullscreen.
50 bool HasActiveEffectivelyFullscreenVideo() const;
51
45 // WebContentsObserver implementation. 52 // WebContentsObserver implementation.
46 void WebContentsDestroyed() override; 53 void WebContentsDestroyed() override;
47 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; 54 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
48 bool OnMessageReceived(const IPC::Message& message, 55 bool OnMessageReceived(const IPC::Message& message,
49 RenderFrameHost* render_frame_host) override; 56 RenderFrameHost* render_frame_host) override;
50 void WasShown() override; 57 void WasShown() override;
51 void WasHidden() override; 58 void WasHidden() override;
52 59
53 bool has_audio_power_save_blocker_for_testing() const { 60 bool has_audio_power_save_blocker_for_testing() const {
54 return !!audio_power_save_blocker_; 61 return !!audio_power_save_blocker_;
(...skipping 12 matching lines...) Expand all
67 void OnMediaDestroyed(RenderFrameHost* render_frame_host, int delegate_id); 74 void OnMediaDestroyed(RenderFrameHost* render_frame_host, int delegate_id);
68 void OnMediaPaused(RenderFrameHost* render_frame_host, 75 void OnMediaPaused(RenderFrameHost* render_frame_host,
69 int delegate_id, 76 int delegate_id,
70 bool reached_end_of_stream); 77 bool reached_end_of_stream);
71 void OnMediaPlaying(RenderFrameHost* render_frame_host, 78 void OnMediaPlaying(RenderFrameHost* render_frame_host,
72 int delegate_id, 79 int delegate_id,
73 bool has_video, 80 bool has_video,
74 bool has_audio, 81 bool has_audio,
75 bool is_remote, 82 bool is_remote,
76 media::MediaContentType media_content_type); 83 media::MediaContentType media_content_type);
84 void OnMediaEffectivelyFullscreenChange(RenderFrameHost* render_frame_host,
85 int delegate_id,
86 bool is_fullscreen);
77 87
78 // Clear |render_frame_host|'s tracking entry for its power save blockers. 88 // Clear |render_frame_host|'s tracking entry for its power save blockers.
79 void ClearPowerSaveBlockers(RenderFrameHost* render_frame_host); 89 void ClearPowerSaveBlockers(RenderFrameHost* render_frame_host);
80 90
81 // Creates an audio or video power save blocker respectively. 91 // Creates an audio or video power save blocker respectively.
82 void CreateAudioPowerSaveBlocker(); 92 void CreateAudioPowerSaveBlocker();
83 void CreateVideoPowerSaveBlocker(); 93 void CreateVideoPowerSaveBlocker();
84 94
85 // Releases the audio power save blockers if |active_audio_players_| is empty. 95 // Releases the audio power save blockers if |active_audio_players_| is empty.
86 // Likewise, releases the video power save blockers if |active_video_players_| 96 // Likewise, releases the video power save blockers if |active_video_players_|
(...skipping 12 matching lines...) Expand all
99 // entries are added to |removed_players|. 109 // entries are added to |removed_players|.
100 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, 110 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host,
101 ActiveMediaPlayerMap* player_map, 111 ActiveMediaPlayerMap* player_map,
102 std::set<MediaPlayerId>* removed_players); 112 std::set<MediaPlayerId>* removed_players);
103 113
104 // Tracking variables and associated power save blockers for media playback. 114 // Tracking variables and associated power save blockers for media playback.
105 ActiveMediaPlayerMap active_audio_players_; 115 ActiveMediaPlayerMap active_audio_players_;
106 ActiveMediaPlayerMap active_video_players_; 116 ActiveMediaPlayerMap active_video_players_;
107 std::unique_ptr<device::PowerSaveBlocker> audio_power_save_blocker_; 117 std::unique_ptr<device::PowerSaveBlocker> audio_power_save_blocker_;
108 std::unique_ptr<device::PowerSaveBlocker> video_power_save_blocker_; 118 std::unique_ptr<device::PowerSaveBlocker> video_power_save_blocker_;
119 base::Optional<MediaPlayerId> fullscreen_player_;
109 120
110 MediaSessionControllersManager session_controllers_manager_; 121 MediaSessionControllersManager session_controllers_manager_;
111 122
112 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver); 123 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver);
113 }; 124 };
114 125
115 } // namespace content 126 } // namespace content
116 127
117 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_ 128 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698