Changeset 159775 in webkit


Ignore:
Timestamp:
Nov 25, 2013, 4:47:51 PM (11 years ago)
Author:
mitz@apple.com
Message:

[Cocoa] Use class extensions for IPI
https://bugs.webkit.org/show_bug.cgi?id=124870

Reviewed by Sam Weinig.

  • UIProcess/API/mac/WKBrowsingContextController.mm: Reordered methods so that the Private

cateogry isn’t stuck between the API methods and the internal methods.
(-[WKBrowsingContextController setPaginationMode:]):
(-[WKBrowsingContextController paginationMode]):
(-[WKBrowsingContextController setPaginationBehavesLikeColumns:]):
(-[WKBrowsingContextController paginationBehavesLikeColumns]):
(-[WKBrowsingContextController setPageLength:]):
(-[WKBrowsingContextController pageLength]):
(-[WKBrowsingContextController setGapBetweenPages:]):
(-[WKBrowsingContextController gapBetweenPages]):
(-[WKBrowsingContextController pageCount]):
(-[WKBrowsingContextController handle]):

  • UIProcess/API/mac/WKBrowsingContextControllerInternal.h: Changed Internal category into

a class extension.

  • UIProcess/API/mac/WKConnection.mm:
  • UIProcess/API/mac/WKConnectionInternal.h: Changed Internal category into a class

extension.

  • WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm:
  • WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h: Ditto.
