Allow WebFramePolicyListenerProxy to be used multiple times
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Aug 2018 18:04:51 +0000 (18:04 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Aug 2018 18:04:51 +0000 (18:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188229

Reviewed by Chris Dumez.

This fixes a regression from r234210 in clients that misuse the API.

* UIProcess/WebFramePolicyListenerProxy.cpp:
(WebKit::WebFramePolicyListenerProxy::use):
(WebKit::WebFramePolicyListenerProxy::download):
(WebKit::WebFramePolicyListenerProxy::ignore):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp

index b404a71..aaefbdf 100644 (file)
@@ -1,3 +1,17 @@
+2018-08-01  Alex Christensen  <achristensen@webkit.org>
+
+        Allow WebFramePolicyListenerProxy to be used multiple times
+        https://bugs.webkit.org/show_bug.cgi?id=188229
+
+        Reviewed by Chris Dumez.
+
+        This fixes a regression from r234210 in clients that misuse the API.
+
+        * UIProcess/WebFramePolicyListenerProxy.cpp:
+        (WebKit::WebFramePolicyListenerProxy::use):
+        (WebKit::WebFramePolicyListenerProxy::download):
+        (WebKit::WebFramePolicyListenerProxy::ignore):
+
 2018-08-01  Aditya Keerthi  <akeerthi@apple.com>
 
         [iOS] Color picker should have a border when presented in a popover
index fe4308d..f395743 100644 (file)
@@ -42,17 +42,20 @@ WebFramePolicyListenerProxy::WebFramePolicyListenerProxy(CompletionHandler<void(
 
 void WebFramePolicyListenerProxy::use(API::WebsitePolicies* policies, ShouldProcessSwapIfPossible swap)
 {
-    m_completionHandler(WebCore::PolicyAction::Use, policies, swap);
+    if (m_completionHandler)
+        m_completionHandler(WebCore::PolicyAction::Use, policies, swap);
 }
 
 void WebFramePolicyListenerProxy::download()
 {
-    m_completionHandler(WebCore::PolicyAction::Download, nullptr, ShouldProcessSwapIfPossible::No);
+    if (m_completionHandler)
+        m_completionHandler(WebCore::PolicyAction::Download, nullptr, ShouldProcessSwapIfPossible::No);
 }
 
 void WebFramePolicyListenerProxy::ignore()
 {
-    m_completionHandler(WebCore::PolicyAction::Ignore, nullptr, ShouldProcessSwapIfPossible::No);
+    if (m_completionHandler)
+        m_completionHandler(WebCore::PolicyAction::Ignore, nullptr, ShouldProcessSwapIfPossible::No);
 }
 
 } // namespace WebKit