Title: [127884] trunk/Source
Revision
127884
Author
[email protected]
Date
2012-09-07 10:13:18 -0700 (Fri, 07 Sep 2012)

Log Message

[BlackBerry] when one of multiple tabs uses authentication, user can get the auth dialog while the other tab has focus.
https://bugs.webkit.org/show_bug.cgi?id=95488
PR: 186597.

Internally reviewed by Joe Mason.
Patch by Lianghui Chen <[email protected]> on 2012-09-07
Reviewed by Yong Li.

Source/WebCore:

The fix for this PR will come as 2 patches. This is the first patch which
will make the authentication challenge asynchronous inside WebKit. The
bext patch will add an AuthenticationChallengeManager that manages these
authentication requests asynchronously.

This patch add AuthenticationChallengeClient interface to define asynchronous
authentication challenge callback. And MediaPlayerPrivateBlackBerry and
NetworkJob are changed to inherit from AuthenticationChallengeClient to
support asynchronous authentication challenge.

Note: there is also an accompanying platform patch to make our PlatformPlayer
to support asychronous authentication, see PR 186597 for details.

No new tests as this is platform specific change.

* platform/blackberry/AuthenticationChallengeManager.h: Added.
(WebCore):
(AuthenticationChallengeClient):
* platform/blackberry/PageClientBlackBerry.h:
(WebCore):
* platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
(WebCore::MediaPlayerPrivate::onAuthenticationNeeded):
(WebCore::MediaPlayerPrivate::notifyChallengeResult):
* platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h:
(MediaPlayerPrivate):
* platform/network/blackberry/NetworkJob.cpp:
(WebCore::NetworkJob::sendRequestWithCredentials):
(WebCore::NetworkJob::notifyChallengeResult):
(WebCore):
* platform/network/blackberry/NetworkJob.h:
(WebCore):
(NetworkJob):

Source/WebKit/blackberry:

Use new AuthenticationChallengeClient interface to make authentication
challenge asynchronous to NetworkJob, MediaPlayerPrivateBlackBerry, and
other module that will use HTTP authentication. WebPage itself still use
synchronous authentication though. Switching to asynchronous authentication
in WebPage will require bigger platform layer change and not very necessary
at the moment for this bug.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::authenticationChallenge):
* Api/WebPage_p.h:
(WebCore):
(WebPagePrivate):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (127883 => 127884)


--- trunk/Source/WebCore/ChangeLog	2012-09-07 17:09:09 UTC (rev 127883)
+++ trunk/Source/WebCore/ChangeLog	2012-09-07 17:13:18 UTC (rev 127884)
@@ -1,3 +1,45 @@
+2012-09-07  Lianghui Chen  <[email protected]>
+
+        [BlackBerry] when one of multiple tabs uses authentication, user can get the auth dialog while the other tab has focus.
+        https://bugs.webkit.org/show_bug.cgi?id=95488
+        PR: 186597.
+
+        Internally reviewed by Joe Mason.
+        Reviewed by Yong Li.
+
+        The fix for this PR will come as 2 patches. This is the first patch which
+        will make the authentication challenge asynchronous inside WebKit. The
+        bext patch will add an AuthenticationChallengeManager that manages these
+        authentication requests asynchronously.
+
+        This patch add AuthenticationChallengeClient interface to define asynchronous
+        authentication challenge callback. And MediaPlayerPrivateBlackBerry and
+        NetworkJob are changed to inherit from AuthenticationChallengeClient to
+        support asynchronous authentication challenge.
+
+        Note: there is also an accompanying platform patch to make our PlatformPlayer
+        to support asychronous authentication, see PR 186597 for details.
+
+        No new tests as this is platform specific change.
+
+        * platform/blackberry/AuthenticationChallengeManager.h: Added.
+        (WebCore):
+        (AuthenticationChallengeClient):
+        * platform/blackberry/PageClientBlackBerry.h:
+        (WebCore):
+        * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
+        (WebCore::MediaPlayerPrivate::onAuthenticationNeeded):
+        (WebCore::MediaPlayerPrivate::notifyChallengeResult):
+        * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h:
+        (MediaPlayerPrivate):
+        * platform/network/blackberry/NetworkJob.cpp:
+        (WebCore::NetworkJob::sendRequestWithCredentials):
+        (WebCore::NetworkJob::notifyChallengeResult):
+        (WebCore):
+        * platform/network/blackberry/NetworkJob.h:
+        (WebCore):
+        (NetworkJob):
+
 2012-09-07  Dominic Mazzoni  <[email protected]>
 
         AX: ARIA spin button should support range value attributes

