Title: [151691] trunk/Source
Revision
151691
Author
[email protected]
Date
2013-06-18 13:14:32 -0700 (Tue, 18 Jun 2013)

Log Message

Re-implement WebFrameNetworkingContext.
<rdar://problem/13174821>.

Reviewed by Alexey Proskuryakov.

* WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h: Added.
(WebKit::WebFrameNetworkingContext::create):
(WebKit::WebFrameNetworkingContext::WebFrameNetworkingContext):
* WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm: Added.
(WebKit::WebFrameNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase):
(WebKit::WebFrameNetworkingContext::ensurePrivateBrowsingSession):
(WebKit::WebFrameNetworkingContext::destroyPrivateBrowsingSession):
(WebKit::WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts):
(WebKit::WebFrameNetworkingContext::needsSiteSpecificQuirks):
(WebKit::WebFrameNetworkingContext::localFileContentSniffingEnabled):
(WebKit::WebFrameNetworkingContext::scheduledRunLoopPairs):
(WebKit::WebFrameNetworkingContext::sourceApplicationAuditData):
(WebKit::WebFrameNetworkingContext::blockedError):
(WebKit::WebFrameNetworkingContext::storageSession):
* WebCoreSupport/WebFrameNetworkingContext.h: Added.
(WebFrameNetworkingContext::create):
(WebFrameNetworkingContext::WebFrameNetworkingContext):
(WebFrameNetworkingContext::userAgent):
* WebCoreSupport/WebFrameNetworkingContext.mm: Added.
(WebFrameNetworkingContext::ensurePrivateBrowsingSession):
(WebFrameNetworkingContext::destroyPrivateBrowsingSession):
(WebFrameNetworkingContext::needsSiteSpecificQuirks):
(WebFrameNetworkingContext::localFileContentSniffingEnabled):
(WebFrameNetworkingContext::scheduledRunLoopPairs):
(WebFrameNetworkingContext::sourceApplicationAuditData):
(WebFrameNetworkingContext::blockedError):
(WebFrameNetworkingContext::storageSession):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (151690 => 151691)


--- trunk/Source/WebKit/mac/ChangeLog	2013-06-18 20:05:08 UTC (rev 151690)
+++ trunk/Source/WebKit/mac/ChangeLog	2013-06-18 20:14:32 UTC (rev 151691)
@@ -1,3 +1,24 @@
+2013-06-18  Roger Fong  <[email protected]>
+
+        Re-implement WebFrameNetworkingContext.
+        <rdar://problem/13174821>.
+
+        Reviewed by Alexey Proskuryakov.
+
+        * WebCoreSupport/WebFrameNetworkingContext.h: Added.
+        (WebFrameNetworkingContext::create):
+        (WebFrameNetworkingContext::WebFrameNetworkingContext):
+        (WebFrameNetworkingContext::userAgent):
+        * WebCoreSupport/WebFrameNetworkingContext.mm: Added.
+        (WebFrameNetworkingContext::ensurePrivateBrowsingSession):
+        (WebFrameNetworkingContext::destroyPrivateBrowsingSession):
+        (WebFrameNetworkingContext::needsSiteSpecificQuirks):
+        (WebFrameNetworkingContext::localFileContentSniffingEnabled):
+        (WebFrameNetworkingContext::scheduledRunLoopPairs):
+        (WebFrameNetworkingContext::sourceApplicationAuditData):
+        (WebFrameNetworkingContext::blockedError):
+        (WebFrameNetworkingContext::storageSession):
+
 2013-06-18  Alexey Proskuryakov  <[email protected]>
 
         <rdar://problem/13174821> Remove files with an incorrect license.

