Reduce PassRefPtr in WebKit2 - 3
[WebKit-https.git] / Source / WebCore / loader / EmptyClients.cpp
index d60bd30..ea9255c 100644 (file)
 #include "config.h"
 #include "EmptyClients.h"
 
-#include "DateTimeChooser.h"
+#include "ColorChooser.h"
+#include "DatabaseProvider.h"
 #include "DocumentLoader.h"
 #include "FileChooser.h"
 #include "FormState.h"
 #include "Frame.h"
 #include "FrameNetworkingContext.h"
 #include "HTMLFormElement.h"
+#include "IDBFactoryBackendInterface.h"
+#include "PageConfiguration.h"
+#include "StorageArea.h"
+#include "StorageNamespace.h"
+#include "StorageNamespaceProvider.h"
+#include <wtf/NeverDestroyed.h>
 
-#if ENABLE(INPUT_TYPE_COLOR)
-#include "ColorChooser.h"
+namespace WebCore {
+
+class EmptyDatabaseProvider final : public DatabaseProvider {
+#if ENABLE(INDEXED_DATABASE)
+    virtual RefPtr<IDBFactoryBackendInterface> createIDBFactoryBackend() { return nullptr; }
 #endif
+};
 
-#if ENABLE(WEB_INTENTS) 
-#include "IntentRequest.h" 
-#endif 
+class EmptyStorageNamespaceProvider final : public StorageNamespaceProvider {
+    struct EmptyStorageArea : public StorageArea {
+        virtual unsigned length() override { return 0; }
+        virtual String key(unsigned) override { return String(); }
+        virtual String item(const String&) override { return String(); }
+        virtual void setItem(Frame*, const String&, const String&, bool&) override { }
+        virtual void removeItem(Frame*, const String&) override { }
+        virtual void clear(Frame*) override { }
+        virtual bool contains(const String&) override { return false; }
+        virtual bool canAccessStorage(Frame*) override { return false; }
+        virtual StorageType storageType() const override { return LocalStorage; }
+        virtual size_t memoryBytesUsedByCache() override { return 0; }
+        SecurityOrigin& securityOrigin() override { return SecurityOrigin::createUnique(); }
+    };
+
+    struct EmptyStorageNamespace final : public StorageNamespace {
+        virtual RefPtr<StorageArea> storageArea(PassRefPtr<SecurityOrigin>) override { return adoptRef(new EmptyStorageArea); }
+        virtual RefPtr<StorageNamespace> copy(Page*) override { return adoptRef(new EmptyStorageNamespace); }
+    };
+
+    virtual RefPtr<StorageNamespace> createSessionStorageNamespace(Page&, unsigned) override
+    {
+        return adoptRef(new EmptyStorageNamespace);
+    }
+
+    virtual RefPtr<StorageNamespace> createLocalStorageNamespace(unsigned) override
+    {
+        return adoptRef(new EmptyStorageNamespace);
+    }
+
+    virtual RefPtr<StorageNamespace> createTransientLocalStorageNamespace(SecurityOrigin&, unsigned) override
+    {
+        return adoptRef(new EmptyStorageNamespace);
+    }
+};
 
-namespace WebCore {
+class EmptyVisitedLinkStore : public VisitedLinkStore {
+    virtual bool isLinkVisited(Page&, LinkHash, const URL&, const AtomicString&) override { return false; }
+    virtual void addVisitedLink(Page&, LinkHash) override { }
+};
 
-void fillWithEmptyClients(Page::PageClients& pageClients)
+void fillWithEmptyClients(PageConfiguration& pageConfiguration)
 {
-    static ChromeClient* dummyChromeClient = adoptPtr(new EmptyChromeClient).leakPtr();
-    pageClients.chromeClient = dummyChromeClient;
+    static NeverDestroyed<EmptyChromeClient> dummyChromeClient;
+    pageConfiguration.chromeClient = &dummyChromeClient.get();
 
 #if ENABLE(CONTEXT_MENUS)
-    static ContextMenuClient* dummyContextMenuClient = adoptPtr(new EmptyContextMenuClient).leakPtr();
-    pageClients.contextMenuClient = dummyContextMenuClient;
+    static NeverDestroyed<EmptyContextMenuClient> dummyContextMenuClient;
+    pageConfiguration.contextMenuClient = &dummyContextMenuClient.get();
 #endif
 
 #if ENABLE(DRAG_SUPPORT)
-    static DragClient* dummyDragClient = adoptPtr(new EmptyDragClient).leakPtr();
-    pageClients.dragClient = dummyDragClient;
+    static NeverDestroyed<EmptyDragClient> dummyDragClient;
+    pageConfiguration.dragClient = &dummyDragClient.get();
 #endif
 
-    static EditorClient* dummyEditorClient = adoptPtr(new EmptyEditorClient).leakPtr();
-    pageClients.editorClient = dummyEditorClient;
+    static NeverDestroyed<EmptyEditorClient> dummyEditorClient;
+    pageConfiguration.editorClient = &dummyEditorClient.get();
+
+    static NeverDestroyed<EmptyInspectorClient> dummyInspectorClient;
+    pageConfiguration.inspectorClient = &dummyInspectorClient.get();
+
+    static NeverDestroyed<EmptyFrameLoaderClient> dummyFrameLoaderClient;
+    pageConfiguration.loaderClientForMainFrame = &dummyFrameLoaderClient.get();
+
+    static NeverDestroyed<EmptyProgressTrackerClient> dummyProgressTrackerClient;
+    pageConfiguration.progressTrackerClient = &dummyProgressTrackerClient.get();
 
-    static InspectorClient* dummyInspectorClient = adoptPtr(new EmptyInspectorClient).leakPtr();
-    pageClients.inspectorClient = dummyInspectorClient;
+    static NeverDestroyed<EmptyDiagnosticLoggingClient> dummyDiagnosticLoggingClient;
+    pageConfiguration.diagnosticLoggingClient = &dummyDiagnosticLoggingClient.get();
+
+    pageConfiguration.databaseProvider = adoptRef(new EmptyDatabaseProvider);
+    pageConfiguration.storageNamespaceProvider = adoptRef(new EmptyStorageNamespaceProvider);
+    pageConfiguration.visitedLinkStore = adoptRef(new EmptyVisitedLinkStore);
 }
 
 class EmptyPopupMenu : public PopupMenu {
@@ -87,39 +146,32 @@ private:
     RefPtr<EmptyPopupMenu> m_popup;
 };
 
-PassRefPtr<PopupMenu> EmptyChromeClient::createPopupMenu(PopupMenuClient*) const
+RefPtr<PopupMenu> EmptyChromeClient::createPopupMenu(PopupMenuClient*) const
 {
     return adoptRef(new EmptyPopupMenu());
 }
 
-PassRefPtr<SearchPopupMenu> EmptyChromeClient::createSearchPopupMenu(PopupMenuClient*) const
+RefPtr<SearchPopupMenu> EmptyChromeClient::createSearchPopupMenu(PopupMenuClient*) const
 {
     return adoptRef(new EmptySearchPopupMenu());
 }
 
 #if ENABLE(INPUT_TYPE_COLOR)
-PassOwnPtr<ColorChooser> EmptyChromeClient::createColorChooser(ColorChooserClient*, const Color&)
+std::unique_ptr<ColorChooser> EmptyChromeClient::createColorChooser(ColorChooserClient*, const Color&)
 {
     return nullptr;
 }
 #endif
 
-#if ENABLE(CALENDAR_PICKER)
-PassRefPtr<DateTimeChooser> EmptyChromeClient::openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&)
-{
-    return PassRefPtr<DateTimeChooser>();
-}
-#endif
-
 void EmptyChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser>)
 {
 }
 
