Title: [142926] trunk/Source/WebCore
Revision
142926
Author
[email protected]
Date
2013-02-14 15:14:45 -0800 (Thu, 14 Feb 2013)

Log Message

[BlackBerry] Notify platform layer of failing to get authentication credentials
https://bugs.webkit.org/show_bug.cgi?id=109751

Patch by Joe Mason <[email protected]> on 2013-02-13
Reviewed by Yong Li.
Reviewed internally by Leo Yang
Internal PR: 181302

The BlackBerry platform network layer needs to know if a stream failed to get authentication credentials.
This patch is using newly added stream API to do it.

No functionality changed no new tests.

* platform/network/blackberry/NetworkJob.cpp:
(WebCore::NetworkJob::notifyAuthReceived):
(WebCore::NetworkJob::sendRequestWithCredentials):
(WebCore::NetworkJob::notifyChallengeResult):
* platform/network/blackberry/NetworkJob.h:
* platform/network/blackberry/NetworkManager.cpp:
(WebCore::protectionSpaceToPlatformAuth):
(WebCore):
(WebCore::setAuthCredentials):
* platform/network/blackberry/NetworkManager.h:
(WebCore):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (142925 => 142926)


--- trunk/Source/WebCore/ChangeLog	2013-02-14 22:54:43 UTC (rev 142925)
+++ trunk/Source/WebCore/ChangeLog	2013-02-14 23:14:45 UTC (rev 142926)
@@ -1,3 +1,29 @@
+2013-02-13 Joe Mason <[email protected]>
+
+        [BlackBerry] Notify platform layer of failing to get authentication credentials
+        https://bugs.webkit.org/show_bug.cgi?id=109751
+
+        Reviewed by Yong Li.
+        Reviewed internally by Leo Yang
+        Internal PR: 181302
+
+        The BlackBerry platform network layer needs to know if a stream failed to get authentication credentials.
+        This patch is using newly added stream API to do it.
+
+        No functionality changed no new tests.
+
+        * platform/network/blackberry/NetworkJob.cpp:
+        (WebCore::NetworkJob::notifyAuthReceived):
+        (WebCore::NetworkJob::sendRequestWithCredentials):
+        (WebCore::NetworkJob::notifyChallengeResult):
+        * platform/network/blackberry/NetworkJob.h:
+        * platform/network/blackberry/NetworkManager.cpp:
+        (WebCore::protectionSpaceToPlatformAuth):
+        (WebCore):
+        (WebCore::setAuthCredentials):
+        * platform/network/blackberry/NetworkManager.h:
+        (WebCore):
+
 2013-02-14  Kondapally Kalyan  <[email protected]>
 
         [GTK] Fix indentation in GNUmakefile.list.am.

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


--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp	2013-02-14 22:54:43 UTC (rev 142925)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp	2013-02-14 23:14:45 UTC (rev 142926)
@@ -354,8 +354,19 @@
         }
         storeCredentials();
     }
-    if (result != AuthResultSuccess)
-        m_newJobWithCredentialsStarted = sendRequestWithCredentials(serverType, scheme, realm, requireCredentials);
+    if (result != AuthResultSuccess) {
+        switch (sendRequestWithCredentials(serverType, scheme, realm, requireCredentials)) {
+        case SendRequestSucceeded:
+            m_newJobWithCredentialsStarted = true;
+            break;
+        case SendRequestCancelled:
+            streamFailedToGetCredentials(authType, authProtocol, authScheme);
+            // fall through
+        case SendRequestWaiting:
+            m_newJobWithCredentialsStarted = false;
+            break;
+        }
+    }
 }
 
 void NetworkJob::notifyStringHeaderReceived(const String& key, const String& value)
@@ -778,15 +789,15 @@
     return true;
 }
 
