Title: [153355] trunk/Source
Revision
153355
Author
[email protected]
Date
2013-07-25 16:23:42 -0700 (Thu, 25 Jul 2013)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (153354 => 153355)


--- trunk/Source/WebCore/ChangeLog	2013-07-25 23:14:51 UTC (rev 153354)
+++ trunk/Source/WebCore/ChangeLog	2013-07-25 23:23:42 UTC (rev 153355)
@@ -1,3 +1,44 @@
+2013-07-25  Kwang Yul Seo  <[email protected]>
+
+        [WK2][Soup] Add private browsing support
+        https://bugs.webkit.org/show_bug.cgi?id=118657
+
+        Reviewed by Gustavo Noronha Silva.
+
+        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.
+
 2013-07-25  Tim Horton  <[email protected]>
 
         Null check m_frame in maximum and minimumScrollPosition

Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (153354 => 153355)


--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h	2013-07-25 23:14:51 UTC (rev 153354)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h	2013-07-25 23:23:42 UTC (rev 153355)
@@ -45,15 +45,18 @@
     WTF_MAKE_NONCOPYABLE(NetworkStorageSession); WTF_MAKE_FAST_ALLOCATED;
 public:
     static NetworkStorageSession& defaultStorageSession();
-    static PassOwnPtr<NetworkStorageSession> createPrivateBrowsingSession(const String& identifierBase);
+    static PassOwnPtr<NetworkStorageSession> createPrivateBrowsingSession(const String& identifierBase = String());
 
     static void switchToNewTestingSession();
 
+#if PLATFORM(MAC) || USE(CFNETWORK) || USE(SOUP)
+    bool isPrivateBrowsingSession() const { return m_isPrivate; }
+#endif
+
 #if PLATFORM(MAC) || USE(CFNETWORK)
     // May be null, in which case a Foundation default should be used.
     CFURLStorageSessionRef platformSession() { return m_platformSession.get(); }
     RetainPtr<CFHTTPCookieStorageRef> cookieStorage() const;
-    bool isPrivateBrowsingSession() const { return m_isPrivate; }
 #elif USE(SOUP)
     void setSoupSession(SoupSession* session) { m_session = session; }
     SoupSession* soupSession() const { return m_session; }
@@ -68,13 +71,16 @@
     NetworkStorageSession(RetainPtr<CFURLStorageSessionRef>);
     NetworkStorageSession();
     RetainPtr<CFURLStorageSessionRef> m_platformSession;
-    bool m_isPrivate;
 #elif USE(SOUP)
     NetworkStorageSession(SoupSession*);
     SoupSession* m_session;
 #else
     RefPtr<NetworkingContext> m_context;
 #endif
+
+#if PLATFORM(MAC) || USE(CFNETWORK) || USE(SOUP)
+    bool m_isPrivate;
+#endif
 };
 
 #if PLATFORM(WIN) && USE(CFNETWORK)

Modified: trunk/Source/WebCore/platform/network/ResourceHandle.h (153354 => 153355)


--- trunk/Source/WebCore/platform/network/ResourceHandle.h	2013-07-25 23:14:51 UTC (rev 153354)
+++ trunk/Source/WebCore/platform/network/ResourceHandle.h	2013-07-25 23:23:42 UTC (rev 153355)
@@ -168,6 +168,7 @@
     bool cancelledOrClientless();
     void ensureReadBuffer();
     static SoupSession* defaultSession();
+    static SoupSession* createPrivateBrowsingSession();
     static uint64_t getSoupRequestInitiatingPageID(SoupRequest*);
     static void setHostAllowsAnyHTTPSCertificate(const String&);
     static void setClientCertificate(const String& host, GTlsCertificate*);

Modified: trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp (153354 => 153355)


--- trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp	2013-07-25 23:14:51 UTC (rev 153354)
+++ trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp	2013-07-25 23:23:42 UTC (rev 153355)
@@ -56,6 +56,15 @@
     return jar;
 }
 
