Title: [160275] trunk/Tools
Revision
160275
Author
wei...@apple.com
Date
2013-12-07 18:36:37 -0800 (Sat, 07 Dec 2013)

Log Message

Convert MiniBrowser to use WKProcessGroup and WKBrowsingContextGroup
https://bugs.webkit.org/show_bug.cgi?id=125400

Reviewed by Dan Bernstein.

* MiniBrowser/mac/AppDelegate.h:
* MiniBrowser/mac/AppDelegate.m:
* MiniBrowser/mac/WK2BrowserWindowController.h:
* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController initWithProcessGroup:browsingContextGroup:]):
(-[WK2BrowserWindowController dealloc]):
(createNewPage):
(-[WK2BrowserWindowController awakeFromNib]):
(-[WK2BrowserWindowController browsingContextController:didNavigateWithNavigationData:]):
(-[WK2BrowserWindowController browsingContextController:didPerformClientRedirectFromURL:toURL:]):
(-[WK2BrowserWindowController browsingContextController:didPerformServerRedirectFromURL:toURL:]):
(-[WK2BrowserWindowController browsingContextController:didUpdateHistoryTitle:forURL:]):
Replace global WKContextRef and WKPageGroupRef with WKProcessGroup and WKBrowsingContextGroup. Also
replace context based WKContextHistoryClient with WKBrowsingContextController based WKBrowsingContextHistoryDelegate

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (160274 => 160275)


--- trunk/Tools/ChangeLog	2013-12-07 17:39:33 UTC (rev 160274)
+++ trunk/Tools/ChangeLog	2013-12-08 02:36:37 UTC (rev 160275)
@@ -1,3 +1,25 @@
+2013-12-07  Sam Weinig  <s...@webkit.org>
+
+        Convert MiniBrowser to use WKProcessGroup and WKBrowsingContextGroup
+        https://bugs.webkit.org/show_bug.cgi?id=125400
+
+        Reviewed by Dan Bernstein.
+
+        * MiniBrowser/mac/AppDelegate.h:
+        * MiniBrowser/mac/AppDelegate.m:
+        * MiniBrowser/mac/WK2BrowserWindowController.h:
+        * MiniBrowser/mac/WK2BrowserWindowController.m:
+        (-[WK2BrowserWindowController initWithProcessGroup:browsingContextGroup:]):
+        (-[WK2BrowserWindowController dealloc]):
+        (createNewPage):
+        (-[WK2BrowserWindowController awakeFromNib]):
+        (-[WK2BrowserWindowController browsingContextController:didNavigateWithNavigationData:]):
+        (-[WK2BrowserWindowController browsingContextController:didPerformClientRedirectFromURL:toURL:]):
+        (-[WK2BrowserWindowController browsingContextController:didPerformServerRedirectFromURL:toURL:]):
+        (-[WK2BrowserWindowController browsingContextController:didUpdateHistoryTitle:forURL:]):
+        Replace global WKContextRef and WKPageGroupRef with WKProcessGroup and WKBrowsingContextGroup. Also
+        replace context based WKContextHistoryClient with WKBrowsingContextController based WKBrowsingContextHistoryDelegate
+
 2013-12-07  Gustavo Noronha Silva  <g...@gnome.org>
 
         [GTK] Run each gtest subtest separately instead of in one go

Modified: trunk/Tools/MiniBrowser/mac/AppDelegate.h (160274 => 160275)


--- trunk/Tools/MiniBrowser/mac/AppDelegate.h	2013-12-07 17:39:33 UTC (rev 160274)
+++ trunk/Tools/MiniBrowser/mac/AppDelegate.h	2013-12-08 02:36:37 UTC (rev 160275)
@@ -24,8 +24,9 @@
  */
 
 @interface BrowserAppDelegate : NSObject <NSApplicationDelegate> {
-    WKContextRef _processContext;
-    WKPageGroupRef _pageGroup;
+    WKProcessGroup *_processGroup;
+    WKBrowsingContextGroup *_browsingContextGroup;
+
     NSMutableSet *_browserWindows;
 }
 