-bool NetworkJob::sendRequestWithCredentials(ProtectionSpaceServerType type, ProtectionSpaceAuthenticationScheme scheme, const String& realm, bool requireCredentials)
+NetworkJob::SendRequestResult NetworkJob::sendRequestWithCredentials(ProtectionSpaceServerType type, ProtectionSpaceAuthenticationScheme scheme, const String& realm, bool requireCredentials)
 {
     ASSERT(m_handle);
     if (!m_handle)
-        return false;
+        return SendRequestCancelled;
 
     KURL newURL = m_response.url();
     if (!newURL.isValid())
-        return false;
+        return SendRequestCancelled;
 
     // IMPORTANT: if a new source of credentials is added to this method, be sure to handle it in
     // purgeCredentials as well!
@@ -845,7 +856,7 @@
             // and parsed, so if we cancel the authentication challenge when loading the main
             // resource, we should also cancel loading the favicon when it starts to
             // load. If not we will receive another challenge which may confuse the user.
-            return false;
+            return SendRequestCancelled;
         }
 
         // CredentialStore is empty. Ask the user via dialog.
@@ -863,10 +874,10 @@
         // Before asking the user for credentials, we check if the URL contains that.
         if (username.isEmpty() && password.isEmpty()) {
             if (m_handle->firstRequest().targetType() != ResourceRequest::TargetIsMainFrame && BlackBerry::Platform::Settings::instance()->isChromeProcess())
-                return false;
+                return SendRequestCancelled;
 
             if (!m_frame || !m_frame->page())
-                return false;
+                return SendRequestCancelled;
 
             // DO overwrite any existing credentials with the empty credential
             updateCurrentWebChallenge(AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError()));
@@ -876,7 +887,7 @@
 
             AuthenticationChallengeManager::instance()->authenticationChallenge(newURL, protectionSpace,
                 Credential(), this, m_frame->page()->chrome()->client()->platformPageClient());
-            return false;
+            return SendRequestWaiting;
         }
 
         credential = Credential(username, password, CredentialPersistenceForSession);
@@ -885,7 +896,7 @@
     }
 
     notifyChallengeResult(newURL, protectionSpace, AuthenticationChallengeSuccess, credential);
-    return m_newJobWithCredentialsStarted;
+    return m_newJobWithCredentialsStarted ? SendRequestSucceeded : SendRequestCancelled;
 }
 
 void NetworkJob::storeCredentials()
@@ -999,8 +1010,14 @@
         updateDeferLoadingCount(-1);
     }
 
-    if (result != AuthenticationChallengeSuccess)
+    if (result != AuthenticationChallengeSuccess) {
+        NetworkRequest::AuthType authType;
+        NetworkRequest::AuthProtocol authProtocol;
+        NetworkRequest::AuthScheme authScheme;
+        protectionSpaceToPlatformAuth(protectionSpace, authType, authProtocol, authScheme);
+        streamFailedToGetCredentials(authType, authProtocol, authScheme);
         return;
+    }
 
     updateCurrentWebChallenge(AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError()), /* allowOverwrite */ false);
 

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


--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h	2013-02-14 22:54:43 UTC (rev 142925)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h	2013-02-14 23:14:45 UTC (rev 142926)
@@ -138,7 +138,12 @@
 
     // The server needs authentication credentials. Search in the CredentialStorage
     // or prompt the user via dialog, then resend the request with the credentials.
-    bool sendRequestWithCredentials(ProtectionSpaceServerType, ProtectionSpaceAuthenticationScheme, const String& realm, bool requireCredentials = true);
+    enum SendRequestResult {
+        SendRequestSucceeded,
+        SendRequestCancelled,
+        SendRequestWaiting
+    };
+    SendRequestResult sendRequestWithCredentials(ProtectionSpaceServerType, ProtectionSpaceAuthenticationScheme, const String& realm, bool requireCredentials = true);
 
     void storeCredentials();
     void storeCredentials(AuthenticationChallenge&);

Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkManager.cpp (142925 => 142926)


