<!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>[164460] 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/164460">164460</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2014-02-20 17:50:03 -0800 (Thu, 20 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>We need something like WKPageUIClient in the Obj-C API
https://bugs.webkit.org/show_bug.cgi?id=129123
&lt;rdar://problem/15338439&gt;

Reviewed by Sam Weinig.

* UIProcess/API/APIUIClient.h:
* UIProcess/API/Cocoa/WKUIDelegate.h: Added.
* UIProcess/API/Cocoa/WKWebView.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView initWithFrame:configuration:]):
(-[WKWebView UIDelegate]):
(-[WKWebView setUIDelegate:]):
* UIProcess/Cocoa/UIClient.h: Added.
* UIProcess/Cocoa/UIClient.mm: Added.
(WebKit::UIClient::UIClient):
(WebKit::UIClient::~UIClient):
(WebKit::UIClient::delegate):
(WebKit::UIClient::setDelegate):
(WebKit::UIClient::runJavaScriptAlert):
(WebKit::UIClient::runJavaScriptConfirm):
(WebKit::UIClient::runJavaScriptPrompt):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::uiClient):
* WebKit2.xcodeproj/project.pbxproj:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIUIClienth">trunk/Source/WebKit2/UIProcess/API/APIUIClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKUIDelegateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaUIClienth">trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaUIClientmm">trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (164459 => 164460)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-02-21 01:20:48 UTC (rev 164459)
+++ trunk/Source/WebKit2/ChangeLog        2014-02-21 01:50:03 UTC (rev 164460)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2014-02-20  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        We need something like WKPageUIClient in the Obj-C API
+        https://bugs.webkit.org/show_bug.cgi?id=129123
+        &lt;rdar://problem/15338439&gt;
+
+        Reviewed by Sam Weinig.
+
+        * UIProcess/API/APIUIClient.h:
+        * UIProcess/API/Cocoa/WKUIDelegate.h: Added.
+        * UIProcess/API/Cocoa/WKWebView.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView initWithFrame:configuration:]):
+        (-[WKWebView UIDelegate]):
+        (-[WKWebView setUIDelegate:]):
+        * UIProcess/Cocoa/UIClient.h: Added.
+        * UIProcess/Cocoa/UIClient.mm: Added.
+        (WebKit::UIClient::UIClient):
+        (WebKit::UIClient::~UIClient):
+        (WebKit::UIClient::delegate):
+        (WebKit::UIClient::setDelegate):
+        (WebKit::UIClient::runJavaScriptAlert):
+        (WebKit::UIClient::runJavaScriptConfirm):
+        (WebKit::UIClient::runJavaScriptPrompt):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::uiClient):
+        * WebKit2.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2014-02-20  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add very basic image control rendering
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIUIClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIUIClient.h (164459 => 164460)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIUIClient.h        2014-02-21 01:20:48 UTC (rev 164459)
+++ trunk/Source/WebKit2/UIProcess/API/APIUIClient.h        2014-02-21 01:50:03 UTC (rev 164460)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;WKPage.h&quot;
</span><span class="cx"> #include &quot;WebEvent.h&quot;
</span><span class="cx"> #include &quot;WebHitTestResult.h&quot;
</span><ins>+#include &quot;WebPageProxy.h&quot;
</ins><span class="cx"> #include &lt;WebCore/FloatRect.h&gt;
</span><span class="cx"> #include &lt;functional&gt;
</span><span class="cx"> #include &lt;wtf/PassRefPtr.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKUIDelegateh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegate.h (0 => 164460)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegate.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegate.h        2014-02-21 01:50:03 UTC (rev 164460)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &lt;Foundation/Foundation.h&gt;
+#import &lt;WebKit2/WKFoundation.h&gt;
+
+#if WK_API_ENABLED
+
+@class WKFrameInfo;
+
+@protocol WKUIDelegate &lt;NSObject&gt;
+
+@optional
+
+- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)())completionHandler;
+
+- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler;
+
+- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString *result))completionHandler;
+
+@end
+
+#endif // WK_API_ENABLED
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.h (164459 => 164460)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.h        2014-02-21 01:20:48 UTC (rev 164459)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.h        2014-02-21 01:50:03 UTC (rev 164460)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> @class WKWebViewConfiguration;
</span><span class="cx"> 
</span><span class="cx"> @protocol WKNavigationDelegate;
</span><ins>+@protocol WKUIDelegate;
</ins><span class="cx"> 
</span><span class="cx"> /*!
</span><span class="cx">  A @link WKWebView @/link displays interactive Web content.
</span><span class="lines">@@ -59,6 +60,8 @@
</span><span class="cx"> 
</span><span class="cx"> @property (nonatomic, weak) id &lt;WKNavigationDelegate&gt; navigationDelegate;
</span><span class="cx"> 
</span><ins>+@property (nonatomic, weak) id &lt;WKUIDelegate&gt; UIDelegate;
+
</ins><span class="cx"> /*! @abstract The view's back-forward list. */
</span><span class="cx"> @property (nonatomic, readonly) WKBackForwardList *backForwardList;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (164459 => 164460)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-02-21 01:20:48 UTC (rev 164459)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-02-21 01:50:03 UTC (rev 164460)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #import &quot;RemoteLayerTreeTransaction.h&quot;
</span><span class="cx"> #import &quot;RemoteObjectRegistry.h&quot;
</span><span class="cx"> #import &quot;RemoteObjectRegistryMessages.h&quot;
</span><ins>+#import &quot;UIClient.h&quot;
</ins><span class="cx"> #import &quot;ViewGestureController.h&quot;
</span><span class="cx"> #import &quot;WKBackForwardListInternal.h&quot;
</span><span class="cx"> #import &quot;WKBackForwardListItemInternal.h&quot;
</span><span class="lines">@@ -43,6 +44,7 @@
</span><span class="cx"> #import &quot;WKPreferencesInternal.h&quot;
</span><span class="cx"> #import &quot;WKProcessClassInternal.h&quot;
</span><span class="cx"> #import &quot;WKRemoteObjectRegistryInternal.h&quot;
</span><ins>+#import &quot;WKUIDelegate.h&quot;
</ins><span class="cx"> #import &quot;WKWebViewConfigurationPrivate.h&quot;
</span><span class="cx"> #import &quot;WebCertificateInfo.h&quot;
</span><span class="cx"> #import &quot;WebContext.h&quot;
</span><span class="lines">@@ -161,6 +163,8 @@
</span><span class="cx">     _page-&gt;setPolicyClient(_navigationState-&gt;createPolicyClient());
</span><span class="cx">     _page-&gt;setLoaderClient(_navigationState-&gt;createLoaderClient());
</span><span class="cx"> 
</span><ins>+    _page-&gt;setUIClient(std::make_unique&lt;WebKit::UIClient&gt;(self));
+
</ins><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -194,6 +198,16 @@
</span><span class="cx">     _navigationState-&gt;setNavigationDelegate(navigationDelegate);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (id &lt;WKUIDelegate&gt;)UIDelegate
+{
+    return [static_cast&lt;WebKit::UIClient&amp;&gt;(_page-&gt;uiClient()).delegate().leakRef() autorelease];
+}
+
+- (void)setUIDelegate:(id&lt;WKUIDelegate&gt;)UIDelegate
+{
+    static_cast&lt;WebKit::UIClient&amp;&gt;(_page-&gt;uiClient()).setDelegate(UIDelegate);
+}
+
</ins><span class="cx"> - (WKNavigation *)loadRequest:(NSURLRequest *)request
</span><span class="cx"> {
</span><span class="cx">     uint64_t navigationID = _page-&gt;loadRequest(request);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUIClienth"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.h (0 => 164460)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.h        2014-02-21 01:50:03 UTC (rev 164460)
</span><span class="lines">@@ -0,0 +1,70 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef UIClient_h
+#define UIClient_h
+
+#import &quot;WKFoundation.h&quot;
+
+#if WK_API_ENABLED
+
+#import &quot;APIUIClient.h&quot;
+#import &quot;WeakObjCPtr.h&quot;
+#import &lt;wtf/RetainPtr.h&gt;
+
+@class WKWebView;
+@protocol WKUIDelegate;
+
+namespace WebKit {
+
+class UIClient : public API::UIClient {
+public:
+    explicit UIClient(WKWebView *);
+    ~UIClient();
+
+    RetainPtr&lt;id &lt;WKUIDelegate&gt; &gt; delegate();
+    void setDelegate(id &lt;WKUIDelegate&gt;);
+
+private:
+    // API::UIClient
+    virtual void runJavaScriptAlert(WebKit::WebPageProxy*, const WTF::String&amp;, WebKit::WebFrameProxy*, std::function&lt;void ()&gt; completionHandler) override;
+    virtual void runJavaScriptConfirm(WebKit::WebPageProxy*, const WTF::String&amp;, WebKit::WebFrameProxy*, std::function&lt;void (bool)&gt; completionHandler) override;
+    virtual void runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&amp;, const WTF::String&amp;, WebKit::WebFrameProxy*, std::function&lt;void (const WTF::String&amp;)&gt; completionHandler) override;
+
+    WKWebView *m_webView;
+    WeakObjCPtr&lt;id &lt;WKUIDelegate&gt; &gt; m_delegate;
+
+    struct {
+        bool webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler : 1;
+        bool webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler : 1;
+        bool webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler : 1;
+    } m_delegateMethods;
+};
+
+} // namespace WebKit
+
+#endif // WK_API_ENABLED
+
+#endif // UIClient_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUIClientmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.mm (0 => 164460)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.mm                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.mm        2014-02-21 01:50:03 UTC (rev 164460)
</span><span class="lines">@@ -0,0 +1,115 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;UIClient.h&quot;
+
+#if WK_API_ENABLED
+
+#import &quot;WKFrameInfoInternal.h&quot;
+#import &quot;WKUIDelegate.h&quot;
+
+namespace WebKit {
+
+UIClient::UIClient(WKWebView *webView)
+    : m_webView(webView)
+{
+}
+
+UIClient::~UIClient()
+{
+}
+
+RetainPtr&lt;id &lt;WKUIDelegate&gt; &gt; UIClient::delegate()
+{
+    return m_delegate.get();
+}
+
+void UIClient::setDelegate(id &lt;WKUIDelegate&gt; delegate)
+{
+    m_delegate = delegate;
+
+    m_delegateMethods.webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:)];
+    m_delegateMethods.webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)];
+    m_delegateMethods.webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:)];
+}
+
+void UIClient::runJavaScriptAlert(WebKit::WebPageProxy*, const WTF::String&amp; message, WebKit::WebFrameProxy* webFrameProxy, std::function&lt;void ()&gt; completionHandler)
+{
+    if (!m_delegateMethods.webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler) {
+        completionHandler();
+        return;
+    }
+
+    auto delegate = m_delegate.get();
+    if (!delegate) {
+        completionHandler();
+        return;
+    }
+
+    [delegate webView:m_webView runJavaScriptAlertPanelWithMessage:message initiatedByFrame:adoptNS([[WKFrameInfo alloc] initWithWebFrameProxy:*webFrameProxy]).get() completionHandler:[completionHandler] {
+        completionHandler();
+    }];
+}
+
+void UIClient::runJavaScriptConfirm(WebKit::WebPageProxy*, const WTF::String&amp; message, WebKit::WebFrameProxy* webFrameProxy, std::function&lt;void (bool)&gt; completionHandler)
+{
+    if (!m_delegateMethods.webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler) {
+        completionHandler(false);
+        return;
+    }
+
+    auto delegate = m_delegate.get();
+    if (!delegate) {
+        completionHandler(false);
+        return;
+    }
+
+    [delegate webView:m_webView runJavaScriptConfirmPanelWithMessage:message initiatedByFrame:adoptNS([[WKFrameInfo alloc] initWithWebFrameProxy:*webFrameProxy]).get() completionHandler:[completionHandler](BOOL result) {
+        completionHandler(result);
+    }];
+}
+
+void UIClient::runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&amp; message, const WTF::String&amp; defaultValue, WebKit::WebFrameProxy* webFrameProxy, std::function&lt;void (const WTF::String&amp;)&gt; completionHandler)
+{
+    if (!m_delegateMethods.webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler) {
+        completionHandler(String());
+        return;
+    }
+
+    auto delegate = m_delegate.get();
+    if (!delegate) {
+        completionHandler(String());
+        return;
+    }
+
+    [delegate webView:m_webView runJavaScriptTextInputPanelWithPrompt:message defaultText:defaultValue initiatedByFrame:adoptNS([[WKFrameInfo alloc] initWithWebFrameProxy:*webFrameProxy]).get() completionHandler:[completionHandler](NSString *result) {
+        completionHandler(result);
+    }];
+}
+
+} // namespace WebKit
+
+#endif // WK_API_ENABLED
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (164459 => 164460)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-02-21 01:20:48 UTC (rev 164459)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-02-21 01:50:03 UTC (rev 164460)
</span><span class="lines">@@ -374,6 +374,8 @@
</span><span class="cx">     void initializeFormClient(const WKPageFormClientBase*);
</span><span class="cx">     void setLoaderClient(std::unique_ptr&lt;API::LoaderClient&gt;);
</span><span class="cx">     void setPolicyClient(std::unique_ptr&lt;API::PolicyClient&gt;);
</span><ins>+
+    API::UIClient&amp; uiClient() { return *m_uiClient; }
</ins><span class="cx">     void setUIClient(std::unique_ptr&lt;API::UIClient&gt;);
</span><span class="cx"> #if PLATFORM(EFL)
</span><span class="cx">     void initializeUIPopupMenuClient(const WKPageUIPopupMenuClientBase*);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (164459 => 164460)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-02-21 01:20:48 UTC (rev 164459)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-02-21 01:50:03 UTC (rev 164460)
</span><span class="lines">@@ -341,6 +341,7 @@
</span><span class="cx">                 1AD25E96167AB08100EA9BCD /* DownloadProxyMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD25E94167AB08100EA9BCD /* DownloadProxyMap.h */; };
</span><span class="cx">                 1AD3306E16B1D991004F60E7 /* StorageAreaImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD3306C16B1D991004F60E7 /* StorageAreaImpl.cpp */; };
</span><span class="cx">                 1AD3306F16B1D991004F60E7 /* StorageAreaImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD3306D16B1D991004F60E7 /* StorageAreaImpl.h */; };
</span><ins>+                1AD8790A18B6C38A006CAFD7 /* WKUIDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD8790918B6C38A006CAFD7 /* WKUIDelegate.h */; };
</ins><span class="cx">                 1ADCB86A189831B30022EE5A /* NavigationActionData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ADCB868189831B30022EE5A /* NavigationActionData.cpp */; };
</span><span class="cx">                 1ADCB86B189831B30022EE5A /* NavigationActionData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ADCB869189831B30022EE5A /* NavigationActionData.h */; };
</span><span class="cx">                 1ADF591A1890528E0043C145 /* WKWebViewConfiguration.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1ADF59181890528E0043C145 /* WKWebViewConfiguration.mm */; };
</span><span class="lines">@@ -375,6 +376,8 @@
</span><span class="cx">                 1AFDD3151891B54000153970 /* APIPolicyClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFDD3141891B54000153970 /* APIPolicyClient.h */; };
</span><span class="cx">                 1AFDD3171891C94700153970 /* WKPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFDD3161891C94700153970 /* WKPreferences.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 1AFDD3191891CA1200153970 /* WKPreferences.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AFDD3181891CA1200153970 /* WKPreferences.mm */; };
</span><ins>+                1AFE436518B6C081009C7A48 /* UIClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AFE436318B6C081009C7A48 /* UIClient.mm */; };
+                1AFE436618B6C081009C7A48 /* UIClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFE436418B6C081009C7A48 /* UIClient.h */; };
</ins><span class="cx">                 1AFF49001833DE78009AB15A /* WKDeprecatedFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFF48FE1833DE78009AB15A /* WKDeprecatedFunctions.cpp */; };
</span><span class="cx">                 1C8E25A81270E3BB00BC7BD0 /* WebInspectorFrontendClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C8E256B1270DE3800BC7BD0 /* WebInspectorFrontendClient.cpp */; };
</span><span class="cx">                 1C8E25A91270E3BC00BC7BD0 /* WebInspectorFrontendClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C8E256A1270DE3800BC7BD0 /* WebInspectorFrontendClient.h */; };
</span><span class="lines">@@ -2029,6 +2032,7 @@
</span><span class="cx">                 1AD25E94167AB08100EA9BCD /* DownloadProxyMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadProxyMap.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1AD3306C16B1D991004F60E7 /* StorageAreaImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StorageAreaImpl.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1AD3306D16B1D991004F60E7 /* StorageAreaImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageAreaImpl.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                1AD8790918B6C38A006CAFD7 /* WKUIDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUIDelegate.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 1ADCB868189831B30022EE5A /* NavigationActionData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigationActionData.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1ADCB869189831B30022EE5A /* NavigationActionData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationActionData.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1ADF59181890528E0043C145 /* WKWebViewConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewConfiguration.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -2063,6 +2067,8 @@
</span><span class="cx">                 1AFDD3141891B54000153970 /* APIPolicyClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIPolicyClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1AFDD3161891C94700153970 /* WKPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPreferences.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1AFDD3181891CA1200153970 /* WKPreferences.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPreferences.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                1AFE436318B6C081009C7A48 /* UIClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIClient.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                1AFE436418B6C081009C7A48 /* UIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 1AFF48FE1833DE78009AB15A /* WKDeprecatedFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKDeprecatedFunctions.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1BB417C912C00CCA002BE67B /* TextCheckerCompletion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCheckerCompletion.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1C77C1951288A872006A742F /* WebInspectorProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebInspectorProxy.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -4032,6 +4038,8 @@
</span><span class="cx">                                 1A422F8C18B29C6400D8CD96 /* HistoryClient.mm */,
</span><span class="cx">                                 1ABC3DF41899E437004F0626 /* NavigationState.h */,
</span><span class="cx">                                 1ABC3DF31899E437004F0626 /* NavigationState.mm */,
</span><ins>+                                1AFE436418B6C081009C7A48 /* UIClient.h */,
+                                1AFE436318B6C081009C7A48 /* UIClient.mm */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = Cocoa;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -4388,6 +4396,7 @@
</span><span class="cx">                                 1A43E827188F3CDC009E4D30 /* WKProcessClassConfiguration.mm */,
</span><span class="cx">                                 1A43E82B188F3CF5009E4D30 /* WKProcessClassConfigurationPrivate.h */,
</span><span class="cx">                                 1A3CC16818907EB0001E6ED8 /* WKProcessClassInternal.h */,
</span><ins>+                                1AD8790918B6C38A006CAFD7 /* WKUIDelegate.h */,
</ins><span class="cx">                                 1A3CC16518906ACF001E6ED8 /* WKWebView.h */,
</span><span class="cx">                                 1A3CC16418906ACF001E6ED8 /* WKWebView.mm */,
</span><span class="cx">                                 1ADF59191890528E0043C145 /* WKWebViewConfiguration.h */,
</span><span class="lines">@@ -6301,6 +6310,7 @@
</span><span class="cx">                                 377EAD4817E2C77B002D193D /* WKUserContentInjectedFrames.h in Headers */,
</span><span class="cx">                                 BC8699B5116AADAA002A925B /* WKView.h in Headers */,
</span><span class="cx">                                 BC8F2F2B16273A2C005FACB5 /* WKWebProcessPlugInBrowserContextController.h in Headers */,
</span><ins>+                                1AD8790A18B6C38A006CAFD7 /* WKUIDelegate.h in Headers */,
</ins><span class="cx">                                 290F4272172A0C7400939FF0 /* ChildProcessSupplement.h in Headers */,
</span><span class="cx">                                 1A6F9F9011E13EFC00DB1371 /* CommandLine.h in Headers */,
</span><span class="cx">                                 37C4E9F6131C6E7E0029BD5A /* config.h in Headers */,
</span><span class="lines">@@ -6494,6 +6504,7 @@
</span><span class="cx">                                 7CD622781739D863005BD7FF /* PluginSandboxProfile.h in Headers */,
</span><span class="cx">                                 1AAB037A185A7C6A00EDF501 /* MessageSender.h in Headers */,
</span><span class="cx">                                 1A6FB7AF11E64B6800DB1371 /* PluginView.h in Headers */,
</span><ins>+                                1AFE436618B6C081009C7A48 /* UIClient.h in Headers */,
</ins><span class="cx">                                 E1CC1B9012D7EADF00625838 /* PrintInfo.h in Headers */,
</span><span class="cx">                                 BC1A7C581136E19C00FB7167 /* ProcessLauncher.h in Headers */,
</span><span class="cx">                                 BC597075116591D000551FCA /* ProcessModel.h in Headers */,
</span><span class="lines">@@ -7770,6 +7781,7 @@
</span><span class="cx">                                 1AAB037C185F99D800EDF501 /* APIData.cpp in Sources */,
</span><span class="cx">                                 BC8147AA12F64CDA007B2C32 /* InjectedBundlePagePolicyClient.cpp in Sources */,
</span><span class="cx">                                 659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */,
</span><ins>+                                1AFE436518B6C081009C7A48 /* UIClient.mm in Sources */,
</ins><span class="cx">                                 BCA8C6AF11E3C08700812FB7 /* InjectedBundlePageUIClient.cpp in Sources */,
</span><span class="cx">                                 0F5947A3187B3B7D00437857 /* RemoteScrollingCoordinatorTransaction.cpp in Sources */,
</span><span class="cx">                                 BC33E0D212408E8600360F3F /* InjectedBundleRangeHandle.cpp in Sources */,
</span></span></pre>
</div>
</div>

</body>
</html>