1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
content / public / test / media_start_stop_observer.cc [blame]
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/test/media_start_stop_observer.h"
namespace content {
MediaStartStopObserver::MediaStartStopObserver(WebContents* web_contents,
Type type)
: WebContentsObserver(web_contents), type_(type) {}
MediaStartStopObserver::~MediaStartStopObserver() = default;
void MediaStartStopObserver::MediaStartedPlaying(const MediaPlayerInfo& info,
const MediaPlayerId& id) {
if (type_ != Type::kStart)
return;
run_loop_.Quit();
}
void MediaStartStopObserver::MediaPictureInPictureChanged(
bool is_picture_in_picture) {
if (is_picture_in_picture && type_ != Type::kEnterPictureInPicture)
return;
if (!is_picture_in_picture && type_ != Type::kExitPictureInPicture)
return;
run_loop_.Quit();
}
void MediaStartStopObserver::MediaStoppedPlaying(
const MediaPlayerInfo& info,
const MediaPlayerId& id,
WebContentsObserver::MediaStoppedReason reason) {
if (type_ != Type::kStop)
return;
run_loop_.Quit();
}
void MediaStartStopObserver::Wait() {
run_loop_.Run();
}
} // namespace content