Added: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h (0 => 151691)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h	                        (rev 0)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h	2013-06-18 20:14:32 UTC (rev 151691)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef WebFrameNetworkingContext_h
+#define WebFrameNetworkingContext_h
+
+#include <WebCore/FrameNetworkingContext.h>
+
+class WebFrameNetworkingContext : public WebCore::FrameNetworkingContext {
+public:
+    static PassRefPtr<WebFrameNetworkingContext> create(WebCore::Frame* frame, const String& useragent)
+    {
+        return adoptRef(new WebFrameNetworkingContext(frame, useragent));
+    }
+
+#if USE(CFNETWORK)
+    static void setCookieAcceptPolicyForAllContexts(WebKitCookieStorageAcceptPolicy);
+#endif
+    static void setPrivateBrowsingStorageSessionIdentifierBase(const String&);
+    static void ensurePrivateBrowsingSession();
+    static void destroyPrivateBrowsingSession();
+
+private:
+    WebFrameNetworkingContext(WebCore::Frame* frame, const String& userAgent)
+        : WebCore::FrameNetworkingContext(frame), m_userAgent(userAgent)
+    {
+    }
+
+    virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const OVERRIDE;
+    virtual WebCore::NetworkStorageSession& storageSession() const OVERRIDE;
+    virtual String referrer() const OVERRIDE;
+    virtual String userAgent() const { return m_userAgent; }
+
+    String m_userAgent;
+};
+
+#endif

Added: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm (0 => 151691)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm	                        (rev 0)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm	2013-06-18 20:14:32 UTC (rev 151691)
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "WebViewPrivate.h"
+#include "WebFrameInternal.h"
+#include <WebFrameNetworkingContext.h>
+#include <WebCore/FrameLoader.h>
+#include <WebCore/FrameLoaderClient.h>
+#include <WebCore/NetworkStorageSession.h>
+#include <WebCore/Page.h>
+#include <WebCore/ResourceError.h>
+#include <WebCore/Settings.h>
+
+using namespace WebCore;
+
+static NetworkStorageSession* privateSession;
+
+void WebFrameNetworkingContext::ensurePrivateBrowsingSession()
+{
+    ASSERT(isMainThread());
+
+    if (privateSession)
+        return;
+
+    privateSession = NetworkStorageSession::createPrivateBrowsingSession([[NSBundle mainBundle] bundleIdentifier]).leakPtr();
+}
+
+void WebFrameNetworkingContext::destroyPrivateBrowsingSession()
+{
+    ASSERT(isMainThread());
+
+    delete privateSession;
+    privateSession = 0;
+}
+
+bool WebFrameNetworkingContext::needsSiteSpecificQuirks() const
+{
+    return frame() && frame()->settings() && frame()->settings()->needsSiteSpecificQuirks();
+}
+
+bool WebFrameNetworkingContext::localFileContentSniffingEnabled() const
+{
+    return frame() && frame()->settings() && frame()->settings()->localFileContentSniffingEnabled();
+}
+
+SchedulePairHashSet* WebFrameNetworkingContext::scheduledRunLoopPairs() const
+{
+    if (!frame() || !frame()->page())
+        return 0;
+    return frame()->page()->scheduledRunLoopPairs();
+}
+
+RetainPtr<CFDataRef> WebFrameNetworkingContext::sourceApplicationAuditData() const
+{
+    if (!frame() || !frame()->page())
+        return 0;
+    
+    WebView *webview = kit(frame()->page());
+    
+    if (!webview)
+        return 0;
+    return reinterpret_cast<CFDataRef>(webview._sourceApplicationAuditData);
+}
+
+ResourceError WebFrameNetworkingContext::blockedError(const ResourceRequest& request) const
+{
+    return frame()->loader()->client()->blockedError(request);
+}
+
+NetworkStorageSession& WebFrameNetworkingContext::storageSession() const
+{
+    ASSERT(isMainThread());
+
+    if (frame() && frame()->settings() && frame()->settings()->privateBrowsingEnabled())
+        return *privateSession;
+
+    return NetworkStorageSession::defaultStorageSession();
+}

Modified: trunk/Source/WebKit/win/ChangeLog (151690 => 151691)