--- trunk/Source/WebCore/platform/network/blackberry/NetworkManager.cpp	2013-02-14 22:54:43 UTC (rev 142925)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkManager.cpp	2013-02-14 23:14:45 UTC (rev 142926)
@@ -57,18 +57,9 @@
     return startJob(playerId, page->groupName(), job, request, streamFactory, frame, defersLoading ? 1 : 0);
 }
 
-static void setAuthCredentials(NetworkRequest& platformRequest, const AuthenticationChallenge& challenge)
+void protectionSpaceToPlatformAuth(const ProtectionSpace& protectionSpace, NetworkRequest::AuthType& authType, NetworkRequest::AuthProtocol& authProtocol, NetworkRequest::AuthScheme& authScheme)
 {
-    if (challenge.isNull())
-        return;
-
-    Credential credential = challenge.proposedCredential();
-    const ProtectionSpace& protectionSpace = challenge.protectionSpace();
-
-    String username = credential.user();
-    String password = credential.password();
-
-    NetworkRequest::AuthScheme authScheme = NetworkRequest::AuthSchemeNone;
+    authScheme = NetworkRequest::AuthSchemeNone;
     switch (protectionSpace.authenticationScheme()) {
     case ProtectionSpaceAuthenticationSchemeDefault:
         authScheme = NetworkRequest::AuthSchemeDefault;
@@ -90,8 +81,8 @@
         break;
     }
 
-    NetworkRequest::AuthType authType = NetworkRequest::AuthTypeNone;
-    NetworkRequest::AuthProtocol authProtocol = NetworkRequest::AuthProtocolNone;
+    authType = NetworkRequest::AuthTypeNone;
+    authProtocol = NetworkRequest::AuthProtocolNone;
     switch (protectionSpace.serverType()) {
     case ProtectionSpaceServerHTTP:
         authType = NetworkRequest::AuthTypeHost;
@@ -125,7 +116,24 @@
         ASSERT_NOT_REACHED();
         break;
     }
+}
 
+static void setAuthCredentials(NetworkRequest& platformRequest, const AuthenticationChallenge& challenge)
+{
+    if (challenge.isNull())
+        return;
+
+    Credential credential = challenge.proposedCredential();
+    const ProtectionSpace& protectionSpace = challenge.protectionSpace();
+
+    String username = credential.user();
+    String password = credential.password();
+
+    NetworkRequest::AuthType authType;
+    NetworkRequest::AuthProtocol authProtocol;
+    NetworkRequest::AuthScheme authScheme;
+    protectionSpaceToPlatformAuth(protectionSpace, authType, authProtocol, authScheme);
+
     if (authType != NetworkRequest::AuthTypeNone && authProtocol != NetworkRequest::AuthProtocolNone && authScheme != NetworkRequest::AuthSchemeNone)
         platformRequest.setCredentials(authType, authProtocol, authScheme, username.utf8().data(), password.utf8().data());
 }

Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkManager.h (142925 => 142926)


--- trunk/Source/WebCore/platform/network/blackberry/NetworkManager.h	2013-02-14 22:54:43 UTC (rev 142925)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkManager.h	2013-02-14 23:14:45 UTC (rev 142926)
@@ -23,6 +23,7 @@
 #include "ResourceHandle.h"
 
 #include <BlackBerryPlatformSingleton.h>
+#include <network/NetworkRequest.h>
 #include <wtf/Vector.h>
 
 namespace BlackBerry {
@@ -37,6 +38,8 @@
 class Frame;
 class NetworkJob;
 
+void protectionSpaceToPlatformAuth(const ProtectionSpace&, BlackBerry::Platform::NetworkRequest::AuthType&, BlackBerry::Platform::NetworkRequest::AuthProtocol&, BlackBerry::Platform::NetworkRequest::AuthScheme&);
+
 class NetworkManager : public BlackBerry::Platform::ThreadUnsafeSingleton<NetworkManager> {
     SINGLETON_DEFINITION_THREADUNSAFE(NetworkManager)
 public:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to