Make PolicyAction an encodable enum class
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Sep 2017 05:52:40 +0000 (05:52 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Sep 2017 05:52:40 +0000 (05:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=177480

Reviewed by Antti Koivisto.

Source/WebCore:

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::responseReceived):
(WebCore::DocumentLoader::continueAfterContentPolicy):
* loader/FrameLoaderTypes.h:
* loader/PolicyChecker.cpp:
(WebCore::PolicyChecker::checkNavigationPolicy):
(WebCore::PolicyChecker::checkNewWindowPolicy):

Source/WebKit:

* NetworkProcess/Downloads/DownloadManager.cpp:
(WebKit::DownloadManager::continueDecidePendingDownloadDestination):
(WebKit::DownloadManager::cancelDownload):
* NetworkProcess/NetworkCORSPreflightChecker.cpp:
(WebKit::NetworkCORSPreflightChecker::didReceiveResponseNetworkSession):
* NetworkProcess/NetworkDataTask.cpp:
(WebKit::NetworkDataTask::didReceiveResponse):
* NetworkProcess/NetworkDataTaskBlob.cpp:
(WebKit::NetworkDataTaskBlob::dispatchDidReceiveResponse):
* NetworkProcess/NetworkLoad.cpp:
(WebKit::NetworkLoad::~NetworkLoad):
(WebKit::NetworkLoad::continueDidReceiveResponse):
(WebKit::NetworkLoad::notifyDidReceiveResponse):
* NetworkProcess/PingLoad.cpp:
(WebKit::PingLoad::didReceiveResponseNetworkSession):
* NetworkProcess/capture/NetworkDataTaskReplay.cpp:
(WebKit::NetworkCapture::NetworkDataTaskReplay::didReceiveResponse):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(toNSURLSessionResponseDisposition):
* NetworkProcess/soup/NetworkDataTaskSoup.cpp:
(WebKit::NetworkDataTaskSoup::dispatchDidReceiveResponse):
* Scripts/webkit/messages.py:
(headers_for_type):
* UIProcess/WebFormSubmissionListenerProxy.h:
* UIProcess/WebFrameListenerProxy.h:
(WebKit::WebFrameListenerProxy::navigation): Deleted.
* UIProcess/WebFramePolicyListenerProxy.cpp:
(WebKit::WebFramePolicyListenerProxy::use):
(WebKit::WebFramePolicyListenerProxy::download):
(WebKit::WebFramePolicyListenerProxy::ignore):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::receivedPolicyDecision):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::invalidatePolicyListener):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didReceivePolicyDecision):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Source/WebKitLegacy/mac:

* Plugins/WebPluginContainerCheck.mm:
(-[WebPluginContainerCheck _continueWithPolicy:]):
(-[WebPluginContainerCheck _isForbiddenFileLoad]):
* WebCoreSupport/WebFrameLoaderClient.mm:
(-[WebFramePolicyListener invalidate]):
(-[WebFramePolicyListener ignore]):
(-[WebFramePolicyListener download]):
(-[WebFramePolicyListener use]):
(-[WebFramePolicyListener continue]):
* WebView/WebPolicyDelegate.mm:
(-[WebPolicyDecisionListener use]):
(-[WebPolicyDecisionListener ignore]):
(-[WebPolicyDecisionListener download]):

