Diff
Modified: trunk/Source/WebKit2/ChangeLog (98284 => 98285)
--- trunk/Source/WebKit2/ChangeLog 2011-10-24 21:58:41 UTC (rev 98284)
+++ trunk/Source/WebKit2/ChangeLog 2011-10-24 22:07:24 UTC (rev 98285)
@@ -1,3 +1,30 @@
+2011-10-24 Sam Weinig <[email protected]>
+
+ Hook up minimalist load delegate to WKBrowsingContextController
+ https://bugs.webkit.org/show_bug.cgi?id=70764
+
+ Reviewed by Simon Fraser.
+
+ * UIProcess/API/mac/WKBrowsingContextController.h:
+ * UIProcess/API/mac/WKBrowsingContextController.mm:
+ (-[WKBrowsingContextController loadDelegate]):
+ (-[WKBrowsingContextController setLoadDelegate:]):
+ Add loadDelegate getter/setter. As per convention, the delegate is not
+ retained.
+
+ (didStartProvisionalLoadForFrame):
+ (didCommitLoadForFrame):
+ (didFinishLoadForFrame):
+ (setUpPageLoaderClient):
+ (-[WKBrowsingContextController initWithPageRef:]):
+ Hookup the delegate to a WKPageLoaderClient.
+
+ * UIProcess/API/mac/WKBrowsingContextLoadDelegate.h: Added.
+ Add load delegate as a proper protocol.
+
+ * WebKit2.xcodeproj/project.pbxproj:
+ Add new file.
+
2011-10-24 Michael Saboff <[email protected]>
WebKit doesn't build with recent changes to libdispatch
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.h (98284 => 98285)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.h 2011-10-24 21:58:41 UTC (rev 98284)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.h 2011-10-24 22:07:24 UTC (rev 98285)
@@ -27,6 +27,7 @@
#import <WebKit2/WKBase.h>
@class WKBrowsingContextControllerData;
+@protocol WKBrowsingContextLoadDelegate;
WK_EXPORT
@interface WKBrowsingContextController : NSObject {
@@ -34,6 +35,11 @@
WKBrowsingContextControllerData *_data;
}
+#pragma mark Delegates
+
+@property(assign) id<WKBrowsingContextLoadDelegate> loadDelegate;
+
+
#pragma mark Loading
/* Load a request. This is only valid for requests of non-file: URLs. Passing a
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm (98284 => 98285)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm 2011-10-24 21:58:41 UTC (rev 98284)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm 2011-10-24 22:07:24 UTC (rev 98285)
@@ -35,6 +35,7 @@
#import "WKURLRequest.h"
#import "WKURLRequestNS.h"
+#import "WKBrowsingContextLoadDelegate.h"
static inline NSString *autoreleased(WKStringRef string)
{
@@ -51,7 +52,11 @@
@interface WKBrowsingContextControllerData : NSObject {
@public
+ // Underlying WKPageRef.
WKRetainPtr<WKPageRef> _pageRef;
+
+ // Delegate for load callbacks.
+ id<WKBrowsingContextLoadDelegate> _loadDelegate;
}
@end
@@ -71,6 +76,19 @@
return _data->_pageRef.get();
}
+#pragma mark Delegates
+
+- (id<WKBrowsingContextLoadDelegate>)loadDelegate
+{
+ return _data->_loadDelegate;
+}
+
+- (void)setLoadDelegate:(id<WKBrowsingContextLoadDelegate>)loadDelegate
+{
+ _data->_loadDelegate = loadDelegate;
+}
+
+
#pragma mark Loading
- (void)loadRequest:(NSURLRequest *)request
@@ -185,6 +203,48 @@
@implementation WKBrowsingContextController (Internal)
+static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
+ [browsingContext.loadDelegate browsingContextControllerDidStartProvisionalLoad:browsingContext];
+}
+
+static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
+ [browsingContext.loadDelegate browsingContextControllerDidCommitLoad:browsingContext];
+}
+
+static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
+ [browsingContext.loadDelegate browsingContextControllerDidFinishLoad:browsingContext];
+}
+
+static void setUpPageLoaderClient(WKBrowsingContextController *browsingContext, WKPageRef pageRef)
+{
+ WKPageLoaderClient loaderClient;
+ memset(&loaderClient, 0, sizeof(loaderClient));
+
+ loaderClient.version = kWKPageLoaderClientCurrentVersion;
+ loaderClient.clientInfo = browsingContext;
+ loaderClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame;
+ loaderClient.didCommitLoadForFrame = didCommitLoadForFrame;
+ loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+
+ WKPageSetPageLoaderClient(pageRef, &loaderClient);
+}
+
+
/* This should only be called from associate view. */
- (id)initWithPageRef:(WKPageRef)pageRef
@@ -196,6 +256,8 @@
_data = [[WKBrowsingContextControllerData alloc] init];
_data->_pageRef = pageRef;
+ setUpPageLoaderClient(self, pageRef);
+
return self;
}
Added: trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextLoadDelegate.h (0 => 98285)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextLoadDelegate.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextLoadDelegate.h 2011-10-24 22:07:24 UTC (rev 98285)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 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 <Foundation/Foundation.h>
+#import <WebKit2/WKBase.h>
+
+@class WKBrowsingContextController;
+
+@protocol WKBrowsingContextLoadDelegate <NSObject>
+@optional
+
+/* Sent when the provisional load begins. */
+- (void)browsingContextControllerDidStartProvisionalLoad:(WKBrowsingContextController *)sender;
+
+/* Sent when the load gets committed. */
+- (void)browsingContextControllerDidCommitLoad:(WKBrowsingContextController *)sender;
+
+/* Sent when the load completes. */
+- (void)browsingContextControllerDidFinishLoad:(WKBrowsingContextController *)sender;
+
+@end
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (98284 => 98285)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2011-10-24 21:58:41 UTC (rev 98284)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2011-10-24 22:07:24 UTC (rev 98285)
@@ -695,6 +695,7 @@
BCBAACF41452324F0053F82F /* WKBrowsingContextGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBAACEE145232430053F82F /* WKBrowsingContextGroup.h */; settings = {ATTRIBUTES = (Public, ); }; };
BCBAACF51452324F0053F82F /* WKBrowsingContextGroup.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCBAACEF145232440053F82F /* WKBrowsingContextGroup.mm */; };
BCBAACF61452324F0053F82F /* WKBrowsingContextGroupInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBAACF0145232480053F82F /* WKBrowsingContextGroupInternal.h */; };
+ BCBAAD0B14560A430053F82F /* WKBrowsingContextLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBAAD0A14560A430053F82F /* WKBrowsingContextLoadDelegate.h */; };
BCBCB0CB1215E32100DE59CA /* ImmutableDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBCB0CA1215E32100DE59CA /* ImmutableDictionary.h */; };
BCBCB0CD1215E33A00DE59CA /* ImmutableDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCBCB0CC1215E33A00DE59CA /* ImmutableDictionary.cpp */; };
BCBD3914125BB1A800D2C29F /* WebPageProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCBD3912125BB1A800D2C29F /* WebPageProxyMessageReceiver.cpp */; };
@@ -726,7 +727,7 @@
BCD597D0112B56AC00EC8C23 /* WKPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD597CE112B56AC00EC8C23 /* WKPreferences.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCD597D1112B56AC00EC8C23 /* WKPreferences.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD597CF112B56AC00EC8C23 /* WKPreferences.cpp */; };
BCD597D6112B56DC00EC8C23 /* WKPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD597D4112B56DC00EC8C23 /* WKPage.cpp */; };
- BCD597D7112B56DC00EC8C23 /* WKPage.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD597D5112B56DC00EC8C23 /* WKPage.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ BCD597D7112B56DC00EC8C23 /* WKPage.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD597D5112B56DC00EC8C23 /* WKPage.h */; settings = {ATTRIBUTES = (Public, ); }; };
BCD597FF112B57BE00EC8C23 /* WebPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD597FD112B57BE00EC8C23 /* WebPreferences.h */; };
BCD59800112B57BE00EC8C23 /* WebPreferences.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD597FE112B57BE00EC8C23 /* WebPreferences.cpp */; };
BCD598AC112B7FDF00EC8C23 /* WebPreferencesStore.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD598AA112B7FDF00EC8C23 /* WebPreferencesStore.h */; };
@@ -1660,6 +1661,7 @@
BCBAACEE145232430053F82F /* WKBrowsingContextGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBrowsingContextGroup.h; sourceTree = "<group>"; };
BCBAACEF145232440053F82F /* WKBrowsingContextGroup.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKBrowsingContextGroup.mm; sourceTree = "<group>"; };
BCBAACF0145232480053F82F /* WKBrowsingContextGroupInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBrowsingContextGroupInternal.h; sourceTree = "<group>"; };
+ BCBAAD0A14560A430053F82F /* WKBrowsingContextLoadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBrowsingContextLoadDelegate.h; sourceTree = "<group>"; };
BCBCB0CA1215E32100DE59CA /* ImmutableDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImmutableDictionary.h; sourceTree = "<group>"; };
BCBCB0CC1215E33A00DE59CA /* ImmutableDictionary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImmutableDictionary.cpp; sourceTree = "<group>"; };
BCBD38FA125BAB9A00D2C29F /* WebPageProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebPageProxy.messages.in; sourceTree = "<group>"; };
@@ -2934,6 +2936,7 @@
BCBAACEE145232430053F82F /* WKBrowsingContextGroup.h */,
BCBAACEF145232440053F82F /* WKBrowsingContextGroup.mm */,
BCBAACF0145232480053F82F /* WKBrowsingContextGroupInternal.h */,
+ BCBAAD0A14560A430053F82F /* WKBrowsingContextLoadDelegate.h */,
BCBAACE5145225C90053F82F /* WKProcessGroup.h */,
BCBAACE6145225CA0053F82F /* WKProcessGroup.mm */,
BCBAACE7145225CB0053F82F /* WKProcessGroupInternal.h */,
@@ -3923,6 +3926,7 @@
BCBAACED145225E30053F82F /* WKProcessGroupInternal.h in Headers */,
BCBAACF41452324F0053F82F /* WKBrowsingContextGroup.h in Headers */,
BCBAACF61452324F0053F82F /* WKBrowsingContextGroupInternal.h in Headers */,
+ BCBAAD0B14560A430053F82F /* WKBrowsingContextLoadDelegate.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};