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/CompletionHandler.h>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/WeakPtr.h>
namespace IPC {
class MessageSender;
}
namespace WebCore {
class AuthenticationChallenge;
class Credential;
}
namespace WebKit {
class ChildProcess;
class Download;
class DownloadID;
class WebFrame;
enum class AuthenticationChallengeDisposition {
UseCredential,
PerformDefaultHandling,
Cancel,
RejectProtectionSpace
};
using ChallengeCompletionHandler = CompletionHandler<void(AuthenticationChallengeDisposition, const WebCore::Credential&)>;
class AuthenticationManager : public NetworkProcessSupplement, public IPC::MessageReceiver, public CanMakeWeakPtr<AuthenticationManager> {
WTF_MAKE_NONCOPYABLE(AuthenticationManager);
public:
explicit AuthenticationManager(ChildProcess&);
static const char* supplementName();
void didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
void didReceiveAuthenticationChallenge(IPC::MessageSender& download, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
void continueCanAuthenticateAgainstProtectionSpace(DownloadID, bool canAuthenticate);
#endif
void useCredentialForChallenge(uint64_t challengeID, const WebCore::Credential&);
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(); }
private:
struct Challenge {
uint64_t pageID;
WebCore::AuthenticationChallenge challenge;
ChallengeCompletionHandler completionHandler;
};
#if HAVE(SEC_KEY_PROXY)
void initializeConnection(IPC::Connection*) final;
#endif
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
uint64_t addChallengeToChallengeMap(Challenge&&);
bool shouldCoalesceChallenge(uint64_t pageID, uint64_t challengeID, const WebCore::AuthenticationChallenge&) const;
void useCredentialForSingleChallenge(uint64_t challengeID, const WebCore::Credential&);
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