Title: [136533] trunk/Source/WebKit2
Revision
136533
Author
[email protected]
Date
2012-12-04 10:59:15 -0800 (Tue, 04 Dec 2012)

Log Message

        [WK2] Track private browsing session explicitly
        <rdar://problem/12714532>
        https://bugs.webkit.org/show_bug.cgi?id=103953

        Reviewed by Jessie Berlin.

        * Shared/WebProcessCreationParameters.cpp: (WebKit::WebProcessCreationParameters::encode):
        Fixed a confusing ifdef - this code is inside PLATFORM(WIN), so PLATFORM(MAC)
        makes no sense.

        * UIProcess/API/C/WKPreferences.cpp: (WKPreferencesSetPrivateBrowsingEnabled):
        This is the only place in WK2 where we can learn that private browsing got disabled -
        no other functions are called when there are no pages open.

        * UIProcess/WebContext.h:
        * UIProcess/WebContext.cpp:
        (WebKit::WebContext::willStartUsingPrivateBrowsing):
        (WebKit::WebContext::willStopUsingPrivateBrowsing):
        Count the number of API calls. We only implement a single shared private browsing
        session, not one per page group as API implies. When private browsing gets disabled,
        we want to destroy its session.

        * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences):
        Ensure a private browsing session if the current page needs it.

        * WebProcess/WebProcess.h:
        * WebProcess/WebProcess.messages.in:
        * WebProcess/WebProcess.cpp:
        (WebKit::WebProcess::ensurePrivateBrowsingSession):
        (WebKit::WebProcess::destroyPrivateBrowsingSession):
        Call through to WebFrameNetworkingContext.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (136532 => 136533)


--- trunk/Source/WebKit2/ChangeLog	2012-12-04 18:58:14 UTC (rev 136532)
+++ trunk/Source/WebKit2/ChangeLog	2012-12-04 18:59:15 UTC (rev 136533)
@@ -1,3 +1,37 @@
+2012-12-03  Alexey Proskuryakov  <[email protected]>
+
+        [WK2] Track private browsing session explicitly
+        <rdar://problem/12714532>
+        https://bugs.webkit.org/show_bug.cgi?id=103953
+
+        Reviewed by Jessie Berlin.
+
+        * Shared/WebProcessCreationParameters.cpp: (WebKit::WebProcessCreationParameters::encode):
+        Fixed a confusing ifdef - this code is inside PLATFORM(WIN), so PLATFORM(MAC)
+        makes no sense.
+
+        * UIProcess/API/C/WKPreferences.cpp: (WKPreferencesSetPrivateBrowsingEnabled):
+        This is the only place in WK2 where we can learn that private browsing got disabled -
+        no other functions are called when there are no pages open.
+
+        * UIProcess/WebContext.h:
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::willStartUsingPrivateBrowsing):
+        (WebKit::WebContext::willStopUsingPrivateBrowsing):
+        Count the number of API calls. We only implement a single shared private browsing
+        session, not one per page group as API implies. When private browsing gets disabled,
+        we want to destroy its session.
+
+        * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences):
+        Ensure a private browsing session if the current page needs it.
+
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::ensurePrivateBrowsingSession):
+        (WebKit::WebProcess::destroyPrivateBrowsingSession):
+        Call through to WebFrameNetworkingContext.
+
 2012-12-04  Yuni Jeong  <[email protected]>
 
         [EFL][WK2] Add APIs to toggle plug-ins support.

Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp (136532 => 136533)


--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp	2012-12-04 18:58:14 UTC (rev 136532)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp	2012-12-04 18:59:15 UTC (rev 136533)
@@ -107,7 +107,7 @@
     encoder << cfURLCacheDiskCapacity;
     encoder << cfURLCacheMemoryCapacity;
     encoder << initialHTTPCookieAcceptPolicy;
