Pass down website autoplay policies to media elements
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jan 2017 21:03:42 +0000 (21:03 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jan 2017 21:03:42 +0000 (21:03 +0000)
commitc84d426588b712c635715170cf44a7bc95d12b9f
tree380f006b5817e53d29a4c979d71d4c40af358d7c
parent5be461ec947b6f5cd18109a27f90e3458e00c101
Pass down website autoplay policies to media elements
https://bugs.webkit.org/show_bug.cgi?id=167355

Patch by Matt Rajca <mrajca@apple.com> on 2017-01-24
Reviewed by Alex Christensen.

Source/WebCore:

Autoplay policies can be specified at the global web view preferences level or on a per-page
basis during navigation. This patch ensures that policies specified on a per-page basis hold
precedence over global policies. If no policies are specified during navigation, global
policies are used. A WebsiteAutoplayPolicy::Default option has been added to let clients
explicitly specify web view defaults should be used.

* dom/Document.cpp:
(WebCore::Document::audioPlaybackRequiresUserGesture):
(WebCore::Document::videoPlaybackRequiresUserGesture):
* dom/Document.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::playInternal):
* loader/DocumentLoader.h:
(WebCore::DocumentLoader::audioPlaybackRequiresUserGesture):
(WebCore::DocumentLoader::setAudioPlaybackRequiresUserGesture):
(WebCore::DocumentLoader::videoPlaybackRequiresUserGesture):
(WebCore::DocumentLoader::setVideoPlaybackRequiresUserGesture):

Source/WebKit2:

Autoplay policies can be specified at the global web view preferences level or on a per-page
basis during navigation. This patch ensures that policies specified on a per-page basis hold
precedence over global policies. If no policies are specified during navigation, global
policies are used. A WebsiteAutoplayPolicy::Default option has been added to let clients
explicitly specify web view defaults should be used.

* Shared/WebsitePolicies.h:
* UIProcess/API/C/WKWebsitePolicies.cpp:
(WKWebsitePoliciesGetAutoplayPolicy):
(WKWebsitePoliciesSetAutoplayPolicy):
* UIProcess/API/C/WKWebsitePolicies.h:
* UIProcess/API/Cocoa/_WKWebsitePolicies.h:
* UIProcess/API/Cocoa/_WKWebsitePolicies.mm:
(-[_WKWebsitePolicies setAutoplayPolicy:]):
(-[_WKWebsitePolicies autoplayPolicy]):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/autoplay-check.html: Renamed from Tools/TestWebKitAPI/Tests/WebKit2/autoplayCheck.html to match our naming conventions.
* TestWebKitAPI/Tests/WebKit2/autoplay-no-audio-check.html: Added.
* TestWebKitAPI/Tests/WebKit2/test-without-audio-track.mp4: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
(-[AutoplayPoliciesDelegate _webView:decidePolicyForNavigationAction:decisionHandler:]):
(TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211097 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/loader/DocumentLoader.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebsitePolicies.h
Source/WebKit2/UIProcess/API/APIWebsitePolicies.h
Source/WebKit2/UIProcess/API/C/WKWebsitePolicies.cpp
Source/WebKit2/UIProcess/API/C/WKWebsitePolicies.h
Source/WebKit2/UIProcess/API/Cocoa/_WKWebsitePolicies.h
Source/WebKit2/UIProcess/API/Cocoa/_WKWebsitePolicies.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/autoplay-check.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2/autoplay-no-audio-check.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2/test-without-audio-track.mp4 [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm