Entering Tab View after a bunch of YouTube pages were opened in background tabs makes...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Nov 2012 21:52:47 +0000 (21:52 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Nov 2012 21:52:47 +0000 (21:52 +0000)
commit09ed2332e1aa6f38ca5a25d2e82971cb72e0004e
treec4bd1233c5ec90c5dba8830d23a85640cdfc3aaf
parentc8e793f8ada2b7f6fe723338ed458f0a8d3a07f5
Entering Tab View after a bunch of YouTube pages were opened in background tabs makes all of them start playing simultaneously
https://bugs.webkit.org/show_bug.cgi?id=103358

Reviewed by Adele Peterson.

To fix this, this patch adds WKPageSetMayStartMediaWhenInWindow(), which allows the client to
prevent media from starting automatically when the view is put in a window.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode): Encode mayStartMediaWhenInWindow.
(WebKit::WebPageCreationParameters::decode): Decode mayStartMediaWhenInWindow.
* Shared/WebPageCreationParameters.h:
(WebPageCreationParameters): Added boolean member mayStartMediaWhenInWindow.
* UIProcess/API/C/WKPage.cpp:
(WKPageSetMayStartMediaWhenInWindow): Added. Calls through to WebPageProxy.
* UIProcess/API/C/WKPagePrivate.h: Declared WKPageSetMayStartMediaWhenInWindow.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy): Added initializiation of m_mayStartMediaWhenInWindow
to true, the value matching the current behavior.
(WebKit::WebPageProxy::setMayStartMediaWhenInWindow): Added. Updates
m_mayStartMediaWhenInWindow and sends a message to the Web process to do the same.
(WebKit::WebPageProxy::creationParameters): Changed to set mayStartMediaWhenInWindow in the
process creation parameters.
* UIProcess/WebPageProxy.h:
(WebPageProxy): Declared setMayStartMediaWhenInWindow() and added member variable
m_mayStartMediaWhenInWindow.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage): Initialized m_mayStartMediaWhenInWindow from the creation
parameters.
(WebKit::WebPage::setIsInWindow): Made starting of media upon being added to a window
conditional on m_mayStartMediaWhenInWindow.
(WebKit::WebPage::setMayStartMediaWhenInWindow): Added. Sets m_mayStartMediaWhenInWindow. If
already in a window when changing from false to true, starts m_setCanStartMediaTimer.
* WebProcess/WebPage/WebPage.h:
(WebPage): Declared setMayStartMediaWhenInWindow() and added member variable m_mayStartMediaWhenInWindow.
* WebProcess/WebPage/WebPage.messages.in: Added SetMayStartMediaWhenInWindow.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135915 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPageCreationParameters.cpp
Source/WebKit2/Shared/WebPageCreationParameters.h
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPagePrivate.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in