+SoupCookieJar* createPrivateBrowsingCookieJar()
+{
+    SoupCookieJar* jar = soup_cookie_jar_new();
+
+    soup_cookie_jar_set_accept_policy(jar, SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY);
+
+    return jar;
+}
+
 void setSoupCookieJar(SoupCookieJar* jar)
 {
     defaultCookieJar() = jar;

Modified: trunk/Source/WebCore/platform/network/soup/CookieJarSoup.h (153354 => 153355)


--- trunk/Source/WebCore/platform/network/soup/CookieJarSoup.h	2013-07-25 23:14:51 UTC (rev 153354)
+++ trunk/Source/WebCore/platform/network/soup/CookieJarSoup.h	2013-07-25 23:23:42 UTC (rev 153355)
@@ -34,6 +34,8 @@
 SoupCookieJar* soupCookieJar();
 void setSoupCookieJar(SoupCookieJar*);
 
+SoupCookieJar* createPrivateBrowsingCookieJar();
+
 }
 
 #endif

Modified: trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp (153354 => 153355)


--- trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp	2013-07-25 23:14:51 UTC (rev 153354)
+++ trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp	2013-07-25 23:23:42 UTC (rev 153355)
@@ -30,11 +30,13 @@
 #include "ResourceHandle.h"
 #include <wtf/MainThread.h>
 #include <wtf/PassOwnPtr.h>
+#include <wtf/text/StringConcatenate.h>
 
 namespace WebCore {
 
 NetworkStorageSession::NetworkStorageSession(SoupSession* session)
     : m_session(session)
+    , m_isPrivate(false)
 {
 }
 
@@ -54,8 +56,10 @@
 
 PassOwnPtr<NetworkStorageSession> NetworkStorageSession::createPrivateBrowsingSession(const String&)
 {
-    ASSERT_NOT_REACHED();
-    return nullptr;
+    OwnPtr<NetworkStorageSession> session = adoptPtr(new NetworkStorageSession(ResourceHandle::createPrivateBrowsingSession()));
+    session->m_isPrivate = true;
+
+    return session.release();
 }
 
 void NetworkStorageSession::switchToNewTestingSession()

Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (153354 => 153355)


--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2013-07-25 23:14:51 UTC (rev 153354)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2013-07-25 23:23:42 UTC (rev 153355)
@@ -1366,9 +1366,8 @@
     handle->didReceiveAuthenticationChallenge(AuthenticationChallenge(session, soupMessage, soupAuth, retrying, handle.get()));
 }
 
-SoupSession* ResourceHandle::defaultSession()
+static SoupSession* createSoupSession()
 {
-    static SoupSession* session = 0;
     // Values taken from http://www.browserscope.org/  following
     // the rule "Do What Every Other Modern Browser Is Doing". They seem
     // to significantly improve page loading time compared to soup's
@@ -1376,26 +1375,37 @@
     static const int maxConnections = 35;
     static const int maxConnectionsPerHost = 6;
 
-    if (!session) {
-        session = soup_session_async_new();
-        g_object_set(session,
-                     SOUP_SESSION_MAX_CONNS, maxConnections,
-                     SOUP_SESSION_MAX_CONNS_PER_HOST, maxConnectionsPerHost,
-                     SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_DECODER,
-                     SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_SNIFFER,
-                     SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_PROXY_RESOLVER_DEFAULT,
-                     SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
-                     NULL);
-        g_signal_connect(session, "authenticate", G_CALLBACK(authenticateCallback), 0);
+    SoupSession* session = soup_session_async_new();
+    g_object_set(session,
+        SOUP_SESSION_MAX_CONNS, maxConnections,
+        SOUP_SESSION_MAX_CONNS_PER_HOST, maxConnectionsPerHost,
+        SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_DECODER,
+        SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_SNIFFER,
+        SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_PROXY_RESOLVER_DEFAULT,
+        SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
+        NULL);
+    g_signal_connect(session, "authenticate", G_CALLBACK(authenticateCallback), 0);
 
 #if ENABLE(WEB_TIMING)
-        g_signal_connect(session, "request-started", G_CALLBACK(requestStartedCallback), 0);
+    g_signal_connect(session, "request-started", G_CALLBACK(requestStartedCallback), 0);
 #endif
-    }
 
     return session;
 }
 