--- trunk/Source/WebKit/win/ChangeLog	2013-06-18 20:05:08 UTC (rev 151690)
+++ trunk/Source/WebKit/win/ChangeLog	2013-06-18 20:14:32 UTC (rev 151691)
@@ -1,3 +1,22 @@
+2013-06-18  Roger Fong  <[email protected]>
+
+        Re-implement WebFrameNetworkingContext.
+        <rdar://problem/13174821>.
+
+        Reviewed by Alexey Proskuryakov.
+
+        * WebCoreSupport/WebFrameNetworkingContext.cpp: Added.
+        (WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts):
+        (WebFrameNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase):
+        (WebFrameNetworkingContext::ensurePrivateBrowsingSession):
+        (WebFrameNetworkingContext::destroyPrivateBrowsingSession):
+        (WebFrameNetworkingContext::blockedError):
+        (WebFrameNetworkingContext::referrer):
+        (WebFrameNetworkingContext::storageSession):
+        * WebCoreSupport/WebFrameNetworkingContext.h: Added.
+        (WebFrameNetworkingContext::create):
+        (WebFrameNetworkingContext::WebFrameNetworkingContext):
+
 2013-06-18  Alexey Proskuryakov  <[email protected]>
 
         <rdar://problem/13174821> Remove files with an incorrect license.

Added: trunk/Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.cpp (0 => 151691)


--- trunk/Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.cpp	                        (rev 0)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.cpp	2013-06-18 20:14:32 UTC (rev 151691)
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebFrameNetworkingContext.h"
+#include "WebView.h"
+#if USE(CFNETWORK)
+#include <CFNetwork/CFHTTPCookiesPriv.h>
+#endif
+#include <WebCore/FrameLoader.h>
+#include <WebCore/FrameLoaderClient.h>
+#include <WebCore/NetworkStorageSession.h>
+#include <WebCore/Page.h>
+#include <WebCore/ResourceError.h>
+#include <WebCore/Settings.h>
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
+
+using namespace WebCore;
+
+static NetworkStorageSession* privateSession;
+static String* identifierBase;
+
+#if USE(CFNETWORK)
+void WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts(WebKitCookieStorageAcceptPolicy policy)
+{
+    if (RetainPtr<CFHTTPCookieStorageRef> cookieStorage = NetworkStorageSession::defaultStorageSession().cookieStorage())
+        CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage.get(), policy);
+
+    if (privateSession)
+        CFHTTPCookieStorageSetCookieAcceptPolicy(privateSession->cookieStorage().get(), policy);
+}
+#endif
+
+void WebFrameNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase(const String& base)
+{
+    ASSERT(isMainThread());
+
+    delete identifierBase;
+
+    identifierBase = new String(base);
+}
+
+void WebFrameNetworkingContext::ensurePrivateBrowsingSession()
+{
+#if USE(CF_NETWORK)
+    ASSERT(isMainThread());
+
+    if (privateSession)
+        return;
+
+    String base;
+    if (!identifierBase)
+        base = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleIdentifierKey);
+    else
+        base = *identifierBase;
+
+    privateSession = NetworkStorageSession::createPrivateBrowsingSession(base).leakPtr();
+#endif
+}
+
+void WebFrameNetworkingContext::destroyPrivateBrowsingSession()
+{
+    ASSERT(isMainThread());
+
+    delete privateSession;
+    privateSession = 0;
+}
+
+ResourceError WebFrameNetworkingContext::blockedError(const ResourceRequest& request) const
+{
+    return frame()->loader()->client()->blockedError(request);
+}
+
+String WebFrameNetworkingContext::referrer() const
+{
+    return frame()->loader()->referrer();
+}
+
+NetworkStorageSession& WebFrameNetworkingContext::storageSession() const
+{
+    ASSERT(isMainThread());
+
+    if (frame() && frame()->settings() && frame()->settings()->privateBrowsingEnabled())
+        return *privateSession;
+
+    return NetworkStorageSession::defaultStorageSession();
+}

Added: trunk/Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.h (0 => 151691)


