Bug 1513681 - part1 : dispatch 'GloballyAutoplayBlocked' event when site is blocked r=cpearce,smaug

This event is used to notify tab that this site is blocked and we should show the blocking icon for it. Patch2 will handle following details.

Differential Revision: https://phabricator.services.mozilla.com/D14794

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alastor Wu 2019-01-04 19:05:52 +00:00
Родитель da7650abaa
Коммит 4d16da70e0
3 изменённых файлов: 19 добавлений и 0 удалений

Просмотреть файл

@ -11738,6 +11738,20 @@ void Document::NotifyUserGestureActivation() {
}
}
void Document::MaybeNotifyAutoplayBlocked() {
Document* topLevelDoc = GetTopLevelContentDocument();
if (!topLevelDoc) {
return;
}
// This event is used to notify front-end side that we've blocked autoplay,
// so front-end side should show blocking icon as well.
RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher(
topLevelDoc, NS_LITERAL_STRING("GloballyAutoplayBlocked"),
CanBubble::eYes, ChromeOnlyDispatch::eYes);
asyncDispatcher->PostDOMEvent();
}
void Document::SetDocTreeHadAudibleMedia() {
Document* topLevelDoc = GetTopLevelContentDocument();
if (!topLevelDoc) {

Просмотреть файл

@ -3485,6 +3485,10 @@ class Document : public nsINode,
void ReportShadowDOMUsage();
// When the doc is blocked permanantly, we would dispatch event to notify
// front-end side to show blocking icon.
void MaybeNotifyAutoplayBlocked();
// Sets flags for media autoplay telemetry.
void SetDocTreeHadAudibleMedia();
void SetDocTreeHadPlayRevoked();

Просмотреть файл

@ -3697,6 +3697,7 @@ void HTMLMediaElement::DispatchEventsWhenPlayWasNotAllowed() {
ChromeOnlyDispatch::eYes);
asyncDispatcher->PostDOMEvent();
#endif
OwnerDoc()->MaybeNotifyAutoplayBlocked();
}
void HTMLMediaElement::PlayInternal(bool aHandlingUserInput) {