2 * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "ContextMenu.h"
32 #include "ContextMenuProvider.h"
33 #include <wtf/RefCounted.h>
34 #include <wtf/Vector.h>
35 #include <wtf/text/WTFString.h>
40 class FrontendMenuProvider;
41 class InspectorFrontendClient;
44 class InspectorFrontendHost : public RefCounted<InspectorFrontendHost> {
46 static Ref<InspectorFrontendHost> create(InspectorFrontendClient* client, Page* frontendPage)
48 return adoptRef(*new InspectorFrontendHost(client, frontendPage));
51 WEBCORE_EXPORT ~InspectorFrontendHost();
52 WEBCORE_EXPORT void disconnectClient();
55 void requestSetDockSide(const String&);
58 void inspectedURLChanged(const String&);
60 void setZoomFactor(float);
63 String userInterfaceLayoutDirection();
65 void setAttachedWindowHeight(unsigned);
66 void setAttachedWindowWidth(unsigned);
68 void startWindowDrag();
69 void moveWindowBy(float x, float y) const;
71 String localizedStringsURL();
72 String backendCommandsURL();
73 String debuggableType();
74 unsigned inspectionLevel();
79 void copyText(const String& text);
80 void killText(const String& text, bool shouldPrependToKillRing, bool shouldStartNewSequence);
81 void openInNewTab(const String& url);
83 void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs);
84 void append(const String& url, const String& content);
85 void close(const String& url);
87 struct ContextMenuItem {
90 std::optional<int> id;
91 std::optional<bool> enabled;
92 std::optional<bool> checked;
93 std::optional<Vector<ContextMenuItem>> subItems;
95 void showContextMenu(Event&, Vector<ContextMenuItem>&&);
97 void sendMessageToBackend(const String& message);
98 void dispatchEventAsContextMenuEvent(Event&);
101 void unbufferedLog(const String& message);
104 void inspectInspector();
107 #if ENABLE(CONTEXT_MENUS)
108 friend class FrontendMenuProvider;
110 WEBCORE_EXPORT InspectorFrontendHost(InspectorFrontendClient*, Page* frontendPage);
112 InspectorFrontendClient* m_client;
113 Page* m_frontendPage;
114 #if ENABLE(CONTEXT_MENUS)
115 FrontendMenuProvider* m_menuProvider;
119 } // namespace WebCore