--- trunk/Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.h	                        (rev 0)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.h	2013-06-18 20:14:32 UTC (rev 151691)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebFrameNetworkingContext_h
+#define WebFrameNetworkingContext_h
+
+#include <WebCore/FrameNetworkingContext.h>
+
+class WebFrameNetworkingContext : public WebCore::FrameNetworkingContext {
+public:
+    static PassRefPtr<WebFrameNetworkingContext> create(WebCore::Frame* frame)
+    {
+        return adoptRef(new WebFrameNetworkingContext(frame));
+    }
+
+    static void ensurePrivateBrowsingSession();
+    static void destroyPrivateBrowsingSession();
+
+private:
+
+    WebFrameNetworkingContext(WebCore::Frame* frame)
+        : WebCore::FrameNetworkingContext(frame)
+    {
+    }
+
+    virtual bool needsSiteSpecificQuirks() const OVERRIDE;
+    virtual bool localFileContentSniffingEnabled() const OVERRIDE;
+    virtual SchedulePairHashSet* scheduledRunLoopPairs() const OVERRIDE;
+    virtual RetainPtr<CFDataRef> sourceApplicationAuditData() const OVERRIDE;
+    virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const OVERRIDE;
+    virtual WebCore::NetworkStorageSession& storageSession() const OVERRIDE;
+
+};
+
+#endif

Modified: trunk/Source/WebKit2/ChangeLog (151690 => 151691)


--- trunk/Source/WebKit2/ChangeLog	2013-06-18 20:05:08 UTC (rev 151690)
+++ trunk/Source/WebKit2/ChangeLog	2013-06-18 20:14:32 UTC (rev 151691)
@@ -1,3 +1,25 @@
+2013-06-18  Roger Fong  <[email protected]>
+
+        Re-implement WebFrameNetworkingContext.
+        <rdar://problem/13174821>.
+
+        Reviewed by Alexey Proskuryakov.
+
+        * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h: Added.
+        (WebKit::WebFrameNetworkingContext::create):
+        (WebKit::WebFrameNetworkingContext::WebFrameNetworkingContext):
+        * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm: Added.
+        (WebKit::WebFrameNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase):
+        (WebKit::WebFrameNetworkingContext::ensurePrivateBrowsingSession):
+        (WebKit::WebFrameNetworkingContext::destroyPrivateBrowsingSession):
+        (WebKit::WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts):
+        (WebKit::WebFrameNetworkingContext::needsSiteSpecificQuirks):
+        (WebKit::WebFrameNetworkingContext::localFileContentSniffingEnabled):
+        (WebKit::WebFrameNetworkingContext::scheduledRunLoopPairs):
+        (WebKit::WebFrameNetworkingContext::sourceApplicationAuditData):
+        (WebKit::WebFrameNetworkingContext::blockedError):
+        (WebKit::WebFrameNetworkingContext::storageSession):
+
 2013-06-18  Alexey Proskuryakov  <[email protected]>
 
         <rdar://problem/13174821> Remove files with an incorrect license.

Added: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h (0 => 151691)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h	2013-06-18 20:14:32 UTC (rev 151691)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebFrameNetworkingContext_h
+#define WebFrameNetworkingContext_h
+
+#include "HTTPCookieAcceptPolicy.h"
+#include "WebFrame.h"
+#include <WebCore/FrameNetworkingContext.h>
+
+namespace WebKit {
+
+class WebFrameNetworkingContext : public WebCore::FrameNetworkingContext {
+public:
+    static PassRefPtr<WebFrameNetworkingContext> create(WebFrame* frame)
+    {
+        return adoptRef(new WebFrameNetworkingContext(frame));
+    }
+
+    static void setPrivateBrowsingStorageSessionIdentifierBase(const String&);
+    static void ensurePrivateBrowsingSession();
+    static void destroyPrivateBrowsingSession();
+    static void setCookieAcceptPolicyForAllContexts(HTTPCookieAcceptPolicy);
+
+private:
+    WebFrameNetworkingContext(WebFrame* frame)
+        : WebCore::FrameNetworkingContext(frame->coreFrame())
+    {
+    }
+
+    virtual bool needsSiteSpecificQuirks() const OVERRIDE;
+    virtual bool localFileContentSniffingEnabled() const OVERRIDE;
+    virtual SchedulePairHashSet* scheduledRunLoopPairs() const OVERRIDE;
+    virtual RetainPtr<CFDataRef> sourceApplicationAuditData() const OVERRIDE;
+    virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const OVERRIDE;
+    virtual WebCore::NetworkStorageSession& storageSession() const OVERRIDE;
+};
+
+}
+
+#endif