-void EmptyFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String&)
+void EmptyFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String&, FramePolicyFunction)
 {
 }
 
-void EmptyFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>)
+void EmptyFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, FramePolicyFunction)
 {
 }
 
@@ -127,52 +179,39 @@ void EmptyFrameLoaderClient::dispatchWillSendSubmitEvent(PassRefPtr<FormState>)
 {
 }
 
-void EmptyFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction, PassRefPtr<FormState>)
+void EmptyFrameLoaderClient::dispatchWillSubmitForm(PassRefPtr<FormState>, FramePolicyFunction)
 {
 }
 
-PassRefPtr<DocumentLoader> EmptyFrameLoaderClient::createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData)
+Ref<DocumentLoader> EmptyFrameLoaderClient::createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData)
 {
     return DocumentLoader::create(request, substituteData);
 }
 
-PassRefPtr<Frame> EmptyFrameLoaderClient::createFrame(const KURL&, const String&, HTMLFrameOwnerElement*, const String&, bool, int, int)
+RefPtr<Frame> EmptyFrameLoaderClient::createFrame(const URL&, const String&, HTMLFrameOwnerElement*, const String&, bool, int, int)
 {
-    return 0;
+    return nullptr;
 }
 
-PassRefPtr<Widget> EmptyFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool)
+RefPtr<Widget> EmptyFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement*, const URL&, const Vector<String>&, const Vector<String>&, const String&, bool)
 {
-    return 0;
+    return nullptr;
 }
 
 void EmptyFrameLoaderClient::recreatePlugin(Widget*)
 {
 }
 
-PassRefPtr<Widget> EmptyFrameLoaderClient::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL&, const Vector<String>&, const Vector<String>&)
+PassRefPtr<Widget> EmptyFrameLoaderClient::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const URL&, const Vector<String>&, const Vector<String>&)
 {
     return 0;
 }
 
-#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-PassRefPtr<Widget> EmptyFrameLoaderClient::createMediaPlayerProxyPlugin(const IntSize&, HTMLMediaElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&)
-{
-    return 0;
-}
-#endif
-
 PassRefPtr<FrameNetworkingContext> EmptyFrameLoaderClient::createNetworkingContext()
 {
     return PassRefPtr<FrameNetworkingContext>();
 }
 
-#if ENABLE(WEB_INTENTS)
-void EmptyFrameLoaderClient::dispatchIntent(PassRefPtr<IntentRequest>)
-{
-}
-#endif
-
 void EmptyTextCheckerClient::requestCheckingOfString(PassRefPtr<TextCheckingRequest>)
 {
 }
@@ -187,7 +226,7 @@ void EmptyEditorClient::registerRedoStep(PassRefPtr<UndoStep>)
 
 #if ENABLE(CONTEXT_MENUS)
 #if USE(CROSS_PLATFORM_CONTEXT_MENUS)
-PassOwnPtr<ContextMenu> EmptyContextMenuClient::customizeMenu(PassOwnPtr<ContextMenu>)
+std::unique_ptr<ContextMenu> EmptyContextMenuClient::customizeMenu(std::unique_ptr<ContextMenu>)
 {
     return nullptr;
 }