Changeset 153355 in webkit


Ignore:
Timestamp:
Jul 25, 2013 4:23:42 PM (11 years ago)
Author:
kseo@webkit.org
Message:

[WK2][Soup] Add private browsing support
https://bugs.webkit.org/show_bug.cgi?id=118657

Reviewed by Gustavo Noronha Silva.

Source/WebCore:

Support private browsing by adding a method to create a private
browsing soup session. This private browsing session uses a
non-persistent cookie jar and does not use the disk cache feature.

No new tests. Covered by existing private browsing tests.

  • platform/network/NetworkStorageSession.h:

(WebCore::NetworkStorageSession::isPrivateBrowsingSession):
Add USE(SOUP) guard to isPrivateBrowsingSession() and m_isPrivate.

  • platform/network/ResourceHandle.h:

Add a factory method to create a private browsing session for soup.

  • platform/network/soup/CookieJarSoup.cpp:

(WebCore::createPrivateBrowsingCookieJar):

  • platform/network/soup/CookieJarSoup.h:

Add a method to create a non-persistent cookie jar for private browsing.

  • platform/network/soup/NetworkStorageSessionSoup.cpp:

(WebCore::NetworkStorageSession::NetworkStorageSession):
Initialize m_isPrivate to false.
(WebCore::NetworkStorageSession::createPrivateBrowsingSession):
Implement the method by invoking ResourceHandle::createPrivateBrowsingSession.

  • platform/network/soup/ResourceHandleSoup.cpp:

(WebCore::createSoupSession):
Extract common soup session creation code so that both defaultSession
and createPrivateBrowsingSession can use this function to create a soup
session.
(WebCore::ResourceHandle::defaultSession):
Change to use createSoupSession.
(WebCore::ResourceHandle::createPrivateBrowsingSession):
Create a session which uses a non-persistent cookie jar.

Source/WebKit2:

Support private browsing in WK2 by implementing private browsing
related methods in WebFrameNetworkingContext.

  • WebProcess/InjectedBundle/InjectedBundle.cpp:

(WebKit::InjectedBundle::setPrivateBrowsingEnabled):
Add USE(SOUP) guard.

  • WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp:

Add private browsing support methods. Copied from the Mac port.
(WebKit::WebFrameNetworkingContext::ensurePrivateBrowsingSession):
(WebKit::WebFrameNetworkingContext::destroyPrivateBrowsingSession):
(WebKit::WebFrameNetworkingContext::storageSession):
Check if the frame enables private browsing and return the private
browsing session.

  • WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h:
  • WebProcess/WebProcess.cpp:

(WebKit::WebProcess::ensurePrivateBrowsingSession):
Add USE(SOUP) guard.

