Bug 1476701 - notify observer when audible autoplay occurred. r=cpearce,jaws

In our autoplay shield-study, we want to collect the information which could tell us how many website
contains audible autoplay media, but there is no way to get this information on current API desigin.

Therefore, I would like to send a new notification when autoplay occurred.

The extension code could get the information by following way,
```
Services.obs.addObserver((subject, topic, data) => {
    // DO SOMETHING
}, "AudibleAutoplayMediaOccurred");
```

MozReview-Commit-ID: 4bSYcxDZOGK
This commit is contained in:
alwu
2018-07-25 09:08:44 -07:00
parent f474a291b9
commit c96fe8806b
6 changed files with 51 additions and 6 deletions

View File

@@ -4013,7 +4013,7 @@ HTMLMediaElement::AudioChannelAgentDelayingPlayback()
}
void
HTMLMediaElement::ReportAutoplayTelemetry() const
HTMLMediaElement::UpdateHadAudibleAutoplayState() const
{
// If we're audible, and autoplaying...
if ((Volume() > 0.0 && !Muted()) &&
@@ -4086,7 +4086,7 @@ HTMLMediaElement::Play(ErrorResult& aRv)
return promise.forget();
}
ReportAutoplayTelemetry();
UpdateHadAudibleAutoplayState();
const bool handlingUserInput = EventStateManager::IsHandlingUserInput();
switch (AutoplayPolicy::IsAllowedToPlay(*this)) {
@@ -6246,7 +6246,7 @@ HTMLMediaElement::CheckAutoplayDataReady()
return;
}
ReportAutoplayTelemetry();
UpdateHadAudibleAutoplayState();
switch (AutoplayPolicy::IsAllowedToPlay(*this)) {
case nsIAutoplay::BLOCKED:
return;