Modified: trunk/Tools/MiniBrowser/mac/AppDelegate.m (160274 => 160275)


--- trunk/Tools/MiniBrowser/mac/AppDelegate.m	2013-12-07 17:39:33 UTC (rev 160274)
+++ trunk/Tools/MiniBrowser/mac/AppDelegate.m	2013-12-08 02:36:37 UTC (rev 160275)
@@ -28,7 +28,7 @@
 #import "WK1BrowserWindowController.h"
 #import "WK2BrowserWindowController.h"
 
-#import <WebKit2/WKContextPrivate.h>
+#import <WebKit2/WebKit2.h>
 #import <WebKit2/WKStringCF.h>
 #import <WebKit2/WKURLCF.h>
 
@@ -41,77 +41,12 @@
 
 @implementation BrowserAppDelegate
 
-// MARK: History Client Callbacks
-
-static void didNavigateWithNavigationData(WKContextRef context, WKPageRef page, WKNavigationDataRef navigationData, WKFrameRef frame, const void *clientInfo)
-{
-    WKStringRef wkTitle = WKNavigationDataCopyTitle(navigationData);
-    CFStringRef title = WKStringCopyCFString(0, wkTitle);
-    WKRelease(wkTitle);
-
-    WKURLRef wkURL = WKNavigationDataCopyURL(navigationData);
-    CFURLRef url = "" wkURL);
-    WKRelease(wkURL);
-
-    LOG(@"HistoryClient - didNavigateWithNavigationData - title: %@ - url: %@", title, url);
-    CFRelease(title);
-    CFRelease(url);
-}
-
-static void didPerformClientRedirect(WKContextRef context, WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void *clientInfo)
-{
-    CFURLRef cfSourceURL = WKURLCopyCFURL(0, sourceURL);
-    CFURLRef cfDestinationURL = WKURLCopyCFURL(0, destinationURL);
-    LOG(@"HistoryClient - didPerformClientRedirect - sourceURL: %@ - destinationURL: %@", cfSourceURL, cfDestinationURL);
-    CFRelease(cfSourceURL);
-    CFRelease(cfDestinationURL);
-}
-
-static void didPerformServerRedirect(WKContextRef context, WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void *clientInfo)
-{
-    CFURLRef cfSourceURL = WKURLCopyCFURL(0, sourceURL);
-    CFURLRef cfDestinationURL = WKURLCopyCFURL(0, destinationURL);
-    LOG(@"HistoryClient - didPerformServerRedirect - sourceURL: %@ - destinationURL: %@", cfSourceURL, cfDestinationURL);
-    CFRelease(cfSourceURL);
-    CFRelease(cfDestinationURL);
-}
-
-static void didUpdateHistoryTitle(WKContextRef context, WKPageRef page, WKStringRef title, WKURLRef URL, WKFrameRef frame, const void *clientInfo)
-{
-    CFStringRef cfTitle = WKStringCopyCFString(0, title);
-    CFURLRef cfURL = WKURLCopyCFURL(0, URL);
-    LOG(@"HistoryClient - didUpdateHistoryTitle - title: %@ - URL: %@", cfTitle, cfURL);
-    CFRelease(cfTitle);
-    CFRelease(cfURL);
-}
-
-static void populateVisitedLinks(WKContextRef context, const void *clientInfo)
-{
-    LOG(@"HistoryClient - populateVisitedLinks");
-}
-
 - (id)init
 {
     self = [super init];
     if (self) {
-        WKContextHistoryClientV0 historyClient = {
-            { 0, self },
-            didNavigateWithNavigationData,
-            didPerformClientRedirect,
-            didPerformServerRedirect,
-            didUpdateHistoryTitle,
-            populateVisitedLinks
-        };
-
-        _processContext = WKContextCreate();
-
-        WKContextSetHistoryClient(_processContext, &historyClient.base);
-        WKContextSetCacheModel(_processContext, kWKCacheModelPrimaryWebBrowser);
-
-        WKStringRef pageGroupIdentifier = WKStringCreateWithCFString(CFSTR("MiniBrowser"));
-        _pageGroup = WKPageGroupCreateWithIdentifier(pageGroupIdentifier);
-        WKRelease(pageGroupIdentifier);
-
+        _processGroup = [[WKProcessGroup alloc] init];
+        _browsingContextGroup = [[WKBrowsingContextGroup alloc] initWithIdentifier:@"MiniBrowser"];
         _browserWindows = [[NSMutableSet alloc] init];
     }
 
@@ -126,7 +61,7 @@
         controller = [[WK1BrowserWindowController alloc] initWithWindowNibName:@"BrowserWindow"];
 #if WK_API_ENABLED
     else if ([sender tag] == WebKit2NewWindowTag)
-        controller = [[WK2BrowserWindowController alloc] initWithContext:_processContext pageGroup:_pageGroup];
+        controller = [[WK2BrowserWindowController alloc] initWithProcessGroup:_processGroup browsingContextGroup:_browsingContextGroup];
 #endif
 
     if (!controller)
@@ -157,8 +92,11 @@
         [controller applicationTerminating];
     }
 
