Changeset 196453 in webkit


Ignore:
Timestamp:
Feb 11, 2016 4:02:03 PM (8 years ago)
Author:
achristensen@apple.com
Message:

Move Download authentication code to AuthenticationManager
https://bugs.webkit.org/show_bug.cgi?id=154132

Reviewed by Sam Weinig.

When a video element makes a request that receives an authentication challenge, the
AuthenticationManager receives an AuthenticationChallenge without an AuthenticationClient.
As a result, Download::receivedCredential and other functions were being called, which
sent a message to the challenge's sender. This functionality is not specific to downloads,
so I moved it from Download to AuthenticationManager.

This fixes http/tests/media/video-auth.html when using NetworkSession
because I use AuthenticationManager::receivedCredential if there is no AuthenticationClient
instead of improperly asserting that there is always an AuthenticationClient if there is no
completionHandler.

  • NetworkProcess/Downloads/Download.h:
  • NetworkProcess/Downloads/ios/DownloadIOS.mm:

(WebKit::Download::platformDidFinish):
(WebKit::Download::receivedCredential): Deleted.
(WebKit::Download::receivedRequestToContinueWithoutCredential): Deleted.
(WebKit::Download::receivedCancellation): Deleted.
(WebKit::Download::receivedRequestToPerformDefaultHandling): Deleted.
(WebKit::Download::receivedChallengeRejection): Deleted.

  • NetworkProcess/Downloads/mac/DownloadMac.mm:

(WebKit::Download::platformDidFinish):
(WebKit::Download::receivedCredential): Deleted.
(WebKit::Download::receivedRequestToContinueWithoutCredential): Deleted.
(WebKit::Download::receivedCancellation): Deleted.
(WebKit::Download::receivedRequestToPerformDefaultHandling): Deleted.
(WebKit::Download::receivedChallengeRejection): Deleted.

  • NetworkProcess/Downloads/soup/DownloadSoup.cpp:

(WebKit::Download::platformDidFinish):
(WebKit::Download::receivedCredential): Deleted.
(WebKit::Download::receivedRequestToContinueWithoutCredential): Deleted.
(WebKit::Download::receivedCancellation): Deleted.
(WebKit::Download::continueWithoutCredential): Deleted.
(WebKit::Download::useCredential): Deleted.
(WebKit::Download::cancelAuthenticationChallenge): Deleted.
(WebKit::Download::receivedRequestToPerformDefaultHandling): Deleted.
(WebKit::Download::receivedChallengeRejection): Deleted.

  • PlatformEfl.cmake:
  • PlatformGTK.cmake:
  • PlatformMac.cmake:
  • Shared/Authentication/AuthenticationManager.cpp:

(WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):
(WebKit::AuthenticationManager::useCredentialForSingleChallenge):
(WebKit::AuthenticationManager::continueWithoutCredentialForChallenge):
(WebKit::AuthenticationManager::continueWithoutCredentialForSingleChallenge):
(WebKit::AuthenticationManager::cancelChallenge):
(WebKit::AuthenticationManager::cancelSingleChallenge):
(WebKit::AuthenticationManager::performDefaultHandling):
(WebKit::AuthenticationManager::performDefaultHandlingForSingleChallenge):
(WebKit::AuthenticationManager::rejectProtectionSpaceAndContinue):
(WebKit::AuthenticationManager::rejectProtectionSpaceAndContinueForSingleChallenge):

  • Shared/Authentication/AuthenticationManager.h:

(WebKit::AuthenticationManager::outstandingAuthenticationChallengeCount):

  • Shared/Authentication/cocoa: Added.
  • Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm: Added.

(WebKit::AuthenticationManager::receivedCredential):
(WebKit::AuthenticationManager::receivedRequestToContinueWithoutCredential):
(WebKit::AuthenticationManager::receivedCancellation):
(WebKit::AuthenticationManager::receivedRequestToPerformDefaultHandling):
(WebKit::AuthenticationManager::receivedChallengeRejection):

  • Shared/Authentication/soup: Added.
  • Shared/Authentication/soup/AuthenticationManagerSoup.cpp: Added.

