Changeset 75174 in webkit


Ignore:
Timestamp:
Jan 6, 2011 11:27:23 AM (13 years ago)
Author:
bweinstein@apple.com
Message:

WebKit2: Should be able to call into injected bundle to ask if we should allow resource loads
https://bugs.webkit.org/show_bug.cgi?id=51969

Reviewed by Ada Chan.

Tools:

Add shouldLoadResourceForFrame to WTR::InjectedBundlePage.

  • WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:

(WTR::InjectedBundlePage::InjectedBundlePage):
(WTR::InjectedBundlePage::shouldLoadResourceForFrame): Stub implementation.

  • WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:

WebKit2:

Add the ability to call into the injected bundle to ask if we should allow resource loads.
If the injected bundle says we should cancel, we clear out the ResourceRequest that was
passed into willSendRequest, which cancels the resource load.

  • WebProcess/InjectedBundle/API/c/WKBundlePage.h: Add the new callback for allowing/cancelling

resource loads.

  • WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:

(WebKit::InjectedBundlePageLoaderClient::shouldLoadResourceForFrame): Calls through to the client.

  • WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:
  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::dispatchWillSendRequest): Ask the InjectedBundlePageLoaderClient if we

should load the resource or not.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r75169 r75174  
     12011-01-05  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Ada Chan.
     4
     5        WebKit2: Should be able to call into injected bundle to ask if we should allow resource loads
     6        https://bugs.webkit.org/show_bug.cgi?id=51969
     7       
     8        Add shouldLoadResourceForFrame to WTR::InjectedBundlePage.
     9
     10        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
     11        (WTR::InjectedBundlePage::InjectedBundlePage):
     12        (WTR::InjectedBundlePage::shouldLoadResourceForFrame): Stub implementation.
     13        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
     14
    1152011-01-06  James Robinson  <jamesr@chromium.org>
    216
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp

    r73412 r75174  
    191191        didCancelClientRedirectForFrame,
    192192        willPerformClientRedirectForFrame,
    193         didHandleOnloadEventsForFrame
     193        didHandleOnloadEventsForFrame,
     194        shouldLoadResourceForFrame
    194195    };
    195196    WKBundlePageSetLoaderClient(m_page, &loaderClient);
     
    323324}
    324325
     326bool InjectedBundlePage::shouldLoadResourceForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKURLRef, const void* clientInfo)
     327{
     328    return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->shouldLoadResourceForFrame(frame);
     329}
     330
    325331
    326332void InjectedBundlePage::didStartProvisionalLoadForFrame(WKBundleFrameRef frame)
     
    562568}
    563569
     570bool InjectedBundlePage::shouldLoadResourceForFrame(WKBundleFrameRef frame)
     571{
     572    return true;
     573}
     574
    564575// UI Client Callbacks
    565576
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h

    r73412 r75174  
    6565    static void didDisplayInsecureContentForFrame(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void*);
    6666    static void didRunInsecureContentForFrame(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void*);
     67    static bool shouldLoadResourceForFrame(WKBundlePageRef, WKBundleFrameRef, WKURLRef, const void*);
    6768    void didStartProvisionalLoadForFrame(WKBundleFrameRef);
    6869    void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundleFrameRef);
     
    8081    void didDisplayInsecureContentForFrame(WKBundleFrameRef);
    8182    void didRunInsecureContentForFrame(WKBundleFrameRef);
     83    bool shouldLoadResourceForFrame(WKBundleFrameRef);
    8284
    8385    // UI Client
  • trunk/WebKit2/ChangeLog

    r75171 r75174  
     12011-01-05  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Ada Chan.
     4
     5        WebKit2: Should be able to call into injected bundle to ask if we should allow resource loads
     6        https://bugs.webkit.org/show_bug.cgi?id=51969
     7       
     8        Add the ability to call into the injected bundle to ask if we should allow resource loads.
     9        If the injected bundle says we should cancel, we clear out the ResourceRequest that was
     10        passed into willSendRequest, which cancels the resource load.
     11
     12        * WebProcess/InjectedBundle/API/c/WKBundlePage.h: Add the new callback for allowing/cancelling
     13            resource loads.
     14        * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
     15        (WebKit::InjectedBundlePageLoaderClient::shouldLoadResourceForFrame): Calls through to the client.
     16        * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:
     17        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     18        (WebKit::WebFrameLoaderClient::dispatchWillSendRequest): Ask the InjectedBundlePageLoaderClient if we
     19            should load the resource or not.
     20
    1212011-01-06  Jeff Miller  <jeffm@apple.com>
    222
  • trunk/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h

    r74698 r75174  
    8888typedef void (*WKBundlePageWillPerformClientRedirectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKURLRef url, double delay, double date, const void *clientInfo);
    8989typedef void (*WKBundlePageDidHandleOnloadEventsForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
     90typedef bool (*WKBundlePageShouldLoadResourceForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKURLRef url, const void *clientInfo);
    9091
    9192
     
    113114    WKBundlePageWillPerformClientRedirectForFrameCallback               willPerformClientRedirectForFrame;
    114115    WKBundlePageDidHandleOnloadEventsForFrameCallback                   didHandleOnloadEventsForFrame;
     116    WKBundlePageShouldLoadResourceForFrameCallback                      shouldLoadResourceForFrame;
    115117};
    116118typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient;
  • trunk/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp

    r73412 r75174  
    176176}
    177177
     178bool InjectedBundlePageLoaderClient::shouldLoadResourceForFrame(WebPage* page, WebFrame* frame, const String& subResourceURL)
     179{
     180    if (!m_client.shouldLoadResourceForFrame)
     181        return true;
     182
     183    return m_client.shouldLoadResourceForFrame(toAPI(page), toAPI(frame), toURLRef(subResourceURL.impl()), m_client.clientInfo);
     184}
     185
    178186void InjectedBundlePageLoaderClient::didClearWindowObjectForFrame(WebPage* page, WebFrame* frame, DOMWrapperWorld* world)
    179187{
  • trunk/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h

    r73412 r75174  
    6161    void didRunInsecureContentForFrame(WebPage*, WebFrame*, RefPtr<APIObject>& userData);
    6262
     63    bool shouldLoadResourceForFrame(WebPage*, WebFrame*, const String&);
     64
    6365    void didClearWindowObjectForFrame(WebPage*, WebFrame*, WebCore::DOMWrapperWorld*);
    6466    void didCancelClientRedirectForFrame(WebPage*, WebFrame*);
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r75031 r75174  
    157157        return;
    158158
     159    if (!webPage->injectedBundleLoaderClient().shouldLoadResourceForFrame(webPage, m_frame, request.url().string())) {
     160        request = ResourceRequest();
     161        // FIXME: We should probably send a message saying we cancelled the request for the resource.
     162        return;
     163    }
     164
    159165    webPage->send(Messages::WebPageProxy::DidSendRequestForResource(m_frame->frameID(), identifier, request, redirectResponse));
    160166}
Note: See TracChangeset for help on using the changeset viewer.