Added: trunk/Source/WebCore/platform/blackberry/AuthenticationChallengeManager.h (0 => 127884)


--- trunk/Source/WebCore/platform/blackberry/AuthenticationChallengeManager.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/blackberry/AuthenticationChallengeManager.h	2012-09-07 17:13:18 UTC (rev 127884)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef AuthenticationChallengeManager_h
+#define AuthenticationChallengeManager_h
+
+namespace WebCore {
+
+class Credential;
+class KURL;
+class ProtectionSpace;
+
+enum AuthenticationChallengeResult {
+    AuthenticationChallengeSuccess,
+    AuthenticationChallengeCancelled
+};
+
+class AuthenticationChallengeClient {
+public:
+    virtual void notifyChallengeResult(const KURL&, const ProtectionSpace&, AuthenticationChallengeResult, const Credential&) = 0;
+};
+
+} // namespace WebCore
+
+#endif // AuthenticationChallengeManager_h

Modified: trunk/Source/WebCore/platform/blackberry/PageClientBlackBerry.h (127883 => 127884)


--- trunk/Source/WebCore/platform/blackberry/PageClientBlackBerry.h	2012-09-07 17:09:09 UTC (rev 127883)
+++ trunk/Source/WebCore/platform/blackberry/PageClientBlackBerry.h	2012-09-07 17:13:18 UTC (rev 127884)
@@ -19,7 +19,6 @@
 #ifndef PageClientBlackBerry_h
 #define PageClientBlackBerry_h
 
-#include "Credential.h"
 #include "Cursor.h"
 #include "WebPageClient.h"
 
@@ -33,6 +32,8 @@
 }
 
 namespace WebCore {
+    class AuthenticationChallengeClient;
+    class Credential;
     class IntRect;
     class IntSize;
     class KURL;
@@ -70,7 +71,7 @@
     virtual int showAlertDialog(BlackBerry::WebKit::WebPageClient::AlertType) = 0;
     virtual bool isActive() const = 0;
     virtual bool isVisible() const = 0;
-    virtual bool authenticationChallenge(const WebCore::KURL&, const WebCore::ProtectionSpace&, WebCore::Credential&) = 0;
+    virtual void authenticationChallenge(const WebCore::KURL&, const WebCore::ProtectionSpace&, const WebCore::Credential&, WebCore::AuthenticationChallengeClient*) = 0;
     virtual SaveCredentialType notifyShouldSaveCredential(bool) = 0;
     virtual void syncProxyCredential(const WebCore::Credential&) = 0;
 };

Modified: trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp (127883 => 127884)


--- trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp	2012-09-07 17:09:09 UTC (rev 127883)
+++ trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp	2012-09-07 17:13:18 UTC (rev 127884)
@@ -696,25 +696,31 @@
                            static_cast<ProtectionSpaceAuthenticationScheme>(authChallenge.authScheme()));
 }
 
-bool MediaPlayerPrivate::onAuthenticationNeeded(MMRAuthChallenge& authChallenge)
+void MediaPlayerPrivate::onAuthenticationNeeded(MMRAuthChallenge& authChallenge)
 {
     KURL url(ParsedURLString, String(authChallenge.url().c_str()));
     if (!url.isValid())
-        return false;
+        return;
 
     ProtectionSpace protectionSpace = generateProtectionSpaceFromMMRAuthChallenge(authChallenge);
     Credential credential = CredentialStorage::get(protectionSpace);
-    bool isConfirmed = false;
-    if (credential.isEmpty()) {
-        isConfirmed = m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient()->authenticationChallenge(url, protectionSpace, credential);
+    if (!credential.isEmpty()) {
+        notifyChallengeResult(url, protectionSpace, AuthenticationChallengeSuccess, credential);
+        return;
+    }
 
-    } else
-        isConfirmed = true;
+    if (frameView() && frameView()->hostWindow())
+        frameView()->hostWindow()->platformPageClient()->authenticationChallenge(url, protectionSpace, credential, this);
+}
 