+SoupSession* ResourceHandle::defaultSession()
+{
+    static SoupSession* session = createSoupSession();
+    return session;
+}
+
+SoupSession* ResourceHandle::createPrivateBrowsingSession()
+{
+    SoupSession* session = createSoupSession();
+    soup_session_add_feature(session, SOUP_SESSION_FEATURE(createPrivateBrowsingCookieJar()));
+    return session;
+}
+
 uint64_t ResourceHandle::getSoupRequestInitiatingPageID(SoupRequest* request)
 {
     uint64_t* initiatingPageIDPtr = static_cast<uint64_t*>(g_object_get_data(G_OBJECT(request), gSoupRequestInitiatingPageIDKey));

Modified: trunk/Source/WebKit2/ChangeLog (153354 => 153355)


--- trunk/Source/WebKit2/ChangeLog	2013-07-25 23:14:51 UTC (rev 153354)
+++ trunk/Source/WebKit2/ChangeLog	2013-07-25 23:23:42 UTC (rev 153355)
@@ -1,5 +1,32 @@
 2013-07-25  Kwang Yul Seo  <[email protected]>
 
+        [WK2][Soup] Add private browsing support
+        https://bugs.webkit.org/show_bug.cgi?id=118657
+
+        Reviewed by Gustavo Noronha Silva.
+
+        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.
+
+2013-07-25  Kwang Yul Seo  <[email protected]>
+
         Build fix: use of long long in CoreIPC::ArgumentEncoder and CoreIPC::ArgumentDecoder
         https://bugs.webkit.org/show_bug.cgi?id=118228
 

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp (153354 => 153355)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp	2013-07-25 23:14:51 UTC (rev 153354)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp	2013-07-25 23:23:42 UTC (rev 153355)
@@ -304,7 +304,7 @@
 void InjectedBundle::setPrivateBrowsingEnabled(WebPageGroupProxy* pageGroup, bool enabled)
 {
     // FIXME (NetworkProcess): This test-only function doesn't work with NetworkProcess, <https://bugs.webkit.org/show_bug.cgi?id=115274>.
-#if PLATFORM(MAC) || USE(CFNETWORK)
+#if PLATFORM(MAC) || USE(CFNETWORK) || USE(SOUP)
     if (enabled)
         WebFrameNetworkingContext::ensurePrivateBrowsingSession();
     else

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp (153354 => 153355)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp	2013-07-25 23:14:51 UTC (rev 153354)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp	2013-07-25 23:23:42 UTC (rev 153355)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2012 Igalia S.L.
+ * Copyright (C) 2013 Company 100 Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,11 +29,32 @@
 
 #include "WebFrame.h"
 #include "WebPage.h"
+#include <WebCore/Settings.h>
 
 using namespace WebCore;
 
 namespace WebKit {
 
+static NetworkStorageSession* privateSession;
+
+void WebFrameNetworkingContext::ensurePrivateBrowsingSession()
+{
+    ASSERT(isMainThread());
+
+    if (privateSession)
+        return;
+
+    privateSession = NetworkStorageSession::createPrivateBrowsingSession().leakPtr();
+}
+
+void WebFrameNetworkingContext::destroyPrivateBrowsingSession()
+{
+    ASSERT(isMainThread());
+
+    delete privateSession;
+    privateSession = 0;
+}
+
 WebFrameNetworkingContext::WebFrameNetworkingContext(WebFrame* frame)
     : FrameNetworkingContext(frame->coreFrame())
     , m_initiatingPageID(0)
@@ -43,6 +65,9 @@
 
 NetworkStorageSession& WebFrameNetworkingContext::storageSession() const
 {
+    if (frame() && frame()->settings() && frame()->settings()->privateBrowsingEnabled())
+        return *privateSession;
+
     return NetworkStorageSession::defaultStorageSession();
 }
 

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h (153354 => 153355)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h	2013-07-25 23:14:51 UTC (rev 153354)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h	2013-07-25 23:23:42 UTC (rev 153355)
@@ -41,6 +41,9 @@
         return adoptRef(new WebFrameNetworkingContext(frame));
     }
 
+    static void ensurePrivateBrowsingSession();
+    static void destroyPrivateBrowsingSession();
+
 private:
     WebFrameNetworkingContext(WebFrame*);
 

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (153354 => 153355)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2013-07-25 23:14:51 UTC (rev 153354)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2013-07-25 23:23:42 UTC (rev 153355)
@@ -453,7 +453,7 @@
 
 void WebProcess::ensurePrivateBrowsingSession()
 {
-#if PLATFORM(MAC) || USE(CFNETWORK)
+#if PLATFORM(MAC) || USE(CFNETWORK) || USE(SOUP)
     WebFrameNetworkingContext::ensurePrivateBrowsingSession();
 #endif
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to