-    WKRelease(_processContext);
-    _processContext = 0;
+    [_processGroup release];
+    _processGroup = nil;
+
+    [_browsingContextGroup release];
+    _browsingContextGroup = nil;
 }
 
 - (BrowserWindowController *)frontmostBrowserWindowController
@@ -200,7 +138,7 @@
             return;
 
         // FIXME: add a way to open in WK1 also.
-        BrowserWindowController *newBrowserWindowController = [[WK2BrowserWindowController alloc] initWithContext:_processContext pageGroup:_pageGroup];
+        BrowserWindowController *newBrowserWindowController = [[WK2BrowserWindowController alloc] initWithProcessGroup:_processGroup browsingContextGroup:_browsingContextGroup];
         [newBrowserWindowController.window makeKeyAndOrderFront:self];
 
         NSURL *url = "" objectAtIndex:0];

Modified: trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.h (160274 => 160275)


--- trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.h	2013-12-07 17:39:33 UTC (rev 160274)
+++ trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.h	2013-12-08 02:36:37 UTC (rev 160275)
@@ -29,7 +29,7 @@
 
 @interface WK2BrowserWindowController : BrowserWindowController <BrowserController>
 
-- (id)initWithContext:(WKContextRef)context pageGroup:(WKPageGroupRef)pageGroup;
+- (id)initWithProcessGroup:(WKProcessGroup *)processGroup browsingContextGroup:(WKBrowsingContextGroup *)browsingContextGroup;
 
 @end
 

Modified: trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m (160274 => 160275)


--- trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2013-12-07 17:39:33 UTC (rev 160274)
+++ trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2013-12-08 02:36:37 UTC (rev 160275)
@@ -29,27 +29,30 @@
 
 #import "AppDelegate.h"
 #import <WebKit2/WKBrowsingContextControllerPrivate.h>
+#import <WebKit2/WKBrowsingContextHistoryDelegate.h>
 #import <WebKit2/WKBrowsingContextLoadDelegatePrivate.h>
 #import <WebKit2/WKBrowsingContextPolicyDelegate.h>
+#import <WebKit2/WKNavigationData.h>
 #import <WebKit2/WKPagePrivate.h>
 #import <WebKit2/WKStringCF.h>
 #import <WebKit2/WKURLCF.h>
 #import <WebKit2/WKViewPrivate.h>
 
-@interface WK2BrowserWindowController () <WKBrowsingContextLoadDelegatePrivate, WKBrowsingContextPolicyDelegate>
+@interface WK2BrowserWindowController () <WKBrowsingContextLoadDelegatePrivate, WKBrowsingContextPolicyDelegate, WKBrowsingContextHistoryDelegate>
 @end
 
 @implementation WK2BrowserWindowController {
-    WKContextRef _context;
-    WKPageGroupRef _pageGroup;
+    WKProcessGroup *_processGroup;
+    WKBrowsingContextGroup *_browsingContextGroup;
+
     WKView *_webView;
 }
 
