Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Authentication manager cleanup
https://bugs.webkit.org/show_bug.cgi?id=105144

Reviewed by Sam Weinig.

Some cleanup to make it possible to reuse the authentication manager from the network process.

* UIProcess/Authentication/AuthenticationChallengeProxy.cpp:
(WebKit::AuthenticationChallengeProxy::AuthenticationChallengeProxy):
(WebKit::AuthenticationChallengeProxy::~AuthenticationChallengeProxy):
(WebKit::AuthenticationChallengeProxy::useCredential):
(WebKit::AuthenticationChallengeProxy::cancel):
* UIProcess/Authentication/AuthenticationChallengeProxy.h:
(WebKit::AuthenticationChallengeProxy::create):
(AuthenticationChallengeProxy):
* UIProcess/Downloads/DownloadProxy.cpp:
(WebKit::DownloadProxy::didReceiveAuthenticationChallenge):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didReceiveAuthenticationChallenge):
* WebProcess/Authentication/AuthenticationManager.cpp:
(WebKit::AuthenticationManager::AuthenticationManager):
(WebKit::AuthenticationManager::setConnection):
(WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):
(WebKit::AuthenticationManager::useCredentialForChallenge):
* WebProcess/Authentication/AuthenticationManager.h:
* WebProcess/Downloads/Download.cpp:
(WebKit::Download::didReceiveAuthenticationChallenge):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):
(WebKit::WebProcess::initialize):
* WebProcess/WebProcess.h:
(WebKit::WebProcess::authenticationManager):
(WebProcess):

Canonical link: https://commits.webkit.org/123375@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@137862 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Dec 17, 2012
1 parent 843392d commit cd1b994
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 31 deletions.
38 changes: 38 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,41 @@
2012-12-16 Anders Carlsson <andersca@apple.com>

Authentication manager cleanup
https://bugs.webkit.org/show_bug.cgi?id=105144

Reviewed by Sam Weinig.

Some cleanup to make it possible to reuse the authentication manager from the network process.

* UIProcess/Authentication/AuthenticationChallengeProxy.cpp:
(WebKit::AuthenticationChallengeProxy::AuthenticationChallengeProxy):
(WebKit::AuthenticationChallengeProxy::~AuthenticationChallengeProxy):
(WebKit::AuthenticationChallengeProxy::useCredential):
(WebKit::AuthenticationChallengeProxy::cancel):
* UIProcess/Authentication/AuthenticationChallengeProxy.h:
(WebKit::AuthenticationChallengeProxy::create):
(AuthenticationChallengeProxy):
* UIProcess/Downloads/DownloadProxy.cpp:
(WebKit::DownloadProxy::didReceiveAuthenticationChallenge):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didReceiveAuthenticationChallenge):
* WebProcess/Authentication/AuthenticationManager.cpp:
(WebKit::AuthenticationManager::AuthenticationManager):
(WebKit::AuthenticationManager::setConnection):
(WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):
(WebKit::AuthenticationManager::useCredentialForChallenge):
* WebProcess/Authentication/AuthenticationManager.h:
* WebProcess/Downloads/Download.cpp:
(WebKit::Download::didReceiveAuthenticationChallenge):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):
(WebKit::WebProcess::initialize):
* WebProcess/WebProcess.h:
(WebKit::WebProcess::authenticationManager):
(WebProcess):

2012-12-16 Anders Carlsson <andersca@apple.com>

Rudimentary support for main resource downloads
Expand Down
Expand Up @@ -28,19 +28,19 @@

#include "AuthenticationDecisionListener.h"
#include "AuthenticationManagerMessages.h"
#include "ChildProcessProxy.h"
#include "WebCertificateInfo.h"
#include "WebCoreArgumentCoders.h"
#include "WebCredential.h"
#include "WebPageProxy.h"
#include "WebProcessProxy.h"
#include "WebProtectionSpace.h"

