1 /* 2 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 #include "config.h" 27 #include "PlatformStrategiesJava.h" 28 29 #include "NotImplemented.h" 30 #include "PlatformCookieJar.h" 31 #include "FrameNetworkingContextJava.h" 32 #include "NetworkStorageSession.h" 33 34 #include "WebKitLegacy/WebCoreSupport/WebResourceLoadScheduler.h" 35 #include <wtf/NeverDestroyed.h> 36 #include <WebCore/BlobRegistryImpl.h> 37 #include <WebCore/NetworkStorageSession.h> 38 #include <WebCore/Page.h> 39 #include <WebCore/PageGroup.h> 40 #include <WebCore/PlatformCookieJar.h> 41 42 namespace WebCore { 43 void PlatformStrategiesJava::initialize() 44 { 45 static NeverDestroyed<PlatformStrategiesJava> platformStrategies; 46 } 47 48 PlatformStrategiesJava::PlatformStrategiesJava() 49 { 50 setPlatformStrategies(this); 51 } 52 53 CookiesStrategy* PlatformStrategiesJava::createCookiesStrategy() 54 { 55 return this; 56 } 57 58 LoaderStrategy* PlatformStrategiesJava::createLoaderStrategy() 59 { 60 return new WebResourceLoadScheduler; 61 } 62 63 PasteboardStrategy* PlatformStrategiesJava::createPasteboardStrategy() 64 { 65 // This is currently used only by Mac code. 66 notImplemented(); 67 return 0; 68 } 69 70 WebCore::BlobRegistry* PlatformStrategiesJava::createBlobRegistry() 71 { 72 return new WebCore::BlobRegistryImpl; 73 } 74 75 // CookiesStrategy 76 std::pair<String, bool> PlatformStrategiesJava::cookiesForDOM(const WebCore::NetworkStorageSession& session, const WebCore::URL& firstParty, const WebCore::URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, WebCore::IncludeSecureCookies includeSecureCookies) 77 { 78 return WebCore::cookiesForDOM(session, firstParty, url, frameID, pageID, includeSecureCookies); 79 } 80 81 void PlatformStrategiesJava::setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String& cookieString) 82 { 83 WebCore::setCookiesFromDOM(session, firstParty, url, frameID, pageID, cookieString); 84 } 85 86 bool PlatformStrategiesJava::cookiesEnabled(const NetworkStorageSession& session) 87 { 88 return WebCore::cookiesEnabled(session); 89 } 90 91 std::pair<String, bool> PlatformStrategiesJava::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, WebCore::IncludeSecureCookies includeSecureCookies) 92 { 93 return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url, frameID, pageID, includeSecureCookies); 94 } 95 96 std::pair<String, bool> PlatformStrategiesJava::cookieRequestHeaderFieldValue(PAL::SessionID sessionID, const URL& firstParty, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, WebCore::IncludeSecureCookies includeSecureCookies) 97 { 98 auto& session = sessionID.isEphemeral() ? FrameNetworkingContextJava::ensurePrivateBrowsingSession() : NetworkStorageSession::defaultStorageSession(); 99 return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url, frameID, pageID, includeSecureCookies); 100 } 101 102 bool PlatformStrategiesJava::getRawCookies(const NetworkStorageSession& session, const URL& firstParty, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>& rawCookies) 103 { 104 return WebCore::getRawCookies(session, firstParty, url, frameID, pageID, rawCookies); 105 } 106 107 void PlatformStrategiesJava::deleteCookie(const NetworkStorageSession& session, const URL& url, const String& cookieName) 108 { 109 WebCore::deleteCookie(session, url, cookieName); 110 } 111 112 } // namespace WebCore