Title: [105439] trunk/Source/WebKit2
Revision
105439
Author
[email protected]
Date
2012-01-19 12:55:19 -0800 (Thu, 19 Jan 2012)

Log Message

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.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (105438 => 105439)


--- trunk/Source/WebKit2/ChangeLog	2012-01-19 20:52:32 UTC (rev 105438)
+++ trunk/Source/WebKit2/ChangeLog	2012-01-19 20:55:19 UTC (rev 105439)
@@ -1,3 +1,30 @@
+2012-01-18  Ada Chan  <[email protected]>
+
+        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  <[email protected]>
 
         [GTK] WebKit2 GTK+ API public headers are not installed

Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp (105438 => 105439)


--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp	2012-01-19 20:52:32 UTC (rev 105438)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp	2012-01-19 20:55:19 UTC (rev 105439)
@@ -55,6 +55,7 @@
     encoder->encode(canRunBeforeUnloadConfirmPanel);
     encoder->encode(canRunModal);
     encoder->encode(deviceScaleFactor);
+    encoder->encode(mediaVolume);
 
 #if PLATFORM(MAC)
     encoder->encode(isSmartInsertDeleteEnabled);
@@ -111,6 +112,8 @@
         return false;
     if (!decoder->decode(parameters.deviceScaleFactor))
         return false;
+    if (!decoder->decode(parameters.mediaVolume))
+        return false;
 
 #if PLATFORM(MAC)
     if (!decoder->decode(parameters.isSmartInsertDeleteEnabled))

Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.h (105438 => 105439)


--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.h	2012-01-19 20:52:32 UTC (rev 105438)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.h	2012-01-19 20:55:19 UTC (rev 105439)
@@ -76,6 +76,8 @@
     bool canRunModal;
 
     float deviceScaleFactor;
+    
+    float mediaVolume;
 
 #if PLATFORM(MAC)
     bool isSmartInsertDeleteEnabled;

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (105438 => 105439)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2012-01-19 20:52:32 UTC (rev 105438)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2012-01-19 20:55:19 UTC (rev 105439)
@@ -661,3 +661,8 @@
 {
     toImpl(page)->setShouldSendEventsSynchronously(sync);
 }
+
+void WKPageSetMediaVolume(WKPageRef page, float volume)
+{
+    toImpl(page)->setMediaVolume(volume);    
+}

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h (105438 => 105439)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h	2012-01-19 20:52:32 UTC (rev 105438)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h	2012-01-19 20:55:19 UTC (rev 105439)
@@ -87,6 +87,8 @@
 
 WK_EXPORT void WKPageSetShouldSendEventsSynchronously(WKPageRef page, bool sync);
 
+WK_EXPORT void WKPageSetMediaVolume(WKPageRef page, float volume);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (105438 => 105439)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-01-19 20:52:32 UTC (rev 105438)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-01-19 20:55:19 UTC (rev 105439)
@@ -199,6 +199,7 @@
     , m_pageCount(0)
     , m_renderTreeSize(0)
     , m_shouldSendEventsSynchronously(false)
+    , m_mediaVolume(1)
 {
 #ifndef NDEBUG
     webPageProxyCounter.increment();
@@ -2320,6 +2321,19 @@
     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 @@
     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;

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (105438 => 105439)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2012-01-19 20:52:32 UTC (rev 105438)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2012-01-19 20:55:19 UTC (rev 105439)
@@ -607,6 +607,8 @@
     void setShouldSendEventsSynchronously(bool sync) { m_shouldSendEventsSynchronously = sync; };
 
     void printMainFrame();
+    
+    void setMediaVolume(float);
 
     // WebPopupMenuProxy::Client
     virtual NativeWebMouseEvent* currentlyProcessedMouseDownEvent();
@@ -1002,6 +1004,8 @@
     static WKPageDebugPaintFlags s_debugPaintFlags;
 
     bool m_shouldSendEventsSynchronously;
+    
+    float m_mediaVolume;
 
 #if PLATFORM(QT)
     WTF::HashSet<RefPtr<QtNetworkRequestData> > m_applicationSchemeRequests;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (105438 => 105439)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-01-19 20:52:32 UTC (rev 105438)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-01-19 20:55:19 UTC (rev 105439)
@@ -271,6 +271,8 @@
         restoreSession(parameters.sessionState);
 
     m_drawingArea->setPaintingEnabled(true);
+    
+    setMediaVolume(parameters.mediaVolume);
 
 #ifndef NDEBUG
     webPageCounter.increment();
@@ -2830,6 +2832,11 @@
 }
 #endif
 
+void WebPage::setMediaVolume(float volume)
+{
+    m_page->setMediaVolume(volume);
+}
+
 void WebPage::runModal()
 {
     if (m_isClosed)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (105438 => 105439)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2012-01-19 20:52:32 UTC (rev 105438)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2012-01-19 20:55:19 UTC (rev 105439)
@@ -438,6 +438,8 @@
     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();

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (105438 => 105439)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2012-01-19 20:52:32 UTC (rev 105438)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2012-01-19 20:55:19 UTC (rev 105439)
@@ -188,6 +188,9 @@
     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
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to