-    if (isConfirmed)
-        authChallenge.setCredential(credential.user().utf8().data(), credential.password().utf8().data(), static_cast<MMRAuthChallenge::CredentialPersistence>(credential.persistence()));
+void MediaPlayerPrivate::notifyChallengeResult(const KURL& url, const ProtectionSpace& protectionSpace, AuthenticationChallengeResult result, const Credential& credential)
+{
+    if (result != AuthenticationChallengeSuccess || !url.isValid())
+        return;
 
-    return isConfirmed;
+    m_platformPlayer->reloadWithCredential(credential.user().utf8(true).data(),
+                                           credential.password().utf8(true).data(),
+                                           static_cast<MMRAuthChallenge::CredentialPersistence>(credential.persistence()));
 }
 
 void MediaPlayerPrivate::onAuthenticationAccepted(const MMRAuthChallenge& authChallenge) const

Modified: trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h (127883 => 127884)


--- trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h	2012-09-07 17:09:09 UTC (rev 127883)
+++ trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h	2012-09-07 17:13:18 UTC (rev 127884)
@@ -20,6 +20,7 @@
 #define MediaPlayerPrivateBlackBerry_h
 
 #if ENABLE(VIDEO)
+#include "AuthenticationChallengeManager.h"
 #include "MediaPlayerPrivate.h"
 
 #include <BlackBerryPlatformPlayer.h>
@@ -32,7 +33,7 @@
 
 namespace WebCore {
 
-class MediaPlayerPrivate : public MediaPlayerPrivateInterface, public BlackBerry::Platform::IPlatformPlayerListener {
+class MediaPlayerPrivate : public MediaPlayerPrivateInterface, public AuthenticationChallengeClient, public BlackBerry::Platform::IPlatformPlayerListener {
 public:
     virtual ~MediaPlayerPrivate();
 
@@ -132,9 +133,11 @@
 #if USE(ACCELERATED_COMPOSITING)
     virtual void onBuffering(bool);
 #endif
-    virtual bool onAuthenticationNeeded(BlackBerry::Platform::MMRAuthChallenge&);
+    virtual void onAuthenticationNeeded(BlackBerry::Platform::MMRAuthChallenge&);
     virtual void onAuthenticationAccepted(const BlackBerry::Platform::MMRAuthChallenge&) const;
 
+    virtual void notifyChallengeResult(const KURL&, const ProtectionSpace&, AuthenticationChallengeResult, const Credential&);
+
     virtual bool isFullscreen() const;
     virtual bool isElementPaused() const;
     virtual bool isTabVisible() const;

Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp (127883 => 127884)


--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp	2012-09-07 17:09:09 UTC (rev 127883)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp	2012-09-07 17:13:18 UTC (rev 127884)
@@ -752,25 +752,22 @@
         String username;
         String password;
 
-        if (username.isEmpty() || password.isEmpty()) {
-            // Before asking the user for credentials, we check if the URL contains that.
-            if (!m_handle->getInternal()->m_user.isEmpty() && !m_handle->getInternal()->m_pass.isEmpty()) {
-                username = m_handle->getInternal()->m_user;
-                password = m_handle->getInternal()->m_pass;
+        // Before asking the user for credentials, we check if the URL contains that.
+        if (!m_handle->getInternal()->m_user.isEmpty() && !m_handle->getInternal()->m_pass.isEmpty()) {
+            username = m_handle->getInternal()->m_user;
+            password = m_handle->getInternal()->m_pass;
 
-                // Prevent them from been used again if they are wrong.
-                // If they are correct, they will the put into CredentialStorage.
-                m_handle->getInternal()->m_user = "";
-                m_handle->getInternal()->m_pass = "";
-            } else {
-                if (m_handle->firstRequest().targetType() != ResourceRequest::TargetIsMainFrame && BlackBerry::Platform::Settings::instance()->isChromeProcess())
-                    return false;
-                Credential inputCredential;
-                if (!m_frame->page()->chrome()->client()->platformPageClient()->authenticationChallenge(newURL, protectionSpace, inputCredential))
-                    return false;
-                username = inputCredential.user();
-                password = inputCredential.password();
-            }
+            // Prevent them from been used again if they are wrong.
+            // If they are correct, they will the put into CredentialStorage.
+            m_handle->getInternal()->m_user = "";
+            m_handle->getInternal()->m_pass = "";
+        } else {
+            if (m_handle->firstRequest().targetType() != ResourceRequest::TargetIsMainFrame && BlackBerry::Platform::Settings::instance()->isChromeProcess())
+                return false;
+
+            m_handle->getInternal()->m_currentWebChallenge = AuthenticationChallenge();
+            m_frame->page()->chrome()->client()->platformPageClient()->authenticationChallenge(newURL, protectionSpace, Credential(), this);
+            return true;
         }
 
         credential = Credential(username, password, CredentialPersistenceForSession);
@@ -778,10 +775,8 @@
         m_handle->getInternal()->m_currentWebChallenge = AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError());
     }
 
-    ResourceRequest newRequest = m_handle->firstRequest();
-    newRequest.setURL(newURL);
-    newRequest.setMustHandleInternally(true);
-    return startNewJobWithRequest(newRequest);
+    notifyChallengeResult(newURL, protectionSpace, AuthenticationChallengeSuccess, credential);
+    return m_newJobWithCredentialsStarted;
 }
 
 void NetworkJob::storeCredentials()
@@ -830,4 +825,20 @@
     NetworkManager::instance()->deleteJob(this);
 }
 
