AuthenticationManager.h [plain text]
#ifndef AuthenticationManager_h
#define AuthenticationManager_h
#include "MessageReceiver.h"
#include "NetworkProcessSupplement.h"
#include "WebProcessSupplement.h"
#include <WebCore/AuthenticationChallenge.h>
#include <wtf/Forward.h>
#include <wtf/Function.h>
#include <wtf/HashMap.h>
namespace WebCore {
class AuthenticationChallenge;
class CertificateInfo;
class Credential;
}
namespace WebKit {
class ChildProcess;
class Download;
class DownloadID;
class PendingDownload;
class WebFrame;
enum class AuthenticationChallengeDisposition {
UseCredential,
PerformDefaultHandling,
Cancel,
RejectProtectionSpace
};
typedef Function<void(AuthenticationChallengeDisposition, const WebCore::Credential&)> ChallengeCompletionHandler;
class AuthenticationManager : public WebProcessSupplement, public NetworkProcessSupplement, public IPC::MessageReceiver {
WTF_MAKE_NONCOPYABLE(AuthenticationManager);
public:
explicit AuthenticationManager(ChildProcess*);
static const char* supplementName();
#if USE(NETWORK_SESSION)
void didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
void didReceiveAuthenticationChallenge(PendingDownload&, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
void continueCanAuthenticateAgainstProtectionSpace(DownloadID, bool canAuthenticate);
#endif
#endif
void didReceiveAuthenticationChallenge(WebFrame*, const WebCore::AuthenticationChallenge&);
void didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const WebCore::AuthenticationChallenge&);
#if !USE(NETWORK_SESSION)
void didReceiveAuthenticationChallenge(Download&, const WebCore::AuthenticationChallenge&);
#endif
void useCredentialForChallenge(uint64_t challengeID, const WebCore::Credential&, const WebCore::CertificateInfo&);
void continueWithoutCredentialForChallenge(uint64_t challengeID);
void cancelChallenge(uint64_t challengeID);
void performDefaultHandling(uint64_t challengeID);
void rejectProtectionSpaceAndContinue(uint64_t challengeID);
uint64_t outstandingAuthenticationChallengeCount() const { return m_challenges.size(); }
static void receivedCredential(const WebCore::AuthenticationChallenge&, const WebCore::Credential&);
static void receivedRequestToContinueWithoutCredential(const WebCore::AuthenticationChallenge&);
static void receivedCancellation(const WebCore::AuthenticationChallenge&);
static void receivedRequestToPerformDefaultHandling(const WebCore::AuthenticationChallenge&);
static void receivedChallengeRejection(const WebCore::AuthenticationChallenge&);
private:
struct Challenge {
uint64_t pageID;
WebCore::AuthenticationChallenge challenge;
#if USE(NETWORK_SESSION)
ChallengeCompletionHandler completionHandler;
#endif
};
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
bool tryUseCertificateInfoForChallenge(const WebCore::AuthenticationChallenge&, const WebCore::CertificateInfo&, const ChallengeCompletionHandler&);
uint64_t addChallengeToChallengeMap(Challenge&&);
bool shouldCoalesceChallenge(uint64_t pageID, uint64_t challengeID, const WebCore::AuthenticationChallenge&) const;
void useCredentialForSingleChallenge(uint64_t challengeID, const WebCore::Credential&, const WebCore::CertificateInfo&);
void continueWithoutCredentialForSingleChallenge(uint64_t challengeID);
void cancelSingleChallenge(uint64_t challengeID);
void performDefaultHandlingForSingleChallenge(uint64_t challengeID);
void rejectProtectionSpaceAndContinueForSingleChallenge(uint64_t challengeID);
Vector<uint64_t> coalesceChallengesMatching(uint64_t challengeID) const;
ChildProcess* m_process;
HashMap<uint64_t, Challenge> m_challenges;
};
}
#endif // AuthenticationManager_h