Create WebPageProxy::m_userMediaPermissionRequestManager only when needed
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Feb 2019 19:47:38 +0000 (19:47 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Feb 2019 19:47:38 +0000 (19:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195051

Reviewed by Eric Carlson.

Before the patch, WebPageProxy::m_userMediaPermissionRequestManager was created
in some methods to reset its state when main document is changing, view is becoming visible...
This code is unnecessary if the page did not create it already using JS APIs such as getUserMedia/enumerateDevices/ondevicechange.
This patch skips processing in the other cases if WebPageProxy::m_userMediaPermissionRequestManager is null.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::close): No need to nullify it since it will be done in resetState shortly after.
(WebKit::WebPageProxy::didChangeMainDocument):
(WebKit::WebPageProxy::viewIsBecomingVisible):
(WebKit::WebPageProxy::clearUserMediaState):
(WebKit::WebPageProxy::updatePlayingMediaDidChange): m_userMediaPermissionRequestManager should not be null here
since there is or was some capturing done for the page.

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebPageProxy.cpp

index 7914022..5cd1aaa 100644 (file)
@@ -1,3 +1,23 @@
+2019-02-26  Youenn Fablet  <youenn@apple.com>
+
+        Create WebPageProxy::m_userMediaPermissionRequestManager only when needed
+        https://bugs.webkit.org/show_bug.cgi?id=195051
+
+        Reviewed by Eric Carlson.
+
+        Before the patch, WebPageProxy::m_userMediaPermissionRequestManager was created
+        in some methods to reset its state when main document is changing, view is becoming visible...
+        This code is unnecessary if the page did not create it already using JS APIs such as getUserMedia/enumerateDevices/ondevicechange.
+        This patch skips processing in the other cases if WebPageProxy::m_userMediaPermissionRequestManager is null.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::close): No need to nullify it since it will be done in resetState shortly after.
+        (WebKit::WebPageProxy::didChangeMainDocument):
+        (WebKit::WebPageProxy::viewIsBecomingVisible):
+        (WebKit::WebPageProxy::clearUserMediaState):
+        (WebKit::WebPageProxy::updatePlayingMediaDidChange): m_userMediaPermissionRequestManager should not be null here
+        since there is or was some capturing done for the page.
+
 2019-02-26  Zalan Bujtas  <zalan@apple.com>
 
         [ContentChangeObserver] Simplify content observation API by removing explicit DOMTimer observation.
index b91bbe3..25960de 100644 (file)
@@ -972,10 +972,6 @@ void WebPageProxy::close()
 
     m_isClosed = true;
 
-#if ENABLE(MEDIA_STREAM)
-    m_userMediaPermissionRequestManager = nullptr;
-#endif
-
     reportPageLoadResult(ResourceError { ResourceError::Type::Cancellation });
 
     if (m_activePopupMenu)
@@ -4293,7 +4289,8 @@ void WebPageProxy::didSameDocumentNavigationForFrame(uint64_t frameID, uint64_t
 void WebPageProxy::didChangeMainDocument(uint64_t frameID)
 {
 #if ENABLE(MEDIA_STREAM)
-    userMediaPermissionRequestManager().resetAccess(frameID);
+    if (m_userMediaPermissionRequestManager)
+        m_userMediaPermissionRequestManager->resetAccess(frameID);
 #else
     UNUSED_PARAM(frameID);
 #endif
@@ -4302,7 +4299,8 @@ void WebPageProxy::didChangeMainDocument(uint64_t frameID)
 void WebPageProxy::viewIsBecomingVisible()
 {
 #if ENABLE(MEDIA_STREAM)
-    userMediaPermissionRequestManager().viewIsBecomingVisible();
+    if (m_userMediaPermissionRequestManager)
+        m_userMediaPermissionRequestManager->viewIsBecomingVisible();
 #endif
 }
 
@@ -7139,7 +7137,8 @@ void WebPageProxy::beginMonitoringCaptureDevices()
 void WebPageProxy::clearUserMediaState()
 {
 #if ENABLE(MEDIA_STREAM)
-    userMediaPermissionRequestManager().clearCachedState();
+    if (m_userMediaPermissionRequestManager)
+        m_userMediaPermissionRequestManager->clearCachedState();
 #endif
 }
 
@@ -7869,7 +7868,7 @@ void WebPageProxy::updatePlayingMediaDidChange(MediaProducer::MediaStateFlags ne
 #if ENABLE(MEDIA_STREAM)
     if (oldMediaCaptureState != newMediaCaptureState) {
         m_uiClient->mediaCaptureStateDidChange(m_mediaState);
-        userMediaPermissionRequestManager().captureStateChanged(oldMediaCaptureState, newMediaCaptureState);
+        m_userMediaPermissionRequestManager->captureStateChanged(oldMediaCaptureState, newMediaCaptureState);
     }
 #endif