Source/WebKitLegacy/win:

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::dispatchDecidePolicyForResponse):
(WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
(WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
* WebFramePolicyListener.cpp:
(WebFramePolicyListener::use):
(WebFramePolicyListener::download):
(WebFramePolicyListener::ignore):
(WebFramePolicyListener::continueSubmit):

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

32 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/FrameLoaderTypes.h
Source/WebCore/loader/PolicyChecker.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp
Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp
Source/WebKit/NetworkProcess/NetworkDataTask.cpp
Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp
Source/WebKit/NetworkProcess/NetworkLoad.cpp
Source/WebKit/NetworkProcess/PingLoad.cpp
Source/WebKit/NetworkProcess/capture/NetworkDataTaskReplay.cpp
Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp
Source/WebKit/Scripts/webkit/messages.py
Source/WebKit/UIProcess/WebFormSubmissionListenerProxy.h
Source/WebKit/UIProcess/WebFrameListenerProxy.h
Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/WebProcess/WebPage/WebFrame.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/Plugins/WebPluginContainerCheck.mm
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKitLegacy/mac/WebView/WebPolicyDelegate.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKitLegacy/win/WebFramePolicyListener.cpp

index 3b8b827..6ad45dd 100644 (file)
@@ -1,3 +1,18 @@
+2017-09-25  Alex Christensen  <achristensen@webkit.org>
+
+        Make PolicyAction an encodable enum class
+        https://bugs.webkit.org/show_bug.cgi?id=177480
+
+        Reviewed by Antti Koivisto.
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::responseReceived):
+        (WebCore::DocumentLoader::continueAfterContentPolicy):
+        * loader/FrameLoaderTypes.h:
+        * loader/PolicyChecker.cpp:
+        (WebCore::PolicyChecker::checkNavigationPolicy):
+        (WebCore::PolicyChecker::checkNewWindowPolicy):
+
 2017-09-25  Timothy Horton  <timothy_horton@apple.com>
 
         Fix the macOS WebCore CMake build
index 1790f90..576982e 100644 (file)
@@ -695,14 +695,14 @@ void DocumentLoader::responseReceived(const ResourceResponse& response)
 
     // Always show content with valid substitute data.
     if (m_substituteData.isValid()) {
-        continueAfterContentPolicy(PolicyUse);
+        continueAfterContentPolicy(PolicyAction::Use);
         return;
     }
 
 #if ENABLE(FTPDIR)
     // Respect the hidden FTP Directory Listing pref so it can be tested even if the policy delegate might otherwise disallow it
     if (m_frame->settings().forceFTPDirectoryListings() && m_response.mimeType() == "application/x-ftp-directory") {
-        continueAfterContentPolicy(PolicyUse);
+        continueAfterContentPolicy(PolicyAction::Use);
         return;
     }
 #endif
@@ -747,7 +747,7 @@ void DocumentLoader::continueAfterContentPolicy(PolicyAction policy)
         return;
 
     switch (policy) {
-    case PolicyUse: {
+    case PolicyAction::Use: {
         // Prevent remote web archives from loading because they can claim to be from any domain and thus avoid cross-domain security checks (4120255).
         if (!frameLoader()->client().canShowMIMEType(m_response.mimeType()) || isRemoteWebArchive(*this)) {
             frameLoader()->policyChecker().cannotShowMIMEType(m_response);
@@ -758,7 +758,7 @@ void DocumentLoader::continueAfterContentPolicy(PolicyAction policy)
         break;
     }
 
-    case PolicyDownload: {
+    case PolicyAction::Download: {
         // m_mainResource can be null, e.g. when loading a substitute resource from application cache.
         if (!m_mainResource) {
             mainReceivedError(frameLoader()->client().cannotShowURLError(m_request));
@@ -787,7 +787,7 @@ void DocumentLoader::continueAfterContentPolicy(PolicyAction policy)
             static_cast<ResourceLoader*>(mainResourceLoader())->didFail(interruptedForPolicyChangeError());
         return;
     }
-    case PolicyIgnore:
+    case PolicyAction::Ignore:
         if (ResourceLoader* mainResourceLoader = this->mainResourceLoader())
             InspectorInstrumentation::continueWithPolicyIgnore(*m_frame, mainResourceLoader->identifier(), *this, m_response);
         stopLoadingForPolicyChange();
index 8dd100d..0a47180 100644 (file)
@@ -38,10 +38,10 @@ enum FrameState {
     FrameStateComplete
 };
 
-enum PolicyAction {
-    PolicyUse,
-    PolicyDownload,
-    PolicyIgnore
+enum class PolicyAction {
+    Use,
+    Download,
+    Ignore
 };
 
 enum class ReloadOption {
@@ -147,3 +147,19 @@ enum class HasInsecureContent {
 };
 
 } // namespace WebCore
+
+namespace WTF {
+
+template<typename> struct EnumTraits;
+template<typename E, E...> struct EnumValues;
+
+template<> struct EnumTraits<WebCore::PolicyAction> {
+    using values = EnumValues<
+        WebCore::PolicyAction,
+        WebCore::PolicyAction::Use,
+        WebCore::PolicyAction::Download,
+        WebCore::PolicyAction::Ignore
+    >;
+};
+
+} // namespace WTF
index 824fd3e..e18a5c0 100644 (file)
@@ -146,13 +146,13 @@ void PolicyChecker::checkNavigationPolicy(const ResourceRequest& request, bool d
     ResourceRequest requestCopy = request;
     m_frame.loader().client().dispatchDecidePolicyForNavigationAction(action, request, didReceiveRedirectResponse, formState, [this, function = WTFMove(function), request = WTFMove(requestCopy), formState = makeRefPtr(formState), suggestedFilename = WTFMove(suggestedFilename)](PolicyAction policyAction) mutable {
         switch (policyAction) {
-        case PolicyDownload:
+        case PolicyAction::Download:
             m_frame.loader().setOriginalURLForDownloadRequest(request);
             m_frame.loader().client().startDownload(request, suggestedFilename);
             FALLTHROUGH;
-        case PolicyIgnore:
+        case PolicyAction::Ignore:
             return function({ }, nullptr, false);
-        case PolicyUse:
+        case PolicyAction::Use:
             if (!m_frame.loader().client().canHandleRequest(request)) {
                 handleUnimplementablePolicy(m_frame.loader().client().cannotShowURLError(request));
                 return function({ }, nullptr, false);
@@ -174,13 +174,13 @@ void PolicyChecker::checkNewWindowPolicy(NavigationAction&& navigationAction, co
 
     m_frame.loader().client().dispatchDecidePolicyForNewWindowAction(navigationAction, request, formState, frameName, [frame = makeRef(m_frame), request, formState = makeRefPtr(formState), frameName, navigationAction, function = WTFMove(function)](PolicyAction policyAction) mutable {
         switch (policyAction) {
-        case PolicyDownload:
+        case PolicyAction::Download:
             frame->loader().client().startDownload(request);
             FALLTHROUGH;
-        case PolicyIgnore:
+        case PolicyAction::Ignore:
             function({ }, nullptr, { }, { }, false);
             return;
-        case PolicyUse:
+        case PolicyAction::Use:
             function(request, formState.get(), frameName, navigationAction, true);
             return;
         }
index ed07881..cf3c7c4 100644 (file)
@@ -1,3 +1,54 @@
+2017-09-25  Alex Christensen  <achristensen@webkit.org>
+
+        Make PolicyAction an encodable enum class
+        https://bugs.webkit.org/show_bug.cgi?id=177480
+
+        Reviewed by Antti Koivisto.
+
+        * NetworkProcess/Downloads/DownloadManager.cpp:
+        (WebKit::DownloadManager::continueDecidePendingDownloadDestination):
+        (WebKit::DownloadManager::cancelDownload):
+        * NetworkProcess/NetworkCORSPreflightChecker.cpp:
+        (WebKit::NetworkCORSPreflightChecker::didReceiveResponseNetworkSession):
+        * NetworkProcess/NetworkDataTask.cpp:
+        (WebKit::NetworkDataTask::didReceiveResponse):
+        * NetworkProcess/NetworkDataTaskBlob.cpp:
+        (WebKit::NetworkDataTaskBlob::dispatchDidReceiveResponse):
+        * NetworkProcess/NetworkLoad.cpp:
+        (WebKit::NetworkLoad::~NetworkLoad):
+        (WebKit::NetworkLoad::continueDidReceiveResponse):
+        (WebKit::NetworkLoad::notifyDidReceiveResponse):
+        * NetworkProcess/PingLoad.cpp:
+        (WebKit::PingLoad::didReceiveResponseNetworkSession):
+        * NetworkProcess/capture/NetworkDataTaskReplay.cpp:
+        (WebKit::NetworkCapture::NetworkDataTaskReplay::didReceiveResponse):
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (toNSURLSessionResponseDisposition):
+        * NetworkProcess/soup/NetworkDataTaskSoup.cpp:
+        (WebKit::NetworkDataTaskSoup::dispatchDidReceiveResponse):
+        * Scripts/webkit/messages.py:
+        (headers_for_type):
+        * UIProcess/WebFormSubmissionListenerProxy.h:
+        * UIProcess/WebFrameListenerProxy.h:
+        (WebKit::WebFrameListenerProxy::navigation): Deleted.
+        * UIProcess/WebFramePolicyListenerProxy.cpp:
+        (WebKit::WebFramePolicyListenerProxy::use):
+        (WebKit::WebFramePolicyListenerProxy::download):
+        (WebKit::WebFramePolicyListenerProxy::ignore):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::receivedPolicyDecision):
+        (WebKit::WebPageProxy::decidePolicyForNavigationAction):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):
+        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
+        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::invalidatePolicyListener):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::didReceivePolicyDecision):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2017-09-25  Yoshiaki Jitsukawa  <Yoshiaki.Jitsukawa@sony.com>
 
         [WinCairo] Share default value of font family preferences among non-cocoa builds
index 6e0adb3..a66c996 100644 (file)
@@ -144,7 +144,7 @@ void DownloadManager::continueDecidePendingDownloadDestination(DownloadID downlo
         ASSERT(m_pendingDownloads.contains(downloadID));
 
         networkDataTask->setPendingDownloadLocation(destination, sandboxExtensionHandle, allowOverwrite);
-        completionHandler(PolicyDownload);
+        completionHandler(PolicyAction::Download);
         if (networkDataTask->state() == NetworkDataTask::State::Canceling || networkDataTask->state() == NetworkDataTask::State::Completed)
             return;
 
@@ -196,7 +196,7 @@ void DownloadManager::cancelDownload(DownloadID downloadID)
         ASSERT(completionHandler);
 
         networkDataTask->cancel();
-        completionHandler(PolicyIgnore);
+        completionHandler(PolicyAction::Ignore);
         m_client.pendingDownloadCanceled(downloadID);
         return;
     }
index 48282bc..6245aaa 100644 (file)
@@ -89,7 +89,7 @@ void NetworkCORSPreflightChecker::didReceiveResponseNetworkSession(WebCore::Reso
 {
     RELEASE_LOG_IF_ALLOWED("didReceiveResponseNetworkSession");
     m_response = WTFMove(response);
-    completionHandler(PolicyAction::PolicyUse);
+    completionHandler(PolicyAction::Use);
 }
 
 void NetworkCORSPreflightChecker::didReceiveData(Ref<WebCore::SharedBuffer>&&)
index c93f8fe..8054b47 100644 (file)
@@ -103,7 +103,7 @@ void NetworkDataTask::didReceiveResponse(ResourceResponse&& response, ResponseCo
         auto url = response.url();
         std::optional<uint16_t> port = url.port();
         if (port && !isDefaultPortForProtocol(port.value(), url.protocol())) {
-            completionHandler(PolicyIgnore);
+            completionHandler(PolicyAction::Ignore);
             cancel();
             m_client->didCompleteWithError({ String(), 0, url, "Cancelled load from '" + url.stringCenterEllipsizedToLength() + "' because it is using HTTP/0.9." });
             return;
index b9f05c5..78e5a41 100644 (file)
@@ -315,13 +315,13 @@ void NetworkDataTaskBlob::dispatchDidReceiveResponse(Error errorCode)
         }
 
         switch (policyAction) {
-        case PolicyAction::PolicyUse:
+        case PolicyAction::Use:
             m_buffer.resize(bufferSize);
             read();
             break;
-        case PolicyAction::PolicyIgnore:
+        case PolicyAction::Ignore:
             break;
-        case PolicyAction::PolicyDownload:
+        case PolicyAction::Download:
             download();
             break;
         }
index cc54b21..39e0c3f 100644 (file)
@@ -134,7 +134,7 @@ NetworkLoad::~NetworkLoad()
     ASSERT(RunLoop::isMain());
 #if USE(NETWORK_SESSION)
     if (m_responseCompletionHandler)
-        m_responseCompletionHandler(PolicyIgnore);
+        m_responseCompletionHandler(PolicyAction::Ignore);
     if (m_redirectCompletionHandler)
         m_redirectCompletionHandler({ });
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
@@ -228,7 +228,7 @@ void NetworkLoad::continueDidReceiveResponse()
 #if USE(NETWORK_SESSION)
     if (m_responseCompletionHandler) {
         auto responseCompletionHandler = std::exchange(m_responseCompletionHandler, nullptr);
-        responseCompletionHandler(PolicyUse);
+        responseCompletionHandler(PolicyAction::Use);
     }
 #else
     if (m_handle)
@@ -403,7 +403,7 @@ void NetworkLoad::notifyDidReceiveResponse(ResourceResponse&& response, Response
         m_responseCompletionHandler = WTFMove(completionHandler);
         return;
     }
-    completionHandler(PolicyUse);
+    completionHandler(PolicyAction::Use);
 }
 
 void NetworkLoad::didReceiveData(Ref<SharedBuffer>&& buffer)
index 9691140..f959bc9 100644 (file)
@@ -175,7 +175,7 @@ void PingLoad::didReceiveChallenge(const AuthenticationChallenge&, ChallengeComp
 void PingLoad::didReceiveResponseNetworkSession(ResourceResponse&& response, ResponseCompletionHandler&& completionHandler)
 {
     RELEASE_LOG_IF_ALLOWED("didReceiveResponseNetworkSession - httpStatusCode: %d", response.httpStatusCode());
-    completionHandler(PolicyAction::PolicyIgnore);
+    completionHandler(PolicyAction::Ignore);
     didFinish();
 }
 
index 5e60b65..f3a65ed 100644 (file)
@@ -249,13 +249,13 @@ void NetworkDataTaskReplay::didReceiveResponse(WebCore::ResourceResponse&& respo
         }
 
         switch (policyAction) {
-        case WebCore::PolicyAction::PolicyUse:
+        case WebCore::PolicyAction::Use:
             enqueueEventHandler();
             break;
-        case WebCore::PolicyAction::PolicyIgnore:
+        case WebCore::PolicyAction::Ignore:
             complete();
             break;
-        case WebCore::PolicyAction::PolicyDownload:
+        case WebCore::PolicyAction::Download:
             DEBUG_LOG_ERROR("WebCore::PolicyAction::PolicyDownload");
             break;
         }
index 60906ca..96afccd 100644 (file)
@@ -57,11 +57,11 @@ using namespace WebKit;
 static NSURLSessionResponseDisposition toNSURLSessionResponseDisposition(WebCore::PolicyAction disposition)
 {
     switch (disposition) {
-    case WebCore::PolicyAction::PolicyIgnore:
+    case WebCore::PolicyAction::Ignore:
         return NSURLSessionResponseCancel;
-    case WebCore::PolicyAction::PolicyUse:
+    case WebCore::PolicyAction::Use:
         return NSURLSessionResponseAllow;
-    case WebCore::PolicyAction::PolicyDownload:
+    case WebCore::PolicyAction::Download:
         return NSURLSessionResponseBecomeDownload;
     }
 }
index 0eb9987..e72c1f6 100644 (file)
@@ -377,7 +377,7 @@ void NetworkDataTaskSoup::dispatchDidReceiveResponse()
         }
 
         switch (policyAction) {
-        case PolicyAction::PolicyUse:
+        case PolicyAction::Use:
             if (m_inputStream)
                 read();
             else if (m_multipartInputStream)
@@ -386,10 +386,10 @@ void NetworkDataTaskSoup::dispatchDidReceiveResponse()
                 ASSERT_NOT_REACHED();
 
             break;
-        case PolicyAction::PolicyIgnore:
+        case PolicyAction::Ignore:
             clearRequest();
             break;
-        case PolicyAction::PolicyDownload:
+        case PolicyAction::Download:
             download();
             break;
         }
index bf79820..7b121c4 100644 (file)
@@ -387,6 +387,7 @@ def headers_for_type(type):
         'WebKit::WebMouseEvent': ['"WebEvent.h"'],
         'WebKit::WebTouchEvent': ['"WebEvent.h"'],
         'WebKit::WebWheelEvent': ['"WebEvent.h"'],
+        'WebCore::PolicyAction': ['<WebCore/FrameLoaderTypes.h>'],
         'struct WebKit::WebUserScriptData': ['"WebUserContentControllerDataTypes.h"'],
         'struct WebKit::WebUserStyleSheetData': ['"WebUserContentControllerDataTypes.h"'],
         'struct WebKit::WebScriptMessageHandlerData': ['"WebUserContentControllerDataTypes.h"'],
index 0bafdac..2a7fa4b 100644 (file)
@@ -29,8 +29,6 @@
 
 namespace WebKit {
 
-class WebFrameProxy;
-
 class WebFormSubmissionListenerProxy : public API::ObjectImpl<API::Object::Type::FormSubmissionListener> {
 public:
     static Ref<WebFormSubmissionListenerProxy> create(WTF::Function<void(void)>&& completionHandler)
index fa56321..c3dfa05 100644 (file)
@@ -43,7 +43,6 @@ public:
     void invalidate();
     uint64_t listenerID() const { return m_listenerID; }
 
-    API::Navigation* navigation() { return m_navigation.get(); }
     void setNavigation(Ref<API::Navigation>&& navigation) { m_navigation = WTFMove(navigation); }
 
 protected:
index ef5e29b..4a74901 100644 (file)
@@ -38,17 +38,17 @@ WebFramePolicyListenerProxy::WebFramePolicyListenerProxy(WebFrameProxy* frame, u
 
 void WebFramePolicyListenerProxy::use(const WebsitePolicies& websitePolicies)
 {
-    receivedPolicyDecision(WebCore::PolicyUse, websitePolicies);
+    receivedPolicyDecision(WebCore::PolicyAction::Use, websitePolicies);
 }
 
 void WebFramePolicyListenerProxy::download()
 {
-    receivedPolicyDecision(WebCore::PolicyDownload, { });
+    receivedPolicyDecision(WebCore::PolicyAction::Download, { });
 }
 
 void WebFramePolicyListenerProxy::ignore()
 {
-    receivedPolicyDecision(WebCore::PolicyIgnore, { });
+    receivedPolicyDecision(WebCore::PolicyAction::Ignore, { });
 }
 
 } // namespace WebKit
index 9091785..da5715d 100644 (file)
@@ -2264,16 +2264,16 @@ void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy& fr
 
     auto transaction = m_pageLoadState.transaction();
 
-    if (action == PolicyIgnore)
+    if (action == PolicyAction::Ignore)
         m_pageLoadState.clearPendingAPIRequestURL(transaction);
 
 #if ENABLE(DOWNLOAD_ATTRIBUTE)
-    if (m_syncNavigationActionHasDownloadAttribute && action == PolicyUse)
-        action = PolicyDownload;
+    if (m_syncNavigationActionHasDownloadAttribute && action == PolicyAction::Use)
+        action = PolicyAction::Download;
 #endif
 
     DownloadID downloadID = { };
-    if (action == PolicyDownload) {
+    if (action == PolicyAction::Download) {
         // Create a download proxy.
         auto* download = m_process->processPool().createDownloadProxy(m_decidePolicyForResponseRequest, this);
         if (navigation) {
@@ -3686,7 +3686,7 @@ void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, const Secur
 
 #if ENABLE(CONTENT_FILTERING)
     if (frame->didHandleContentFilterUnblockNavigation(request)) {
-        reply->send(m_newNavigationID, PolicyIgnore, { }, { });
+        reply->send(m_newNavigationID, PolicyAction::Ignore, { }, { });
         m_newNavigationID = 0;
         return;
     }
index 49698a5..8ba7049 100644 (file)
@@ -98,8 +98,8 @@ messages -> WebPageProxy {
 #endif
 
     # Policy messages
-    DecidePolicyForResponseSync(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, uint64_t navigationID, WebCore::ResourceResponse response, WebCore::ResourceRequest request, bool canShowMIMEType, uint64_t listenerID, WebKit::UserData userData) -> (uint64_t policyAction, WebKit::DownloadID downloadID) Delayed
-    DecidePolicyForNavigationAction(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, uint64_t navigationID, struct WebKit::NavigationActionData navigationActionData, struct WebKit::FrameInfoData originatingFrameInfoData, uint64_t originatingPageID, WebCore::ResourceRequest originalRequest, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::UserData userData) -> (uint64_t newNavigationID, uint64_t policyAction, WebKit::DownloadID downloadID, struct WebKit::WebsitePolicies websitePolicies) Delayed
+    DecidePolicyForResponseSync(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, uint64_t navigationID, WebCore::ResourceResponse response, WebCore::ResourceRequest request, bool canShowMIMEType, uint64_t listenerID, WebKit::UserData userData) -> (enum WebCore::PolicyAction policyAction, WebKit::DownloadID downloadID) Delayed
+    DecidePolicyForNavigationAction(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, uint64_t navigationID, struct WebKit::NavigationActionData navigationActionData, struct WebKit::FrameInfoData originatingFrameInfoData, uint64_t originatingPageID, WebCore::ResourceRequest originalRequest, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::UserData userData) -> (uint64_t newNavigationID, enum WebCore::PolicyAction policyAction, WebKit::DownloadID downloadID, struct WebKit::WebsitePolicies websitePolicies) Delayed
     DecidePolicyForNewWindowAction(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, struct WebKit::NavigationActionData navigationActionData, WebCore::ResourceRequest request, String frameName, uint64_t listenerID, WebKit::UserData userData)
     UnableToImplementPolicy(uint64_t frameID, WebCore::ResourceError error, WebKit::UserData userData)
 
index 382d0af..aeb2723 100644 (file)
@@ -679,12 +679,12 @@ void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceRespons
 {
     WebPage* webPage = m_frame->page();
     if (!webPage) {
-        function(PolicyIgnore);
+        function(PolicyAction::Ignore);
         return;
     }
 
     if (!request.url().string()) {
-        function(PolicyUse);
+        function(PolicyAction::Use);
         return;
     }
 
@@ -693,33 +693,33 @@ void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceRespons
     // Notify the bundle client.
     WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForResponse(webPage, m_frame, response, request, userData);
     if (policy == WKBundlePagePolicyActionUse) {
-        function(PolicyUse);
+        function(PolicyAction::Use);
         return;
     }
 
     bool canShowMIMEType = webPage->canShowMIMEType(response.mimeType());
 
     uint64_t listenerID = m_frame->setUpPolicyListener(WTFMove(function));
-    uint64_t policyAction;
+    PolicyAction policyAction;
     DownloadID downloadID;
 
     Ref<WebFrame> protect(*m_frame);
     WebCore::Frame* coreFrame = m_frame->coreFrame();
     auto navigationID = static_cast<WebDocumentLoader&>(*coreFrame->loader().provisionalDocumentLoader()).navigationID();
     if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForResponseSync(m_frame->frameID(), SecurityOriginData::fromFrame(coreFrame), navigationID, response, request, canShowMIMEType, listenerID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())), Messages::WebPageProxy::DecidePolicyForResponseSync::Reply(policyAction, downloadID), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend)) {
-        m_frame->didReceivePolicyDecision(listenerID, PolicyIgnore, 0, { });
+        m_frame->didReceivePolicyDecision(listenerID, PolicyAction::Ignore, 0, { });
         return;
     }
 
     // We call this synchronously because CFNetwork can only convert a loading connection to a download from its didReceiveResponse callback.
-    m_frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), 0, downloadID);
+    m_frame->didReceivePolicyDecision(listenerID, policyAction, 0, downloadID);
 }
 
 void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const NavigationAction& navigationAction, const ResourceRequest& request, FormState* formState, const String& frameName, FramePolicyFunction&& function)
 {
     WebPage* webPage = m_frame->page();
     if (!webPage) {
-        function(PolicyIgnore);
+        function(PolicyAction::Ignore);
         return;
     }
 
@@ -730,7 +730,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const Navigati
     // Notify the bundle client.
     WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForNewWindowAction(webPage, m_frame, action.get(), request, frameName, userData);
     if (policy == WKBundlePagePolicyActionUse) {
-        function(PolicyUse);
+        function(PolicyAction::Use);
         return;
     }
 
@@ -755,13 +755,13 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat
 {
     WebPage* webPage = m_frame->page();
     if (!webPage) {
-        function(PolicyIgnore);
+        function(PolicyAction::Ignore);
         return;
     }
 
     // Always ignore requests with empty URLs. 
     if (request.isEmpty()) {
-        function(PolicyIgnore);
+        function(PolicyAction::Ignore);
         return;
     }
 
@@ -772,13 +772,13 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat
     // Notify the bundle client.
     WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForNavigationAction(webPage, m_frame, action.get(), request, userData);
     if (policy == WKBundlePagePolicyActionUse) {
-        function(PolicyUse);
+        function(PolicyAction::Use);
         return;
     }
     
     uint64_t listenerID = m_frame->setUpPolicyListener(WTFMove(function));
     uint64_t newNavigationID;
-    uint64_t policyAction;
+    PolicyAction policyAction;
     DownloadID downloadID;
 
     ASSERT(navigationAction.sourceDocument());
@@ -818,7 +818,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat
     Ref<WebFrame> protect(*m_frame);
     WebsitePolicies websitePolicies;
     if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForNavigationAction(m_frame->frameID(), SecurityOriginData::fromFrame(coreFrame), documentLoader->navigationID(), navigationActionData, originatingFrameInfoData, originatingFrame && originatingFrame->page() ? originatingFrame->page()->pageID() : 0, navigationAction.resourceRequest(), request, listenerID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())), Messages::WebPageProxy::DecidePolicyForNavigationAction::Reply(newNavigationID, policyAction, downloadID, websitePolicies))) {
-        m_frame->didReceivePolicyDecision(listenerID, PolicyIgnore, 0, { });
+        m_frame->didReceivePolicyDecision(listenerID, PolicyAction::Ignore, 0, { });
         return;
     }
 
@@ -855,7 +855,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat
     }
 
     // We call this synchronously because WebCore cannot gracefully handle a frame load without a synchronous navigation policy reply.
-    m_frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), newNavigationID, downloadID);
+    m_frame->didReceivePolicyDecision(listenerID, policyAction, newNavigationID, downloadID);
 }
 
 void WebFrameLoaderClient::cancelPolicyCheck()
index b19a44c..3659be4 100644 (file)
@@ -241,7 +241,7 @@ void WebFrame::invalidatePolicyListener()
     m_policyDownloadID = { };
     m_policyListenerID = 0;
     if (auto function = std::exchange(m_policyFunction, nullptr))
-        function(PolicyIgnore);
+        function(PolicyAction::Ignore);
 }
 
 void WebFrame::didReceivePolicyDecision(uint64_t listenerID, PolicyAction action, uint64_t navigationID, DownloadID downloadID)
index 8261e33..1ea7a3c 100644 (file)
@@ -2733,12 +2733,12 @@ void WebPage::setSessionID(PAL::SessionID sessionID)
     m_page->setSessionID(sessionID);
 }
 
-void WebPage::didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t navigationID, const DownloadID& downloadID)
+void WebPage::didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, PolicyAction policyAction, uint64_t navigationID, const DownloadID& downloadID)
 {
     WebFrame* frame = WebProcess::singleton().webFrame(frameID);
     if (!frame)
         return;
-    frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), navigationID, downloadID);
+    frame->didReceivePolicyDecision(listenerID, policyAction, navigationID, downloadID);
 }
 
 void WebPage::continueWillSubmitForm(uint64_t frameID, uint64_t listenerID)
index 6a76917..1f9650a 100644 (file)
@@ -1138,7 +1138,7 @@ private:
     void platformPreferencesDidChange(const WebPreferencesStore&);
     void updatePreferences(const WebPreferencesStore&);
 
-    void didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t navigationID, const DownloadID&);
+    void didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, WebCore::PolicyAction, uint64_t navigationID, const DownloadID&);
     void continueWillSubmitForm(uint64_t frameID, uint64_t listenerID);
     void setUserAgent(const String&);
     void setCustomTextEncodingName(const String&);