Location:
trunk/Source
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r153349 r153355  
     12013-07-25  Kwang Yul Seo  <skyul@company100.net>
     2
     3        [WK2][Soup] Add private browsing support
     4        https://bugs.webkit.org/show_bug.cgi?id=118657
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        Support private browsing by adding a method to create a private
     9        browsing soup session. This private browsing session uses a
     10        non-persistent cookie jar and does not use the disk cache feature.
     11
     12        No new tests. Covered by existing private browsing tests.
     13
     14        * platform/network/NetworkStorageSession.h:
     15        (WebCore::NetworkStorageSession::isPrivateBrowsingSession):
     16        Add USE(SOUP) guard to isPrivateBrowsingSession() and m_isPrivate.
     17
     18        * platform/network/ResourceHandle.h:
     19        Add a factory method to create a private browsing session for soup.
     20
     21        * platform/network/soup/CookieJarSoup.cpp:
     22        (WebCore::createPrivateBrowsingCookieJar):
     23        * platform/network/soup/CookieJarSoup.h:
     24        Add a method to create a non-persistent cookie jar for private browsing.
     25
     26        * platform/network/soup/NetworkStorageSessionSoup.cpp:
     27        (WebCore::NetworkStorageSession::NetworkStorageSession):
     28        Initialize m_isPrivate to false.
     29        (WebCore::NetworkStorageSession::createPrivateBrowsingSession):
     30        Implement the method by invoking ResourceHandle::createPrivateBrowsingSession.
     31
     32        * platform/network/soup/ResourceHandleSoup.cpp:
     33        (WebCore::createSoupSession):
     34        Extract common soup session creation code so that both defaultSession
     35        and createPrivateBrowsingSession can use this function to create a soup
     36        session.
     37        (WebCore::ResourceHandle::defaultSession):
     38        Change to use createSoupSession.
     39        (WebCore::ResourceHandle::createPrivateBrowsingSession):
     40        Create a session which uses a non-persistent cookie jar.
     41
    1422013-07-25  Tim Horton  <timothy_horton@apple.com>
    243
  • trunk/Source/WebCore/platform/network/NetworkStorageSession.h

    r152672 r153355  
    4646public:
    4747    static NetworkStorageSession& defaultStorageSession();
    48     static PassOwnPtr<NetworkStorageSession> createPrivateBrowsingSession(const String& identifierBase);
     48    static PassOwnPtr<NetworkStorageSession> createPrivateBrowsingSession(const String& identifierBase = String());
    4949
    5050    static void switchToNewTestingSession();
     51
     52#if PLATFORM(MAC) || USE(CFNETWORK) || USE(SOUP)
     53    bool isPrivateBrowsingSession() const { return m_isPrivate; }
     54#endif
    5155
    5256#if PLATFORM(MAC) || USE(CFNETWORK)
     
    5458    CFURLStorageSessionRef platformSession() { return m_platformSession.get(); }
    5559    RetainPtr<CFHTTPCookieStorageRef> cookieStorage() const;
    56     bool isPrivateBrowsingSession() const { return m_isPrivate; }
    5760#elif USE(SOUP)
    5861    void setSoupSession(SoupSession* session) { m_session = session; }
     
    6972    NetworkStorageSession();
    7073    RetainPtr<CFURLStorageSessionRef> m_platformSession;
    71     bool m_isPrivate;
    7274#elif USE(SOUP)
    7375    NetworkStorageSession(SoupSession*);
     
    7577#else
    7678    RefPtr<NetworkingContext> m_context;
     79#endif
     80
     81#if PLATFORM(MAC) || USE(CFNETWORK) || USE(SOUP)
     82    bool m_isPrivate;
    7783#endif
    7884};
  • trunk/Source/WebCore/platform/network/ResourceHandle.h

    r152908 r153355  
    169169    void ensureReadBuffer();
    170170    static SoupSession* defaultSession();
     171    static SoupSession* createPrivateBrowsingSession();
    171172    static uint64_t getSoupRequestInitiatingPageID(SoupRequest*);
    172173    static void setHostAllowsAnyHTTPSCertificate(const String&);
  • trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp

    r144936 r153355  
    5757}
    5858
     59SoupCookieJar* createPrivateBrowsingCookieJar()
     60{
     61    SoupCookieJar* jar = soup_cookie_jar_new();
     62
     63    soup_cookie_jar_set_accept_policy(jar, SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY);
     64
     65    return jar;
     66}
     67
    5968void setSoupCookieJar(SoupCookieJar* jar)
    6069{
  • trunk/Source/WebCore/platform/network/soup/CookieJarSoup.h

    r134082 r153355  
    3535void setSoupCookieJar(SoupCookieJar*);
    3636
     37SoupCookieJar* createPrivateBrowsingCookieJar();
     38
    3739}
    3840
  • trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp

    r152672 r153355  
    3131#include <wtf/MainThread.h>
    3232#include <wtf/PassOwnPtr.h>
     33#include <wtf/text/StringConcatenate.h>
    3334
    3435namespace WebCore {
     
    3637NetworkStorageSession::NetworkStorageSession(SoupSession* session)
    3738    : m_session(session)
     39    , m_isPrivate(false)
    3840{
    3941}
     
    5557PassOwnPtr<NetworkStorageSession> NetworkStorageSession::createPrivateBrowsingSession(const String&)
    5658{
    57     ASSERT_NOT_REACHED();
    58     return nullptr;
     59    OwnPtr<NetworkStorageSession> session = adoptPtr(new NetworkStorageSession(ResourceHandle::createPrivateBrowsingSession()));
     60    session->m_isPrivate = true;
     61
     62    return session.release();
    5963}
    6064
  • trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp

    r153045 r153355  
    13671367}
    13681368
    1369 SoupSession* ResourceHandle::defaultSession()
    1370 {
    1371     static SoupSession* session = 0;
     1369static SoupSession* createSoupSession()
     1370{
    13721371    // Values taken from http://www.browserscope.org/  following
    13731372    // the rule "Do What Every Other Modern Browser Is Doing". They seem
     
    13771376    static const int maxConnectionsPerHost = 6;
    13781377
    1379     if (!session) {
    1380         session = soup_session_async_new();
    1381         g_object_set(session,
    1382                      SOUP_SESSION_MAX_CONNS, maxConnections,
    1383                      SOUP_SESSION_MAX_CONNS_PER_HOST, maxConnectionsPerHost,
    1384                      SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_DECODER,
    1385                      SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_SNIFFER,
    1386                      SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_PROXY_RESOLVER_DEFAULT,
    1387                      SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
    1388                      NULL);
    1389         g_signal_connect(session, "authenticate", G_CALLBACK(authenticateCallback), 0);
     1378    SoupSession* session = soup_session_async_new();
     1379    g_object_set(session,
     1380        SOUP_SESSION_MAX_CONNS, maxConnections,
     1381        SOUP_SESSION_MAX_CONNS_PER_HOST, maxConnectionsPerHost,
     1382        SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_DECODER,
     1383        SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_SNIFFER,
     1384        SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_PROXY_RESOLVER_DEFAULT,
     1385        SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
     1386        NULL);
     1387    g_signal_connect(session, "authenticate", G_CALLBACK(authenticateCallback), 0);
    13901388
    13911389#if ENABLE(WEB_TIMING)
    1392         g_signal_connect(session, "request-started", G_CALLBACK(requestStartedCallback), 0);
    1393 #endif
    1394     }
    1395 
     1390    g_signal_connect(session, "request-started", G_CALLBACK(requestStartedCallback), 0);
     1391#endif
     1392
     1393    return session;
     1394}
     1395
     1396SoupSession* ResourceHandle::defaultSession()
     1397{
     1398    static SoupSession* session = createSoupSession();
     1399    return session;
     1400}
     1401
     1402SoupSession* ResourceHandle::createPrivateBrowsingSession()
     1403{
     1404    SoupSession* session = createSoupSession();
     1405    soup_session_add_feature(session, SOUP_SESSION_FEATURE(createPrivateBrowsingCookieJar()));
    13961406    return session;
    13971407}
  • trunk/Source/WebKit2/ChangeLog

    r153352 r153355  
     12013-07-25  Kwang Yul Seo  <skyul@company100.net>
     2
     3        [WK2][Soup] Add private browsing support
     4        https://bugs.webkit.org/show_bug.cgi?id=118657
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        Support private browsing in WK2 by implementing private browsing
     9        related methods in WebFrameNetworkingContext.
     10
     11        * WebProcess/InjectedBundle/InjectedBundle.cpp:
     12        (WebKit::InjectedBundle::setPrivateBrowsingEnabled):
     13        Add USE(SOUP) guard.
     14
     15        * WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp:
     16        Add private browsing support methods. Copied from the Mac port.
     17        (WebKit::WebFrameNetworkingContext::ensurePrivateBrowsingSession):
     18        (WebKit::WebFrameNetworkingContext::destroyPrivateBrowsingSession):
     19        (WebKit::WebFrameNetworkingContext::storageSession):
     20        Check if the frame enables private browsing and return the private
     21        browsing session.
     22        * WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h:
     23
     24        * WebProcess/WebProcess.cpp:
     25        (WebKit::WebProcess::ensurePrivateBrowsingSession):
     26        Add USE(SOUP) guard.
     27
    1282013-07-25  Kwang Yul Seo  <skyul@company100.net>
    229
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp

    r151832 r153355  
    305305{
    306306    // FIXME (NetworkProcess): This test-only function doesn't work with NetworkProcess, <https://bugs.webkit.org/show_bug.cgi?id=115274>.
    307 #if PLATFORM(MAC) || USE(CFNETWORK)
     307#if PLATFORM(MAC) || USE(CFNETWORK) || USE(SOUP)
    308308    if (enabled)
    309309        WebFrameNetworkingContext::ensurePrivateBrowsingSession();
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp

    r141749 r153355  
    11/*
    22 * Copyright (C) 2012 Igalia S.L.
     3 * Copyright (C) 2013 Company 100 Inc.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2930#include "WebFrame.h"
    3031#include "WebPage.h"
     32#include <WebCore/Settings.h>
    3133
    3234using namespace WebCore;
    3335
    3436namespace WebKit {
     37
     38static NetworkStorageSession* privateSession;
     39
     40void WebFrameNetworkingContext::ensurePrivateBrowsingSession()
     41{
     42    ASSERT(isMainThread());
     43
     44    if (privateSession)
     45        return;
     46
     47    privateSession = NetworkStorageSession::createPrivateBrowsingSession().leakPtr();
     48}
     49
     50void WebFrameNetworkingContext::destroyPrivateBrowsingSession()
     51{
     52    ASSERT(isMainThread());
     53
     54    delete privateSession;
     55    privateSession = 0;
     56}
    3557
    3658WebFrameNetworkingContext::WebFrameNetworkingContext(WebFrame* frame)
     
    4466NetworkStorageSession& WebFrameNetworkingContext::storageSession() const
    4567{
     68    if (frame() && frame()->settings() && frame()->settings()->privateBrowsingEnabled())
     69        return *privateSession;
     70
    4671    return NetworkStorageSession::defaultStorageSession();
    4772}
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h

    r141749 r153355  
    4242    }
    4343
     44    static void ensurePrivateBrowsingSession();
     45    static void destroyPrivateBrowsingSession();
     46
    4447private:
    4548    WebFrameNetworkingContext(WebFrame*);
  • trunk/Source/WebKit2/WebProcess/WebProcess.cpp

    r152340 r153355  
    454454void WebProcess::ensurePrivateBrowsingSession()
    455455{
    456 #if PLATFORM(MAC) || USE(CFNETWORK)
     456#if PLATFORM(MAC) || USE(CFNETWORK) || USE(SOUP)
    457457    WebFrameNetworkingContext::ensurePrivateBrowsingSession();
    458458#endif
Note: See TracChangeset for help on using the changeset viewer.