2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2015-2020 Apple Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "InspectorFrontendAPIDispatcher.h"
35 #include "InspectorFrontendClient.h"
36 #include <wtf/Forward.h>
37 #include <wtf/Noncopyable.h>
38 #include <wtf/text/WTFString.h>
44 class InspectorController;
45 class InspectorBackendDispatchTask;
46 class InspectorFrontendHost;
49 class InspectorFrontendClientLocal : public InspectorFrontendClient {
50 WTF_MAKE_NONCOPYABLE(InspectorFrontendClientLocal);
51 WTF_MAKE_FAST_ALLOCATED;
53 class WEBCORE_EXPORT Settings {
54 WTF_MAKE_FAST_ALLOCATED;
57 virtual ~Settings() = default;
58 virtual String getProperty(const String& name);
59 virtual void setProperty(const String& name, const String& value);
60 virtual void deleteProperty(const String& name);
63 WEBCORE_EXPORT InspectorFrontendClientLocal(InspectorController* inspectedPageController, Page* frontendPage, std::unique_ptr<Settings>);
64 WEBCORE_EXPORT ~InspectorFrontendClientLocal() override;
66 WEBCORE_EXPORT void resetState() override;
68 WEBCORE_EXPORT void windowObjectCleared() final;
69 WEBCORE_EXPORT void frontendLoaded() override;
70 WEBCORE_EXPORT void pagePaused() final;
71 WEBCORE_EXPORT void pageUnpaused() final;
73 void startWindowDrag() override { }
74 WEBCORE_EXPORT void moveWindowBy(float x, float y) final;
76 WEBCORE_EXPORT UserInterfaceLayoutDirection userInterfaceLayoutDirection() const final;
78 WEBCORE_EXPORT void requestSetDockSide(DockSide) final;
79 WEBCORE_EXPORT void changeAttachedWindowHeight(unsigned) final;
80 WEBCORE_EXPORT void changeAttachedWindowWidth(unsigned) final;
81 WEBCORE_EXPORT void changeSheetRect(const FloatRect&) final;
82 WEBCORE_EXPORT void openURLExternally(const String& url) final;
83 bool canSave() override { return false; }
84 void save(const String&, const String&, bool, bool) override { }
85 void append(const String&, const String&) override { }
87 virtual void attachWindow(DockSide) = 0;
88 virtual void detachWindow() = 0;
90 WEBCORE_EXPORT void sendMessageToBackend(const String& message) final;
92 WEBCORE_EXPORT bool isUnderTest() final;
93 bool isRemote() const final { return false; }
94 WEBCORE_EXPORT unsigned inspectionLevel() const final;
95 String backendCommandsURL() const final { return String(); };
97 InspectorFrontendAPIDispatcher& frontendAPIDispatcher() final { return m_frontendAPIDispatcher; }
98 Page* frontendPage() final { return m_frontendPage; }
100 WEBCORE_EXPORT bool canAttachWindow();
101 WEBCORE_EXPORT void setDockingUnavailable(bool);
103 WEBCORE_EXPORT static unsigned constrainedAttachedWindowHeight(unsigned preferredHeight, unsigned totalWindowHeight);
104 WEBCORE_EXPORT static unsigned constrainedAttachedWindowWidth(unsigned preferredWidth, unsigned totalWindowWidth);
106 // Direct Frontend API
107 WEBCORE_EXPORT bool isDebuggingEnabled();
108 WEBCORE_EXPORT void setDebuggingEnabled(bool);
110 WEBCORE_EXPORT bool isTimelineProfilingEnabled();
111 WEBCORE_EXPORT void setTimelineProfilingEnabled(bool);
113 WEBCORE_EXPORT bool isProfilingJavaScript();
114 WEBCORE_EXPORT void startProfilingJavaScript();
115 WEBCORE_EXPORT void stopProfilingJavaScript();
117 WEBCORE_EXPORT void showConsole();
119 WEBCORE_EXPORT void showMainResourceForFrame(Frame*);
121 WEBCORE_EXPORT void showResources();
123 WEBCORE_EXPORT void setAttachedWindow(DockSide);
125 WEBCORE_EXPORT Page* inspectedPage() const;
126 Page* frontendPage() const { return m_frontendPage; }
129 virtual void setAttachedWindowHeight(unsigned) = 0;
130 virtual void setAttachedWindowWidth(unsigned) = 0;
131 WEBCORE_EXPORT void restoreAttachedWindowHeight();
133 virtual void setSheetRect(const WebCore::FloatRect&) = 0;
136 friend class FrontendMenuProvider;
137 Optional<bool> evaluationResultToBoolean(InspectorFrontendAPIDispatcher::EvaluationResult);
139 InspectorController* m_inspectedPageController { nullptr };
140 Page* m_frontendPage { nullptr };
141 // TODO(yurys): this ref shouldn't be needed.
142 RefPtr<InspectorFrontendHost> m_frontendHost;
143 std::unique_ptr<InspectorFrontendClientLocal::Settings> m_settings;
145 Ref<InspectorBackendDispatchTask> m_dispatchTask;
146 Ref<InspectorFrontendAPIDispatcher> m_frontendAPIDispatcher;
149 } // namespace WebCore