Fixed for widget crash when multiple authentication has to be done.
authorSungman Kim <ssungmai.kim@samsung.com>
Tue, 30 Apr 2013 09:14:49 +0000 (18:14 +0900)
committerSungman Kim <ssungmai.kim@samsung.com>
Tue, 30 Apr 2013 11:03:33 +0000 (20:03 +0900)
When the multiple authentication message is sent to WRT,
the crash is occurred after second popup because authenticationChallengeProxy is released.

[Title] Fixed for widget crash when multiple authentication has to be done.
[Issue#] N/A
[Problem] When the multiple authentication message is sent to WRT from webkit, crash is occurred.
[Cause] authenticationChallengeProxy is release after second message.
[Solution] Change the send messgae method to sendSync with delayed option.
[SCMRequest] N/A

Change-Id: Icf1b0d3738759ae2f54137ba852eca1d873215ac

14 files changed:
Source/WebKit2/UIProcess/API/C/WKPage.h
Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp
Source/WebKit2/UIProcess/API/efl/ewk_auth_challenge.cpp
Source/WebKit2/UIProcess/API/efl/ewk_auth_challenge_private.h
Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/WebKit2/UIProcess/WebLoaderClient.cpp
Source/WebKit2/UIProcess/WebLoaderClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/efl/PageLoadClientEfl.cpp
Source/WebKit2/UIProcess/efl/PageLoadClientEfl.h
Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp
Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp

index 3843ebb..f97cd44 100755 (executable)
@@ -76,7 +76,11 @@ typedef void (*WKPageDidDisplayInsecureContentForFrameCallback)(WKPageRef page,
 typedef void (*WKPageDidRunInsecureContentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
 typedef void (*WKPageDidDetectXSSForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
 typedef bool (*WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback)(WKPageRef page, WKFrameRef frame, WKProtectionSpaceRef protectionSpace, const void *clientInfo);
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+typedef bool (*WKPageDidReceiveAuthenticationChallengeInFrameCallback)(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo);
+#else
 typedef void (*WKPageDidReceiveAuthenticationChallengeInFrameCallback)(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo);
+#endif
 typedef void (*WKPageDidChangeBackForwardListCallback)(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void *clientInfo);
 typedef bool (*WKPageShouldGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, const void *clientInfo);
 typedef void (*WKPageDidNewFirstVisuallyNonEmptyLayoutCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo);
index 2c605ce..650d8fd 100755 (executable)
@@ -250,8 +250,6 @@ EwkViewImpl::~EwkViewImpl()
     }
 #endif
 
-    if (authChallenge)
-        ewkAuthChallengeDelete(authChallenge);
     if (policyDecision)
         ewkPolicyDecisionDelete(policyDecision);
 
index 29ca054..70918a0 100644 (file)
@@ -42,6 +42,9 @@ using namespace WebKit;
  */
 struct _Ewk_Auth_Challenge {
     WKAuthenticationChallengeRef authenticationChallenge;
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+    WKPageRef page;
+#endif
 
     CString realm;
     CString url;
@@ -50,7 +53,11 @@ struct _Ewk_Auth_Challenge {
     bool isSuspended;
 };
 
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+Ewk_Auth_Challenge* ewkAuthChallengeCreate(WKPageRef page, WKAuthenticationChallengeRef authenticationChallenge)
+#else
 Ewk_Auth_Challenge* ewkAuthChallengeCreate(WKAuthenticationChallengeRef authenticationChallenge)
+#endif
 {
     EINA_SAFETY_ON_NULL_RETURN_VAL(authenticationChallenge, 0);
 
@@ -62,6 +69,9 @@ Ewk_Auth_Challenge* ewkAuthChallengeCreate(WKAuthenticationChallengeRef authenti
 
     Ewk_Auth_Challenge* authChallenge = new Ewk_Auth_Challenge;
 
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+    authChallenge->page = page;
+#endif
     authChallenge->authenticationChallenge = authenticationChallenge;
     authChallenge->realm = toImpl(realmString.get())->string().utf8();
     authChallenge->url = toImpl(hostString.get())->string().utf8();
@@ -121,6 +131,7 @@ void ewk_auth_challenge_credential_use(Ewk_Auth_Challenge* authChallenge, char*
     EINA_SAFETY_ON_NULL_RETURN(password);
 
     authChallenge->isDecided = true;
+    toImpl(authChallenge->page)->replyReceiveAuthenticationChallengeInFrame(true);
 
     WKAuthenticationChallengeRef authenticationChallenge = authChallenge->authenticationChallenge;
     WKAuthenticationDecisionListenerRef authenticationDecisionListener = WKAuthenticationChallengeGetDecisionListener(authenticationChallenge);
@@ -131,6 +142,8 @@ void ewk_auth_challenge_credential_use(Ewk_Auth_Challenge* authChallenge, char*
     WKRetainPtr<WKCredentialRef> credential(AdoptWK, WKCredentialCreate(userString.get(), passwordString.get(), kWKCredentialPersistenceNone));
 
     WKAuthenticationDecisionListenerUseCredential(authenticationDecisionListener, credential.get());
+    ewkAuthChallengeDelete(authChallenge);
+
 }
 
 void ewk_auth_challenge_credential_cancel(Ewk_Auth_Challenge* authChallenge)
@@ -138,11 +151,13 @@ void ewk_auth_challenge_credential_cancel(Ewk_Auth_Challenge* authChallenge)
     EINA_SAFETY_ON_NULL_RETURN(authChallenge);
 
     authChallenge->isDecided = true;
+    toImpl(authChallenge->page)->replyReceiveAuthenticationChallengeInFrame(false);
 
     WKAuthenticationChallengeRef authenticationChallenge = authChallenge->authenticationChallenge;
     WKAuthenticationDecisionListenerRef authenticationDecisionListener = WKAuthenticationChallengeGetDecisionListener(authenticationChallenge);
 
     WKAuthenticationDecisionListenerCancel(authenticationDecisionListener);
+    ewkAuthChallengeDelete(authChallenge);
 }
 
 #endif // #if OS(TIZEN)
index 00e30c8..f8a3cb9 100644 (file)
 #include "WKAuthenticationChallenge.h"
 #include "ewk_auth_challenge.h"
 
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+Ewk_Auth_Challenge* ewkAuthChallengeCreate(WKPageRef page, WKAuthenticationChallengeRef authenticationChallenge);
+#else
 Ewk_Auth_Challenge* ewkAuthChallengeCreate(WKAuthenticationChallengeRef authenticationChallenge);
+#endif
 void ewkAuthChallengeDelete(Ewk_Auth_Challenge* authChallenge);
 bool ewkAuthChallengeDecided(Ewk_Auth_Challenge* authChallenge);
 bool ewkAuthChallengeSuspended(Ewk_Auth_Challenge* authChallenge);
 
-#endif // ewk_auth_challenge_private_h
\ No newline at end of file
+#endif // ewk_auth_challenge_private_h
index a46eede..f1e6bcb 100644 (file)
@@ -2004,8 +2004,6 @@ void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Cha
     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
 
-    if (impl->authChallenge)
-        ewkAuthChallengeDelete(impl->authChallenge);
     impl->authChallenge = authChallenge;
 
     evas_object_smart_callback_call(ewkView, "authentication,challenge", impl->authChallenge);
index 4d3c459..98ca732 100644 (file)
@@ -196,6 +196,15 @@ bool WebLoaderClient::canAuthenticateAgainstProtectionSpaceInFrame(WebPageProxy*
     return m_client.canAuthenticateAgainstProtectionSpaceInFrame(toAPI(page), toAPI(frame), toAPI(protectionSpace), m_client.clientInfo);
 }
 
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+bool WebLoaderClient::didReceiveAuthenticationChallengeInFrame(WebPageProxy* page, WebFrameProxy* frame, AuthenticationChallengeProxy* authenticationChallenge)
+{
+    if (!m_client.didReceiveAuthenticationChallengeInFrame)
+        return false;
+
+    return m_client.didReceiveAuthenticationChallengeInFrame(toAPI(page), toAPI(frame), toAPI(authenticationChallenge), m_client.clientInfo);
+}
+#else
 void WebLoaderClient::didReceiveAuthenticationChallengeInFrame(WebPageProxy* page, WebFrameProxy* frame, AuthenticationChallengeProxy* authenticationChallenge)
 {
     if (!m_client.didReceiveAuthenticationChallengeInFrame)
@@ -203,6 +212,7 @@ void WebLoaderClient::didReceiveAuthenticationChallengeInFrame(WebPageProxy* pag
 
     m_client.didReceiveAuthenticationChallengeInFrame(toAPI(page), toAPI(frame), toAPI(authenticationChallenge), m_client.clientInfo);
 }
+#endif
 
 void WebLoaderClient::didStartProgress(WebPageProxy* page)
 {
index f1291a2..632e855 100644 (file)
@@ -85,7 +85,11 @@ public:
     void didNewFirstVisuallyNonEmptyLayout(WebPageProxy*, APIObject*);
     
     bool canAuthenticateAgainstProtectionSpaceInFrame(WebPageProxy*, WebFrameProxy*, WebProtectionSpace*);
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+    bool didReceiveAuthenticationChallengeInFrame(WebPageProxy*, WebFrameProxy*, AuthenticationChallengeProxy*);
+#else
     void didReceiveAuthenticationChallengeInFrame(WebPageProxy*, WebFrameProxy*, AuthenticationChallengeProxy*);
+#endif
 
     void didStartProgress(WebPageProxy*);
     void didChangeProgress(WebPageProxy*);
index 82b1771..2a78b55 100755 (executable)
@@ -4237,18 +4237,26 @@ void WebPageProxy::canAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID
     canAuthenticate = m_loaderClient.canAuthenticateAgainstProtectionSpaceInFrame(this, frame, protectionSpace.get());
 }
 
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+void WebPageProxy::didReceiveAuthenticationChallenge(uint64_t frameID, const AuthenticationChallenge& coreChallenge, uint64_t challengeID, PassRefPtr<Messages::WebPageProxy::DidReceiveAuthenticationChallenge::DelayedReply> reply)
+#else
 void WebPageProxy::didReceiveAuthenticationChallenge(uint64_t frameID, const AuthenticationChallenge& coreChallenge, uint64_t challengeID)
+#endif
 {
     WebFrameProxy* frame = process()->webFrame(frameID);
     MESSAGE_CHECK(frame);
 
 #if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
     RefPtr<AuthenticationChallengeProxy> authenticationChallenge = frame->setUpAuthenticationChallengeProxy(coreChallenge, challengeID, process());
+    m_AuthReply = reply;
+
+    if (!m_loaderClient.didReceiveAuthenticationChallengeInFrame(this, frame, authenticationChallenge.get()))
+        replyReceiveAuthenticationChallengeInFrame(true);
 #else
     RefPtr<AuthenticationChallengeProxy> authenticationChallenge = AuthenticationChallengeProxy::create(coreChallenge, challengeID, process());
-#endif
 
     m_loaderClient.didReceiveAuthenticationChallengeInFrame(this, frame, authenticationChallenge.get());
+#endif
 }
 
 #if ENABLE(TIZEN_SQL_DATABASE)
index c1f8e82..00b6c41 100644 (file)
@@ -921,6 +921,10 @@ public:
 #endif
 #endif
 
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+    void replyReceiveAuthenticationChallengeInFrame(bool result);
+#endif
+
 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
     void replyPolicyForCertificateError(bool result);
 #endif
@@ -1335,7 +1339,11 @@ private:
     void frameSetLargestFrameChanged(uint64_t frameID);
 
     void canAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID, const WebCore::ProtectionSpace&, bool& canAuthenticate);
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+    void didReceiveAuthenticationChallenge(uint64_t frameID, const WebCore::AuthenticationChallenge&, uint64_t challengeID, PassRefPtr<Messages::WebPageProxy::DidReceiveAuthenticationChallenge::DelayedReply>);
+#else
     void didReceiveAuthenticationChallenge(uint64_t frameID, const WebCore::AuthenticationChallenge&, uint64_t challengeID);
+#endif
 
     void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&);
 
@@ -1653,6 +1661,10 @@ private:
 #endif
 #endif
 
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+    RefPtr<Messages::WebPageProxy::DidReceiveAuthenticationChallenge::DelayedReply> m_AuthReply;
+#endif
+
 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
     RefPtr<Messages::WebPageProxy::DecidePolicyForCertificateError::DelayedReply> m_allowedReply;
 #endif
index 8d3cb98..607a3c7 100755 (executable)
@@ -301,7 +301,12 @@ messages -> WebPageProxy {
 
     # Authentication messages
     CanAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID, WebCore::ProtectionSpace protectionSpace) -> (bool canAuthenticate)
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+    DidReceiveAuthenticationChallenge(uint64_t frameID, WebCore::AuthenticationChallenge challenge, uint64_t challengeID) -> (bool canAuthenticate) Delayed
+#endif
+#if !ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
     DidReceiveAuthenticationChallenge(uint64_t frameID, WebCore::AuthenticationChallenge challenge, uint64_t challengeID)
+#endif
 
     # Database messages
 #if ENABLE(TIZEN_SQL_DATABASE)
index 7568466..8d4c977 100755 (executable)
@@ -191,6 +191,24 @@ void PageLoadClientEfl::didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef page, W
     ewkViewDidFirstVisuallyNonEmptyLayout(ewkView);
 }
 
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+bool PageLoadClientEfl::didReceiveAuthenticationChallengeInFrame(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void* clientInfo)
+{
+#if !ENABLE(TIZEN_AUTHENTICATION_CHALLENGE_ENABLED_IN_ALL_FRAMES)
+    if (!WKFrameIsMainFrame(frame))
+        return false;
+#endif
+
+    Evas_Object* ewkView = toPageLoadClientEfl(clientInfo)->viewImpl()->view();
+    Ewk_Auth_Challenge* authChallenge = ewkAuthChallengeCreate(page, authenticationChallenge);
+    ewkViewDidReceiveAuthenticationChallenge(ewkView, authChallenge);
+
+    if (!ewkAuthChallengeDecided(authChallenge) && !ewkAuthChallengeSuspended(authChallenge))
+        ewk_auth_challenge_credential_cancel(authChallenge);
+
+    return true;
+}
+#else
 void PageLoadClientEfl::didReceiveAuthenticationChallengeInFrame(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void* clientInfo)
 {
 #if !ENABLE(TIZEN_AUTHENTICATION_CHALLENGE_ENABLED_IN_ALL_FRAMES)
@@ -205,6 +223,7 @@ void PageLoadClientEfl::didReceiveAuthenticationChallengeInFrame(WKPageRef page,
     if (!ewkAuthChallengeDecided(authChallenge) && !ewkAuthChallengeSuspended(authChallenge))
         ewk_auth_challenge_credential_cancel(authChallenge);
 }
+#endif
 
 void PageLoadClientEfl::processDidCrash(WKPageRef page, const void* clientInfo)
 {
index e84eb25..fbb033b 100755 (executable)
@@ -65,7 +65,11 @@ private:
 #if OS(TIZEN)
     static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo);
     static void didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo);
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+    static bool didReceiveAuthenticationChallengeInFrame(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void* clientInfo);
+#else
     static void didReceiveAuthenticationChallengeInFrame(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void* clientInfo);
+#endif
     static void processDidCrash(WKPageRef page, const void* clientInfo);
 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
     static void didStartProgress(WKPageRef page, const void* clientInfo);
index db7a0a1..2c1d87e 100644 (file)
@@ -749,6 +749,17 @@ void WebPageProxy::replyBeforeUnloadConfirmPanel(bool result)
 }
 #endif
 
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+void WebPageProxy::replyReceiveAuthenticationChallengeInFrame(bool result)
+{
+    if (!m_AuthReply)
+        return;
+
+    m_AuthReply->send(result);
+    m_AuthReply = nullptr;
+}
+#endif
+
 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
 void WebPageProxy::replyPolicyForCertificateError(bool result)
 {
index 44e8306..ac5f70f 100644 (file)
@@ -69,8 +69,13 @@ void AuthenticationManager::didReceiveAuthenticationChallenge(WebFrame* frame, c
 
     uint64_t challengeID = generateAuthenticationChallengeID();
     m_challenges.set(challengeID, authenticationChallenge);    
-    
+
+#if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
+    bool canAuthenticate = false;
+    WebProcess::shared().connection()->sendSync(Messages::WebPageProxy::DidReceiveAuthenticationChallenge(frame->frameID(), authenticationChallenge, challengeID), Messages::WebPageProxy::DidReceiveAuthenticationChallenge::Reply(canAuthenticate), frame->page()->pageID());
+#else
     WebProcess::shared().connection()->send(Messages::WebPageProxy::DidReceiveAuthenticationChallenge(frame->frameID(), authenticationChallenge, challengeID), frame->page()->pageID());
+#endif
 }
 
 void AuthenticationManager::didReceiveAuthenticationChallenge(Download* download, const AuthenticationChallenge& authenticationChallenge)