Changeset 211140 in webkit


Ignore:
Timestamp:
Jan 25, 2017 4:22:54 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

[SOUP] Custom protocols don't work in private browsing mode
https://bugs.webkit.org/show_bug.cgi?id=167236

Reviewed by Sergio Villar Senin.

Source/WebCore:

Add static method to set the global custom protocols request type and setup method to add the feature to the session.

  • platform/network/soup/SoupNetworkSession.cpp:

(WebCore::SoupNetworkSession::SoupNetworkSession):
(WebCore::SoupNetworkSession::setCustomProtocolRequestType):
(WebCore::SoupNetworkSession::setupCustomProtocols):

  • platform/network/soup/SoupNetworkSession.h:

Source/WebKit2:

We only register them in the default session, they should be registered in all existing sessions, and also on
newly created ones.

  • NetworkProcess/CustomProtocols/soup/CustomProtocolManagerSoup.cpp:

(WebKit::CustomProtocolManager::registerProtocolClass): Set the WEBKIT_TYPE_SOUP_REQUEST_GENERIC as type for
custom protocols.
(WebKit::CustomProtocolManager::registerScheme): Use g_type_class_peek instead of g_type_class_ref since we know
the class was already created in registerProtocolClass(). Setup custom protocols in all existing sessions.

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r211139 r211140  
     12017-01-25  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [SOUP] Custom protocols don't work in private browsing mode
     4        https://bugs.webkit.org/show_bug.cgi?id=167236
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        Add static method to set the global custom protocols request type and setup method to add the feature to the session.
     9
     10        * platform/network/soup/SoupNetworkSession.cpp:
     11        (WebCore::SoupNetworkSession::SoupNetworkSession):
     12        (WebCore::SoupNetworkSession::setCustomProtocolRequestType):
     13        (WebCore::SoupNetworkSession::setupCustomProtocols):
     14        * platform/network/soup/SoupNetworkSession.h:
     15
    1162017-01-25  Ryosuke Niwa  <rniwa@webkit.org>
    217
  • trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp

    r211027 r211140  
    4949static CString gInitialAcceptLanguages;
    5050static SoupNetworkProxySettings gProxySettings;
     51static GType gCustomProtocolRequestType;
    5152
    5253#if !LOG_DISABLED
     
    140141        SOUP_SESSION_SSL_STRICT, FALSE,
    141142        nullptr);
     143
     144    setupCustomProtocols();
    142145
    143146    if (!gInitialAcceptLanguages.isNull())
     
    290293}
    291294
     295void SoupNetworkSession::setCustomProtocolRequestType(GType requestType)
     296{
     297    ASSERT(g_type_is_a(requestType, SOUP_TYPE_REQUEST));
     298    gCustomProtocolRequestType = requestType;
     299}
     300
     301void SoupNetworkSession::setupCustomProtocols()
     302{
     303    if (!g_type_is_a(gCustomProtocolRequestType, SOUP_TYPE_REQUEST))
     304        return;
     305
     306    auto* requestClass = static_cast<SoupRequestClass*>(g_type_class_peek(gCustomProtocolRequestType));
     307    if (!requestClass || !requestClass->schemes)
     308        return;
     309
     310    soup_session_add_feature_by_type(m_soupSession.get(), gCustomProtocolRequestType);
     311}
     312
    292313void SoupNetworkSession::setShouldIgnoreTLSErrors(bool ignoreTLSErrors)
    293314{
  • trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.h

    r211014 r211140  
    3333#include <wtf/text/WTFString.h>
    3434
     35typedef size_t GType;
    3536typedef struct _SoupCache SoupCache;
    3637typedef struct _SoupCookieJar SoupCookieJar;
     
    7172    static void allowSpecificHTTPSCertificateForHost(const CertificateInfo&, const String& host);
    7273
     74    static void setCustomProtocolRequestType(GType);
     75    void setupCustomProtocols();
     76
    7377private:
    7478    void setupLogger();
  • trunk/Source/WebKit2/ChangeLog

    r211138 r211140  
     12017-01-25  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [SOUP] Custom protocols don't work in private browsing mode
     4        https://bugs.webkit.org/show_bug.cgi?id=167236
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        We only register them in the default session, they should be registered in all existing sessions, and also on
     9        newly created ones.
     10
     11        * NetworkProcess/CustomProtocols/soup/CustomProtocolManagerSoup.cpp:
     12        (WebKit::CustomProtocolManager::registerProtocolClass): Set the WEBKIT_TYPE_SOUP_REQUEST_GENERIC as type for
     13        custom protocols.
     14        (WebKit::CustomProtocolManager::registerScheme): Use g_type_class_peek instead of g_type_class_ref since we know
     15        the class was already created in registerProtocolClass(). Setup custom protocols in all existing sessions.
     16
    1172017-01-24  Carlos Garcia Campos  <cgarcia@igalia.com>
    218
  • trunk/Source/WebKit2/NetworkProcess/CustomProtocols/soup/CustomProtocolManagerSoup.cpp

    r211014 r211140  
    7878{
    7979    static_cast<WebKitSoupRequestGenericClass*>(g_type_class_ref(WEBKIT_TYPE_SOUP_REQUEST_GENERIC))->client = &CustomProtocolRequestClient::singleton();
     80    SoupNetworkSession::setCustomProtocolRequestType(WEBKIT_TYPE_SOUP_REQUEST_GENERIC);
    8081}
    8182
     
    9091    g_ptr_array_add(m_registeredSchemes.get(), nullptr);
    9192
    92     auto* genericRequestClass = static_cast<SoupRequestClass*>(g_type_class_ref(WEBKIT_TYPE_SOUP_REQUEST_GENERIC));
     93    auto* genericRequestClass = static_cast<SoupRequestClass*>(g_type_class_peek(WEBKIT_TYPE_SOUP_REQUEST_GENERIC));
     94    ASSERT(genericRequestClass);
    9395    genericRequestClass->schemes = const_cast<const char**>(reinterpret_cast<char**>(m_registeredSchemes->pdata));
    94     soup_session_add_feature_by_type(NetworkStorageSession::defaultStorageSession().getOrCreateSoupNetworkSession().soupSession(), WEBKIT_TYPE_SOUP_REQUEST_GENERIC);
     96    NetworkStorageSession::forEach([](const WebCore::NetworkStorageSession& session) {
     97        if (auto* soupSession = session.soupNetworkSession())
     98            soupSession->setupCustomProtocols();
     99    });
    95100}
    96101
Note: See TracChangeset for help on using the changeset viewer.