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, IPC::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;
uint64_t challengeID = m_challengeID;
m_challengeID = 0;
if (!credential) {
m_connection->send(Messages::AuthenticationManager::ContinueWithoutCredentialForChallenge(challengeID), 0);
return;
}
WebCore::CertificateInfo certificateInfo;
if (credential->certificateInfo())
certificateInfo = credential->certificateInfo()->certificateInfo();
m_connection->send(Messages::AuthenticationManager::UseCredentialForChallenge(challengeID, credential->credential(), certificateInfo), 0);
}
void AuthenticationChallengeProxy::cancel()
{
if (!m_challengeID)
return;
m_connection->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);
m_challengeID = 0;
}
void AuthenticationChallengeProxy::performDefaultHandling()
{
if (!m_challengeID)
return;
m_connection->send(Messages::AuthenticationManager::PerformDefaultHandling(m_challengeID), 0);
m_challengeID = 0;
}
void AuthenticationChallengeProxy::rejectProtectionSpaceAndContinue()
{
if (!m_challengeID)
return;
m_connection->send(Messages::AuthenticationManager::RejectProtectionSpaceAndContinue(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();
}
}