[GTK] Test /webkit2/WebKitWebContext/languages crashes with network process enabled
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jan 2014 17:30:21 +0000 (17:30 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jan 2014 17:30:21 +0000 (17:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126130

Reviewed by Anders Carlsson.

We need to notify the network process when the user preferred
languages have changed to update the SoupSession accordingly.

* NetworkProcess/NetworkProcess.h: Add
userPreferredLanguagesChanged when using soup network backend.
* NetworkProcess/NetworkProcess.messages.in: Add
UserPreferredLanguagesChanged message when using soup network
backend.
* NetworkProcess/soup/NetworkProcessSoup.cpp:
(WebKit::NetworkProcess::userPreferredLanguagesChanged): Update
the SoupSession to use the given languages.
(WebKit::NetworkProcess::platformInitializeNetworkProcess): Call
userPreferredLanguagesChanged() when initialization parameters
contain languages.
(WebKit::NetworkProcess::allowSpecificHTTPSCertificateForHost):
Remove unnedded WebCore prefix.
(WebKit::NetworkProcess::clearCacheForAllOrigins): Simplify using
a single line.
* Shared/Network/NetworkProcessCreationParameters.cpp:
(WebKit::NetworkProcessCreationParameters::encode): Encode the
languages vector.
(WebKit::NetworkProcessCreationParameters::decode): Decode the
languages vector.
* Shared/Network/NetworkProcessCreationParameters.h:
* UIProcess/WebContext.cpp:
(WebKit::WebContext::languageChanged): Send a message also to the
network process.
* UIProcess/soup/WebContextSoup.cpp:
(WebKit::WebContext::platformInitializeNetworkProcess): Set
languages initial parameter.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161976 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkProcess.h
Source/WebKit2/NetworkProcess/NetworkProcess.messages.in
Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp
Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.cpp
Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.h
Source/WebKit2/UIProcess/WebContext.cpp
Source/WebKit2/UIProcess/soup/WebContextSoup.cpp

index 39efcb1..c780e25 100644 (file)
@@ -1,5 +1,43 @@
 2014-01-14  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        [GTK] Test /webkit2/WebKitWebContext/languages crashes with network process enabled
+        https://bugs.webkit.org/show_bug.cgi?id=126130
+
+        Reviewed by Anders Carlsson.
+
+        We need to notify the network process when the user preferred
+        languages have changed to update the SoupSession accordingly.
+
+        * NetworkProcess/NetworkProcess.h: Add
+        userPreferredLanguagesChanged when using soup network backend.
+        * NetworkProcess/NetworkProcess.messages.in: Add
+        UserPreferredLanguagesChanged message when using soup network
+        backend.
+        * NetworkProcess/soup/NetworkProcessSoup.cpp:
+        (WebKit::NetworkProcess::userPreferredLanguagesChanged): Update
+        the SoupSession to use the given languages.
+        (WebKit::NetworkProcess::platformInitializeNetworkProcess): Call
+        userPreferredLanguagesChanged() when initialization parameters
+        contain languages.
+        (WebKit::NetworkProcess::allowSpecificHTTPSCertificateForHost):
+        Remove unnedded WebCore prefix.
+        (WebKit::NetworkProcess::clearCacheForAllOrigins): Simplify using
+        a single line.
+        * Shared/Network/NetworkProcessCreationParameters.cpp:
+        (WebKit::NetworkProcessCreationParameters::encode): Encode the
+        languages vector.
+        (WebKit::NetworkProcessCreationParameters::decode): Decode the
+        languages vector.
+        * Shared/Network/NetworkProcessCreationParameters.h:
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::languageChanged): Send a message also to the
+        network process.
+        * UIProcess/soup/WebContextSoup.cpp:
+        (WebKit::WebContext::platformInitializeNetworkProcess): Set
+        languages initial parameter.
+
+2014-01-14  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         [SOUP] SoupNetworkSession::setAcceptLanguages should receive a const reference
         https://bugs.webkit.org/show_bug.cgi?id=126966
 
index acd2710..248e3ac 100644 (file)
@@ -115,6 +115,7 @@ private:
 
 #if USE(SOUP)
     void setIgnoreTLSErrors(bool);
+    void userPreferredLanguagesChanged(const Vector<String>&);
 #endif
 
     // Platform Helpers
index 3525d6c..6ad6c25 100644 (file)
@@ -31,6 +31,7 @@ messages -> NetworkProcess LegacyReceiver {
 
 #if USE(SOUP)
     SetIgnoreTLSErrors(bool ignoreTLSErrors)
+    UserPreferredLanguagesChanged(Vector<String> languages)
 #endif
 
     EnsurePrivateBrowsingSession()
index 58dd5c6..55c14fa 100644 (file)
 #if ENABLE(NETWORK_PROCESS)
 #include "NetworkProcess.h"
 
-#include "CertificateInfo.h"
 #include "NetworkProcessCreationParameters.h"
 #include "ResourceCachesToClear.h"
 #include "WebCookieManager.h"
+#include <WebCore/CertificateInfo.h>
 #include <WebCore/FileSystem.h>
 #include <WebCore/NotImplemented.h>
 #include <WebCore/ResourceHandle.h>
@@ -75,6 +75,11 @@ static uint64_t getMemorySize()
 #endif
 }
 
+void NetworkProcess::userPreferredLanguagesChanged(const Vector<String>& languages)
+{
+    SoupNetworkSession::defaultSession().setAcceptLanguages(languages);
+}
+
 void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreationParameters& parameters)
 {
     ASSERT(!parameters.diskCacheDirectory.isEmpty());
@@ -88,6 +93,9 @@ void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreati
     }
     supplement<WebCookieManager>()->setHTTPCookieAcceptPolicy(parameters.cookieAcceptPolicy);
 
