<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[127884] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/127884">127884</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2012-09-07 10:13:18 -0700 (Fri, 07 Sep 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>[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 &lt;liachen@rim.com&gt; 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):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformblackberryPageClientBlackBerryh">trunk/Source/WebCore/platform/blackberry/PageClientBlackBerry.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsblackberryMediaPlayerPrivateBlackBerrycpp">trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsblackberryMediaPlayerPrivateBlackBerryh">trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkblackberryNetworkJobcpp">trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkblackberryNetworkJobh">trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h</a></li>
<li><a href="#trunkSourceWebKitblackberryApiWebPagecpp">trunk/Source/WebKit/blackberry/Api/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKitblackberryApiWebPage_ph">trunk/Source/WebKit/blackberry/Api/WebPage_p.h</a></li>
<li><a href="#trunkSourceWebKitblackberryChangeLog">trunk/Source/WebKit/blackberry/ChangeLog</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformblackberryAuthenticationChallengeManagerh">trunk/Source/WebCore/platform/blackberry/AuthenticationChallengeManager.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (127883 => 127884)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2012-09-07  Lianghui Chen  &lt;liachen@rim.com&gt;
+
+        [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):
+
</ins><span class="cx"> 2012-09-07  Dominic Mazzoni  &lt;dmazzoni@google.com&gt;
</span><span class="cx"> 
</span><span class="cx">         AX: ARIA spin button should support range value attributes
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformblackberryAuthenticationChallengeManagerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/blackberry/AuthenticationChallengeManager.h (0 => 127884)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+/*
+ * 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&amp;, const ProtectionSpace&amp;, AuthenticationChallengeResult, const Credential&amp;) = 0;
+};
+
+} // namespace WebCore
+
+#endif // AuthenticationChallengeManager_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformblackberryPageClientBlackBerryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/blackberry/PageClientBlackBerry.h (127883 => 127884)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -19,7 +19,6 @@
</span><span class="cx"> #ifndef PageClientBlackBerry_h
</span><span class="cx"> #define PageClientBlackBerry_h
</span><span class="cx"> 
</span><del>-#include &quot;Credential.h&quot;
</del><span class="cx"> #include &quot;Cursor.h&quot;
</span><span class="cx"> #include &quot;WebPageClient.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -33,6 +32,8 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><ins>+    class AuthenticationChallengeClient;
+    class Credential;
</ins><span class="cx">     class IntRect;
</span><span class="cx">     class IntSize;
</span><span class="cx">     class KURL;
</span><span class="lines">@@ -70,7 +71,7 @@
</span><span class="cx">     virtual int showAlertDialog(BlackBerry::WebKit::WebPageClient::AlertType) = 0;
</span><span class="cx">     virtual bool isActive() const = 0;
</span><span class="cx">     virtual bool isVisible() const = 0;
</span><del>-    virtual bool authenticationChallenge(const WebCore::KURL&amp;, const WebCore::ProtectionSpace&amp;, WebCore::Credential&amp;) = 0;
</del><ins>+    virtual void authenticationChallenge(const WebCore::KURL&amp;, const WebCore::ProtectionSpace&amp;, const WebCore::Credential&amp;, WebCore::AuthenticationChallengeClient*) = 0;
</ins><span class="cx">     virtual SaveCredentialType notifyShouldSaveCredential(bool) = 0;
</span><span class="cx">     virtual void syncProxyCredential(const WebCore::Credential&amp;) = 0;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsblackberryMediaPlayerPrivateBlackBerrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp (127883 => 127884)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -696,25 +696,31 @@
</span><span class="cx">                            static_cast&lt;ProtectionSpaceAuthenticationScheme&gt;(authChallenge.authScheme()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool MediaPlayerPrivate::onAuthenticationNeeded(MMRAuthChallenge&amp; authChallenge)
</del><ins>+void MediaPlayerPrivate::onAuthenticationNeeded(MMRAuthChallenge&amp; authChallenge)
</ins><span class="cx"> {
</span><span class="cx">     KURL url(ParsedURLString, String(authChallenge.url().c_str()));
</span><span class="cx">     if (!url.isValid())
</span><del>-        return false;
</del><ins>+        return;
</ins><span class="cx"> 
</span><span class="cx">     ProtectionSpace protectionSpace = generateProtectionSpaceFromMMRAuthChallenge(authChallenge);
</span><span class="cx">     Credential credential = CredentialStorage::get(protectionSpace);
</span><del>-    bool isConfirmed = false;
-    if (credential.isEmpty()) {
-        isConfirmed = m_webCorePlayer-&gt;mediaPlayerClient()-&gt;mediaPlayerHostWindow()-&gt;platformPageClient()-&gt;authenticationChallenge(url, protectionSpace, credential);
</del><ins>+    if (!credential.isEmpty()) {
+        notifyChallengeResult(url, protectionSpace, AuthenticationChallengeSuccess, credential);
+        return;
+    }
</ins><span class="cx"> 
</span><del>-    } else
-        isConfirmed = true;
</del><ins>+    if (frameView() &amp;&amp; frameView()-&gt;hostWindow())
+        frameView()-&gt;hostWindow()-&gt;platformPageClient()-&gt;authenticationChallenge(url, protectionSpace, credential, this);
+}
</ins><span class="cx"> 
</span><del>-    if (isConfirmed)
-        authChallenge.setCredential(credential.user().utf8().data(), credential.password().utf8().data(), static_cast&lt;MMRAuthChallenge::CredentialPersistence&gt;(credential.persistence()));
</del><ins>+void MediaPlayerPrivate::notifyChallengeResult(const KURL&amp; url, const ProtectionSpace&amp; protectionSpace, AuthenticationChallengeResult result, const Credential&amp; credential)
+{
+    if (result != AuthenticationChallengeSuccess || !url.isValid())
+        return;
</ins><span class="cx"> 
</span><del>-    return isConfirmed;
</del><ins>+    m_platformPlayer-&gt;reloadWithCredential(credential.user().utf8(true).data(),
+                                           credential.password().utf8(true).data(),
+                                           static_cast&lt;MMRAuthChallenge::CredentialPersistence&gt;(credential.persistence()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivate::onAuthenticationAccepted(const MMRAuthChallenge&amp; authChallenge) const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsblackberryMediaPlayerPrivateBlackBerryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h (127883 => 127884)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -20,6 +20,7 @@
</span><span class="cx"> #define MediaPlayerPrivateBlackBerry_h
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO)
</span><ins>+#include &quot;AuthenticationChallengeManager.h&quot;
</ins><span class="cx"> #include &quot;MediaPlayerPrivate.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &lt;BlackBerryPlatformPlayer.h&gt;
</span><span class="lines">@@ -32,7 +33,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class MediaPlayerPrivate : public MediaPlayerPrivateInterface, public BlackBerry::Platform::IPlatformPlayerListener {
</del><ins>+class MediaPlayerPrivate : public MediaPlayerPrivateInterface, public AuthenticationChallengeClient, public BlackBerry::Platform::IPlatformPlayerListener {
</ins><span class="cx"> public:
</span><span class="cx">     virtual ~MediaPlayerPrivate();
</span><span class="cx"> 
</span><span class="lines">@@ -132,9 +133,11 @@
</span><span class="cx"> #if USE(ACCELERATED_COMPOSITING)
</span><span class="cx">     virtual void onBuffering(bool);
</span><span class="cx"> #endif
</span><del>-    virtual bool onAuthenticationNeeded(BlackBerry::Platform::MMRAuthChallenge&amp;);
</del><ins>+    virtual void onAuthenticationNeeded(BlackBerry::Platform::MMRAuthChallenge&amp;);
</ins><span class="cx">     virtual void onAuthenticationAccepted(const BlackBerry::Platform::MMRAuthChallenge&amp;) const;
</span><span class="cx"> 
</span><ins>+    virtual void notifyChallengeResult(const KURL&amp;, const ProtectionSpace&amp;, AuthenticationChallengeResult, const Credential&amp;);
+
</ins><span class="cx">     virtual bool isFullscreen() const;
</span><span class="cx">     virtual bool isElementPaused() const;
</span><span class="cx">     virtual bool isTabVisible() const;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkblackberryNetworkJobcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp (127883 => 127884)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -752,25 +752,22 @@
</span><span class="cx">         String username;
</span><span class="cx">         String password;
</span><span class="cx"> 
</span><del>-        if (username.isEmpty() || password.isEmpty()) {
-            // Before asking the user for credentials, we check if the URL contains that.
-            if (!m_handle-&gt;getInternal()-&gt;m_user.isEmpty() &amp;&amp; !m_handle-&gt;getInternal()-&gt;m_pass.isEmpty()) {
-                username = m_handle-&gt;getInternal()-&gt;m_user;
-                password = m_handle-&gt;getInternal()-&gt;m_pass;
</del><ins>+        // Before asking the user for credentials, we check if the URL contains that.
+        if (!m_handle-&gt;getInternal()-&gt;m_user.isEmpty() &amp;&amp; !m_handle-&gt;getInternal()-&gt;m_pass.isEmpty()) {
+            username = m_handle-&gt;getInternal()-&gt;m_user;
+            password = m_handle-&gt;getInternal()-&gt;m_pass;
</ins><span class="cx"> 
</span><del>-                // Prevent them from been used again if they are wrong.
-                // If they are correct, they will the put into CredentialStorage.
-                m_handle-&gt;getInternal()-&gt;m_user = &quot;&quot;;
-                m_handle-&gt;getInternal()-&gt;m_pass = &quot;&quot;;
-            } else {
-                if (m_handle-&gt;firstRequest().targetType() != ResourceRequest::TargetIsMainFrame &amp;&amp; BlackBerry::Platform::Settings::instance()-&gt;isChromeProcess())
-                    return false;
-                Credential inputCredential;
-                if (!m_frame-&gt;page()-&gt;chrome()-&gt;client()-&gt;platformPageClient()-&gt;authenticationChallenge(newURL, protectionSpace, inputCredential))
-                    return false;
-                username = inputCredential.user();
-                password = inputCredential.password();
-            }
</del><ins>+            // Prevent them from been used again if they are wrong.
+            // If they are correct, they will the put into CredentialStorage.
+            m_handle-&gt;getInternal()-&gt;m_user = &quot;&quot;;
+            m_handle-&gt;getInternal()-&gt;m_pass = &quot;&quot;;
+        } else {
+            if (m_handle-&gt;firstRequest().targetType() != ResourceRequest::TargetIsMainFrame &amp;&amp; BlackBerry::Platform::Settings::instance()-&gt;isChromeProcess())
+                return false;
+
+            m_handle-&gt;getInternal()-&gt;m_currentWebChallenge = AuthenticationChallenge();
+            m_frame-&gt;page()-&gt;chrome()-&gt;client()-&gt;platformPageClient()-&gt;authenticationChallenge(newURL, protectionSpace, Credential(), this);
+            return true;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         credential = Credential(username, password, CredentialPersistenceForSession);
</span><span class="lines">@@ -778,10 +775,8 @@
</span><span class="cx">         m_handle-&gt;getInternal()-&gt;m_currentWebChallenge = AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ResourceRequest newRequest = m_handle-&gt;firstRequest();
-    newRequest.setURL(newURL);
-    newRequest.setMustHandleInternally(true);
-    return startNewJobWithRequest(newRequest);
</del><ins>+    notifyChallengeResult(newURL, protectionSpace, AuthenticationChallengeSuccess, credential);
+    return m_newJobWithCredentialsStarted;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void NetworkJob::storeCredentials()
</span><span class="lines">@@ -830,4 +825,20 @@
</span><span class="cx">     NetworkManager::instance()-&gt;deleteJob(this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void NetworkJob::notifyChallengeResult(const KURL&amp; url, const ProtectionSpace&amp; protectionSpace, AuthenticationChallengeResult result, const Credential&amp; credential)
+{
+    if (result != AuthenticationChallengeSuccess || protectionSpace.host().isEmpty() || !url.isValid()) {
+        m_newJobWithCredentialsStarted = false;
+        return;
+    }
+
+    if (m_handle-&gt;getInternal()-&gt;m_currentWebChallenge.isNull())
+        m_handle-&gt;getInternal()-&gt;m_currentWebChallenge = AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError());
+
+    ResourceRequest newRequest = m_handle-&gt;firstRequest();
+    newRequest.setURL(m_response.url());
+    newRequest.setMustHandleInternally(true);
+    m_newJobWithCredentialsStarted = startNewJobWithRequest(newRequest);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkblackberryNetworkJobh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h (127883 => 127884)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -19,8 +19,9 @@
</span><span class="cx"> #ifndef NetworkJob_h
</span><span class="cx"> #define NetworkJob_h
</span><span class="cx"> 
</span><ins>+#include &quot;AuthenticationChallengeManager.h&quot;
</ins><span class="cx"> #include &quot;DeferredData.h&quot;
</span><del>-#include &quot;ProtectionSpace.h&quot;
</del><ins>+#include &quot;PlatformString.h&quot;
</ins><span class="cx"> #include &quot;ResourceHandle.h&quot;
</span><span class="cx"> #include &quot;ResourceResponse.h&quot;
</span><span class="cx"> #include &quot;Timer.h&quot;
</span><span class="lines">@@ -39,11 +40,13 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class Credential;
</ins><span class="cx"> class Frame;
</span><span class="cx"> class KURL;
</span><ins>+class ProtectionSpace;
</ins><span class="cx"> class ResourceRequest;
</span><span class="cx"> 
</span><del>-class NetworkJob : public BlackBerry::Platform::FilterStream {
</del><ins>+class NetworkJob : public AuthenticationChallengeClient, public BlackBerry::Platform::FilterStream {
</ins><span class="cx"> public:
</span><span class="cx">     NetworkJob();
</span><span class="cx">     bool initialize(int playerId,
</span><span class="lines">@@ -81,6 +84,8 @@
</span><span class="cx">     void handleNotifyClose(int status);
</span><span class="cx">     virtual int status() const { return m_extendedStatusCode; }
</span><span class="cx"> 
</span><ins>+    virtual void notifyChallengeResult(const KURL&amp;, const ProtectionSpace&amp;, AuthenticationChallengeResult, const Credential&amp;);
+
</ins><span class="cx"> private:
</span><span class="cx">     bool isClientAvailable() const { return !m_cancelled &amp;&amp; m_handle &amp;&amp; m_handle-&gt;client(); }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitblackberryApiWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (127883 => 127884)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -20,6 +20,7 @@
</span><span class="cx"> #include &quot;WebPage.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ApplicationCacheStorage.h&quot;
</span><ins>+#include &quot;AuthenticationChallengeManager.h&quot;
</ins><span class="cx"> #include &quot;AutofillManager.h&quot;
</span><span class="cx"> #include &quot;BackForwardController.h&quot;
</span><span class="cx"> #include &quot;BackForwardListImpl.h&quot;
</span><span class="lines">@@ -2267,14 +2268,20 @@
</span><span class="cx">     return m_client-&gt;isActive();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool WebPagePrivate::authenticationChallenge(const KURL&amp; url, const ProtectionSpace&amp; protectionSpace, Credential&amp; inputCredential)
</del><ins>+void WebPagePrivate::authenticationChallenge(const KURL&amp; url, const ProtectionSpace&amp; protectionSpace, const Credential&amp; inputCredential, AuthenticationChallengeClient* client)
</ins><span class="cx"> {
</span><span class="cx">     WebString username;
</span><span class="cx">     WebString password;
</span><span class="cx"> 
</span><span class="cx"> #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
</span><del>-    if (m_dumpRenderTree)
-        return m_dumpRenderTree-&gt;didReceiveAuthenticationChallenge(inputCredential);
</del><ins>+    if (m_dumpRenderTree) {
+        Credential credential(inputCredential, inputCredential.persistence());
+        if (m_dumpRenderTree-&gt;didReceiveAuthenticationChallenge(credential))
+            client-&gt;notifyChallengeResult(url, protectionSpace, AuthenticationChallengeSuccess, credential);
+        else
+            client-&gt;notifyChallengeResult(url, protectionSpace, AuthenticationChallengeCancelled, inputCredential);
+        return;
+    }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(BLACKBERRY_CREDENTIAL_PERSIST)
</span><span class="lines">@@ -2291,8 +2298,11 @@
</span><span class="cx"> #else
</span><span class="cx">     Credential credential(username, password, CredentialPersistenceNone);
</span><span class="cx"> #endif
</span><del>-    inputCredential = credential;
-    return isConfirmed;
</del><ins>+
+    if (isConfirmed)
+        client-&gt;notifyChallengeResult(url, protectionSpace, AuthenticationChallengeSuccess, credential);
+    else
+        client-&gt;notifyChallengeResult(url, protectionSpace, AuthenticationChallengeCancelled, inputCredential);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PageClientBlackBerry::SaveCredentialType WebPagePrivate::notifyShouldSaveCredential(bool isNew)
</span></span></pre></div>
<a id="trunkSourceWebKitblackberryApiWebPage_ph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (127883 => 127884)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> #define DEFAULT_MAX_LAYOUT_HEIGHT 768
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><ins>+class AuthenticationChallengeClient;
</ins><span class="cx"> class AutofillManager;
</span><span class="cx"> class DOMWrapperWorld;
</span><span class="cx"> class Document;
</span><span class="lines">@@ -201,7 +202,7 @@
</span><span class="cx">     virtual int showAlertDialog(WebPageClient::AlertType atype);
</span><span class="cx">     virtual bool isActive() const;
</span><span class="cx">     virtual bool isVisible() const { return m_visible; }
</span><del>-    virtual bool authenticationChallenge(const WebCore::KURL&amp;, const WebCore::ProtectionSpace&amp;, WebCore::Credential&amp;);
</del><ins>+    virtual void authenticationChallenge(const WebCore::KURL&amp;, const WebCore::ProtectionSpace&amp;, const WebCore::Credential&amp;, WebCore::AuthenticationChallengeClient*);
</ins><span class="cx">     virtual SaveCredentialType notifyShouldSaveCredential(bool);
</span><span class="cx">     virtual void syncProxyCredential(const WebCore::Credential&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitblackberryChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/blackberry/ChangeLog (127883 => 127884)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2012-09-07  Lianghui Chen  &lt;liachen@rim.com&gt;
+
+        [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):
+
</ins><span class="cx"> 2012-09-07  Rob Buis  &lt;rbuis@rim.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [BlackBerry] Remove feature about:cache/disable and about:cache/enable
</span></span></pre>
</div>
</div>

</body>
</html>