Added: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm (0 => 151691)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm	2013-06-18 20:14:32 UTC (rev 151691)
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebCookieManager.h"
+#include "WebFrameNetworkingContext.h"
+#include <WebCore/Frame.h>
+#include <WebCore/FrameLoader.h>
+#include <WebCore/FrameLoaderClient.h>
+#include <WebCore/NetworkStorageSession.h>
+#include <WebCore/Page.h>
+#include <WebCore/ResourceError.h>
+#include <WebCore/Settings.h>
+#include <WebKitSystemInterface.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static NetworkStorageSession* privateSession;
+static String* identifierBase;
+    
+void WebFrameNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase(const String& base)
+{
+    ASSERT(isMainThread());
+
+    delete identifierBase;
+
+    identifierBase = new String(base);
+}
+
+void WebFrameNetworkingContext::ensurePrivateBrowsingSession()
+{
+    ASSERT(isMainThread());
+
+    if (privateSession)
+        return;
+
+    String base;
+    if (!identifierBase)
+        base = [[NSBundle mainBundle] bundleIdentifier];
+    else
+        base = *identifierBase;
+
+    privateSession = NetworkStorageSession::createPrivateBrowsingSession(base).leakPtr();
+}
+
+void WebFrameNetworkingContext::destroyPrivateBrowsingSession()
+{
+    ASSERT(isMainThread());
+
+    delete privateSession;
+    privateSession = 0;
+}
+
+void WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts(HTTPCookieAcceptPolicy policy)
+{
+    [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:static_cast<NSHTTPCookieAcceptPolicy>(policy)];
+
+    if (RetainPtr<CFHTTPCookieStorageRef> cookieStorage = NetworkStorageSession::defaultStorageSession().cookieStorage())
+        WKSetHTTPCookieAcceptPolicy(cookieStorage.get(), policy);
+
+    if (privateSession)
+        WKSetHTTPCookieAcceptPolicy(privateSession->cookieStorage().get(), policy);
+}
+    
+bool WebFrameNetworkingContext::needsSiteSpecificQuirks() const
+{
+    return frame() && frame()->settings() && frame()->settings()->needsSiteSpecificQuirks();
+}
+
+bool WebFrameNetworkingContext::localFileContentSniffingEnabled() const
+{
+    return frame() && frame()->settings() && frame()->settings()->localFileContentSniffingEnabled();
+}
+
+SchedulePairHashSet* WebFrameNetworkingContext::scheduledRunLoopPairs() const
+{
+    if (!frame() || !frame()->page())
+        return frame()->page()->scheduledRunLoopPairs();
+    return 0;
+}
+
+RetainPtr<CFDataRef> WebFrameNetworkingContext::sourceApplicationAuditData() const
+{
+    return RetainPtr<CFDataRef>();
+}
+
+ResourceError WebFrameNetworkingContext::blockedError(const ResourceRequest& request) const
+{
+    return frame()->loader()->client()->blockedError(request);
+}
+
+NetworkStorageSession& WebFrameNetworkingContext::storageSession() const
+{
+    ASSERT(isMainThread());
+
+    if (frame() && frame()->settings() && frame()->settings()->privateBrowsingEnabled())
+        return *privateSession;
+
+    return NetworkStorageSession::defaultStorageSession();
+}
+    
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to