Use modern async IPC with reply for device orientation permission
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 10 Mar 2019 04:34:19 +0000 (04:34 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 10 Mar 2019 04:34:19 +0000 (04:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195529

Reviewed by Ryosuke Niwa.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::requestDeviceOrientationAndMotionAccess):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::shouldAllowDeviceOrientationAndMotionAccess):
(WebKit::nextDeviceOrientationAndMotionPermissionCallbackID): Deleted.
(WebKit::WebPage::didReceiveDeviceOrientationAndMotionAccessDecision): Deleted.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in

index 80be999..1a9ad99 100644 (file)
@@ -1,3 +1,21 @@
+2019-03-09  Chris Dumez  <cdumez@apple.com>
+
+        Use modern async IPC with reply for device orientation permission
+        https://bugs.webkit.org/show_bug.cgi?id=195529
+
+        Reviewed by Ryosuke Niwa.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::requestDeviceOrientationAndMotionAccess):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::shouldAllowDeviceOrientationAndMotionAccess):
+        (WebKit::nextDeviceOrientationAndMotionPermissionCallbackID): Deleted.
+        (WebKit::WebPage::didReceiveDeviceOrientationAndMotionAccessDecision): Deleted.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2019-03-09  Zalan Bujtas  <zalan@apple.com>
 
         [ContentChangeObserver] Start observing for content change between touchEnd and mouseMoved start
index de136c0..ca0d491 100644 (file)
@@ -7175,14 +7175,10 @@ void WebPageProxy::clearUserMediaState()
 }
 
 #if ENABLE(DEVICE_ORIENTATION)
-void WebPageProxy::requestDeviceOrientationAndMotionAccess(WebCore::SecurityOriginData&& originData, uint64_t callbackID)
+void WebPageProxy::requestDeviceOrientationAndMotionAccess(WebCore::SecurityOriginData&& originData, CompletionHandler<void(bool)>&& completionHandler)
 {
     auto origin = API::SecurityOrigin::create(originData.securityOrigin());
-    m_uiClient->shouldAllowDeviceOrientationAndMotionAccess(*this, origin.get(), [this, weakThis = makeWeakPtr(*this), callbackID](bool granted) {
-        if (!weakThis || !isValid())
-            return;
-        m_process->send(Messages::WebPage::DidReceiveDeviceOrientationAndMotionAccessDecision(callbackID, granted), m_pageID);
-    });
+    m_uiClient->shouldAllowDeviceOrientationAndMotionAccess(*this, origin.get(), WTFMove(completionHandler));
 }
 #endif
 
index a802b10..34a6039 100644 (file)
@@ -1402,7 +1402,7 @@ public:
 #endif
 
 #if ENABLE(DEVICE_ORIENTATION)
-    void requestDeviceOrientationAndMotionAccess(WebCore::SecurityOriginData&&, uint64_t callbackID);
+    void requestDeviceOrientationAndMotionAccess(WebCore::SecurityOriginData&&, CompletionHandler<void(bool)>&&);
 #endif
 
     static WebPageProxy* nonEphemeralWebPageProxy();
index 0b12e2b..b278d5c 100644 (file)
@@ -534,7 +534,7 @@ messages -> WebPageProxy {
     LoadSynchronousURLSchemeTask(struct WebKit::URLSchemeTaskParameters parameters) -> (WebCore::ResourceResponse response, WebCore::ResourceError error, IPC::DataReference data) Delayed
 
 #if ENABLE(DEVICE_ORIENTATION)
-    RequestDeviceOrientationAndMotionAccess(struct WebCore::SecurityOriginData origin, uint64_t callbackID);
+    RequestDeviceOrientationAndMotionAccess(struct WebCore::SecurityOriginData origin) -> (bool granted) Async
 #endif
 
 #if ENABLE(ATTACHMENT_ELEMENT)
index 609e369..9824b22 100644 (file)
@@ -6341,26 +6341,9 @@ void WebPage::requestStorageAccess(String&& subFrameHost, String&& topFrameHost,
 #endif
 
 #if ENABLE(DEVICE_ORIENTATION)
-static uint64_t nextDeviceOrientationAndMotionPermissionCallbackID()
+void WebPage::shouldAllowDeviceOrientationAndMotionAccess(const WebCore::SecurityOrigin& origin, CompletionHandler<void(bool)>&& completionHandler)
 {
-    static uint64_t nextCallbackID = 0;
-    return ++nextCallbackID;
-}
-
-void WebPage::shouldAllowDeviceOrientationAndMotionAccess(const WebCore::SecurityOrigin& origin, CompletionHandler<void(bool)>&& callback)
-{
-    auto callbackID = nextDeviceOrientationAndMotionPermissionCallbackID();
-    ASSERT(!m_deviceOrientationAndMotionPermissionCallbackMap.contains(callbackID));
-    m_deviceOrientationAndMotionPermissionCallbackMap.add(callbackID, WTFMove(callback));
-
-    send(Messages::WebPageProxy::RequestDeviceOrientationAndMotionAccess(origin.data(), callbackID));
-}
-
-void WebPage::didReceiveDeviceOrientationAndMotionAccessDecision(uint64_t callbackID, bool granted)
-{
-    auto callback = m_deviceOrientationAndMotionPermissionCallbackMap.take(callbackID);
-    ASSERT(callback);
-    callback(granted);
+    sendWithAsyncReply(Messages::WebPageProxy::RequestDeviceOrientationAndMotionAccess(origin.data()), WTFMove(completionHandler));
 }
 #endif
     
index 25ef232..cd954e8 100644 (file)
@@ -1210,10 +1210,6 @@ private:
     void requestAdditionalItemsForDragSession(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition);
 #endif
 
-#if ENABLE(DEVICE_ORIENTATION)
-    void didReceiveDeviceOrientationAndMotionAccessDecision(uint64_t callbackID, bool granted);
-#endif
-
 #if !PLATFORM(COCOA) && !PLATFORM(WPE)
     static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
 #endif
@@ -1844,10 +1840,6 @@ private:
     HashMap<uint64_t, WTF::Function<void(bool granted)>> m_storageAccessResponseCallbackMap;
     HashMap<ShareSheetCallbackID, WTF::Function<void(bool completed)>> m_shareSheetResponseCallbackMap;
 
-#if ENABLE(DEVICE_ORIENTATION)
-    HashMap<uint64_t, WTF::CompletionHandler<void(bool granted)>> m_deviceOrientationAndMotionPermissionCallbackMap;
-#endif
-
 #if ENABLE(APPLICATION_MANIFEST)
     HashMap<uint64_t, uint64_t> m_applicationManifestFetchCallbackMap;
 #endif
index 9d7239d..cce7722 100644 (file)
@@ -363,10 +363,6 @@ messages -> WebPage LegacyReceiver {
     # Notification
     DidReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed)
 
-#if ENABLE(DEVICE_ORIENTATION)
-    DidReceiveDeviceOrientationAndMotionAccessDecision(uint64_t callbackID, bool granted)
-#endif
-
     # Printing.
     BeginPrinting(uint64_t frameID, struct WebKit::PrintInfo printInfo)
     EndPrinting()