-#if PLATFORM(MAC) || USE(CFNETWORK)
+#if USE(CFNETWORK)
     CFDataRef storageSession = serializedDefaultStorageSession.get();
     encoder << static_cast<bool>(storageSession);
     if (storageSession)

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp (136532 => 136533)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2012-12-04 18:58:14 UTC (rev 136532)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2012-12-04 18:59:15 UTC (rev 136533)
@@ -28,6 +28,7 @@
 #include "WKPreferencesPrivate.h"
 
 #include "WKAPICast.h"
+#include "WebContext.h"
 #include "WebPreferences.h"
 #include <WebCore/Settings.h>
 #include <wtf/PassRefPtr.h>
@@ -330,6 +331,15 @@
 
 void WKPreferencesSetPrivateBrowsingEnabled(WKPreferencesRef preferencesRef, bool enabled)
 {
+    if (toImpl(preferencesRef)->privateBrowsingEnabled() == enabled)
+        return;
+
+    // Regardless of whether there are any open pages, we should tell WebContext, so that it could track browsing sessions.
+    if (enabled)
+        WebContext::willStartUsingPrivateBrowsing();
+    else
+        WebContext::willStopUsingPrivateBrowsing();
+
     toImpl(preferencesRef)->setPrivateBrowsingEnabled(enabled);
 }
 

Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (136532 => 136533)


--- trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-12-04 18:58:14 UTC (rev 136532)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-12-04 18:59:15 UTC (rev 136533)
@@ -89,6 +89,8 @@
 
 static const double sharedSecondaryProcessShutdownTimeout = 60;
 
+unsigned WebContext::m_privateBrowsingEnterCount;
+
 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, webContextCounter, ("WebContext"));
 
 PassRefPtr<WebContext> WebContext::create(const String& injectedBundlePath)
@@ -322,6 +324,28 @@
 #endif
 }
 
+void WebContext::willStartUsingPrivateBrowsing()
+{
+    if (m_privateBrowsingEnterCount++)
+        return;
+
+    const Vector<WebContext*>& contexts = allContexts();
+    for (size_t i = 0, count = contexts.size(); i < count; ++i)
+        contexts[i]->sendToAllProcesses(Messages::WebProcess::EnsurePrivateBrowsingSession());
+}
+
+void WebContext::willStopUsingPrivateBrowsing()
+{
+    // If the client asks to disable private browsing without enabling it first, it may be resetting a persistent preference,
+    // so it is still necessary to destroy any existing private browsing session.
+    if (m_privateBrowsingEnterCount && --m_privateBrowsingEnterCount)
+        return;
+
+    const Vector<WebContext*>& contexts = allContexts();
+    for (size_t i = 0, count = contexts.size(); i < count; ++i)
+        contexts[i]->sendToAllProcesses(Messages::WebProcess::DestroyPrivateBrowsingSession());
+}
+
 WebProcessProxy* WebContext::ensureSharedWebProcess()
 {
     ASSERT(m_processModel == ProcessModelSharedSecondaryProcess);

Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (136532 => 136533)


--- trunk/Source/WebKit2/UIProcess/WebContext.h	2012-12-04 18:58:14 UTC (rev 136532)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h	2012-12-04 18:59:15 UTC (rev 136533)
@@ -249,6 +249,9 @@
     static bool applicationIsOccluded() { return s_applicationIsOccluded; }
 #endif
 
+    static void willStartUsingPrivateBrowsing();
+    static void willStopUsingPrivateBrowsing();
+
 private:
     WebContext(ProcessModel, const String& injectedBundlePath);
 
@@ -341,6 +344,10 @@
     bool m_alwaysUsesComplexTextCodePath;
     bool m_shouldUseFontSmoothing;
 
+    // How many times an API call was used to enable the preference.
+    // The variable can be 0 when private browsing is used if it's enabled due to a persistent preference.
+    static unsigned m_privateBrowsingEnterCount;
+
     // Messages that were posted before any pages were created.
     // The client should use initialization messages instead, so that a restarted process would get the same state.
     Vector<pair<String, RefPtr<APIObject> > > m_messagesToInjectedBundlePostedToEmptyContext;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (136532 => 136533)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-12-04 18:58:14 UTC (rev 136532)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-12-04 18:59:15 UTC (rev 136533)
@@ -60,7 +60,6 @@
 #include "WebEvent.h"
 #include "WebEventConversion.h"
 #include "WebFrame.h"
-#include "WebFrameNetworkingContext.h"
 #include "WebFullScreenManager.h"
 #include "WebFullScreenManagerMessages.h"
 #include "WebGeolocationClient.h"
@@ -2233,12 +2232,8 @@
     settings->setFrameFlatteningEnabled(store.getBoolValueForKey(WebPreferencesKey::frameFlatteningEnabledKey()));
 
     bool privateBrowsingEnabled = store.getBoolValueForKey(WebPreferencesKey::privateBrowsingEnabledKey());
-#if (PLATFORM(MAC) || USE(CFNETWORK)) && !PLATFORM(WIN)
     if (privateBrowsingEnabled)
-        WebFrameNetworkingContext::ensurePrivateBrowsingSession();
-    else
-        WebFrameNetworkingContext::destroyPrivateBrowsingSession();
-#endif
+        WebProcess::shared().ensurePrivateBrowsingSession();
     settings->setPrivateBrowsingEnabled(privateBrowsingEnabled);
 
     settings->setDeveloperExtrasEnabled(store.getBoolValueForKey(WebPreferencesKey::developerExtrasEnabledKey()));

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (136532 => 136533)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2012-12-04 18:58:14 UTC (rev 136532)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2012-12-04 18:59:15 UTC (rev 136533)
@@ -387,6 +387,20 @@
     m_fullKeyboardAccessEnabled = fullKeyboardAccessEnabled;
 }
 