namespace WebKit {

AuthenticationChallengeProxy::AuthenticationChallengeProxy(const WebCore::AuthenticationChallenge& authenticationChallenge, uint64_t challengeID, WebProcessProxy* process)
AuthenticationChallengeProxy::AuthenticationChallengeProxy(const WebCore::AuthenticationChallenge& authenticationChallenge, uint64_t challengeID, CoreIPC::Connection* connection)
: m_coreAuthenticationChallenge(authenticationChallenge)
, m_challengeID(challengeID)
, m_process(process)
, m_connection(connection)
{
ASSERT(m_challengeID);
m_listener = AuthenticationDecisionListener::create(this);
Expand All @@ -49,9 +49,9 @@ AuthenticationChallengeProxy::AuthenticationChallengeProxy(const WebCore::Authen
AuthenticationChallengeProxy::~AuthenticationChallengeProxy()
{
// If an outstanding AuthenticationChallengeProxy is being destroyed even though it hasn't been responded to yet,
// we cancel it here so the WebProcess isn't waiting for an answer forever.
// we cancel it here so the process isn't waiting for an answer forever.
if (m_challengeID)
m_process->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);
m_connection->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);

if (m_listener)
m_listener->detachChallenge();
Expand All @@ -63,11 +63,11 @@ void AuthenticationChallengeProxy::useCredential(WebCredential* credential)
return;

if (!credential)
m_process->send(Messages::AuthenticationManager::ContinueWithoutCredentialForChallenge(m_challengeID), 0);
m_connection->send(Messages::AuthenticationManager::ContinueWithoutCredentialForChallenge(m_challengeID), 0);
else {
WebCertificateInfo* certificateInfo = credential->certificateInfo();
PlatformCertificateInfo platformInfo = certificateInfo ? certificateInfo->platformCertificateInfo() : PlatformCertificateInfo();
m_process->send(Messages::AuthenticationManager::UseCredentialForChallenge(m_challengeID, credential->core(), platformInfo), 0);
m_connection->send(Messages::AuthenticationManager::UseCredentialForChallenge(m_challengeID, credential->core(), platformInfo), 0);
}

m_challengeID = 0;
Expand All @@ -78,7 +78,7 @@ void AuthenticationChallengeProxy::cancel()
if (!m_challengeID)
return;

m_process->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);
m_connection->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);

