OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #include "content/renderer/media/renderer_webmediaplayer_delegate.h" | 5 #include "content/renderer/media/renderer_webmediaplayer_delegate.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 DVLOG(2) << __func__ << "(" << player_id << ", " << has_video << ", " | 91 DVLOG(2) << __func__ << "(" << player_id << ", " << has_video << ", " |
92 << has_audio << ", " << static_cast<int>(media_content_type) << ")"; | 92 << has_audio << ", " << static_cast<int>(media_content_type) << ")"; |
93 DCHECK(id_map_.Lookup(player_id)); | 93 DCHECK(id_map_.Lookup(player_id)); |
94 | 94 |
95 has_played_media_ = true; | 95 has_played_media_ = true; |
96 if (has_video) { | 96 if (has_video) { |
97 if (!playing_videos_.count(player_id)) { | 97 if (!playing_videos_.count(player_id)) { |
98 playing_videos_.insert(player_id); | 98 playing_videos_.insert(player_id); |
99 has_played_video_ = true; | 99 has_played_video_ = true; |
100 } | 100 } |
101 if (has_video && IsFrameHidden() && !IsFrameClosed()) | |
sandersd (OOO until July 31)
2017/02/13 22:56:20
Duplicate |has_video| condition.
whywhat
2017/02/15 17:13:12
Done.
| |
102 background_video_allowed_ = true; | |
101 } else { | 103 } else { |
102 playing_videos_.erase(player_id); | 104 playing_videos_.erase(player_id); |
103 } | 105 } |
104 | 106 |
105 Send(new MediaPlayerDelegateHostMsg_OnMediaPlaying( | 107 Send(new MediaPlayerDelegateHostMsg_OnMediaPlaying( |
106 routing_id(), player_id, has_video, has_audio, false, | 108 routing_id(), player_id, has_video, has_audio, false, |
107 media_content_type)); | 109 media_content_type)); |
108 | 110 |
109 ScheduleUpdateTask(); | 111 ScheduleUpdateTask(); |
110 } | 112 } |
111 | 113 |
112 void RendererWebMediaPlayerDelegate::DidPause(int player_id) { | 114 void RendererWebMediaPlayerDelegate::DidPause(int player_id) { |
113 DVLOG(2) << __func__ << "(" << player_id << ")"; | 115 DVLOG(2) << __func__ << "(" << player_id << ")"; |
114 DCHECK(id_map_.Lookup(player_id)); | 116 DCHECK(id_map_.Lookup(player_id)); |
117 | |
118 if (playing_videos_.count(player_id) && IsFrameHidden() && !IsFrameClosed()) | |
DaleCurtis
2017/02/13 22:44:54
Hmm, is this right? Can you add some comments abou
whywhat
2017/02/14 01:36:28
This is consistent with the user pressing on the p
whywhat
2017/02/15 17:13:12
Added a user gesture check to that so we won't blo
| |
119 background_video_allowed_ = false; | |
sandersd (OOO until July 31)
2017/02/13 22:56:20
This can leave us in a strange state where there i
whywhat
2017/02/14 01:36:28
Hm, how? This is called when video is being paused
sandersd (OOO until July 31)
2017/02/14 01:39:39
There can be more than one playing video on a page
whywhat
2017/02/15 17:13:12
This is already the case with OnMediaDelegatePause
sandersd (OOO until July 31)
2017/02/15 21:54:08
There is a difference, though; OnMediaDelegatePaus
| |
120 | |
115 playing_videos_.erase(player_id); | 121 playing_videos_.erase(player_id); |
116 Send(new MediaPlayerDelegateHostMsg_OnMediaPaused(routing_id(), player_id, | 122 Send(new MediaPlayerDelegateHostMsg_OnMediaPaused(routing_id(), player_id, |
117 false)); | 123 false)); |
118 | 124 |
119 // Required to keep background playback statistics up to date. | 125 // Required to keep background playback statistics up to date. |
120 ScheduleUpdateTask(); | 126 ScheduleUpdateTask(); |
121 } | 127 } |
122 | 128 |
123 void RendererWebMediaPlayerDelegate::PlayerGone(int player_id) { | 129 void RendererWebMediaPlayerDelegate::PlayerGone(int player_id) { |
124 DVLOG(2) << __func__ << "(" << player_id << ")"; | 130 DVLOG(2) << __func__ << "(" << player_id << ")"; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 player->OnIdleTimeout(); | 370 player->OnIdleTimeout(); |
365 } | 371 } |
366 } | 372 } |
367 } | 373 } |
368 | 374 |
369 void RendererWebMediaPlayerDelegate::OnDestruct() { | 375 void RendererWebMediaPlayerDelegate::OnDestruct() { |
370 delete this; | 376 delete this; |
371 } | 377 } |
372 | 378 |
373 } // namespace media | 379 } // namespace media |
OLD | NEW |