Changeset 167611 in webkit


Ignore:
Timestamp:
Apr 21, 2014 12:51:01 PM (10 years ago)
Author:
andersca@apple.com
Message:

Need default WKNavigationDelegate behavior
https://bugs.webkit.org/show_bug.cgi?id=131944
<rdar://problem/15949822>

Reviewed by Dan Bernstein.

Port the WebKit1 default delegate behavior over.

  • UIProcess/Cocoa/NavigationState.mm:

(WebKit::NavigationState::PolicyClient::decidePolicyForNavigationAction):
(WebKit::NavigationState::PolicyClient::decidePolicyForResponse):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r167610 r167611  
     12014-04-21  Anders Carlsson  <andersca@apple.com>
     2
     3        Need default WKNavigationDelegate behavior
     4        https://bugs.webkit.org/show_bug.cgi?id=131944
     5        <rdar://problem/15949822>
     6
     7        Reviewed by Dan Bernstein.
     8
     9        Port the WebKit1 default delegate behavior over.
     10
     11        * UIProcess/Cocoa/NavigationState.mm:
     12        (WebKit::NavigationState::PolicyClient::decidePolicyForNavigationAction):
     13        (WebKit::NavigationState::PolicyClient::decidePolicyForResponse):
     14
    1152014-04-21  Dan Bernstein  <mitz@apple.com>
    216
  • trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm

    r167572 r167611  
    211211{
    212212    if (!m_navigationState.m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionDecisionHandler) {
    213         // FIXME: <rdar://problem/15949822> Figure out what the "default delegate behavior" should be here.
    214         listener->use();
     213        if (!destinationFrame) {
     214            listener->use();
     215            return;
     216        }
     217
     218        NSURLRequest *nsURLRequest = request.nsURLRequest(WebCore::DoNotUpdateHTTPBody);
     219        if ([NSURLConnection canHandleRequest:nsURLRequest]) {
     220            listener->use();
     221            return;
     222        }
     223
     224#if PLATFORM(MAC)
     225        // A file URL shouldn't fall through to here, but if it did,
     226        // it would be a security risk to open it.
     227        if (![nsURLRequest.URL isFileURL])
     228            [[NSWorkspace sharedWorkspace] openURL:nsURLRequest.URL];
     229#endif
     230        listener->ignore();
    215231        return;
    216232    }
     
    267283{
    268284    if (!m_navigationState.m_navigationDelegateMethods.webViewDecidePolicyForNavigationResponseDecisionHandler) {
    269         // FIXME: <rdar://problem/15949822> Figure out what the "default delegate behavior" should be here.
    270         listener->use();
     285        NSURL *url = resourceResponse.nsURLResponse().URL;
     286        if ([url isFileURL]) {
     287            BOOL isDirectory = NO;
     288            BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:url.path isDirectory:&isDirectory];
     289
     290            if (exists && !isDirectory && canShowMIMEType)
     291                listener->use();
     292            else
     293                listener->ignore();
     294            return;
     295        }
     296
     297        if (canShowMIMEType)
     298            listener->use();
     299        else
     300            listener->ignore();
    271301        return;
    272302    }
     
    276306        return;
    277307
    278     // FIXME: Set up the navigation response object.
    279308    auto navigationResponse = adoptNS([[WKNavigationResponse alloc] init]);
    280309
Note: See TracChangeset for help on using the changeset viewer.