m_challengeID = 0;
}
Expand Down
Expand Up @@ -39,17 +39,17 @@ namespace CoreIPC {
namespace WebKit {

class AuthenticationDecisionListener;
class ChildProcessProxy;
class WebCredential;
class WebProcessProxy;
class WebProtectionSpace;

class AuthenticationChallengeProxy : public APIObject {
public:
static const Type APIType = TypeAuthenticationChallenge;

static PassRefPtr<AuthenticationChallengeProxy> create(const WebCore::AuthenticationChallenge& authenticationChallenge, uint64_t challengeID, WebProcessProxy* process)
static PassRefPtr<AuthenticationChallengeProxy> create(const WebCore::AuthenticationChallenge& authenticationChallenge, uint64_t challengeID, CoreIPC::Connection* connection)
{
return adoptRef(new AuthenticationChallengeProxy(authenticationChallenge, challengeID, process));
return adoptRef(new AuthenticationChallengeProxy(authenticationChallenge, challengeID, connection));
}

~AuthenticationChallengeProxy();
Expand All @@ -64,13 +64,13 @@ class AuthenticationChallengeProxy : public APIObject {
const WebCore::AuthenticationChallenge& core() { return m_coreAuthenticationChallenge; }

private:
AuthenticationChallengeProxy(const WebCore::AuthenticationChallenge&, uint64_t challengeID, WebProcessProxy*);
AuthenticationChallengeProxy(const WebCore::AuthenticationChallenge&, uint64_t challengeID, CoreIPC::Connection*);

virtual Type type() const { return APIType; }

WebCore::AuthenticationChallenge m_coreAuthenticationChallenge;
uint64_t m_challengeID;
RefPtr<WebProcessProxy> m_process;
RefPtr<CoreIPC::Connection> m_connection;
RefPtr<AuthenticationDecisionListener> m_listener;
mutable RefPtr<WebCredential> m_webCredential;
mutable RefPtr<WebProtectionSpace> m_webProtectionSpace;
Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp
Expand Up @@ -124,7 +124,8 @@ void DownloadProxy::didReceiveAuthenticationChallenge(const AuthenticationChalle

// FIXME (Multi-WebProcess): <rdar://problem/12239483> Downloads shouldn't be handled in the web process.
// Once this is fixed, remove WebContext::deprecatedSharedProcess().
RefPtr<AuthenticationChallengeProxy> authenticationChallengeProxy = AuthenticationChallengeProxy::create(authenticationChallenge, challengeID, m_webContext->deprecatedSharedProcess());

RefPtr<AuthenticationChallengeProxy> authenticationChallengeProxy = AuthenticationChallengeProxy::create(authenticationChallenge, challengeID, m_webContext->deprecatedSharedProcess()->connection());
m_webContext->downloadClient().didReceiveAuthenticationChallenge(m_webContext.get(), this, authenticationChallengeProxy.get());
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit2/UIProcess/WebPageProxy.cpp
Expand Up @@ -3840,7 +3840,7 @@ void WebPageProxy::didReceiveAuthenticationChallenge(uint64_t frameID, const Aut
WebFrameProxy* frame = m_process->webFrame(frameID);
MESSAGE_CHECK(frame);

RefPtr<AuthenticationChallengeProxy> authenticationChallenge = AuthenticationChallengeProxy::create(coreChallenge, challengeID, m_process.get());
RefPtr<AuthenticationChallengeProxy> authenticationChallenge = AuthenticationChallengeProxy::create(coreChallenge, challengeID, m_process->connection());

m_loaderClient.didReceiveAuthenticationChallengeInFrame(this, frame, authenticationChallenge.get());
}
Expand Down
Expand Up @@ -30,11 +30,11 @@
#include "Download.h"
#include "DownloadProxyMessages.h"
#include "MessageID.h"
#include "MessageReceiverMap.h"
#include "WebCoreArgumentCoders.h"
#include "WebFrame.h"
#include "WebPage.h"
#include "WebPageProxyMessages.h"
#include "WebProcess.h"
#include <WebCore/AuthenticationChallenge.h>
#include <WebCore/AuthenticationClient.h>

Expand All @@ -48,15 +48,15 @@ static uint64_t generateAuthenticationChallengeID()
return uniqueAuthenticationChallengeID++;
}

AuthenticationManager& AuthenticationManager::shared()
AuthenticationManager::AuthenticationManager(CoreIPC::MessageReceiverMap& messageReceiverMap)
{
static AuthenticationManager& manager = *new AuthenticationManager;
return manager;
messageReceiverMap.addMessageReceiver(Messages::AuthenticationManager::messageReceiverName(), this);
}

AuthenticationManager::AuthenticationManager()
void AuthenticationManager::setConnection(CoreIPC::Connection* connection)
{
WebProcess::shared().addMessageReceiver(Messages::AuthenticationManager::messageReceiverName(), this);
ASSERT(!m_connection);
m_connection = connection;
}

void AuthenticationManager::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder)
Expand All @@ -72,7 +72,7 @@ void AuthenticationManager::didReceiveAuthenticationChallenge(WebFrame* frame, c
uint64_t challengeID = generateAuthenticationChallengeID();
m_challenges.set(challengeID, authenticationChallenge);

WebProcess::shared().connection()->send(Messages::WebPageProxy::DidReceiveAuthenticationChallenge(frame->frameID(), authenticationChallenge, challengeID), frame->page()->pageID());
m_connection->send(Messages::WebPageProxy::DidReceiveAuthenticationChallenge(frame->frameID(), authenticationChallenge, challengeID), frame->page()->pageID());
}

void AuthenticationManager::didReceiveAuthenticationChallenge(Download* download, const AuthenticationChallenge& authenticationChallenge)
Expand Down Expand Up @@ -104,7 +104,6 @@ void AuthenticationManager::useCredentialForChallenge(uint64_t challengeID, cons
// This authentication challenge comes from a download.
Download::receivedCredential(challenge, credential);
return;

}

coreClient->receivedCredential(challenge, credential);
Expand Down
17 changes: 11 additions & 6 deletions Source/WebKit2/WebProcess/Authentication/AuthenticationManager.h
Expand Up @@ -30,9 +30,10 @@
#include <wtf/HashMap.h>

namespace CoreIPC {
class ArgumentDecoder;
class Connection;
class MessageID;
class ArgumentDecoder;
class Connection;
class MessageID;
class MessageReceiverMap;
}

namespace WebCore {
Expand All @@ -50,7 +51,10 @@ class AuthenticationManager : private CoreIPC::MessageReceiver {
WTF_MAKE_NONCOPYABLE(AuthenticationManager);

public:
static AuthenticationManager& shared();
// FIXME: ChildProcess should just have a MessageReceiverMap, and this should take a ChildProcess.
explicit AuthenticationManager(CoreIPC::MessageReceiverMap&);

void setConnection(CoreIPC::Connection*);

void didReceiveAuthenticationChallenge(WebFrame*, const WebCore::AuthenticationChallenge&);
void didReceiveAuthenticationChallenge(Download*, const WebCore::AuthenticationChallenge&);
Expand All @@ -60,14 +64,15 @@ class AuthenticationManager : private CoreIPC::MessageReceiver {
void cancelChallenge(uint64_t challengeID);

private:
AuthenticationManager();

// CoreIPC::MessageReceiver
virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&) OVERRIDE;
void didReceiveAuthenticationManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);

bool tryUsePlatformCertificateInfoForChallenge(const WebCore::AuthenticationChallenge&, const PlatformCertificateInfo&);


RefPtr<CoreIPC::Connection> m_connection;

typedef HashMap<uint64_t, WebCore::AuthenticationChallenge> AuthenticationChallengeMap;
AuthenticationChallengeMap m_challenges;
};
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit2/WebProcess/Downloads/Download.cpp
Expand Up @@ -79,7 +79,7 @@ void Download::didStart()

void Download::didReceiveAuthenticationChallenge(const AuthenticationChallenge& authenticationChallenge)
{
AuthenticationManager::shared().didReceiveAuthenticationChallenge(this, authenticationChallenge);
// AuthenticationManager::shared().didReceiveAuthenticationChallenge(this, authenticationChallenge);
}

void Download::didReceiveResponse(const ResourceResponse& response)
Expand Down
Expand Up @@ -211,7 +211,7 @@ void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoa
if (!webPage)
return;

AuthenticationManager::shared().didReceiveAuthenticationChallenge(m_frame, challenge);
WebProcess::shared().authenticationManager().didReceiveAuthenticationChallenge(m_frame, challenge);
}

void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long /*identifier*/, const AuthenticationChallenge&)
Expand Down
3 changes: 3 additions & 0 deletions Source/WebKit2/WebProcess/WebProcess.cpp
Expand Up @@ -174,6 +174,7 @@ WebProcess::WebProcess()
#if USE(SOUP)
, m_soupRequestManager(this)
#endif
, m_authenticationManager(m_messageReceiverMap)
{
#if USE(PLATFORM_STRATEGIES)
// Initialize our platform strategies.
Expand Down Expand Up @@ -201,6 +202,8 @@ void WebProcess::initialize(CoreIPC::Connection::Identifier serverIdentifier, Ru

m_runLoop = runLoop;

m_authenticationManager.setConnection(m_connection.get());

startRandomCrashThreadIfRequested();
}

Expand Down
3 changes: 3 additions & 0 deletions Source/WebKit2/WebProcess/WebProcess.h
Expand Up @@ -26,6 +26,7 @@
#ifndef WebProcess_h
#define WebProcess_h

#include "AuthenticationManager.h"
#include "CacheModel.h"
#include "ChildProcess.h"
#include "DownloadManager.h"
Expand Down Expand Up @@ -217,6 +218,7 @@ class WebProcess : public ChildProcess, private CoreIPC::Connection::QueueClient
void destroyPrivateBrowsingSession();

DownloadManager& downloadManager();
AuthenticationManager& authenticationManager() { return m_authenticationManager; }

private:
WebProcess();
Expand Down Expand Up @@ -393,6 +395,7 @@ class WebProcess : public ChildProcess, private CoreIPC::Connection::QueueClient
WebSoupRequestManager m_soupRequestManager;
#endif

AuthenticationManager m_authenticationManager;
};

} // namespace WebKit
Expand Down

0 comments on commit cd1b994

Please sign in to comment.