⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 98399 in webkit


Ignore:
Timestamp:
Oct 25, 2011, 3:35:52 PM (15 years ago)
Author:
weinig@apple.com
Message:

Flesh out WKBrowsingContextLoadDelegate a bit
https://bugs.webkit.org/show_bug.cgi?id=70846

Source/WebKit2:

Add didReceiveServerRedirectForProvisionalLoad, didFailProvisionalLoad
and didFailLoad.

Reviewed by Anders Carlsson.

Test: WKBrowsingContextLoadDelegateTest

  • UIProcess/API/mac/WKBrowsingContextController.mm:

(didReceiveServerRedirectForProvisionalLoadForFrame):
(didFailProvisionalLoadWithErrorForFrame):
(didFailLoadWithErrorForFrame):
(setUpPageLoaderClient):

  • UIProcess/API/mac/WKBrowsingContextLoadDelegate.h:

Tools:

Reviewed by Anders Carlsson.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKit2ObjC: Added.
  • TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm: Added.

(WKBrowsingContextLoadDelegateTest::WKBrowsingContextLoadDelegateTest):
(WKBrowsingContextLoadDelegateTest::SetUp):
(WKBrowsingContextLoadDelegateTest::TearDown):
(-[SimpleLoadDelegate browsingContextControllerDidFinishLoad:]):
(TEST_F):
Add basic testing for WKBrowsingContextLoadDelegate.

Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r98394 r98399  
     12011-10-25  Sam Weinig  <sam@webkit.org>
     2
     3        Flesh out WKBrowsingContextLoadDelegate a bit
     4        https://bugs.webkit.org/show_bug.cgi?id=70846
     5
     6        Add didReceiveServerRedirectForProvisionalLoad, didFailProvisionalLoad
     7        and didFailLoad.
     8
     9        Reviewed by Anders Carlsson.
     10
     11        Test: WKBrowsingContextLoadDelegateTest
     12
     13        * UIProcess/API/mac/WKBrowsingContextController.mm:
     14        (didReceiveServerRedirectForProvisionalLoadForFrame):
     15        (didFailProvisionalLoadWithErrorForFrame):
     16        (didFailLoadWithErrorForFrame):
     17        (setUpPageLoaderClient):
     18        * UIProcess/API/mac/WKBrowsingContextLoadDelegate.h:
     19
    1202011-10-25  Anders Carlsson  <andersca@apple.com>
    221
  • trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm

    r98386 r98399  
    2828#import "WKBrowsingContextControllerInternal.h"
    2929
     30#import "WKErrorCF.h"
    3031#import "WKFrame.h"
    3132#import "WKPage.h"
     
    3536#import "WKURLRequest.h"
    3637#import "WKURLRequestNS.h"
     38#import <wtf/RetainPtr.h>
    3739
    3840#import "WKBrowsingContextLoadDelegate.h"
     
    204206
    205207    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    206     [browsingContext.loadDelegate browsingContextControllerDidStartProvisionalLoad:browsingContext];
     208    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidStartProvisionalLoad:)])
     209        [browsingContext.loadDelegate browsingContextControllerDidStartProvisionalLoad:browsingContext];
     210}
     211
     212static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
     213{
     214    if (!WKFrameIsMainFrame(frame))
     215        return;
     216
     217    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     218    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:)])
     219        [browsingContext.loadDelegate browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:browsingContext];
     220}
     221
     222static void didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
     223{
     224    if (!WKFrameIsMainFrame(frame))
     225        return;
     226
     227    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     228    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFailProvisionalLoad:withError:)]) {
     229        RetainPtr<CFErrorRef> cfError(AdoptCF, WKErrorCopyCFError(kCFAllocatorDefault, error));
     230        [browsingContext.loadDelegate browsingContextControllerDidFailProvisionalLoad:browsingContext withError:(NSError *)cfError.get()];
     231    }
    207232}
    208233
     
    213238
    214239    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    215     [browsingContext.loadDelegate browsingContextControllerDidCommitLoad:browsingContext];
     240    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidCommitLoad:)])
     241        [browsingContext.loadDelegate browsingContextControllerDidCommitLoad:browsingContext];
    216242}
    217243
     
    222248
    223249    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    224     [browsingContext.loadDelegate browsingContextControllerDidFinishLoad:browsingContext];
     250    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFinishLoad:)])
     251        [browsingContext.loadDelegate browsingContextControllerDidFinishLoad:browsingContext];
     252}
     253
     254static void didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
     255{
     256    if (!WKFrameIsMainFrame(frame))
     257        return;
     258
     259    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     260    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFailLoad:withError:)]) {
     261        RetainPtr<CFErrorRef> cfError(AdoptCF, WKErrorCopyCFError(kCFAllocatorDefault, error));
     262        [browsingContext.loadDelegate browsingContextControllerDidFailLoad:browsingContext withError:(NSError *)cfError.get()];
     263    }
    225264}
    226265
     
    229268    WKPageLoaderClient loaderClient;
    230269    memset(&loaderClient, 0, sizeof(loaderClient));
    231    
     270
    232271    loaderClient.version = kWKPageLoaderClientCurrentVersion;
    233272    loaderClient.clientInfo = browsingContext;
    234273    loaderClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame;
     274    loaderClient.didReceiveServerRedirectForProvisionalLoadForFrame = didReceiveServerRedirectForProvisionalLoadForFrame;
     275    loaderClient.didFailProvisionalLoadWithErrorForFrame = didFailProvisionalLoadWithErrorForFrame;
    235276    loaderClient.didCommitLoadForFrame = didCommitLoadForFrame;
    236277    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
     278    loaderClient.didFailLoadWithErrorForFrame = didFailLoadWithErrorForFrame;
    237279
    238280    WKPageSetPageLoaderClient(pageRef, &loaderClient);
  • trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextLoadDelegate.h

    r98285 r98399  
    3535- (void)browsingContextControllerDidStartProvisionalLoad:(WKBrowsingContextController *)sender;
    3636
     37/* Sent if a server-side redirect was recieved. */
     38- (void)browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:(WKBrowsingContextController *)sender;
     39
     40/* Sent if the provional load fails. */
     41- (void)browsingContextControllerDidFailProvisionalLoad:(WKBrowsingContextController *)sender withError:(NSError *)error;
     42
    3743/* Sent when the load gets committed. */
    3844- (void)browsingContextControllerDidCommitLoad:(WKBrowsingContextController *)sender;
     
    4147- (void)browsingContextControllerDidFinishLoad:(WKBrowsingContextController *)sender;
    4248
     49/* Sent if the commited load fails. */
     50- (void)browsingContextControllerDidFailLoad:(WKBrowsingContextController *)sender withError:(NSError *)error;
     51
    4352@end
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r98285 r98399  
    696696                BCBAACF51452324F0053F82F /* WKBrowsingContextGroup.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCBAACEF145232440053F82F /* WKBrowsingContextGroup.mm */; };
    697697                BCBAACF61452324F0053F82F /* WKBrowsingContextGroupInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBAACF0145232480053F82F /* WKBrowsingContextGroupInternal.h */; };
    698                 BCBAAD0B14560A430053F82F /* WKBrowsingContextLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBAAD0A14560A430053F82F /* WKBrowsingContextLoadDelegate.h */; };
     698                BCBAAD0B14560A430053F82F /* WKBrowsingContextLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBAAD0A14560A430053F82F /* WKBrowsingContextLoadDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
    699699                BCBCB0CB1215E32100DE59CA /* ImmutableDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBCB0CA1215E32100DE59CA /* ImmutableDictionary.h */; };
    700700                BCBCB0CD1215E33A00DE59CA /* ImmutableDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCBCB0CC1215E33A00DE59CA /* ImmutableDictionary.cpp */; };
  • trunk/Tools/ChangeLog

    r98395 r98399  
     12011-10-25  Sam Weinig  <sam@webkit.org>
     2
     3        Flesh out WKBrowsingContextLoadDelegate a bit
     4        https://bugs.webkit.org/show_bug.cgi?id=70846
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     9        * TestWebKitAPI/Tests/WebKit2ObjC: Added.
     10        * TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm: Added.
     11        (WKBrowsingContextLoadDelegateTest::WKBrowsingContextLoadDelegateTest):
     12        (WKBrowsingContextLoadDelegateTest::SetUp):
     13        (WKBrowsingContextLoadDelegateTest::TearDown):
     14        (-[SimpleLoadDelegate browsingContextControllerDidFinishLoad:]):
     15        (TEST_F):
     16        Add basic testing for WKBrowsingContextLoadDelegate.
     17
    1182011-10-25  Alexey Proskuryakov  <ap@apple.com>
    219
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r97633 r98399  
    4444                BC2D004912A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC2D004812A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp */; };
    4545                BC2D006412AA04CE00E732A3 /* file-with-anchor.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = BC2D004A12A9FEB300E732A3 /* file-with-anchor.html */; };
     46                BC3C4C7214575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC3C4C7014575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm */; };
    4647                BC575A90126E74D3006F0F12 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCB9E9F011235BDE00A137E0 /* Cocoa.framework */; };
    4748                BC575A91126E74D3006F0F12 /* WebKit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCA61DB411700EFD00460D1E /* WebKit2.framework */; };
     
    179180                BC2D004812A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageLoadDidChangeLocationWithinPageForFrame.cpp; sourceTree = "<group>"; };
    180181                BC2D004A12A9FEB300E732A3 /* file-with-anchor.html */ = {isa = PBXFileReference; explicitFileType = text.html; fileEncoding = 4; path = "file-with-anchor.html"; sourceTree = "<group>"; };
     182                BC3C4C7014575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKBrowsingContextLoadDelegateTest.mm; path = WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm; sourceTree = "<group>"; };
    181183                BC575946126E7351006F0F12 /* InjectedBundleMain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleMain.cpp; sourceTree = "<group>"; };
    182184                BC575980126E74AF006F0F12 /* InjectedBundleTestWebKitAPI.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InjectedBundleTestWebKitAPI.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
     
    321323                        sourceTree = "<group>";
    322324                };
     325                BC3C4C6F14575B1D0025FB62 /* WebKit2 Objective-C */ = {
     326                        isa = PBXGroup;
     327                        children = (
     328                                BC3C4C7014575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm */,
     329                        );
     330                        name = "WebKit2 Objective-C";
     331                        sourceTree = "<group>";
     332                };
    323333                BC575944126E733C006F0F12 /* InjectedBundle */ = {
    324334                        isa = PBXGroup;
     
    445455                                C07E6CAD13FD67650038B22B /* mac */,
    446456                                BC9096411255616000083756 /* WebKit2 */,
     457                                BC3C4C6F14575B1D0025FB62 /* WebKit2 Objective-C */,
    447458                                BC9096461255618900083756 /* WTF */,
    448459                        );
     
    626637                                C0991C51143C7D68007998F2 /* RetainPtrHashing.cpp in Sources */,
    627638                                52CB47411448FB9300873995 /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp in Sources */,
     639                                BC3C4C7214575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm in Sources */,
    628640                        );
    629641                        runOnlyForDeploymentPostprocessing = 0;
Note: See TracChangeset for help on using the changeset viewer.