1/*
2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 University of Szeged. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 * THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#ifndef RemoteNetworkingContext_h
28#define RemoteNetworkingContext_h
29
30#include <WebCore/NetworkingContext.h>
31#include <WebCore/SessionID.h>
32
33namespace WebKit {
34
35class RemoteNetworkingContext final : public WebCore::NetworkingContext {
36public:
37    static PassRefPtr<RemoteNetworkingContext> create(WebCore::SessionID sessionID, bool shouldClearReferrerOnHTTPSToHTTPRedirect)
38    {
39        return adoptRef(new RemoteNetworkingContext(sessionID, shouldClearReferrerOnHTTPSToHTTPRedirect));
40    }
41    virtual ~RemoteNetworkingContext();
42
43    // FIXME: Remove platform-specific code and use SessionTracker.
44    static void ensurePrivateBrowsingSession(WebCore::SessionID);
45
46    virtual bool shouldClearReferrerOnHTTPSToHTTPRedirect() const override { return m_shouldClearReferrerOnHTTPSToHTTPRedirect; }
47
48private:
49    RemoteNetworkingContext(WebCore::SessionID sessionID, bool shouldClearReferrerOnHTTPSToHTTPRedirect)
50        : m_sessionID(sessionID)
51        , m_shouldClearReferrerOnHTTPSToHTTPRedirect(shouldClearReferrerOnHTTPSToHTTPRedirect)
52#if PLATFORM(COCOA)
53        , m_needsSiteSpecificQuirks(false)
54        , m_localFileContentSniffingEnabled(false)
55#endif
56    { }
57
58    virtual bool isValid() const override;
59    virtual WebCore::NetworkStorageSession& storageSession() const override;
60
61#if PLATFORM(COCOA)
62    void setNeedsSiteSpecificQuirks(bool value) { m_needsSiteSpecificQuirks = value; }
63    virtual bool needsSiteSpecificQuirks() const override;
64    void setLocalFileContentSniffingEnabled(bool value) { m_localFileContentSniffingEnabled = value; }
65    virtual bool localFileContentSniffingEnabled() const override;
66    virtual RetainPtr<CFDataRef> sourceApplicationAuditData() const override;
67    virtual String sourceApplicationIdentifier() const override;
68    virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const override;
69#endif
70
71    WebCore::SessionID m_sessionID;
72    bool m_shouldClearReferrerOnHTTPSToHTTPRedirect;
73
74#if PLATFORM(COCOA)
75    bool m_needsSiteSpecificQuirks;
76    bool m_localFileContentSniffingEnabled;
77#endif
78};
79
80}
81
82#endif // RemoteNetworkingContext_h
83