Need a WebKit2 API for setting media volume https://bugs.webkit.org/show_bug.cgi...
authoradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2012 20:55:19 +0000 (20:55 +0000)
committeradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2012 20:55:19 +0000 (20:55 +0000)
Reviewed by Dan Bernstein.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode): Encode the mediaVolume parameter.
(WebKit::WebPageCreationParameters::decode): Decode the mediaVolume parameter.
* Shared/WebPageCreationParameters.h:
* UIProcess/API/C/WKPage.cpp:
(WKPageSetMediaVolume): Call WebPageProxy::setMediaVolume().
* UIProcess/API/C/WKPagePrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy): Initialize new data member m_mediaVolume.
(WebKit::WebPageProxy::setMediaVolume): Bail if the volume hasn't changed. Update m_mediaVolume
and bail if the page is no longer valid.  Otherwise, send a WebPage::SetMediaVolume message to
the web process.
(WebKit::WebPageProxy::creationParameters): Add media volume to the creation parameters.
* UIProcess/WebPageProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage): Initialize media volume from the WebPageCreationParameters.
(WebKit::WebPage::setMediaVolume): Call Page::setMediaVolume().
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in: Add the SetMediaVolume message.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105439 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

index bec60e9..19a42a3 100644 (file)
@@ -1,3 +1,30 @@
+2012-01-18  Ada Chan  <adachan@apple.com>
+
+        Need a WebKit2 API for setting media volume
+        https://bugs.webkit.org/show_bug.cgi?id=76560
+
+        Reviewed by Dan Bernstein.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode): Encode the mediaVolume parameter.
+        (WebKit::WebPageCreationParameters::decode): Decode the mediaVolume parameter.
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetMediaVolume): Call WebPageProxy::setMediaVolume().
+        * UIProcess/API/C/WKPagePrivate.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy): Initialize new data member m_mediaVolume.
+        (WebKit::WebPageProxy::setMediaVolume): Bail if the volume hasn't changed. Update m_mediaVolume 
+        and bail if the page is no longer valid.  Otherwise, send a WebPage::SetMediaVolume message to 
+        the web process.
+        (WebKit::WebPageProxy::creationParameters): Add media volume to the creation parameters.
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage): Initialize media volume from the WebPageCreationParameters.
+        (WebKit::WebPage::setMediaVolume): Call Page::setMediaVolume().
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in: Add the SetMediaVolume message.
+
 2012-01-19  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] WebKit2 GTK+ API public headers are not installed
index 2e4d99d..d051791 100644 (file)
@@ -55,6 +55,7 @@ void WebPageCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) const
     encoder->encode(canRunBeforeUnloadConfirmPanel);
     encoder->encode(canRunModal);
     encoder->encode(deviceScaleFactor);
+    encoder->encode(mediaVolume);
 
 #if PLATFORM(MAC)
     encoder->encode(isSmartInsertDeleteEnabled);
@@ -111,6 +112,8 @@ bool WebPageCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, WebPag
         return false;
     if (!decoder->decode(parameters.deviceScaleFactor))
         return false;
+    if (!decoder->decode(parameters.mediaVolume))
+        return false;
 
 #if PLATFORM(MAC)
     if (!decoder->decode(parameters.isSmartInsertDeleteEnabled))
index 972dcb0..867c408 100644 (file)
@@ -76,6 +76,8 @@ struct WebPageCreationParameters {
     bool canRunModal;
 
     float deviceScaleFactor;
+    
+    float mediaVolume;
 
 #if PLATFORM(MAC)
     bool isSmartInsertDeleteEnabled;
index 9c7a029..8768a8d 100644 (file)
@@ -661,3 +661,8 @@ void WKPageSetShouldSendEventsSynchronously(WKPageRef page, bool sync)
 {
     toImpl(page)->setShouldSendEventsSynchronously(sync);
 }
+
+void WKPageSetMediaVolume(WKPageRef page, float volume)
+{
+    toImpl(page)->setMediaVolume(volume);    
+}
index d378ade..6572e86 100644 (file)
@@ -87,6 +87,8 @@ WK_EXPORT WKImageRef WKPageCreateSnapshotOfVisibleContent(WKPageRef page);
 
 WK_EXPORT void WKPageSetShouldSendEventsSynchronously(WKPageRef page, bool sync);
 
+WK_EXPORT void WKPageSetMediaVolume(WKPageRef page, float volume);
+
 #ifdef __cplusplus
 }
 #endif