+void NetworkJob::notifyChallengeResult(const KURL& url, const ProtectionSpace& protectionSpace, AuthenticationChallengeResult result, const Credential& credential)
+{
+    if (result != AuthenticationChallengeSuccess || protectionSpace.host().isEmpty() || !url.isValid()) {
+        m_newJobWithCredentialsStarted = false;
+        return;
+    }
+
+    if (m_handle->getInternal()->m_currentWebChallenge.isNull())
+        m_handle->getInternal()->m_currentWebChallenge = AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError());
+
+    ResourceRequest newRequest = m_handle->firstRequest();
+    newRequest.setURL(m_response.url());
+    newRequest.setMustHandleInternally(true);
+    m_newJobWithCredentialsStarted = startNewJobWithRequest(newRequest);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h (127883 => 127884)


--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h	2012-09-07 17:09:09 UTC (rev 127883)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h	2012-09-07 17:13:18 UTC (rev 127884)
@@ -19,8 +19,9 @@
 #ifndef NetworkJob_h
 #define NetworkJob_h
 
+#include "AuthenticationChallengeManager.h"
 #include "DeferredData.h"
-#include "ProtectionSpace.h"
+#include "PlatformString.h"
 #include "ResourceHandle.h"
 #include "ResourceResponse.h"
 #include "Timer.h"
