<!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>[159902] trunk/Tools</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/159902">159902</a></dd>
<dt>Author</dt> <dd>mitz@apple.com</dd>
<dt>Date</dt> <dd>2013-12-01 16:50:07 -0800 (Sun, 01 Dec 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Mac] Transition MiniBrowser to the Cocoa API: policy delegate
https://bugs.webkit.org/show_bug.cgi?id=125046
Reviewed by Sam Weinig.
* MiniBrowser/mac/AppDelegate.m:
(-[BrowserAppDelegate newWindow:]): Added WK_API_ENABLED guards.
(-[BrowserAppDelegate openDocument:]): Ditto.
* MiniBrowser/mac/WK2BrowserWindowController.h: Ditto. Also moved ivar declarations from the
interface to the implementation.
* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController awakeFromNib]): Changed to set the policy delegate instead of
the policy client.
(-[WK2BrowserWindowController browsingContextController:decidePolicyForNavigationAction:decisionHandler:]):
Moved policy client implementation into this delegate method.
(-[WK2BrowserWindowController browsingContextController:decidePolicyForNewWindowAction:decisionHandler:]):
Ditto.
(-[WK2BrowserWindowController browsingContextController:decidePolicyForResponseAction:decisionHandler:]):
Ditto.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsMiniBrowsermacAppDelegatem">trunk/Tools/MiniBrowser/mac/AppDelegate.m</a></li>
<li><a href="#trunkToolsMiniBrowsermacWK2BrowserWindowControllerh">trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.h</a></li>
<li><a href="#trunkToolsMiniBrowsermacWK2BrowserWindowControllerm">trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (159901 => 159902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2013-12-01 23:40:27 UTC (rev 159901)
+++ trunk/Tools/ChangeLog        2013-12-02 00:50:07 UTC (rev 159902)
</span><span class="lines">@@ -1,5 +1,27 @@
</span><span class="cx"> 2013-12-01 Dan Bernstein <mitz@apple.com>
</span><span class="cx">
</span><ins>+ [Mac] Transition MiniBrowser to the Cocoa API: policy delegate
+ https://bugs.webkit.org/show_bug.cgi?id=125046
+
+ Reviewed by Sam Weinig.
+
+ * MiniBrowser/mac/AppDelegate.m:
+ (-[BrowserAppDelegate newWindow:]): Added WK_API_ENABLED guards.
+ (-[BrowserAppDelegate openDocument:]): Ditto.
+ * MiniBrowser/mac/WK2BrowserWindowController.h: Ditto. Also moved ivar declarations from the
+ interface to the implementation.
+ * MiniBrowser/mac/WK2BrowserWindowController.m:
+ (-[WK2BrowserWindowController awakeFromNib]): Changed to set the policy delegate instead of
+ the policy client.
+ (-[WK2BrowserWindowController browsingContextController:decidePolicyForNavigationAction:decisionHandler:]):
+ Moved policy client implementation into this delegate method.
+ (-[WK2BrowserWindowController browsingContextController:decidePolicyForNewWindowAction:decisionHandler:]):
+ Ditto.
+ (-[WK2BrowserWindowController browsingContextController:decidePolicyForResponseAction:decisionHandler:]):
+ Ditto.
+
+2013-12-01 Dan Bernstein <mitz@apple.com>
+
</ins><span class="cx"> [Mac] Remove the MiniBrowser injected bundle
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=125041
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsMiniBrowsermacAppDelegatem"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/mac/AppDelegate.m (159901 => 159902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/mac/AppDelegate.m        2013-12-01 23:40:27 UTC (rev 159901)
+++ trunk/Tools/MiniBrowser/mac/AppDelegate.m        2013-12-02 00:50:07 UTC (rev 159902)
</span><span class="lines">@@ -125,8 +125,10 @@
</span><span class="cx">
</span><span class="cx"> if (![sender respondsToSelector:@selector(tag)] || [sender tag] == WebKit1NewWindowTag)
</span><span class="cx"> controller = [[WK1BrowserWindowController alloc] initWithWindowNibName:@"BrowserWindow"];
</span><ins>+#if WK_API_ENABLED
</ins><span class="cx"> else if ([sender tag] == WebKit2NewWindowTag)
</span><span class="cx"> controller = [[WK2BrowserWindowController alloc] initWithContext:_processContext pageGroup:_pageGroup];
</span><ins>+#endif
</ins><span class="cx">
</span><span class="cx"> if (!controller)
</span><span class="cx"> return;
</span><span class="lines">@@ -192,6 +194,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if WK_API_ENABLED
</ins><span class="cx"> NSOpenPanel *openPanel = [NSOpenPanel openPanel];
</span><span class="cx"> [openPanel beginWithCompletionHandler:^(NSInteger result) {
</span><span class="cx"> if (result != NSOKButton)
</span><span class="lines">@@ -204,6 +207,7 @@
</span><span class="cx"> NSURL *url = [openPanel.URLs objectAtIndex:0];
</span><span class="cx"> [newBrowserWindowController loadURLString:[url absoluteString]];
</span><span class="cx"> }];
</span><ins>+#endif // WK_API_ENABLED
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkToolsMiniBrowsermacWK2BrowserWindowControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.h (159901 => 159902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.h        2013-12-01 23:40:27 UTC (rev 159901)
+++ trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.h        2013-12-02 00:50:07 UTC (rev 159902)
</span><span class="lines">@@ -25,12 +25,12 @@
</span><span class="cx">
</span><span class="cx"> #import "BrowserWindowController.h"
</span><span class="cx">
</span><del>-@interface WK2BrowserWindowController : BrowserWindowController<BrowserController> {
- WKContextRef _context;
- WKPageGroupRef _pageGroup;
- WKView *_webView;
-}
</del><ins>+#if WK_API_ENABLED
</ins><span class="cx">
</span><ins>+@interface WK2BrowserWindowController : BrowserWindowController <BrowserController>
+
</ins><span class="cx"> - (id)initWithContext:(WKContextRef)context pageGroup:(WKPageGroupRef)pageGroup;
</span><span class="cx">
</span><span class="cx"> @end
</span><ins>+
+#endif // WK_API_ENABLED
</ins></span></pre></div>
<a id="trunkToolsMiniBrowsermacWK2BrowserWindowControllerm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m (159901 => 159902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m        2013-12-01 23:40:27 UTC (rev 159901)
+++ trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m        2013-12-02 00:50:07 UTC (rev 159902)
</span><span class="lines">@@ -25,13 +25,17 @@
</span><span class="cx">
</span><span class="cx"> #import "WK2BrowserWindowController.h"
</span><span class="cx">
</span><ins>+#if WK_API_ENABLED
+
</ins><span class="cx"> #import "AppDelegate.h"
</span><ins>+#import <WebKit2/WKBrowsingContextController.h>
+#import <WebKit2/WKBrowsingContextPolicyDelegate.h>
</ins><span class="cx"> #import <WebKit2/WKPagePrivate.h>
</span><span class="cx"> #import <WebKit2/WKStringCF.h>
</span><span class="cx"> #import <WebKit2/WKURLCF.h>
</span><span class="cx"> #import <WebKit2/WKViewPrivate.h>
</span><span class="cx">
</span><del>-@interface WK2BrowserWindowController ()
</del><ins>+@interface WK2BrowserWindowController () <WKBrowsingContextPolicyDelegate>
</ins><span class="cx"> - (void)didStartProgress;
</span><span class="cx"> - (void)didChangeProgress:(double)value;
</span><span class="cx"> - (void)didFinishProgress;
</span><span class="lines">@@ -44,7 +48,11 @@
</span><span class="cx"> - (BOOL)isPaginated;
</span><span class="cx"> @end
</span><span class="cx">
</span><del>-@implementation WK2BrowserWindowController
</del><ins>+@implementation WK2BrowserWindowController {
+ WKContextRef _context;
+ WKPageGroupRef _pageGroup;
+ WKView *_webView;
+}
</ins><span class="cx">
</span><span class="cx"> - (id)initWithContext:(WKContextRef)context pageGroup:(WKPageGroupRef)pageGroup
</span><span class="cx"> {
</span><span class="lines">@@ -61,6 +69,7 @@
</span><span class="cx"> {
</span><span class="cx"> WKRelease(_context);
</span><span class="cx"> WKRelease(_pageGroup);
</span><ins>+ _webView.browsingContextController.policyDelegate = nil;
</ins><span class="cx"> [_webView release];
</span><span class="cx">
</span><span class="cx"> [super dealloc];
</span><span class="lines">@@ -412,25 +421,6 @@
</span><span class="cx"> [(WK2BrowserWindowController *)clientInfo validateToolbar];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// MARK: Policy Client Callbacks
-
-static void decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKFrameRef originatingFrame, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
-{
- LOG(@"decidePolicyForNavigationAction");
- WKFramePolicyListenerUse(listener);
-}
-
-static void decidePolicyForNewWindowAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
-{
- LOG(@"decidePolicyForNewWindowAction");
- WKFramePolicyListenerUse(listener);
-}
-
-static void decidePolicyForResponse(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, bool canShowMIMEType, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
-{
- WKFramePolicyListenerUse(listener);
-}
-
</del><span class="cx"> // MARK: UI Client Callbacks
</span><span class="cx">
</span><span class="cx"> static WKPageRef createNewPage(WKPageRef page, WKURLRequestRef request, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton button, const void* clientInfo)
</span><span class="lines">@@ -666,19 +656,9 @@
</span><span class="cx"> 0, // pluginLoadPolicy
</span><span class="cx"> };
</span><span class="cx"> WKPageSetPageLoaderClient(_webView.pageRef, &loadClient);
</span><del>-
- WKPagePolicyClient policyClient = {
- kWKPagePolicyClientCurrentVersion,
- self, /* clientInfo */
- 0, /* decidePolicyForNavigationAction_deprecatedForUseWithV0 */
- decidePolicyForNewWindowAction,
- 0, /* decidePolicyForResponse_deprecatedForUseWithV */
- 0, /* unableToImplementPolicy */
- decidePolicyForNavigationAction,
- decidePolicyForResponse,
- };
- WKPageSetPagePolicyClient(_webView.pageRef, &policyClient);
</del><span class="cx">
</span><ins>+ _webView.browsingContextController.policyDelegate = self;
+
</ins><span class="cx"> WKPageUIClient uiClient = {
</span><span class="cx"> kWKPageUIClientCurrentVersion,
</span><span class="cx"> self, /* clientInfo */
</span><span class="lines">@@ -847,4 +827,25 @@
</span><span class="cx"> WKPageFindString(_webView.pageRef, string, kWKFindOptionsCaseInsensitive | kWKFindOptionsWrapAround | kWKFindOptionsShowFindIndicator | kWKFindOptionsShowOverlay, 100);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#pragma mark WKBrowsingContextPolicyDelegate
+
+- (void)browsingContextController:(WKBrowsingContextController *)browsingContext decidePolicyForNavigationAction:(NSDictionary *)actionInformation decisionHandler:(WKPolicyDecisionHandler)decisionHandler
+{
+ LOG(@"decidePolicyForNavigationAction");
+ decisionHandler(WKPolicyDecisionAllow);
+}
+
+- (void)browsingContextController:(WKBrowsingContextController *)browsingContext decidePolicyForNewWindowAction:(NSDictionary *)actionInformation decisionHandler:(WKPolicyDecisionHandler)decisionHandler
+{
+ LOG(@"decidePolicyForNewWindowAction");
+ decisionHandler(WKPolicyDecisionAllow);
+}
+
+- (void)browsingContextController:(WKBrowsingContextController *)browsingContext decidePolicyForResponseAction:(NSDictionary *)actionInformation decisionHandler:(WKPolicyDecisionHandler)decisionHandler
+{
+ decisionHandler(WKPolicyDecisionAllow);
+}
+
</ins><span class="cx"> @end
</span><ins>+
+#endif // WK_API_ENABLED
</ins></span></pre>
</div>
</div>
</body>
</html>