index 52ff6c0..37f03e3 100644 (file)
@@ -199,6 +199,7 @@ WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> p
     , m_pageCount(0)
     , m_renderTreeSize(0)
     , m_shouldSendEventsSynchronously(false)
+    , m_mediaVolume(1)
 {
 #ifndef NDEBUG
     webPageProxyCounter.increment();
@@ -2320,6 +2321,19 @@ void WebPageProxy::printMainFrame()
     printFrame(m_mainFrame->frameID());
 }
 
+void WebPageProxy::setMediaVolume(float volume)
+{
+    if (volume == m_mediaVolume)
+        return;
+    
+    m_mediaVolume = volume;
+    
+    if (!isValid())
+        return;
+    
+    process()->send(Messages::WebPage::SetMediaVolume(volume), m_pageID);    
+}
+
 #if PLATFORM(QT)
 void WebPageProxy::didChangeContentsSize(const IntSize& size)
 {
@@ -3242,6 +3256,7 @@ WebPageCreationParameters WebPageProxy::creationParameters() const
     parameters.canRunBeforeUnloadConfirmPanel = m_uiClient.canRunBeforeUnloadConfirmPanel();
     parameters.canRunModal = m_uiClient.canRunModal();
     parameters.deviceScaleFactor = m_intrinsicDeviceScaleFactor;
+    parameters.mediaVolume = m_mediaVolume;
 
 #if PLATFORM(MAC)
     parameters.isSmartInsertDeleteEnabled = m_isSmartInsertDeleteEnabled;
index 9dade1e..a45cd9f 100644 (file)
@@ -607,6 +607,8 @@ public:
     void setShouldSendEventsSynchronously(bool sync) { m_shouldSendEventsSynchronously = sync; };
 
     void printMainFrame();
+    
+    void setMediaVolume(float);
 
     // WebPopupMenuProxy::Client
     virtual NativeWebMouseEvent* currentlyProcessedMouseDownEvent();
@@ -1002,6 +1004,8 @@ private:
     static WKPageDebugPaintFlags s_debugPaintFlags;
 
     bool m_shouldSendEventsSynchronously;
+    
+    float m_mediaVolume;
 
 #if PLATFORM(QT)
     WTF::HashSet<RefPtr<QtNetworkRequestData> > m_applicationSchemeRequests;
index 365d578..3e40735 100644 (file)
@@ -271,6 +271,8 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
         restoreSession(parameters.sessionState);
 
     m_drawingArea->setPaintingEnabled(true);
+    
+    setMediaVolume(parameters.mediaVolume);
 
 #ifndef NDEBUG
     webPageCounter.increment();
@@ -2830,6 +2832,11 @@ void WebPage::drawPagesToPDF(uint64_t frameID, const PrintInfo& printInfo, uint3
 }
 #endif
 
+void WebPage::setMediaVolume(float volume)
+{
+    m_page->setMediaVolume(volume);
+}
+
 void WebPage::runModal()
 {
     if (m_isClosed)
index 40072cf..e5d202d 100644 (file)
@@ -438,6 +438,8 @@ public:
     void drawPagesToPDF(uint64_t frameID, const PrintInfo&, uint32_t first, uint32_t count, uint64_t callbackID);
 #endif
 
+    void setMediaVolume(float);
+
     bool mainFrameHasCustomRepresentation() const;
 
     void didChangeScrollOffsetForMainFrame();
index 5a3bb45..702479b 100644 (file)
@@ -188,6 +188,9 @@ messages -> WebPage {
     DrawPagesToPDF(uint64_t frameID, WebKit::PrintInfo printInfo, uint32_t first, uint32_t count, uint64_t callbackID)
 #endif
 
+    # Media
+    SetMediaVolume(float volume)
+
     SetMemoryCacheMessagesEnabled(bool memoryCacheMessagesEnabled)
 
     // FIXME: This a dummy message, to avoid breaking the build for platforms that don't require