+    if (!parameters.languages.isEmpty())
+        userPreferredLanguagesChanged(parameters.languages);
+
     setIgnoreTLSErrors(parameters.ignoreTLSErrors);
 }
 
@@ -121,7 +129,7 @@ void NetworkProcess::setIgnoreTLSErrors(bool ignoreTLSErrors)
 
 void NetworkProcess::allowSpecificHTTPSCertificateForHost(const CertificateInfo& certificateInfo, const String& host)
 {
-    WebCore::ResourceHandle::setClientCertificate(host, certificateInfo.certificate());
+    ResourceHandle::setClientCertificate(host, certificateInfo.certificate());
 }
 
 void NetworkProcess::clearCacheForAllOrigins(uint32_t cachesToClear)
index f267c66..e16f5ea 100644 (file)
@@ -59,6 +59,7 @@ void NetworkProcessCreationParameters::encode(IPC::ArgumentEncoder& encoder) con
     encoder << cookiePersistentStorageType;
     encoder.encodeEnum(cookieAcceptPolicy);
     encoder << ignoreTLSErrors;
+    encoder << languages;
 #endif
 }
 
@@ -102,6 +103,8 @@ bool NetworkProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, Net
         return false;
     if (!decoder.decode(result.ignoreTLSErrors))
         return false;
+    if (!decoder.decode(result.languages))
+        return false;
 #endif
 
     return true;
index e89889b..bf6e7b5 100644 (file)
@@ -77,6 +77,7 @@ struct NetworkProcessCreationParameters {
     uint32_t cookiePersistentStorageType;
     HTTPCookieAcceptPolicy cookieAcceptPolicy;
     bool ignoreTLSErrors;
+    Vector<String> languages;
 #endif
 };
 
index c0bc387..e10515b 100644 (file)
@@ -323,6 +323,10 @@ void WebContext::languageChanged(void* context)
 void WebContext::languageChanged()
 {
     sendToAllProcesses(Messages::WebProcess::UserPreferredLanguagesChanged(userPreferredLanguages()));
+#if USE(SOUP) && ENABLE(NETWORK_PROCESS)
+    if (m_usesNetworkProcess && m_networkProcess)
+        m_networkProcess->send(Messages::NetworkProcess::UserPreferredLanguagesChanged(userPreferredLanguages()), 0);
+#endif
 }
 
 void WebContext::fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled)
index 881c034..2c4855b 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "NetworkProcessCreationParameters.h"
 #include "WebCookieManagerProxy.h"
+#include <WebCore/Language.h>
 
 namespace WebKit {
 
@@ -37,6 +38,7 @@ void WebContext::platformInitializeNetworkProcess(NetworkProcessCreationParamete
     supplement<WebCookieManagerProxy>()->getCookiePersistentStorage(parameters.cookiePersistentStoragePath, parameters.cookiePersistentStorageType);
     parameters.cookieAcceptPolicy = m_initialHTTPCookieAcceptPolicy;
     parameters.ignoreTLSErrors = m_ignoreTLSErrors;
+    parameters.languages = WebCore::userPreferredLanguages();
 }
 
 }