Location:
trunk/Source/WebKit2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r159773 r159775  
     12013-11-25  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] Use class extensions for IPI
     4        https://bugs.webkit.org/show_bug.cgi?id=124870
     5
     6        Reviewed by Sam Weinig.
     7
     8        * UIProcess/API/mac/WKBrowsingContextController.mm: Reordered methods so that the Private
     9        cateogry isn’t stuck between the API methods and the internal methods.
     10        (-[WKBrowsingContextController setPaginationMode:]):
     11        (-[WKBrowsingContextController paginationMode]):
     12        (-[WKBrowsingContextController setPaginationBehavesLikeColumns:]):
     13        (-[WKBrowsingContextController paginationBehavesLikeColumns]):
     14        (-[WKBrowsingContextController setPageLength:]):
     15        (-[WKBrowsingContextController pageLength]):
     16        (-[WKBrowsingContextController setGapBetweenPages:]):
     17        (-[WKBrowsingContextController gapBetweenPages]):
     18        (-[WKBrowsingContextController pageCount]):
     19        (-[WKBrowsingContextController handle]):
     20        * UIProcess/API/mac/WKBrowsingContextControllerInternal.h: Changed Internal category into
     21        a class extension.
     22
     23        * UIProcess/API/mac/WKConnection.mm:
     24        * UIProcess/API/mac/WKConnectionInternal.h: Changed Internal category into a class
     25        extension.
     26
     27        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm:
     28        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h: Ditto.
     29
    1302013-11-25  Dan Bernstein  <mitz@apple.com>
    231
  • trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm

    r159773 r159775  
    103103
    104104    std::unique_ptr<PageLoadStateObserver> _pageLoadStateObserver;
    105 
    106 #if PLATFORM(IOS)
    107     id <WKBrowsingContextLoadDelegateInternal> _loadDelegateInternal;
    108 #endif // PLATFORM(IOS)
    109105}
    110106
     
    347343}
    348344
     345static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
     346{
     347    if (!WKFrameIsMainFrame(frame))
     348        return;
     349
     350    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     351    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidStartProvisionalLoad:)])
     352        [browsingContext.loadDelegate browsingContextControllerDidStartProvisionalLoad:browsingContext];
     353}
     354
     355static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
     356{
     357    if (!WKFrameIsMainFrame(frame))
     358        return;
     359
     360    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     361    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:)])
     362        [browsingContext.loadDelegate browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:browsingContext];
     363}
     364
     365static void didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
     366{
     367    if (!WKFrameIsMainFrame(frame))
     368        return;
     369
     370    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     371    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFailProvisionalLoad:withError:)]) {
     372        RetainPtr<CFErrorRef> cfError = adoptCF(WKErrorCopyCFError(kCFAllocatorDefault, error));
     373        [browsingContext.loadDelegate browsingContextControllerDidFailProvisionalLoad:browsingContext withError:(NSError *)cfError.get()];
     374    }
     375}
     376
     377static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
     378{
     379    if (!WKFrameIsMainFrame(frame))
     380        return;
     381
     382    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     383#if PLATFORM(IOS)
     384    if ([browsingContext.loadDelegateInternal respondsToSelector:@selector(browsingContextControllerDidCommitLoad:)])
     385        [browsingContext.loadDelegateInternal browsingContextControllerDidCommitLoad:browsingContext];
     386#endif // PLATFORM(IOS)
     387    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidCommitLoad:)])
     388        [browsingContext.loadDelegate browsingContextControllerDidCommitLoad:browsingContext];
     389}
     390
     391static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
     392{
     393    if (!WKFrameIsMainFrame(frame))
     394        return;
     395
     396    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     397    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFinishLoad:)])
     398        [browsingContext.loadDelegate browsingContextControllerDidFinishLoad:browsingContext];
     399}
     400
     401static void didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
     402{
     403    if (!WKFrameIsMainFrame(frame))
     404        return;
     405
     406    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     407    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFailLoad:withError:)]) {
     408        RetainPtr<CFErrorRef> cfError = adoptCF(WKErrorCopyCFError(kCFAllocatorDefault, error));
     409        [browsingContext.loadDelegate browsingContextControllerDidFailLoad:browsingContext withError:(NSError *)cfError.get()];
     410    }
     411}
     412
     413static void didStartProgress(WKPageRef page, const void* clientInfo)
     414{
     415    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     416    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidStartProgress:)])
     417        [browsingContext.loadDelegate browsingContextControllerDidStartProgress:browsingContext];
     418}
     419
     420static void didChangeProgress(WKPageRef page, const void* clientInfo)
     421{
     422    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     423    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextController:estimatedProgressChangedTo:)])
     424        [browsingContext.loadDelegate browsingContextController:browsingContext estimatedProgressChangedTo:toImpl(page)->estimatedProgress()];
     425}
     426
     427static void didFinishProgress(WKPageRef page, const void* clientInfo)
     428{
     429    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     430    if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFinishProgress:)])
     431        [browsingContext.loadDelegate browsingContextControllerDidFinishProgress:browsingContext];
     432}
     433
     434static void didChangeBackForwardList(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void *clientInfo)
     435{
     436    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     437    if (![browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidChangeBackForwardList:addedItem:removedItems:)])
     438        return;
     439
     440    WKBackForwardListItem *added = addedItem ? wrapper(*toImpl(addedItem)) : nil;
     441    NSArray *removed = removedItems ? wrapper(*toImpl(removedItems)) : nil;
     442    [browsingContext.loadDelegate browsingContextControllerDidChangeBackForwardList:browsingContext addedItem:added removedItems:removed];
     443}
     444
     445static void setUpPageLoaderClient(WKBrowsingContextController *browsingContext, WKPageRef pageRef)
     446{
     447    WKPageLoaderClient loaderClient;
     448    memset(&loaderClient, 0, sizeof(loaderClient));
     449
     450    loaderClient.version = kWKPageLoaderClientCurrentVersion;
     451    loaderClient.clientInfo = browsingContext;
     452    loaderClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame;
     453    loaderClient.didReceiveServerRedirectForProvisionalLoadForFrame = didReceiveServerRedirectForProvisionalLoadForFrame;
     454    loaderClient.didFailProvisionalLoadWithErrorForFrame = didFailProvisionalLoadWithErrorForFrame;
     455    loaderClient.didCommitLoadForFrame = didCommitLoadForFrame;
     456    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
     457    loaderClient.didFailLoadWithErrorForFrame = didFailLoadWithErrorForFrame;
     458
     459    loaderClient.didStartProgress = didStartProgress;
     460    loaderClient.didChangeProgress = didChangeProgress;
     461    loaderClient.didFinishProgress = didFinishProgress;
     462    loaderClient.didChangeBackForwardList = didChangeBackForwardList;
     463
     464    WKPageSetPageLoaderClient(pageRef, &loaderClient);
     465}
     466
     467static WKPolicyDecisionHandler makePolicyDecisionBlock(WKFramePolicyListenerRef listener)
     468{
     469    WKRetain(listener); // Released in the decision handler below.
     470
     471    return [[^(WKPolicyDecision decision) {
     472        switch (decision) {
     473        case WKPolicyDecisionCancel:
     474            WKFramePolicyListenerIgnore(listener);                   
     475            break;
     476       
     477        case WKPolicyDecisionAllow:
     478            WKFramePolicyListenerUse(listener);
     479            break;
     480       
     481        case WKPolicyDecisionBecomeDownload:
     482            WKFramePolicyListenerDownload(listener);
     483            break;
     484        };
     485
     486        WKRelease(listener); // Retained in the context above.
     487    } copy] autorelease];
     488}
     489
     490static void setUpPagePolicyClient(WKBrowsingContextController *browsingContext, WKPageRef pageRef)
     491{
     492    WKPagePolicyClient policyClient;
     493    memset(&policyClient, 0, sizeof(policyClient));
     494
     495    policyClient.version = kWKPagePolicyClientCurrentVersion;
     496    policyClient.clientInfo = browsingContext;
     497
     498    policyClient.decidePolicyForNavigationAction = [](WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKFrameRef originatingFrame, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
     499    {
     500        WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     501        if ([browsingContext.policyDelegate respondsToSelector:@selector(browsingContextController:decidePolicyForNavigationAction:decisionHandler:)]) {
     502            NSDictionary *actionDictionary = @{
     503                WKActionIsMainFrameKey: @(WKFrameIsMainFrame(frame)),
     504                WKActionNavigationTypeKey: @(navigationType),
     505                WKActionModifierFlagsKey: @(modifiers),
     506                WKActionMouseButtonKey: @(mouseButton),
     507                WKActionURLRequestKey: adoptNS(WKURLRequestCopyNSURLRequest(request)).get()
     508            };
     509
     510            if (originatingFrame) {
     511                actionDictionary = [[actionDictionary mutableCopy] autorelease];
     512                [(NSMutableDictionary *)actionDictionary setObject:[NSURL _web_URLWithWTFString:toImpl(originatingFrame)->url() relativeToURL:nil] forKey:WKActionOriginatingFrameURLKey];
     513            }
     514           
     515            [browsingContext.policyDelegate browsingContextController:browsingContext decidePolicyForNavigationAction:actionDictionary decisionHandler:makePolicyDecisionBlock(listener)];
     516        } else
     517            WKFramePolicyListenerUse(listener);
     518    };
     519
     520    policyClient.decidePolicyForNewWindowAction = [](WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
     521    {
     522        WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     523        if ([browsingContext.policyDelegate respondsToSelector:@selector(browsingContextController:decidePolicyForNewWindowAction:decisionHandler:)]) {
     524            NSDictionary *actionDictionary = @{
     525                WKActionIsMainFrameKey: @(WKFrameIsMainFrame(frame)),
     526                WKActionNavigationTypeKey: @(navigationType),
     527                WKActionModifierFlagsKey: @(modifiers),
     528                WKActionMouseButtonKey: @(mouseButton),
     529                WKActionURLRequestKey: adoptNS(WKURLRequestCopyNSURLRequest(request)).get(),
     530                WKActionFrameNameKey: toImpl(frameName)->wrapper()
     531            };
     532           
     533            [browsingContext.policyDelegate browsingContextController:browsingContext decidePolicyForNewWindowAction:actionDictionary decisionHandler:makePolicyDecisionBlock(listener)];
     534        } else
     535            WKFramePolicyListenerUse(listener);
     536    };
     537
     538    policyClient.decidePolicyForResponse = [](WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, bool canShowMIMEType, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
     539    {
     540        WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     541        if ([browsingContext.policyDelegate respondsToSelector:@selector(browsingContextController:decidePolicyForResponseAction:decisionHandler:)]) {
     542            NSDictionary *actionDictionary = @{
     543                WKActionIsMainFrameKey: @(WKFrameIsMainFrame(frame)),
     544                WKActionURLRequestKey: adoptNS(WKURLRequestCopyNSURLRequest(request)).get(),
     545                WKActionURLResponseKey: adoptNS(WKURLResponseCopyNSURLResponse(response)).get(),
     546                WKActionCanShowMIMETypeKey: @(canShowMIMEType),
     547            };
     548
     549            [browsingContext.policyDelegate browsingContextController:browsingContext decidePolicyForResponseAction:actionDictionary decisionHandler:makePolicyDecisionBlock(listener)];
     550        } else
     551            WKFramePolicyListenerUse(listener);
     552    };
     553
     554    WKPageSetPagePolicyClient(pageRef, &policyClient);
     555}
     556
     557/* This should only be called from associate view. */
     558
     559- (id)_initWithPageRef:(WKPageRef)pageRef
     560{
     561    self = [super init];
     562    if (!self)
     563        return nil;
     564
     565    _pageRef = pageRef;
     566
     567    _pageLoadStateObserver = std::make_unique<PageLoadStateObserver>(self);
     568    toImpl(_pageRef.get())->pageLoadState().addObserver(*_pageLoadStateObserver);
     569
     570    setUpPageLoaderClient(self, pageRef);
     571    setUpPagePolicyClient(self, pageRef);
     572
     573    return self;
     574}
     575
     576+ (WKBrowsingContextController *)_browsingContextControllerForPageRef:(WKPageRef)pageRef
     577{
     578    return (WKBrowsingContextController *)WebKit::toImpl(pageRef)->loaderClient().client().clientInfo;
     579}
     580
     581+ (NSMutableSet *)customSchemes
     582{
     583    static NSMutableSet *customSchemes = [[NSMutableSet alloc] init];
     584    return customSchemes;
     585}
     586 
    349587@end
    350588
     
    438676@end
    439677
    440 @implementation WKBrowsingContextController (Internal)
    441 
    442 static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
    443 {
    444     if (!WKFrameIsMainFrame(frame))
    445         return;
    446 
    447     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    448     if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidStartProvisionalLoad:)])
    449         [browsingContext.loadDelegate browsingContextControllerDidStartProvisionalLoad:browsingContext];
    450 }
    451 
    452 static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
    453 {
    454     if (!WKFrameIsMainFrame(frame))
    455         return;
    456 
    457     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    458     if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:)])
    459         [browsingContext.loadDelegate browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:browsingContext];
    460 }
    461 
    462 static void didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
    463 {
    464     if (!WKFrameIsMainFrame(frame))
    465         return;
    466 
    467     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    468     if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFailProvisionalLoad:withError:)]) {
    469         RetainPtr<CFErrorRef> cfError = adoptCF(WKErrorCopyCFError(kCFAllocatorDefault, error));
    470         [browsingContext.loadDelegate browsingContextControllerDidFailProvisionalLoad:browsingContext withError:(NSError *)cfError.get()];
    471     }
    472 }
    473 
    474 static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
    475 {
    476     if (!WKFrameIsMainFrame(frame))
    477         return;
    478 
    479     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    480 #if PLATFORM(IOS)
    481     if ([browsingContext.loadDelegateInternal respondsToSelector:@selector(browsingContextControllerDidCommitLoad:)])
    482         [browsingContext.loadDelegateInternal browsingContextControllerDidCommitLoad:browsingContext];
    483 #endif // PLATFORM(IOS)
    484     if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidCommitLoad:)])
    485         [browsingContext.loadDelegate browsingContextControllerDidCommitLoad:browsingContext];
    486 }
    487 
    488 static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
    489 {
    490     if (!WKFrameIsMainFrame(frame))
    491         return;
    492 
    493     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    494     if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFinishLoad:)])
    495         [browsingContext.loadDelegate browsingContextControllerDidFinishLoad:browsingContext];
    496 }
    497 
    498 static void didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
    499 {
    500     if (!WKFrameIsMainFrame(frame))
    501         return;
    502 
    503     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    504     if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFailLoad:withError:)]) {
    505         RetainPtr<CFErrorRef> cfError = adoptCF(WKErrorCopyCFError(kCFAllocatorDefault, error));
    506         [browsingContext.loadDelegate browsingContextControllerDidFailLoad:browsingContext withError:(NSError *)cfError.get()];
    507     }
    508 }
    509 
    510 static void didStartProgress(WKPageRef page, const void* clientInfo)
    511 {
    512     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    513     if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidStartProgress:)])
    514         [browsingContext.loadDelegate browsingContextControllerDidStartProgress:browsingContext];
    515 }
    516 
    517 static void didChangeProgress(WKPageRef page, const void* clientInfo)
    518 {
    519     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    520     if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextController:estimatedProgressChangedTo:)])
    521         [browsingContext.loadDelegate browsingContextController:browsingContext estimatedProgressChangedTo:toImpl(page)->estimatedProgress()];
    522 }
    523 
    524 static void didFinishProgress(WKPageRef page, const void* clientInfo)
    525 {
    526     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    527     if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFinishProgress:)])
    528         [browsingContext.loadDelegate browsingContextControllerDidFinishProgress:browsingContext];
    529 }
    530 
    531 static void didChangeBackForwardList(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void *clientInfo)
    532 {
    533     WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    534     if (![browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidChangeBackForwardList:addedItem:removedItems:)])
    535         return;
    536 
    537     WKBackForwardListItem *added = addedItem ? wrapper(*toImpl(addedItem)) : nil;
    538     NSArray *removed = removedItems ? wrapper(*toImpl(removedItems)) : nil;
    539     [browsingContext.loadDelegate browsingContextControllerDidChangeBackForwardList:browsingContext addedItem:added removedItems:removed];
    540 }
    541 
    542 static void setUpPageLoaderClient(WKBrowsingContextController *browsingContext, WKPageRef pageRef)
    543 {
    544     WKPageLoaderClient loaderClient;
    545     memset(&loaderClient, 0, sizeof(loaderClient));
    546 
    547     loaderClient.version = kWKPageLoaderClientCurrentVersion;
    548     loaderClient.clientInfo = browsingContext;
    549     loaderClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame;
    550     loaderClient.didReceiveServerRedirectForProvisionalLoadForFrame = didReceiveServerRedirectForProvisionalLoadForFrame;
    551     loaderClient.didFailProvisionalLoadWithErrorForFrame = didFailProvisionalLoadWithErrorForFrame;
    552     loaderClient.didCommitLoadForFrame = didCommitLoadForFrame;
    553     loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
    554     loaderClient.didFailLoadWithErrorForFrame = didFailLoadWithErrorForFrame;
    555 
    556     loaderClient.didStartProgress = didStartProgress;
    557     loaderClient.didChangeProgress = didChangeProgress;
    558     loaderClient.didFinishProgress = didFinishProgress;
    559     loaderClient.didChangeBackForwardList = didChangeBackForwardList;
    560 
    561     WKPageSetPageLoaderClient(pageRef, &loaderClient);
    562 }
    563 
    564 static WKPolicyDecisionHandler makePolicyDecisionBlock(WKFramePolicyListenerRef listener)
    565 {
    566     WKRetain(listener); // Released in the decision handler below.
    567 
    568     return [[^(WKPolicyDecision decision) {
    569         switch (decision) {
    570         case WKPolicyDecisionCancel:
    571             WKFramePolicyListenerIgnore(listener);                   
    572             break;
    573        
    574         case WKPolicyDecisionAllow:
    575             WKFramePolicyListenerUse(listener);
    576             break;
    577        
    578         case WKPolicyDecisionBecomeDownload:
    579             WKFramePolicyListenerDownload(listener);
    580             break;
    581         };
    582 
    583         WKRelease(listener); // Retained in the context above.
    584     } copy] autorelease];
    585 }
    586 
    587 static void setUpPagePolicyClient(WKBrowsingContextController *browsingContext, WKPageRef pageRef)
    588 {
    589     WKPagePolicyClient policyClient;
    590     memset(&policyClient, 0, sizeof(policyClient));
    591 
    592     policyClient.version = kWKPagePolicyClientCurrentVersion;
    593     policyClient.clientInfo = browsingContext;
    594 
    595     policyClient.decidePolicyForNavigationAction = [](WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKFrameRef originatingFrame, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
    596     {
    597         WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    598         if ([browsingContext.policyDelegate respondsToSelector:@selector(browsingContextController:decidePolicyForNavigationAction:decisionHandler:)]) {
    599             NSDictionary *actionDictionary = @{
    600                 WKActionIsMainFrameKey: @(WKFrameIsMainFrame(frame)),
    601                 WKActionNavigationTypeKey: @(navigationType),
    602                 WKActionModifierFlagsKey: @(modifiers),
    603                 WKActionMouseButtonKey: @(mouseButton),
    604                 WKActionURLRequestKey: adoptNS(WKURLRequestCopyNSURLRequest(request)).get()
    605             };
    606 
    607             if (originatingFrame) {
    608                 actionDictionary = [[actionDictionary mutableCopy] autorelease];
    609                 [(NSMutableDictionary *)actionDictionary setObject:[NSURL _web_URLWithWTFString:toImpl(originatingFrame)->url() relativeToURL:nil] forKey:WKActionOriginatingFrameURLKey];
    610             }
    611            
    612             [browsingContext.policyDelegate browsingContextController:browsingContext decidePolicyForNavigationAction:actionDictionary decisionHandler:makePolicyDecisionBlock(listener)];
    613         } else
    614             WKFramePolicyListenerUse(listener);
    615     };
    616 
    617     policyClient.decidePolicyForNewWindowAction = [](WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
    618     {
    619         WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    620         if ([browsingContext.policyDelegate respondsToSelector:@selector(browsingContextController:decidePolicyForNewWindowAction:decisionHandler:)]) {
    621             NSDictionary *actionDictionary = @{
    622                 WKActionIsMainFrameKey: @(WKFrameIsMainFrame(frame)),
    623                 WKActionNavigationTypeKey: @(navigationType),
    624                 WKActionModifierFlagsKey: @(modifiers),
    625                 WKActionMouseButtonKey: @(mouseButton),
    626                 WKActionURLRequestKey: adoptNS(WKURLRequestCopyNSURLRequest(request)).get(),
    627                 WKActionFrameNameKey: toImpl(frameName)->wrapper()
    628             };
    629            
    630             [browsingContext.policyDelegate browsingContextController:browsingContext decidePolicyForNewWindowAction:actionDictionary decisionHandler:makePolicyDecisionBlock(listener)];
    631         } else
    632             WKFramePolicyListenerUse(listener);
    633     };
    634 
    635     policyClient.decidePolicyForResponse = [](WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, bool canShowMIMEType, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
    636     {
    637         WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
    638         if ([browsingContext.policyDelegate respondsToSelector:@selector(browsingContextController:decidePolicyForResponseAction:decisionHandler:)]) {
    639             NSDictionary *actionDictionary = @{
    640                 WKActionIsMainFrameKey: @(WKFrameIsMainFrame(frame)),
    641                 WKActionURLRequestKey: adoptNS(WKURLRequestCopyNSURLRequest(request)).get(),
    642                 WKActionURLResponseKey: adoptNS(WKURLResponseCopyNSURLResponse(response)).get(),
    643                 WKActionCanShowMIMETypeKey: @(canShowMIMEType),
    644             };
    645 
    646             [browsingContext.policyDelegate browsingContextController:browsingContext decidePolicyForResponseAction:actionDictionary decisionHandler:makePolicyDecisionBlock(listener)];
    647         } else
    648             WKFramePolicyListenerUse(listener);
    649     };
    650 
    651     WKPageSetPagePolicyClient(pageRef, &policyClient);
    652 }
    653 
    654 #if PLATFORM(IOS)
    655 - (id <WKBrowsingContextLoadDelegateInternal>)loadDelegateInternal
    656 {
    657     return _loadDelegateInternal;
    658 }
    659 
    660 - (void)setLoadDelegateInternal:(id <WKBrowsingContextLoadDelegateInternal>)loadDelegateInternal
    661 {
    662     _loadDelegateInternal = loadDelegateInternal;
    663 }
    664 #endif // PLATFORM(IOS)
    665 
    666 /* This should only be called from associate view. */
    667 
    668 - (id)_initWithPageRef:(WKPageRef)pageRef
    669 {
    670     self = [super init];
    671     if (!self)
    672         return nil;
    673 
    674     _pageRef = pageRef;
    675 
    676     _pageLoadStateObserver = std::make_unique<PageLoadStateObserver>(self);
    677     toImpl(_pageRef.get())->pageLoadState().addObserver(*_pageLoadStateObserver);
    678 
    679     setUpPageLoaderClient(self, pageRef);
    680     setUpPagePolicyClient(self, pageRef);
    681 
    682     return self;
    683 }
    684 
    685 + (WKBrowsingContextController *)_browsingContextControllerForPageRef:(WKPageRef)pageRef
    686 {
    687     return (WKBrowsingContextController *)WebKit::toImpl(pageRef)->loaderClient().client().clientInfo;
    688 }
    689 
    690 + (NSMutableSet *)customSchemes
    691 {
    692     static NSMutableSet *customSchemes = [[NSMutableSet alloc] init];
    693     return customSchemes;
    694 }
    695  
    696 @end
    697 
    698678#endif // WK_API_ENABLED
  • trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextControllerInternal.h

    r159760 r159775  
    3535#endif // PLATFORM(IOS)
    3636
    37 @interface WKBrowsingContextController (Internal)
     37@interface WKBrowsingContextController ()
    3838
    3939#if PLATFORM(IOS)
  • trunk/Source/WebKit2/UIProcess/API/mac/WKConnection.mm

    r159770 r159775  
    6969}
    7070
    71 @end
    72 
    73 @implementation WKConnection (Internal)
    74 
    7571static void didReceiveMessage(WKConnectionRef, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo)
    7672{
  • trunk/Source/WebKit2/UIProcess/API/mac/WKConnectionInternal.h

    r159760 r159775  
    3030#import <WebKit2/WKBase.h>
    3131
    32 @interface WKConnection (Internal)
     32@interface WKConnection ()
    3333
    3434- (id)_initWithConnectionRef:(WKConnectionRef)connectionRef;
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm

    r159760 r159775  
    4747@end
    4848
    49 @implementation WKWebProcessPlugInController (Internal)
     49@implementation WKWebProcessPlugInController
    5050
    5151static void didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
     
    128128}
    129129
    130 @end
    131 
    132 @implementation WKWebProcessPlugInController
    133 
    134130- (WKConnection *)connection
    135131{
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInInternal.h

    r157620 r159775  
    2828#if WK_API_ENABLED
    2929
    30 @interface WKWebProcessPlugInController (Internal)
     30@interface WKWebProcessPlugInController ()
    3131
    3232+ (WKWebProcessPlugInController *)_shared;
Note: See TracChangeset for help on using the changeset viewer.