AuthenticationChallengeProxy.cpp [plain text]
#include "config.h"
#include "AuthenticationChallengeProxy.h"
#include "AuthenticationDecisionListener.h"
#include "AuthenticationManagerMessages.h"
#include "ChildProcessProxy.h"
#include "WebCertificateInfo.h"
#include "WebCoreArgumentCoders.h"
#include "WebCredential.h"
#include "WebProcessProxy.h"
#include "WebProtectionSpace.h"
namespace WebKit {
AuthenticationChallengeProxy::AuthenticationChallengeProxy(const WebCore::AuthenticationChallenge& authenticationChallenge, uint64_t challengeID, CoreIPC::Connection* connection)
: m_coreAuthenticationChallenge(authenticationChallenge)
, m_challengeID(challengeID)
, m_connection(connection)
{
ASSERT(m_challengeID);
m_listener = AuthenticationDecisionListener::create(this);
}
AuthenticationChallengeProxy::~AuthenticationChallengeProxy()
{
if (m_challengeID)
m_connection->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);
if (m_listener)
m_listener->detachChallenge();
}
void AuthenticationChallengeProxy::useCredential(WebCredential* credential)
{
if (!m_challengeID)
return;
if (!credential)
m_connection->send(Messages::AuthenticationManager::ContinueWithoutCredentialForChallenge(m_challengeID), 0);
else {
WebCertificateInfo* certificateInfo = credential->certificateInfo();
PlatformCertificateInfo platformInfo = certificateInfo ? certificateInfo->platformCertificateInfo() : PlatformCertificateInfo();
m_connection->send(Messages::AuthenticationManager::UseCredentialForChallenge(m_challengeID, credential->core(), platformInfo), 0);
}
m_challengeID = 0;
}
void AuthenticationChallengeProxy::cancel()
{
if (!m_challengeID)
return;
m_connection->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);
m_challengeID = 0;
}
WebCredential* AuthenticationChallengeProxy::proposedCredential() const
{
if (!m_webCredential)
m_webCredential = WebCredential::create(m_coreAuthenticationChallenge.proposedCredential());
return m_webCredential.get();
}
WebProtectionSpace* AuthenticationChallengeProxy::protectionSpace() const
{
if (!m_webProtectionSpace)
m_webProtectionSpace = WebProtectionSpace::create(m_coreAuthenticationChallenge.protectionSpace());
return m_webProtectionSpace.get();
}
}