index 3accf36..a83144f 100644 (file)
@@ -151,7 +151,7 @@ messages -> WebPage LegacyReceiver {
     DidRemoveBackForwardItem(uint64_t backForwardItemID)
 
     UpdateWebsitePolicies(struct WebKit::WebsitePolicies websitePolicies)
-    DidReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t navigationID, WebKit::DownloadID downloadID)
+    DidReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, enum WebCore::PolicyAction policyAction, uint64_t navigationID, WebKit::DownloadID downloadID)
     ContinueWillSubmitForm(uint64_t frameID, uint64_t listenerID)
 
     ClearSelection()
index acb470e..e348a50 100644 (file)
@@ -1,3 +1,24 @@
+2017-09-25  Alex Christensen  <achristensen@webkit.org>
+
+        Make PolicyAction an encodable enum class
+        https://bugs.webkit.org/show_bug.cgi?id=177480
+
+        Reviewed by Antti Koivisto.
+
+        * Plugins/WebPluginContainerCheck.mm:
+        (-[WebPluginContainerCheck _continueWithPolicy:]):
+        (-[WebPluginContainerCheck _isForbiddenFileLoad]):
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (-[WebFramePolicyListener invalidate]):
+        (-[WebFramePolicyListener ignore]):
+        (-[WebFramePolicyListener download]):
+        (-[WebFramePolicyListener use]):
+        (-[WebFramePolicyListener continue]):
+        * WebView/WebPolicyDelegate.mm:
+        (-[WebPolicyDecisionListener use]):
+        (-[WebPolicyDecisionListener ignore]):
+        (-[WebPolicyDecisionListener download]):
+
 2017-09-25  Frederik Riedel  <riedel@apple.com>
 
         Expose way to set values of classified form controls as {Legacy WebKit, WebKit} SPI
