diff options
author | Ben Murdoch <benm@google.com> | 2011-05-13 16:23:25 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-16 11:35:02 +0100 |
commit | 65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch) | |
tree | f478babb801e720de7bfaee23443ffe029f58731 /Source/WebKit2/UIProcess/Authentication | |
parent | 47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff) | |
download | external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2 |
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebKit2/UIProcess/Authentication')
8 files changed, 543 insertions, 0 deletions
diff --git a/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.cpp b/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.cpp new file mode 100644 index 0000000..07b39b2 --- /dev/null +++ b/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "AuthenticationChallengeProxy.h" + +#include "AuthenticationDecisionListener.h" +#include "AuthenticationManagerMessages.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, WebPageProxy* page) + : m_coreAuthenticationChallenge(authenticationChallenge) + , m_challengeID(challengeID) + , m_page(page) +{ + ASSERT(m_challengeID); + m_listener = AuthenticationDecisionListener::create(this); +} + +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. + if (m_challengeID && m_page->process()) + m_page->process()->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), m_page->pageID()); + + if (m_listener) + m_listener->detachChallenge(); +} + +void AuthenticationChallengeProxy::useCredential(WebCredential* credential) +{ + if (!m_challengeID) + return; + + if (!credential) + m_page->process()->send(Messages::AuthenticationManager::ContinueWithoutCredentialForChallenge(m_challengeID), m_page->pageID()); + else + m_page->process()->send(Messages::AuthenticationManager::UseCredentialForChallenge(m_challengeID, credential->core()), m_page->pageID()); + + m_challengeID = 0; +} + +void AuthenticationChallengeProxy::cancel() +{ + if (!m_challengeID) + return; + + m_page->process()->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), m_page->pageID()); + + 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(); +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.h b/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.h new file mode 100644 index 0000000..d4e76dd --- /dev/null +++ b/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.h @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef AuthenticationChallengeProxy_h +#define AuthenticationChallengeProxy_h + +#include "APIObject.h" +#include <WebCore/AuthenticationChallenge.h> +#include <wtf/PassRefPtr.h> + +namespace CoreIPC { + class ArgumentDecoder; + class Connection; + class MessageID; +} + +namespace WebKit { + +class AuthenticationDecisionListener; +class WebCredential; +class WebPageProxy; +class WebProtectionSpace; + +class AuthenticationChallengeProxy : public APIObject { +public: + static const Type APIType = TypeAuthenticationChallenge; + + static PassRefPtr<AuthenticationChallengeProxy> create(const WebCore::AuthenticationChallenge& authenticationChallenge, uint64_t challengeID, WebPageProxy* page) + { + return adoptRef(new AuthenticationChallengeProxy(authenticationChallenge, challengeID, page)); + } + + ~AuthenticationChallengeProxy(); + + void useCredential(WebCredential*); + void cancel(); + + AuthenticationDecisionListener* listener() const { return m_listener.get(); } + WebCredential* proposedCredential() const; + WebProtectionSpace* protectionSpace() const; + int previousFailureCount() const { return m_coreAuthenticationChallenge.previousFailureCount(); } + +private: + AuthenticationChallengeProxy(const WebCore::AuthenticationChallenge&, uint64_t challengeID, WebPageProxy* page); + + virtual Type type() const { return APIType; } + + WebCore::AuthenticationChallenge m_coreAuthenticationChallenge; + uint64_t m_challengeID; + RefPtr<WebPageProxy> m_page; + RefPtr<AuthenticationDecisionListener> m_listener; + mutable RefPtr<WebCredential> m_webCredential; + mutable RefPtr<WebProtectionSpace> m_webProtectionSpace; +}; + +} // namespace WebKit + +#endif // WebAuthenticationChallengeProxy_h diff --git a/Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.cpp b/Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.cpp new file mode 100644 index 0000000..ddcc6c6 --- /dev/null +++ b/Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "AuthenticationDecisionListener.h" + +#include "AuthenticationChallengeProxy.h" +#include "AuthenticationManagerMessages.h" +#include "WebCredential.h" +#include "WebPageProxy.h" +#include "WebProcessProxy.h" + +namespace WebKit { + +AuthenticationDecisionListener::AuthenticationDecisionListener(AuthenticationChallengeProxy* authenticationChallenge) + : m_challengeProxy(authenticationChallenge) +{ +} + +void AuthenticationDecisionListener::useCredential(WebCredential* credential) +{ + if (m_challengeProxy) + m_challengeProxy->useCredential(credential); +} + +void AuthenticationDecisionListener::cancel() +{ + if (m_challengeProxy) + m_challengeProxy->cancel(); +} + +void AuthenticationDecisionListener::detachChallenge() +{ + m_challengeProxy = 0; +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.h b/Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.h new file mode 100644 index 0000000..00af849 --- /dev/null +++ b/Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef AuthenticationDecisionListener_h +#define AuthenticationDecisionListener_h + +#include "APIObject.h" + +#include <wtf/RefPtr.h> + +namespace WebKit { + +class AuthenticationChallengeProxy; +class WebCredential; + +class AuthenticationDecisionListener : public APIObject { +public: + static const Type APIType = TypeAuthenticationDecisionListener; + + static PassRefPtr<AuthenticationDecisionListener> create(AuthenticationChallengeProxy* authenticationChallenge) + { + return adoptRef(new AuthenticationDecisionListener(authenticationChallenge)); + } + + void useCredential(WebCredential*); + void cancel(); + + void detachChallenge(); + +private: + AuthenticationDecisionListener(AuthenticationChallengeProxy* authenticationChallenge); + + virtual Type type() const { return APIType; } + + AuthenticationChallengeProxy* m_challengeProxy; +}; + +} // namespace WebKit + +#endif // WebAuthenticationDecisionListener_h diff --git a/Source/WebKit2/UIProcess/Authentication/WebCredential.cpp b/Source/WebKit2/UIProcess/Authentication/WebCredential.cpp new file mode 100644 index 0000000..b9a346e --- /dev/null +++ b/Source/WebKit2/UIProcess/Authentication/WebCredential.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebCredential.h" + +namespace WebKit { + +WebCredential::WebCredential(const WebCore::Credential& credential) + : m_coreCredential(credential) +{ +} + +const WebCore::Credential& WebCredential::core() +{ + return m_coreCredential; +} + +const String& WebCredential::user() const +{ + return m_coreCredential.user(); +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/Authentication/WebCredential.h b/Source/WebKit2/UIProcess/Authentication/WebCredential.h new file mode 100644 index 0000000..7beac04 --- /dev/null +++ b/Source/WebKit2/UIProcess/Authentication/WebCredential.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebCredential_h +#define WebCredential_h + +#include "APIObject.h" +#include "WebString.h" + +#include <WebCore/Credential.h> +#include <wtf/PassRefPtr.h> + + +namespace WebKit { + +class WebCredential : public APIObject { +public: + static const Type APIType = TypeCredential; + + static PassRefPtr<WebCredential> create(const WebCore::Credential& credential) + { + return adoptRef(new WebCredential(credential)); + } + + static PassRefPtr<WebCredential> create(WebString* username, WebString* password, WebCore::CredentialPersistence persistence) + { + return adoptRef(new WebCredential(WebCore::Credential(username->string(), password->string(), persistence))); + } + + const WebCore::Credential& core(); + + const String& user() const; + +private: + WebCredential(const WebCore::Credential&); + + virtual Type type() const { return APIType; } + + WebCore::Credential m_coreCredential; +}; + +} // namespace WebKit + +#endif // WebCredential_h diff --git a/Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.cpp b/Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.cpp new file mode 100644 index 0000000..1671371 --- /dev/null +++ b/Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WebProtectionSpace.h" + +#include <WebCore/SharedBuffer.h> + +namespace WebKit { + +WebProtectionSpace::WebProtectionSpace(const WebCore::ProtectionSpace& coreProtectionSpace) + : m_coreProtectionSpace(coreProtectionSpace) +{ +} + +const String& WebProtectionSpace::host() const +{ + return m_coreProtectionSpace.host(); +} + +int WebProtectionSpace::port() const +{ + return m_coreProtectionSpace.port(); +} + +const String& WebProtectionSpace::realm() const +{ + return m_coreProtectionSpace.realm(); +} + +bool WebProtectionSpace::isProxy() const +{ + return m_coreProtectionSpace.isProxy(); +} + +WebCore::ProtectionSpaceServerType WebProtectionSpace::serverType() const +{ + return m_coreProtectionSpace.serverType(); +} + +bool WebProtectionSpace::receivesCredentialSecurely() const +{ + return m_coreProtectionSpace.receivesCredentialSecurely(); +} + +WebCore::ProtectionSpaceAuthenticationScheme WebProtectionSpace::authenticationScheme() const +{ + return m_coreProtectionSpace.authenticationScheme(); +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.h b/Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.h new file mode 100644 index 0000000..604236a --- /dev/null +++ b/Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebProtectionSpace_h +#define WebProtectionSpace_h + +#include "APIObject.h" +#include <WebCore/ProtectionSpace.h> +#include <wtf/PassRefPtr.h> + +namespace WebKit { + +class WebProtectionSpace : public APIObject { +public: + static const Type APIType = TypeProtectionSpace; + + static PassRefPtr<WebProtectionSpace> create(const WebCore::ProtectionSpace& protectionSpace) + { + return adoptRef(new WebProtectionSpace(protectionSpace)); + } + + const String& protocol() const; + const String& host() const; + int port() const; + const String& realm() const; + bool isProxy() const; + WebCore::ProtectionSpaceServerType serverType() const; + bool receivesCredentialSecurely() const; + WebCore::ProtectionSpaceAuthenticationScheme authenticationScheme() const; + +private: + WebProtectionSpace(const WebCore::ProtectionSpace&); + + virtual Type type() const { return APIType; } + + WebCore::ProtectionSpace m_coreProtectionSpace; +}; + +} // namespace WebKit + +#endif // WebProtectionSpace_h |