-- (id)initWithContext:(WKContextRef)context pageGroup:(WKPageGroupRef)pageGroup
+- (id)initWithProcessGroup:(WKProcessGroup *)processGroup browsingContextGroup:(WKBrowsingContextGroup *)browsingContextGroup
 {
     if ((self = [super initWithWindowNibName:@"BrowserWindow"])) {
-        _context = WKRetain(context);
-        _pageGroup = WKRetain(pageGroup);
+        _processGroup = [processGroup retain];
+        _browsingContextGroup = [browsingContextGroup retain];
         _zoomTextOnly = NO;
     }
     
@@ -61,13 +64,14 @@
     [progressIndicator unbind:NSHiddenBinding];
     [progressIndicator unbind:NSValueBinding];
 
-    WKRelease(_context);
-    WKRelease(_pageGroup);
     [_webView.browsingContextController removeObserver:self forKeyPath:@"title" context:[WK2BrowserWindowController self]];
     _webView.browsingContextController.loadDelegate = nil;
     _webView.browsingContextController.policyDelegate = nil;
     [_webView release];
 
+    [_browsingContextGroup release];
+    [_processGroup release];
+
     [super dealloc];
 }
 
@@ -313,7 +317,8 @@
 static WKPageRef createNewPage(WKPageRef page, WKURLRequestRef request, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton button, const void* clientInfo)
 {
     LOG(@"createNewPage");
-    WK2BrowserWindowController *controller = [[WK2BrowserWindowController alloc] initWithContext:WKPageGetContext(page) pageGroup:WKPageGetPageGroup(page)];
+    WK2BrowserWindowController *originator = (WK2BrowserWindowController *)clientInfo;
+    WK2BrowserWindowController *controller = [[WK2BrowserWindowController alloc] initWithProcessGroup:originator->_processGroup browsingContextGroup:originator->_browsingContextGroup];
     [controller loadWindow];
 
     return WKRetain(controller->_webView.pageRef);
@@ -497,7 +502,7 @@
 
 - (void)awakeFromNib
 {
-    _webView = [[WKView alloc] initWithFrame:[containerView bounds] contextRef:_context pageGroupRef:_pageGroup];
+    _webView = [[WKView alloc] initWithFrame:[containerView bounds] processGroup:_processGroup browsingContextGroup:_browsingContextGroup];
 
     [_webView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
     [containerView addSubview:_webView];
@@ -508,8 +513,8 @@
     [_webView.browsingContextController addObserver:self forKeyPath:@"title" options:0 context:[WK2BrowserWindowController self]];
 
     _webView.browsingContextController.loadDelegate = self;
-
     _webView.browsingContextController.policyDelegate = self;
+    _webView.browsingContextController.historyDelegate = self;
 
     WKPageUIClientV2 uiClient = {
         { 2, self },
@@ -679,6 +684,28 @@
     decisionHandler(WKPolicyDecisionAllow);
 }
 
+#pragma mark WKBrowsingContextHistoryDelegate
+
+- (void)browsingContextController:(WKBrowsingContextController *)browsingContextController didNavigateWithNavigationData:(WKNavigationData *)navigationData
+{
+    LOG(@"WKBrowsingContextHistoryDelegate - didNavigateWithNavigationData - title: %@ - url: %@", navigationData.title, navigationData.originalRequest.URL);
+}
+
+- (void)browsingContextController:(WKBrowsingContextController *)browsingContextController didPerformClientRedirectFromURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL
+{
+    LOG(@"WKBrowsingContextHistoryDelegate - didPerformClientRedirect - fromURL: %@ - toURL: %@", sourceURL, destinationURL);
+}
+
+- (void)browsingContextController:(WKBrowsingContextController *)browsingContextController didPerformServerRedirectFromURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL
+{
+    LOG(@"WKBrowsingContextHistoryDelegate - didPerformServerRedirect - fromURL: %@ - toURL: %@", sourceURL, destinationURL);
+}
+
+- (void)browsingContextController:(WKBrowsingContextController *)browsingContextController didUpdateHistoryTitle:(NSString *)title forURL:(NSURL *)URL
+{
+    LOG(@"browsingContextController - didUpdateHistoryTitle - title: %@ - URL: %@", title, URL);
+}
+
 @end
 
 #endif // WK_API_ENABLED
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to