1/*
2 * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
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.
16 *
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.
27 */
28
29#pragma once
30
31#include "ContextMenu.h"
32#include "ContextMenuProvider.h"
33#include <wtf/RefCounted.h>
34#include <wtf/Vector.h>
35#include <wtf/text/WTFString.h>
36
37namespace WebCore {
38
39class DOMWrapperWorld;
40class Event;
41class FrontendMenuProvider;
42class InspectorFrontendClient;
43class Page;
44
45class InspectorFrontendHost : public RefCounted<InspectorFrontendHost> {
46public:
47 static Ref<InspectorFrontendHost> create(InspectorFrontendClient* client, Page* frontendPage)
48 {
49 return adoptRef(*new InspectorFrontendHost(client, frontendPage));
50 }
51
52 WEBCORE_EXPORT ~InspectorFrontendHost();
53 WEBCORE_EXPORT void disconnectClient();
54
55 WEBCORE_EXPORT void addSelfToGlobalObjectInWorld(DOMWrapperWorld&);
56
57 void loaded();
58 void requestSetDockSide(const String&);
59 void closeWindow();
60 void reopen();
61 void bringToFront();
62 void inspectedURLChanged(const String&);
63
64 bool supportsShowCertificate() const;
65 bool showCertificate(const String& serializedCertificate);
66
67 void setZoomFactor(float);
68 float zoomFactor();
69
70 String userInterfaceLayoutDirection();
71
72 void setAttachedWindowHeight(unsigned);
73 void setAttachedWindowWidth(unsigned);
74
75 void setSheetRect(float x, float y, unsigned width, unsigned height);
76
77 void startWindowDrag();
78 void moveWindowBy(float x, float y) const;
79
80 bool isRemote() const;
81 String localizedStringsURL();
82 String backendCommandsURL();
83 String debuggableType();
84 unsigned inspectionLevel();
85
86 String platform();
87 String port();
88
89 void copyText(const String& text);
90 void killText(const String& text, bool shouldPrependToKillRing, bool shouldStartNewSequence);
91 void openInNewTab(const String& url);
92 bool canSave();
93 void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs);
94 void append(const String& url, const String& content);
95 void close(const String& url);
96
97 struct ContextMenuItem {
98 String type;
99 String label;
100 Optional<int> id;
101 Optional<bool> enabled;
102 Optional<bool> checked;
103 Optional<Vector<ContextMenuItem>> subItems;
104 };
105 void showContextMenu(Event&, Vector<ContextMenuItem>&&);
106
107 void sendMessageToBackend(const String& message);
108 void dispatchEventAsContextMenuEvent(Event&);
109
110 bool isUnderTest();
111 void unbufferedLog(const String& message);
112
113 void beep();
114 void inspectInspector();
115 bool isBeingInspected();
116
117private:
118#if ENABLE(CONTEXT_MENUS)
119 friend class FrontendMenuProvider;
120#endif
121 WEBCORE_EXPORT InspectorFrontendHost(InspectorFrontendClient*, Page* frontendPage);
122
123 InspectorFrontendClient* m_client;
124 Page* m_frontendPage;
125#if ENABLE(CONTEXT_MENUS)
126 FrontendMenuProvider* m_menuProvider;
127#endif
128};
129
130} // namespace WebCore
131