index a310eb5..58124c3 100644 (file)
@@ -87,9 +87,9 @@ using namespace WebCore;
 - (void)_continueWithPolicy:(PolicyAction)policy
 {
     if (_contextInfo)
-        wtfObjcMsgSend<void>(_resultObject, _resultSelector, (policy == PolicyUse), _contextInfo);
+        wtfObjcMsgSend<void>(_resultObject, _resultSelector, (policy == PolicyAction::Use), _contextInfo);
     else     
-        wtfObjcMsgSend<void>(_resultObject, _resultSelector, (policy == PolicyUse));
+        wtfObjcMsgSend<void>(_resultObject, _resultSelector, (policy == PolicyAction::Use));
 
     // this will call indirectly call cancel
     [_controller _webPluginContainerCancelCheckIfAllowedToLoadRequest:self];
@@ -100,7 +100,7 @@ using namespace WebCore;
     Frame* coreFrame = core([_controller webFrame]);
     ASSERT(coreFrame);
     if (!coreFrame->document()->securityOrigin().canDisplay([_request URL])) {
-        [self _continueWithPolicy:PolicyIgnore];
+        [self _continueWithPolicy:PolicyAction::Ignore];
         return YES;
     }
 
index beebf13..a1aa05d 100644 (file)
@@ -2410,7 +2410,7 @@ void WebFrameLoaderClient::finishedLoadingIcon(uint64_t callbackID, SharedBuffer
 {
     _frame = nullptr;
     if (auto policyFunction = std::exchange(_policyFunction, nullptr))
-        policyFunction(PolicyIgnore);
+        policyFunction(PolicyAction::Ignore);
 }
 
 - (void)dealloc
@@ -2433,12 +2433,12 @@ void WebFrameLoaderClient::finishedLoadingIcon(uint64_t callbackID, SharedBuffer
 
 - (void)ignore
 {
-    [self receivedPolicyDecision:PolicyIgnore];
+    [self receivedPolicyDecision:PolicyAction::Ignore];
 }
 
 - (void)download
 {
-    [self receivedPolicyDecision:PolicyDownload];
+    [self receivedPolicyDecision:PolicyAction::Download];
 }
 
 - (void)use
@@ -2448,21 +2448,21 @@ void WebFrameLoaderClient::finishedLoadingIcon(uint64_t callbackID, SharedBuffer
         [LSAppLink openWithURL:_appLinkURL.get() completionHandler:^(BOOL success, NSError *) {
             WebThreadRun(^{
                 if (success)
-                    [self receivedPolicyDecision:PolicyIgnore];
+                    [self receivedPolicyDecision:PolicyAction::Ignore];
                 else
-                    [self receivedPolicyDecision:PolicyUse];
+                    [self receivedPolicyDecision:PolicyAction::Use];
             });
         }];
         return;
     }
 #endif
 
-    [self receivedPolicyDecision:PolicyUse];
+    [self receivedPolicyDecision:PolicyAction::Use];
 }
 
 - (void)continue
 {
-    [self receivedPolicyDecision:PolicyUse];
+    [self receivedPolicyDecision:PolicyAction::Use];
 }
 
 @end
index 0d2db5f..4ed9bfa 100644 (file)
@@ -105,17 +105,17 @@ NSString *WebActionOriginalURLKey = @"WebActionOriginalURLKey";
 
 - (void)use
 {
-    [self _usePolicy:PolicyUse];
+    [self _usePolicy:PolicyAction::Use];
 }
 
 - (void)ignore
 {
-    [self _usePolicy:PolicyIgnore];
+    [self _usePolicy:PolicyAction::Ignore];
 }
 
 - (void)download
 {
-    [self _usePolicy:PolicyDownload];
+    [self _usePolicy:PolicyAction::Download];
 }
 
 @end
index 38522a1..8df5d8c 100644 (file)
@@ -1,3 +1,20 @@
+2017-09-25  Alex Christensen  <achristensen@webkit.org>
+
+        Make PolicyAction an encodable enum class
+        https://bugs.webkit.org/show_bug.cgi?id=177480
+
+        Reviewed by Antti Koivisto.
+
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::dispatchDecidePolicyForResponse):
+        (WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
+        (WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
+        * WebFramePolicyListener.cpp:
+        (WebFramePolicyListener::use):
+        (WebFramePolicyListener::download):
+        (WebFramePolicyListener::ignore):
+        (WebFramePolicyListener::continueSubmit):
+
 2017-09-07  Per Arne Vollan  <pvollan@apple.com>
 
         [Win] fast/canvas/2d.getPath.modification.html is failing.
index 32dfef3..9739f3c 100644 (file)
@@ -527,7 +527,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceRespons
     if (SUCCEEDED(policyDelegate->decidePolicyForMIMEType(webView, BString(response.mimeType()), urlRequest.get(), m_webFrame, setUpPolicyListener(WTFMove(function)).get())))
         return;
 
-    m_policyListenerPrivate->m_policyFunction(PolicyUse);
+    m_policyListenerPrivate->m_policyFunction(PolicyAction::Use);
 }
 
 void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const NavigationAction& action, const ResourceRequest& request, FormState* formState, const String& frameName, FramePolicyFunction&& function)
@@ -546,7 +546,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const Navigati
     if (SUCCEEDED(policyDelegate->decidePolicyForNewWindowAction(webView, actionInformation.get(), urlRequest.get(), BString(frameName), setUpPolicyListener(WTFMove(function)).get())))
         return;
 
-    m_policyListenerPrivate->m_policyFunction(PolicyUse);
+    m_policyListenerPrivate->m_policyFunction(PolicyAction::Use);
 }
 
 void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const NavigationAction& action, const ResourceRequest& request, bool, FormState* formState, FramePolicyFunction&& function)
