<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[163112] trunk/Source/WebKit2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/163112">163112</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2014-01-30 14:06:42 -0800 (Thu, 30 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Implement policy response delegate handling
https://bugs.webkit.org/show_bug.cgi?id=127945
Reviewed by Dan Bernstein.
* UIProcess/API/APIPolicyClient.h:
(API::PolicyClient::decidePolicyForResponse):
* UIProcess/API/C/WKPage.cpp:
(WKPageSetPagePolicyClient):
* UIProcess/API/Cocoa/WKNavigationDelegate.h:
(NS_ENUM):
* UIProcess/Cocoa/NavigationState.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::setNavigationDelegate):
(WebKit::NavigationState::PolicyClient::decidePolicyForNavigationAction):
(WebKit::NavigationState::PolicyClient::decidePolicyForResponse):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::decidePolicyForResponse):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIPolicyClienth">trunk/Source/WebKit2/UIProcess/API/APIPolicyClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKPagecpp">trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKNavigationDelegateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationDelegate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaNavigationStateh">trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaNavigationStatemm">trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (163111 => 163112)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-01-30 21:49:33 UTC (rev 163111)
+++ trunk/Source/WebKit2/ChangeLog        2014-01-30 22:06:42 UTC (rev 163112)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2014-01-30 Anders Carlsson <andersca@apple.com>
+
+ Implement policy response delegate handling
+ https://bugs.webkit.org/show_bug.cgi?id=127945
+
+ Reviewed by Dan Bernstein.
+
+ * UIProcess/API/APIPolicyClient.h:
+ (API::PolicyClient::decidePolicyForResponse):
+ * UIProcess/API/C/WKPage.cpp:
+ (WKPageSetPagePolicyClient):
+ * UIProcess/API/Cocoa/WKNavigationDelegate.h:
+ (NS_ENUM):
+ * UIProcess/Cocoa/NavigationState.h:
+ * UIProcess/Cocoa/NavigationState.mm:
+ (WebKit::NavigationState::setNavigationDelegate):
+ (WebKit::NavigationState::PolicyClient::decidePolicyForNavigationAction):
+ (WebKit::NavigationState::PolicyClient::decidePolicyForResponse):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::decidePolicyForResponse):
+
</ins><span class="cx"> 2014-01-29 Dean Jackson <dino@apple.com>
</span><span class="cx">
</span><span class="cx"> Allow the OpenGL Profiler to get through the sandbox
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIPolicyClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIPolicyClient.h (163111 => 163112)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIPolicyClient.h        2014-01-30 21:49:33 UTC (rev 163111)
+++ trunk/Source/WebKit2/UIProcess/API/APIPolicyClient.h        2014-01-30 22:06:42 UTC (rev 163112)
</span><span class="lines">@@ -53,7 +53,7 @@
</span><span class="cx">
</span><span class="cx"> virtual void decidePolicyForNavigationAction(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebKit::NavigationActionData&, WebKit::WebFrameProxy* originatingFrame, const WebCore::ResourceRequest& originalRequest, const WebCore::ResourceRequest&, RefPtr<WebKit::WebFramePolicyListenerProxy> listener, API::Object* userData) { listener->use(); }
</span><span class="cx"> virtual void decidePolicyForNewWindowAction(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, WebCore::NavigationType, WebKit::WebEvent::Modifiers, WebKit::WebMouseEvent::Button, const WebCore::ResourceRequest&, const WTF::String& frameName, WebKit::WebFramePolicyListenerProxy* listener, API::Object* userData) { listener->use(); }
</span><del>- virtual void decidePolicyForResponse(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, bool canShowMIMEType, WebKit::WebFramePolicyListenerProxy* listener, API::Object* userData) { listener->use(); }
</del><ins>+ virtual void decidePolicyForResponse(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, bool canShowMIMEType, RefPtr<WebKit::WebFramePolicyListenerProxy> listener, API::Object* userData) { listener->use(); }
</ins><span class="cx"> virtual void unableToImplementPolicy(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::ResourceError&, API::Object* userData) { }
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (163111 => 163112)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp        2014-01-30 21:49:33 UTC (rev 163111)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp        2014-01-30 22:06:42 UTC (rev 163112)
</span><span class="lines">@@ -1023,7 +1023,7 @@
</span><span class="cx"> m_client.decidePolicyForNewWindowAction(toAPI(page), toAPI(frame), toAPI(type), toAPI(modifiers), toAPI(mouseButton), toAPI(request.get()), toAPI(frameName.impl()), toAPI(listener), toAPI(userData), m_client.base.clientInfo);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- virtual void decidePolicyForResponse(WebPageProxy* page, WebFrameProxy* frame, const ResourceResponse& resourceResponse, const ResourceRequest& resourceRequest, bool canShowMIMEType, WebFramePolicyListenerProxy* listener, API::Object* userData) override
</del><ins>+ virtual void decidePolicyForResponse(WebPageProxy* page, WebFrameProxy* frame, const ResourceResponse& resourceResponse, const ResourceRequest& resourceRequest, bool canShowMIMEType, RefPtr<WebFramePolicyListenerProxy> listener, API::Object* userData) override
</ins><span class="cx"> {
</span><span class="cx"> if (!m_client.decidePolicyForResponse_deprecatedForUseWithV0 && !m_client.decidePolicyForResponse) {
</span><span class="cx"> listener->use();
</span><span class="lines">@@ -1034,9 +1034,9 @@
</span><span class="cx"> RefPtr<API::URLRequest> request = API::URLRequest::create(resourceRequest);
</span><span class="cx">
</span><span class="cx"> if (m_client.decidePolicyForResponse_deprecatedForUseWithV0)
</span><del>- m_client.decidePolicyForResponse_deprecatedForUseWithV0(toAPI(page), toAPI(frame), toAPI(response.get()), toAPI(request.get()), toAPI(listener), toAPI(userData), m_client.base.clientInfo);
</del><ins>+ m_client.decidePolicyForResponse_deprecatedForUseWithV0(toAPI(page), toAPI(frame), toAPI(response.get()), toAPI(request.get()), toAPI(listener.get()), toAPI(userData), m_client.base.clientInfo);
</ins><span class="cx"> else
</span><del>- m_client.decidePolicyForResponse(toAPI(page), toAPI(frame), toAPI(response.get()), toAPI(request.get()), canShowMIMEType, toAPI(listener), toAPI(userData), m_client.base.clientInfo);
</del><ins>+ m_client.decidePolicyForResponse(toAPI(page), toAPI(frame), toAPI(response.get()), toAPI(request.get()), canShowMIMEType, toAPI(listener.get()), toAPI(userData), m_client.base.clientInfo);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> virtual void unableToImplementPolicy(WebPageProxy* page, WebFrameProxy* frame, const ResourceError& error, API::Object* userData) override
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKNavigationDelegateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationDelegate.h (163111 => 163112)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationDelegate.h        2014-01-30 21:49:33 UTC (rev 163111)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationDelegate.h        2014-01-30 22:06:42 UTC (rev 163112)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx">
</span><span class="cx"> @class WKNavigationAction;
</span><ins>+@class WKNavigationResponse;
</ins><span class="cx"> @class WKWebView;
</span><span class="cx">
</span><span class="cx"> typedef NS_ENUM(NSInteger, WKNavigationPolicyDecision) {
</span><span class="lines">@@ -37,11 +38,18 @@
</span><span class="cx"> WKNavigationPolicyDecisionDownload
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+typedef NS_ENUM(NSInteger, WKNavigationResponsePolicyDecision) {
+ WKNavigationResponsePolicyDecisionCancel,
+ WKNavigationResponsePolicyDecisionAllow,
+ WKNavigationResponsePolicyDecisionBecomeDownload
+};
+
</ins><span class="cx"> @protocol WKNavigationDelegate <NSObject>
</span><span class="cx">
</span><span class="cx"> @optional
</span><span class="cx">
</span><span class="cx"> - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationPolicyDecision))decisionHandler;
</span><ins>+- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicyDecision))decisionHandler;
</ins><span class="cx">
</span><span class="cx"> @end
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaNavigationStateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h (163111 => 163112)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h        2014-01-30 21:49:33 UTC (rev 163111)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h        2014-01-30 22:06:42 UTC (rev 163112)
</span><span class="lines">@@ -62,12 +62,14 @@
</span><span class="cx"> private:
</span><span class="cx"> // API::PolicyClient
</span><span class="cx"> virtual void decidePolicyForNavigationAction(WebPageProxy*, WebFrameProxy*, const NavigationActionData&, WebFrameProxy* originatingFrame, const WebCore::ResourceRequest& originalRequest, const WebCore::ResourceRequest&, RefPtr<WebFramePolicyListenerProxy>, API::Object* userData) override;
</span><ins>+ virtual void decidePolicyForResponse(WebPageProxy*, WebFrameProxy*, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, bool canShowMIMEType, RefPtr<WebFramePolicyListenerProxy>, API::Object* userData) override;
</ins><span class="cx">
</span><span class="cx"> NavigationState& m_navigationState;
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct {
</span><span class="cx"> bool webViewDecidePolicyForNavigationActionDecisionHandler : 1;
</span><ins>+ bool webViewDecidePolicyForNavigationResponseDecisionHandler : 1;
</ins><span class="cx"> } m_navigationDelegateMethods;
</span><span class="cx">
</span><span class="cx"> WKWebView *m_webView;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaNavigationStatemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm (163111 => 163112)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm        2014-01-30 21:49:33 UTC (rev 163111)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm        2014-01-30 22:06:42 UTC (rev 163112)
</span><span class="lines">@@ -52,6 +52,7 @@
</span><span class="cx"> m_navigationDelegate = delegate;
</span><span class="cx">
</span><span class="cx"> m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionDecisionHandler = [delegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)];
</span><ins>+ m_navigationDelegateMethods.webViewDecidePolicyForNavigationResponseDecisionHandler = [delegate respondsToSelector:@selector(webView:decidePolicyForNavigationResponse:decisionHandler:)];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RetainPtr<WKNavigation> NavigationState::createLoadRequestNavigation(uint64_t navigationID, NSURLRequest *request)
</span><span class="lines">@@ -96,7 +97,7 @@
</span><span class="cx"> // FIXME: Set up the navigation action object.
</span><span class="cx"> WKNavigationAction *navigationAction = nil;
</span><span class="cx">
</span><del>- [navigationDelegate.get() webView:m_navigationState.m_webView decidePolicyForNavigationAction:navigationAction decisionHandler:[listener](WKNavigationPolicyDecision policyDecision) {
</del><ins>+ [navigationDelegate webView:m_navigationState.m_webView decidePolicyForNavigationAction:navigationAction decisionHandler:[listener](WKNavigationPolicyDecision policyDecision) {
</ins><span class="cx"> switch (policyDecision) {
</span><span class="cx"> case WKNavigationPolicyDecisionAllow:
</span><span class="cx"> listener->use();
</span><span class="lines">@@ -113,6 +114,38 @@
</span><span class="cx"> }];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void NavigationState::PolicyClient::decidePolicyForResponse(WebPageProxy*, WebFrameProxy*, const WebCore::ResourceResponse&, const WebCore::ResourceRequest& resourceRequest, bool canShowMIMEType, RefPtr<WebFramePolicyListenerProxy> listener, API::Object* userData)
+{
+ if (!m_navigationState.m_navigationDelegateMethods.webViewDecidePolicyForNavigationResponseDecisionHandler) {
+ // FIXME: <rdar://problem/15949822> Figure out what the "default delegate behavior" should be here.
+ listener->use();
+ return;
+ }
+
+ auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
+ if (!navigationDelegate)
+ return;
+
+ // FIXME: Set up the navigation response object.
+ WKNavigationResponse *navigationResponse = nil;
+
+ [navigationDelegate webView:m_navigationState.m_webView decidePolicyForNavigationResponse:navigationResponse decisionHandler:[listener](WKNavigationResponsePolicyDecision policyDecision) {
+ switch (policyDecision) {
+ case WKNavigationResponsePolicyDecisionAllow:
+ listener->use();
+ break;
+
+ case WKNavigationResponsePolicyDecisionCancel:
+ listener->ignore();
+ break;
+
+ case WKNavigationResponsePolicyDecisionBecomeDownload:
+ listener->download();
+ break;
+ }
+ }];
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx">
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (163111 => 163112)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-01-30 21:49:33 UTC (rev 163111)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-01-30 22:06:42 UTC (rev 163112)
</span><span class="lines">@@ -2494,7 +2494,7 @@
</span><span class="cx">
</span><span class="cx"> RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
</span><span class="cx">
</span><del>- m_policyClient->decidePolicyForResponse(this, frame, response, request, canShowMIMEType, listener.get(), userData.get());
</del><ins>+ m_policyClient->decidePolicyForResponse(this, frame, response, request, canShowMIMEType, std::move(listener), userData.get());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebPageProxy::decidePolicyForResponseSync(uint64_t frameID, const ResourceResponse& response, const ResourceRequest& request, bool canShowMIMEType, uint64_t listenerID, IPC::MessageDecoder& decoder, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
</span></span></pre>
</div>
</div>
</body>
</html>