Call WKPageUIClient::isPlayingAudioDidChange() whenever audio starts/stops playing...
authoradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Oct 2014 04:42:01 +0000 (04:42 +0000)
committeradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Oct 2014 04:42:01 +0000 (04:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137050

Reviewed by Anders Carlsson.

Implement WebChromeClient::isPlayingAudioDidChange() which sends the new isPlayingAudio state
over to the UI process. WebPageProxy caches the isPlayingAudio state, and when that changes,
it calls WKPageUIClient::isPlayingAudioDidChange().

* UIProcess/API/APIUIClient.h:
(API::UIClient::isPlayingAudioDidChange):
* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::isPlayingAudioDidChange):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::isPlayingAudio):
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::isPlayingAudioDidChange):
* WebProcess/WebCoreSupport/WebChromeClient.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174384 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/APIUIClient.h
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

index 741cc22..4f45133 100644 (file)
@@ -1,3 +1,28 @@
+2014-10-06  Ada Chan  <adachan@apple.com>
+
+        Call WKPageUIClient::isPlayingAudioDidChange() whenever audio starts/stops playing on a page.
+        https://bugs.webkit.org/show_bug.cgi?id=137050
+
+        Reviewed by Anders Carlsson.
+
+        Implement WebChromeClient::isPlayingAudioDidChange() which sends the new isPlayingAudio state
+        over to the UI process. WebPageProxy caches the isPlayingAudio state, and when that changes,
+        it calls WKPageUIClient::isPlayingAudioDidChange().
+
+        * UIProcess/API/APIUIClient.h:
+        (API::UIClient::isPlayingAudioDidChange):
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetPageUIClient):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::isPlayingAudioDidChange):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::isPlayingAudio):
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::isPlayingAudioDidChange):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+
 2014-10-06  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         [EFL] Restore previous scroll position using restoreViewState()
index 1ca15e3..b788d92 100644 (file)
@@ -144,6 +144,8 @@ public:
     virtual void didRecognizeLongMousePress(WebKit::WebPageProxy*, API::Object*) { }
     virtual void didCancelTrackingPotentialLongMousePress(WebKit::WebPageProxy*, API::Object*) { }
 
+    virtual void isPlayingAudioDidChange(WebKit::WebPageProxy&) { }
+
 #if PLATFORM(IOS)
     virtual RetainPtr<NSArray> actionsForElement(_WKActivatedElementInfo *, RetainPtr<NSArray> defaultActions) { return WTF::move(defaultActions); }
     virtual void didNotHandleTapAsClick(const WebCore::IntPoint&) { }
index 25c725e..930a541 100644 (file)
@@ -1610,6 +1610,14 @@ void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClientBase* wkClient
 
             m_client.didCancelTrackingPotentialLongMousePress(toAPI(page), toAPI(userInfo), m_client.base.clientInfo);
         }
+
+        virtual void isPlayingAudioDidChange(WebPageProxy& page)
+        {
+            if (!m_client.isPlayingAudioDidChange)
+                return;
+
+            m_client.isPlayingAudioDidChange(toAPI(&page), m_client.base.clientInfo);
+        }
     };
 
     toImpl(pageRef)->setUIClient(std::make_unique<UIClient>(wkClient));
index 1535e80..190c915 100644 (file)
@@ -370,6 +370,7 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
     , m_configurationPreferenceValues(configuration.preferenceValues)
     , m_potentiallyChangedViewStateFlags(ViewState::NoFlags)
     , m_viewStateChangeWantsReply(false)
+    , m_isPlayingAudio(false)
 {
     if (m_process->state() == WebProcessProxy::State::Running) {
         if (m_userContentController)
@@ -5244,6 +5245,15 @@ void WebPageProxy::willChangeCurrentHistoryItemForMainFrame()
     recordNavigationSnapshot();
 }
 
+void WebPageProxy::isPlayingAudioDidChange(bool newIsPlayingAudio)
+{
+    if (m_isPlayingAudio == newIsPlayingAudio)
+        return;
+
+    m_isPlayingAudio = newIsPlayingAudio;
+    m_uiClient->isPlayingAudioDidChange(*this);
+}
+
 #if PLATFORM(MAC)
 void WebPageProxy::removeNavigationGestureSnapshot()
 {
index 1029c5f..f0b7827 100644 (file)
@@ -911,6 +911,9 @@ public:
 
     bool isShowingNavigationGestureSnapshot() const { return m_isShowingNavigationGestureSnapshot; }
 
+    void isPlayingAudioDidChange(bool);
+    bool isPlayingAudio() const { return m_isPlayingAudio; }
+
 #if PLATFORM(MAC)
     void removeNavigationGestureSnapshot();
 #endif
@@ -1546,6 +1549,8 @@ private:
     WebPreferencesStore::ValueMap m_configurationPreferenceValues;
     WebCore::ViewState::Flags m_potentiallyChangedViewStateFlags;
     bool m_viewStateChangeWantsReply;
+
+    bool m_isPlayingAudio;
 };
 
 } // namespace WebKit
index 4a6fd57..0f455e7 100644 (file)
@@ -414,4 +414,6 @@ messages -> WebPageProxy {
 #if ENABLE(CONTENT_FILTERING)
     ContentFilterDidBlockLoadForFrame(WebCore::ContentFilter contentFilter, uint64_t frameID)
 #endif
+
+    IsPlayingAudioDidChange(bool newIsPlayingAudio);
 }
index 88173a6..5de0c53 100644 (file)
@@ -1051,6 +1051,11 @@ bool WebChromeClient::shouldUseTiledBackingForFrameView(const FrameView* frameVi
     return m_page->drawingArea()->shouldUseTiledBackingForFrameView(frameView);
 }
 
+void WebChromeClient::isPlayingAudioDidChange(bool newIsPlayingAudio)
+{
+    m_page->send(Messages::WebPageProxy::IsPlayingAudioDidChange(newIsPlayingAudio));
+}
+
 #if ENABLE(SUBTLE_CRYPTO)
 bool WebChromeClient::wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) const
 {
index f5c5b27..b4d7d4a 100644 (file)
@@ -298,6 +298,8 @@ private:
 
     virtual bool shouldUseTiledBackingForFrameView(const WebCore::FrameView*) const override;
 
+    virtual void isPlayingAudioDidChange(bool) override;
+
 #if ENABLE(SUBTLE_CRYPTO)
     virtual bool wrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const override;
     virtual bool unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const override;