Changeset 210785 in webkit
- Timestamp:
- Jan 16, 2017 3:24:23 AM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r210781 r210785 1 2017-01-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [SOUP] Fix handling of accept language property 4 https://bugs.webkit.org/show_bug.cgi?id=166969 5 6 Reviewed by Michael Catanzaro. 7 8 Add SoupNetworkSession::setInitialAcceptLanguages() static method and update setAcceptLanguages to receive the 9 string already built from the languages vector. Now the SoupNetworkSession saves that value globally that 10 is always used when creating new sessions. 11 12 * platform/network/soup/NetworkStorageSessionSoup.cpp: 13 (WebCore::NetworkStorageSession::switchToNewTestingSession): Remove workaround. 14 * platform/network/soup/SoupNetworkSession.cpp: 15 (WebCore::SoupNetworkSession::SoupNetworkSession): If initial accept languages were set, apply them to the newly created context. 16 (WebCore::SoupNetworkSession::setInitialAcceptLanguages): Just save the given value globally. 17 (WebCore::SoupNetworkSession::setAcceptLanguages): It receives now the string, so just set it to the session. 18 * platform/network/soup/SoupNetworkSession.h: 19 1 20 2017-01-15 Michael Catanzaro <mcatanzaro@igalia.com> 2 21 -
trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp
r210729 r210785 85 85 { 86 86 defaultSession() = std::make_unique<NetworkStorageSession>(SessionID::defaultSessionID(), std::make_unique<SoupNetworkSession>()); 87 // FIXME: Creating a testing session is losing soup session values set when initializing the network process.88 g_object_set(defaultSession()->soupNetworkSession().soupSession(), "accept-language", "en-us", nullptr);89 87 } 90 88 -
trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp
r210729 r210785 42 42 #include <wtf/text/Base64.h> 43 43 #include <wtf/text/CString.h> 44 #include <wtf/text/StringBuilder.h>45 44 46 45 namespace WebCore { 47 46 48 47 static bool gIgnoreTLSErrors; 48 static CString gInitialAcceptLanguages; 49 49 50 50 #if !LOG_DISABLED … … 139 139 nullptr); 140 140 141 if (!gInitialAcceptLanguages.isNull()) 142 setAcceptLanguages(gInitialAcceptLanguages); 143 141 144 #if SOUP_CHECK_VERSION(2, 53, 92) 142 145 if (soup_auth_negotiate_supported()) { … … 248 251 } 249 252 250 static CString buildAcceptLanguages(const Vector<String>& languages) 251 { 252 size_t languagesCount = languages.size(); 253 254 // Ignore "C" locale. 255 size_t cLocalePosition = languages.find("c"); 256 if (cLocalePosition != notFound) 257 languagesCount--; 258 259 // Fallback to "en" if the list is empty. 260 if (!languagesCount) 261 return "en"; 262 263 // Calculate deltas for the quality values. 264 int delta; 265 if (languagesCount < 10) 266 delta = 10; 267 else if (languagesCount < 20) 268 delta = 5; 269 else 270 delta = 1; 271 272 // Set quality values for each language. 273 StringBuilder builder; 274 for (size_t i = 0; i < languages.size(); ++i) { 275 if (i == cLocalePosition) 276 continue; 277 278 if (i) 279 builder.appendLiteral(", "); 280 281 builder.append(languages[i]); 282 283 int quality = 100 - i * delta; 284 if (quality > 0 && quality < 100) { 285 char buffer[8]; 286 g_ascii_formatd(buffer, 8, "%.2f", quality / 100.0); 287 builder.append(String::format(";q=%s", buffer)); 288 } 289 } 290 291 return builder.toString().utf8(); 292 } 293 294 void SoupNetworkSession::setAcceptLanguages(const Vector<String>& languages) 295 { 296 g_object_set(m_soupSession.get(), "accept-language", buildAcceptLanguages(languages).data(), nullptr); 253 254 void SoupNetworkSession::setInitialAcceptLanguages(const CString& languages) 255 { 256 gInitialAcceptLanguages = languages; 257 } 258 259 void SoupNetworkSession::setAcceptLanguages(const CString& languages) 260 { 261 g_object_set(m_soupSession.get(), "accept-language", languages.data(), nullptr); 297 262 } 298 263 -
trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.h
r210781 r210785 59 59 void setupHTTPProxyFromEnvironment(); 60 60 61 void setAcceptLanguages(const Vector<String>&); 61 static void setInitialAcceptLanguages(const CString&); 62 void setAcceptLanguages(const CString&); 62 63 63 64 static void setShouldIgnoreTLSErrors(bool); -
trunk/Source/WebKit2/ChangeLog
r210765 r210785 1 2017-01-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [SOUP] Fix handling of accept language property 4 https://bugs.webkit.org/show_bug.cgi?id=166969 5 6 Reviewed by Michael Catanzaro. 7 8 * NetworkProcess/soup/NetworkProcessSoup.cpp: 9 (WebKit::buildAcceptLanguages): Moved from WebCore. 10 (WebKit::NetworkProcess::userPreferredLanguagesChanged): Build the accept language string from the vector and 11 pass set it to SoupNetworkSession to be used for new sessions, and also to all other existing sessions. 12 1 13 2017-01-14 Tim Horton <timothy_horton@apple.com> 2 14 -
trunk/Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp
r210729 r210785 42 42 #include <wtf/glib/GRefPtr.h> 43 43 #include <wtf/glib/GUniquePtr.h> 44 #include <wtf/text/CString.h> 45 #include <wtf/text/StringBuilder.h> 44 46 45 47 using namespace WebCore; … … 47 49 namespace WebKit { 48 50 51 static CString buildAcceptLanguages(const Vector<String>& languages) 52 { 53 size_t languagesCount = languages.size(); 54 55 // Ignore "C" locale. 56 size_t cLocalePosition = languages.find("c"); 57 if (cLocalePosition != notFound) 58 languagesCount--; 59 60 // Fallback to "en" if the list is empty. 61 if (!languagesCount) 62 return "en"; 63 64 // Calculate deltas for the quality values. 65 int delta; 66 if (languagesCount < 10) 67 delta = 10; 68 else if (languagesCount < 20) 69 delta = 5; 70 else 71 delta = 1; 72 73 // Set quality values for each language. 74 StringBuilder builder; 75 for (size_t i = 0; i < languages.size(); ++i) { 76 if (i == cLocalePosition) 77 continue; 78 79 if (i) 80 builder.appendLiteral(", "); 81 82 builder.append(languages[i]); 83 84 int quality = 100 - i * delta; 85 if (quality > 0 && quality < 100) { 86 char buffer[8]; 87 g_ascii_formatd(buffer, 8, "%.2f", quality / 100.0); 88 builder.append(String::format(";q=%s", buffer)); 89 } 90 } 91 92 return builder.toString().utf8(); 93 } 94 49 95 void NetworkProcess::userPreferredLanguagesChanged(const Vector<String>& languages) 50 96 { 51 NetworkStorageSession::defaultStorageSession().soupNetworkSession().setAcceptLanguages(languages); 97 auto acceptLanguages = buildAcceptLanguages(languages); 98 SoupNetworkSession::setInitialAcceptLanguages(acceptLanguages); 99 NetworkStorageSession::forEach([&acceptLanguages](const WebCore::NetworkStorageSession& session) { 100 session.soupNetworkSession().setAcceptLanguages(acceptLanguages); 101 }); 52 102 } 53 103
Note: See TracChangeset
for help on using the changeset viewer.