@@ -39,11 +40,13 @@
 
 namespace WebCore {
 
+class Credential;
 class Frame;
 class KURL;
+class ProtectionSpace;
 class ResourceRequest;
 
-class NetworkJob : public BlackBerry::Platform::FilterStream {
+class NetworkJob : public AuthenticationChallengeClient, public BlackBerry::Platform::FilterStream {
 public:
     NetworkJob();
     bool initialize(int playerId,
@@ -81,6 +84,8 @@
     void handleNotifyClose(int status);
     virtual int status() const { return m_extendedStatusCode; }
 
+    virtual void notifyChallengeResult(const KURL&, const ProtectionSpace&, AuthenticationChallengeResult, const Credential&);
+
 private:
     bool isClientAvailable() const { return !m_cancelled && m_handle && m_handle->client(); }
 

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (127883 => 127884)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-09-07 17:09:09 UTC (rev 127883)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-09-07 17:13:18 UTC (rev 127884)
@@ -20,6 +20,7 @@
 #include "WebPage.h"
 
 #include "ApplicationCacheStorage.h"
+#include "AuthenticationChallengeManager.h"
 #include "AutofillManager.h"
 #include "BackForwardController.h"
 #include "BackForwardListImpl.h"
@@ -2267,14 +2268,20 @@
     return m_client->isActive();
 }
 
-bool WebPagePrivate::authenticationChallenge(const KURL& url, const ProtectionSpace& protectionSpace, Credential& inputCredential)
+void WebPagePrivate::authenticationChallenge(const KURL& url, const ProtectionSpace& protectionSpace, const Credential& inputCredential, AuthenticationChallengeClient* client)
 {
     WebString username;
     WebString password;
 
 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
-    if (m_dumpRenderTree)
-        return m_dumpRenderTree->didReceiveAuthenticationChallenge(inputCredential);
+    if (m_dumpRenderTree) {
+        Credential credential(inputCredential, inputCredential.persistence());
+        if (m_dumpRenderTree->didReceiveAuthenticationChallenge(credential))
+            client->notifyChallengeResult(url, protectionSpace, AuthenticationChallengeSuccess, credential);
+        else
+            client->notifyChallengeResult(url, protectionSpace, AuthenticationChallengeCancelled, inputCredential);
+        return;
+    }
 #endif
 
 #if ENABLE(BLACKBERRY_CREDENTIAL_PERSIST)
@@ -2291,8 +2298,11 @@
 #else
     Credential credential(username, password, CredentialPersistenceNone);
 #endif
-    inputCredential = credential;
-    return isConfirmed;
+
+    if (isConfirmed)
+        client->notifyChallengeResult(url, protectionSpace, AuthenticationChallengeSuccess, credential);
+    else
+        client->notifyChallengeResult(url, protectionSpace, AuthenticationChallengeCancelled, inputCredential);
 }
 
 PageClientBlackBerry::SaveCredentialType WebPagePrivate::notifyShouldSaveCredential(bool isNew)

Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (127883 => 127884)


--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-09-07 17:09:09 UTC (rev 127883)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-09-07 17:13:18 UTC (rev 127884)
@@ -45,6 +45,7 @@
 #define DEFAULT_MAX_LAYOUT_HEIGHT 768
 
 namespace WebCore {
+class AuthenticationChallengeClient;
 class AutofillManager;
 class DOMWrapperWorld;
 class Document;
@@ -201,7 +202,7 @@
     virtual int showAlertDialog(WebPageClient::AlertType atype);
     virtual bool isActive() const;
     virtual bool isVisible() const { return m_visible; }
-    virtual bool authenticationChallenge(const WebCore::KURL&, const WebCore::ProtectionSpace&, WebCore::Credential&);
+    virtual void authenticationChallenge(const WebCore::KURL&, const WebCore::ProtectionSpace&, const WebCore::Credential&, WebCore::AuthenticationChallengeClient*);
     virtual SaveCredentialType notifyShouldSaveCredential(bool);
     virtual void syncProxyCredential(const WebCore::Credential&);
 

Modified: trunk/Source/WebKit/blackberry/ChangeLog (127883 => 127884)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-09-07 17:09:09 UTC (rev 127883)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-09-07 17:13:18 UTC (rev 127884)
@@ -1,3 +1,25 @@
+2012-09-07  Lianghui Chen  <[email protected]>
+
+        [BlackBerry] when one of multiple tabs uses authentication, user can get the auth dialog while the other tab has focus.
+        https://bugs.webkit.org/show_bug.cgi?id=95488
+        PR: 186597.
+
+        Internally reviewed by Joe Mason.
+        Reviewed by Yong Li.
+
+        Use new AuthenticationChallengeClient interface to make authentication
+        challenge asynchronous to NetworkJob, MediaPlayerPrivateBlackBerry, and
+        other module that will use HTTP authentication. WebPage itself still use
+        synchronous authentication though. Switching to asynchronous authentication
+        in WebPage will require bigger platform layer change and not very necessary
+        at the moment for this bug.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::authenticationChallenge):
+        * Api/WebPage_p.h:
+        (WebCore):
+        (WebPagePrivate):
+
 2012-09-07  Rob Buis  <[email protected]>
 
         [BlackBerry] Remove feature about:cache/disable and about:cache/enable
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to