(WebKit::AuthenticationManager::receivedCredential):
(WebKit::AuthenticationManager::receivedRequestToContinueWithoutCredential):
(WebKit::AuthenticationManager::receivedCancellation):
(WebKit::AuthenticationManager::receivedRequestToPerformDefaultHandling):
(WebKit::AuthenticationManager::receivedChallengeRejection):

  • WebKit2.xcodeproj/project.pbxproj:
Location:
trunk/Source/WebKit2
Files:
4 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r196452 r196453  
     12016-02-11  Alex Christensen  <achristensen@webkit.org>
     2
     3        Move Download authentication code to AuthenticationManager
     4        https://bugs.webkit.org/show_bug.cgi?id=154132
     5
     6        Reviewed by Sam Weinig.
     7
     8        When a video element makes a request that receives an authentication challenge, the
     9        AuthenticationManager receives an AuthenticationChallenge without an AuthenticationClient.
     10        As a result, Download::receivedCredential and other functions were being called, which
     11        sent a message to the challenge's sender.  This functionality is not specific to downloads,
     12        so I moved it from Download to AuthenticationManager.
     13
     14        This fixes http/tests/media/video-auth.html when using NetworkSession
     15        because I use AuthenticationManager::receivedCredential if there is no AuthenticationClient
     16        instead of improperly asserting that there is always an AuthenticationClient if there is no
     17        completionHandler.
     18
     19        * NetworkProcess/Downloads/Download.h:
     20        * NetworkProcess/Downloads/ios/DownloadIOS.mm:
     21        (WebKit::Download::platformDidFinish):
     22        (WebKit::Download::receivedCredential): Deleted.
     23        (WebKit::Download::receivedRequestToContinueWithoutCredential): Deleted.
     24        (WebKit::Download::receivedCancellation): Deleted.
     25        (WebKit::Download::receivedRequestToPerformDefaultHandling): Deleted.
     26        (WebKit::Download::receivedChallengeRejection): Deleted.
     27        * NetworkProcess/Downloads/mac/DownloadMac.mm:
     28        (WebKit::Download::platformDidFinish):
     29        (WebKit::Download::receivedCredential): Deleted.
     30        (WebKit::Download::receivedRequestToContinueWithoutCredential): Deleted.
     31        (WebKit::Download::receivedCancellation): Deleted.
     32        (WebKit::Download::receivedRequestToPerformDefaultHandling): Deleted.
     33        (WebKit::Download::receivedChallengeRejection): Deleted.
     34        * NetworkProcess/Downloads/soup/DownloadSoup.cpp:
     35        (WebKit::Download::platformDidFinish):
     36        (WebKit::Download::receivedCredential): Deleted.
     37        (WebKit::Download::receivedRequestToContinueWithoutCredential): Deleted.
     38        (WebKit::Download::receivedCancellation): Deleted.
     39        (WebKit::Download::continueWithoutCredential): Deleted.
     40        (WebKit::Download::useCredential): Deleted.
     41        (WebKit::Download::cancelAuthenticationChallenge): Deleted.
     42        (WebKit::Download::receivedRequestToPerformDefaultHandling): Deleted.
     43        (WebKit::Download::receivedChallengeRejection): Deleted.
     44        * PlatformEfl.cmake:
     45        * PlatformGTK.cmake:
     46        * PlatformMac.cmake:
     47        * Shared/Authentication/AuthenticationManager.cpp:
     48        (WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):
     49        (WebKit::AuthenticationManager::useCredentialForSingleChallenge):
     50        (WebKit::AuthenticationManager::continueWithoutCredentialForChallenge):
     51        (WebKit::AuthenticationManager::continueWithoutCredentialForSingleChallenge):
     52        (WebKit::AuthenticationManager::cancelChallenge):
     53        (WebKit::AuthenticationManager::cancelSingleChallenge):
     54        (WebKit::AuthenticationManager::performDefaultHandling):
     55        (WebKit::AuthenticationManager::performDefaultHandlingForSingleChallenge):
     56        (WebKit::AuthenticationManager::rejectProtectionSpaceAndContinue):
     57        (WebKit::AuthenticationManager::rejectProtectionSpaceAndContinueForSingleChallenge):
     58        * Shared/Authentication/AuthenticationManager.h:
     59        (WebKit::AuthenticationManager::outstandingAuthenticationChallengeCount):
     60        * Shared/Authentication/cocoa: Added.
     61        * Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm: Added.
     62        (WebKit::AuthenticationManager::receivedCredential):
     63        (WebKit::AuthenticationManager::receivedRequestToContinueWithoutCredential):
     64        (WebKit::AuthenticationManager::receivedCancellation):
     65        (WebKit::AuthenticationManager::receivedRequestToPerformDefaultHandling):
     66        (WebKit::AuthenticationManager::receivedChallengeRejection):
     67        * Shared/Authentication/soup: Added.
     68        * Shared/Authentication/soup/AuthenticationManagerSoup.cpp: Added.
     69        (WebKit::AuthenticationManager::receivedCredential):
     70        (WebKit::AuthenticationManager::receivedRequestToContinueWithoutCredential):
     71        (WebKit::AuthenticationManager::receivedCancellation):
     72        (WebKit::AuthenticationManager::receivedRequestToPerformDefaultHandling):
     73        (WebKit::AuthenticationManager::receivedChallengeRejection):
     74        * WebKit2.xcodeproj/project.pbxproj:
     75
    1762016-02-11  Beth Dakin  <bdakin@apple.com>
    277
  • trunk/Source/WebKit2/NetworkProcess/Downloads/Download.h

    r194810 r196453  
    114114#endif
    115115
    116 #if !USE(NETWORK_SESSION)
    117     // Authentication
    118     static void receivedCredential(const WebCore::AuthenticationChallenge&, const WebCore::Credential&);
    119     static void receivedRequestToContinueWithoutCredential(const WebCore::AuthenticationChallenge&);
    120     static void receivedCancellation(const WebCore::AuthenticationChallenge&);
    121     static void receivedRequestToPerformDefaultHandling(const WebCore::AuthenticationChallenge&);
    122     static void receivedChallengeRejection(const WebCore::AuthenticationChallenge&);
    123 
    124     void useCredential(const WebCore::AuthenticationChallenge&, const WebCore::Credential&);
    125     void continueWithoutCredential(const WebCore::AuthenticationChallenge&);
    126     void cancelAuthenticationChallenge(const WebCore::AuthenticationChallenge&);
    127 #endif
    128 
    129116private:
    130117    // IPC::MessageSender
  • trunk/Source/WebKit2/NetworkProcess/Downloads/ios/DownloadIOS.mm

    r194472 r196453  
    158158}
    159159
    160 void Download::receivedCredential(const AuthenticationChallenge&, const Credential&)
    161 {
    162     notImplemented();
    163 }
    164 
    165 void Download::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&)
    166 {
    167     notImplemented();
    168 }
    169 
    170 void Download::receivedCancellation(const AuthenticationChallenge&)
    171 {
    172     notImplemented();
    173 }
    174 
    175 void Download::receivedRequestToPerformDefaultHandling(const WebCore::AuthenticationChallenge&)
    176 {
    177     notImplemented();
    178 }
    179 
    180 void Download::receivedChallengeRejection(const WebCore::AuthenticationChallenge&)
    181 {
    182     notImplemented();
    183 }
    184 
    185160} // namespace WebKit
    186161
  • trunk/Source/WebKit2/NetworkProcess/Downloads/mac/DownloadMac.mm

    r194472 r196453  
    132132}
    133133
    134 void Download::receivedCredential(const AuthenticationChallenge& authenticationChallenge, const Credential& credential)
    135 {
    136     [authenticationChallenge.sender() useCredential:credential.nsCredential() forAuthenticationChallenge:authenticationChallenge.nsURLAuthenticationChallenge()];
    137 }
    138 
    139 void Download::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& authenticationChallenge)
    140 {
    141     [authenticationChallenge.sender() continueWithoutCredentialForAuthenticationChallenge:authenticationChallenge.nsURLAuthenticationChallenge()];
    142 }
    143 
    144 void Download::receivedCancellation(const AuthenticationChallenge& authenticationChallenge)
    145 {
    146     [authenticationChallenge.sender() cancelAuthenticationChallenge:authenticationChallenge.nsURLAuthenticationChallenge()];
    147 }
    148 
    149 void Download::receivedRequestToPerformDefaultHandling(const AuthenticationChallenge& authenticationChallenge)
    150 {
    151     [authenticationChallenge.sender() performDefaultHandlingForAuthenticationChallenge:authenticationChallenge.nsURLAuthenticationChallenge()];
    152 }
    153 
    154 void Download::receivedChallengeRejection(const AuthenticationChallenge& authenticationChallenge)
    155 {
    156     [authenticationChallenge.sender() rejectProtectionSpaceAndContinueWithChallenge:authenticationChallenge.nsURLAuthenticationChallenge()];
    157 }
    158 
    159134} // namespace WebKit
    160135
  • trunk/Source/WebKit2/NetworkProcess/Downloads/soup/DownloadSoup.cpp

    r194419 r196453  
    270270}
    271271
    272 void Download::receivedCredential(const AuthenticationChallenge&, const Credential&)
    273 {
    274     notImplemented();
    275 }
    276 
    277 void Download::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&)
    278 {
    279     notImplemented();
    280 }
    281 
    282 void Download::receivedCancellation(const AuthenticationChallenge&)
    283 {
    284     notImplemented();
    285 }
    286 
    287 void Download::continueWithoutCredential(const AuthenticationChallenge &)
    288 {
    289     notImplemented();
    290 }
    291 
    292 void Download::useCredential(const AuthenticationChallenge&, const Credential&)
    293 {
    294     notImplemented();
    295 }
    296 
    297 void Download::cancelAuthenticationChallenge(const AuthenticationChallenge&)
    298 {
    299     notImplemented();
    300 }
    301 
    302 void Download::receivedRequestToPerformDefaultHandling(const AuthenticationChallenge&)
    303 {
    304     notImplemented();
    305 }
    306 
    307 void Download::receivedChallengeRejection(const AuthenticationChallenge&)
    308 {
    309     notImplemented();
    310 }
    311 
    312272} // namespace WebKit
  • trunk/Source/WebKit2/PlatformEfl.cmake

    r196053 r196453  
    2929
    3030    Shared/API/c/efl/WKArrayEfl.cpp
     31
     32    Shared/Authentication/soup/AuthenticationManagerSoup.cpp
    3133
    3234    Shared/CoordinatedGraphics/CoordinatedBackingStore.cpp
  • trunk/Source/WebKit2/PlatformGTK.cmake

    r196053 r196453  
    5757
    5858    Shared/API/c/cairo/WKImageCairo.cpp
     59
     60    Shared/Authentication/soup/AuthenticationManagerSoup.cpp
    5961
    6062    Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp
  • trunk/Source/WebKit2/PlatformMac.cmake

    r196064 r196453  
    5454    Shared/APIWebArchive.mm
    5555    Shared/APIWebArchiveResource.mm
     56
     57    Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm
    5658
    5759    Shared/API/Cocoa/RemoteObjectInvocation.mm
  • trunk/Source/WebKit2/Shared/Authentication/AuthenticationManager.cpp

    r194810 r196453  
    117117    uint64_t challengeID = addChallengeToChallengeMap({pageID, authenticationChallenge
    118118#if USE(NETWORK_SESSION)
    119         , ChallengeCompletionHandler()
     119        , { }
    120120#endif
    121121    });
     
    162162    uint64_t challengeID = addChallengeToChallengeMap({pageID, authenticationChallenge
    163163#if USE(NETWORK_SESSION)
    164         , ChallengeCompletionHandler()
     164        , { }
    165165#endif
    166166    });
     
    220220        return;
    221221    }
    222 #else
    223     if (!coreClient) {
    224         // FIXME: The authentication client is null for downloads, but it can also be null for canceled loads.
    225         // We should not call Download::receivedCredential in the latter case.
    226         Download::receivedCredential(challenge.challenge, credential);
    227         return;
    228     }
    229 #endif
    230 
    231     ASSERT(coreClient);
    232     coreClient->receivedCredential(challenge.challenge, credential);
     222#endif
     223
     224    if (coreClient)
     225        coreClient->receivedCredential(challenge.challenge, credential);
     226    else
     227        receivedCredential(challenge.challenge, credential);
    233228}
    234229
     
    253248        return;
    254249    }
    255 #else
    256     if (!coreClient) {
    257         // FIXME: The authentication client is null for downloads, but it can also be null for canceled loads.
    258         // We should not call Download::receivedCredential in the latter case.
    259         Download::receivedRequestToContinueWithoutCredential(challenge.challenge);
    260         return;
    261     }
    262 #endif
    263 
    264     ASSERT(coreClient);
    265     coreClient->receivedRequestToContinueWithoutCredential(challenge.challenge);
     250#endif
     251
     252    if (coreClient)
     253        coreClient->receivedRequestToContinueWithoutCredential(challenge.challenge);
     254    else
     255        receivedRequestToContinueWithoutCredential(challenge.challenge);
    266256}
    267257
     
    286276        return;
    287277    }
    288 #else
    289     if (!coreClient) {
    290         // FIXME: The authentication client is null for downloads, but it can also be null for canceled loads.
    291         // We should not call Download::receivedCredential in the latter case.
    292         Download::receivedCancellation(challenge.challenge);
    293         return;
    294     }
    295 #endif
    296 
    297     ASSERT(coreClient);
    298     coreClient->receivedCancellation(challenge.challenge);
     278#endif
     279
     280    if (coreClient)
     281        coreClient->receivedCancellation(challenge.challenge);
     282    else
     283        receivedCancellation(challenge.challenge);
    299284}
    300285
     
    319304        return;
    320305    }
    321 #else
    322     if (!coreClient) {
    323         // FIXME: The authentication client is null for downloads, but it can also be null for canceled loads.
    324         // We should not call Download::receivedCredential in the latter case.
    325         Download::receivedRequestToPerformDefaultHandling(challenge.challenge);
    326         return;
    327     }
    328 #endif
    329 
    330     ASSERT(coreClient);
    331     coreClient->receivedRequestToPerformDefaultHandling(challenge.challenge);
     306#endif
     307
     308    if (coreClient)
     309        coreClient->receivedRequestToPerformDefaultHandling(challenge.challenge);
     310    else
     311        receivedRequestToPerformDefaultHandling(challenge.challenge);
    332312}
    333313
     
    352332        return;
    353333    }
    354 #else
    355     if (!coreClient) {
    356         // FIXME: The authentication client is null for downloads, but it can also be null for canceled loads.
    357         // We should not call Download::receivedCredential in the latter case.
    358         Download::receivedChallengeRejection(challenge.challenge);
    359         return;
    360     }
    361 #endif
    362 
    363     ASSERT(coreClient);
    364     coreClient->receivedChallengeRejection(challenge.challenge);
     334#endif
     335
     336    if (coreClient)
     337        coreClient->receivedChallengeRejection(challenge.challenge);
     338    else
     339        receivedChallengeRejection(challenge.challenge);
    365340}
    366341
  • trunk/Source/WebKit2/Shared/Authentication/AuthenticationManager.h

    r195509 r196453  
    7777    uint64_t outstandingAuthenticationChallengeCount() const { return m_challenges.size(); }
    7878
     79    static void receivedCredential(const WebCore::AuthenticationChallenge&, const WebCore::Credential&);
     80    static void receivedRequestToContinueWithoutCredential(const WebCore::AuthenticationChallenge&);
     81    static void receivedCancellation(const WebCore::AuthenticationChallenge&);
     82    static void receivedRequestToPerformDefaultHandling(const WebCore::AuthenticationChallenge&);
     83    static void receivedChallengeRejection(const WebCore::AuthenticationChallenge&);
     84
    7985private:
    8086    struct Challenge {
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r196370 r196453  
    10401040                52D5A1B11C57496200DE34A3 /* WebVideoFullscreenManagerProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52D5A1AC1C57494E00DE34A3 /* WebVideoFullscreenManagerProxy.mm */; };
    10411041                52D5A1B71C574A0200DE34A3 /* WebVideoFullscreenManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52D5A1B41C5749F200DE34A3 /* WebVideoFullscreenManager.mm */; };
     1042                5C052F261C6D3BD30076E919 /* AuthenticationManagerCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C052F241C6D3AB60076E919 /* AuthenticationManagerCocoa.mm */; };
    10421043                5C1426EC1C23F80900D41183 /* NetworkProcessCreationParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C1426E21C23F80500D41183 /* NetworkProcessCreationParameters.cpp */; };
    10431044                5C1426ED1C23F80900D41183 /* NetworkProcessCreationParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1426E31C23F80500D41183 /* NetworkProcessCreationParameters.h */; };
     
    31313132                52D5A1B31C5749F200DE34A3 /* WebVideoFullscreenManager.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebVideoFullscreenManager.messages.in; sourceTree = "<group>"; };
    31323133                52D5A1B41C5749F200DE34A3 /* WebVideoFullscreenManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebVideoFullscreenManager.mm; sourceTree = "<group>"; };
     3134                5C052F241C6D3AB60076E919 /* AuthenticationManagerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AuthenticationManagerCocoa.mm; path = Authentication/cocoa/AuthenticationManagerCocoa.mm; sourceTree = "<group>"; };
    31333135                5C1426E21C23F80500D41183 /* NetworkProcessCreationParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkProcessCreationParameters.cpp; path = NetworkProcess/NetworkProcessCreationParameters.cpp; sourceTree = "<group>"; };
    31343136                5C1426E31C23F80500D41183 /* NetworkProcessCreationParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkProcessCreationParameters.h; path = NetworkProcess/NetworkProcessCreationParameters.h; sourceTree = "<group>"; };
     
    55325534                        isa = PBXGroup;
    55335535                        children = (
     5536                                5C052F231C6D3AA10076E919 /* cocoa */,
    55345537                                518E8EF616B2091C00E91429 /* mac */,
    55355538                                518E8EF316B2091C00E91429 /* AuthenticationManager.cpp */,
     
    56485651                        );
    56495652                        name = IconDatabase;
     5653                        sourceTree = "<group>";
     5654                };
     5655                5C052F231C6D3AA10076E919 /* cocoa */ = {
     5656                        isa = PBXGroup;
     5657                        children = (
     5658                                5C052F241C6D3AB60076E919 /* AuthenticationManagerCocoa.mm */,
     5659                        );
     5660                        name = cocoa;
    56505661                        sourceTree = "<group>";
    56515662                };
     
    92419252                                BCCF673312C7F15C008F9C35 /* OriginAndDatabases.cpp in Sources */,
    92429253                                7C387434172F5615001BD88A /* PageBanner.cpp in Sources */,
     9254                                5C052F261C6D3BD30076E919 /* AuthenticationManagerCocoa.mm in Sources */,
    92439255                                7C6D37FC172F555F009D2847 /* PageBannerMac.mm in Sources */,
    92449256                                0FCB4E6318BBE3D9000FCFC9 /* PageClientImpl.mm in Sources */,
Note: See TracChangeset for help on using the changeset viewer.