@@ -565,7 +565,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat
     if (SUCCEEDED(policyDelegate->decidePolicyForNavigationAction(webView, actionInformation.get(), urlRequest.get(), m_webFrame, setUpPolicyListener(WTFMove(function)).get())))
         return;
 
-    m_policyListenerPrivate->m_policyFunction(PolicyUse);
+    m_policyListenerPrivate->m_policyFunction(PolicyAction::Use);
 }
 
 void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError& error)
index 0527096..afed2b4 100644 (file)
@@ -93,19 +93,19 @@ ULONG WebFramePolicyListener::Release()
 
 HRESULT WebFramePolicyListener::use()
 {
-    receivedPolicyDecision(PolicyUse);
+    receivedPolicyDecision(PolicyAction::Use);
     return S_OK;
 }
 
 HRESULT WebFramePolicyListener::download()
 {
-    receivedPolicyDecision(PolicyDownload);
+    receivedPolicyDecision(PolicyAction::Download);
     return S_OK;
 }
 
 HRESULT WebFramePolicyListener::ignore()
 {
-    receivedPolicyDecision(PolicyIgnore);
+    receivedPolicyDecision(PolicyAction::Ignore);
     return S_OK;
 }
 
@@ -113,7 +113,7 @@ HRESULT WebFramePolicyListener::ignore()
 
 HRESULT WebFramePolicyListener::continueSubmit()
 {
-    receivedPolicyDecision(PolicyUse);
+    receivedPolicyDecision(PolicyAction::Use);
     return S_OK;
 }