+void WebProcess::ensurePrivateBrowsingSession()
+{
+#if (PLATFORM(MAC) || USE(CFNETWORK)) && !PLATFORM(WIN)
+    WebFrameNetworkingContext::ensurePrivateBrowsingSession();
+#endif
+}
+
+void WebProcess::destroyPrivateBrowsingSession()
+{
+#if (PLATFORM(MAC) || USE(CFNETWORK)) && !PLATFORM(WIN)
+    WebFrameNetworkingContext::destroyPrivateBrowsingSession();
+#endif
+}
+
 void WebProcess::setVisitedLinkTable(const SharedMemory::Handle& handle)
 {
     RefPtr<SharedMemory> sharedMemory = SharedMemory::create(handle, SharedMemory::ReadOnly);

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (136532 => 136533)


--- trunk/Source/WebKit2/WebProcess/WebProcess.h	2012-12-04 18:58:14 UTC (rev 136532)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h	2012-12-04 18:59:15 UTC (rev 136533)
@@ -210,6 +210,9 @@
 
     void setCacheModel(uint32_t);
 
+    void ensurePrivateBrowsingSession();
+    void destroyPrivateBrowsingSession();
+
 private:
     WebProcess();
 

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.messages.in (136532 => 136533)


--- trunk/Source/WebKit2/WebProcess/WebProcess.messages.in	2012-12-04 18:58:14 UTC (rev 136532)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.messages.in	2012-12-04 18:59:15 UTC (rev 136533)
@@ -55,6 +55,10 @@
     SetShouldPaintNativeControls(bool shouldPaintNativeControls)
 #endif
 
+    // Private browsing session is per process. Individual pages or page groups may use the private session or the default one as appropriate.
+    EnsurePrivateBrowsingSession()
+    DestroyPrivateBrowsingSession()
+
     # Plug-ins.
 #if ENABLE(NETSCAPE_PLUGIN_API)
     DidGetPlugins(uint64_t requestID, Vector<WebCore::PluginInfo> plugins) DispatchOnConnectionQueue
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to