~mmach/netext73/webkit2gtk

« back to all changes in this revision

Viewing changes to Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.h

  • Committer: mmach
  • Date: 2023-06-16 17:21:37 UTC
  • Revision ID: netbit73@gmail.com-20230616172137-2rqx6yr96ga9g3kp
1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2016 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
 * 1. Redistributions of source code must retain the above copyright
 
8
 *    notice, this list of conditions and the following disclaimer.
 
9
 * 2. Redistributions in binary form must reproduce the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer in the
 
11
 *    documentation and/or other materials provided with the distribution.
 
12
 *
 
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 
23
 * THE POSSIBILITY OF SUCH DAMAGE.
 
24
 */
 
25
 
 
26
#pragma once
 
27
 
 
28
#include "APIObject.h"
 
29
#include "MessageReceiver.h"
 
30
#include <WebCore/FloatRect.h>
 
31
#include <wtf/Forward.h>
 
32
#include <wtf/HashMap.h>
 
33
#include <wtf/RetainPtr.h>
 
34
#include <wtf/text/WTFString.h>
 
35
 
 
36
#if PLATFORM(MAC)
 
37
OBJC_CLASS NSURL;
 
38
OBJC_CLASS NSWindow;
 
39
OBJC_CLASS WKInspectorViewController;
 
40
OBJC_CLASS WKRemoteWebInspectorProxyObjCAdapter;
 
41
OBJC_CLASS WKWebView;
 
42
#endif
 
43
 
 
44
namespace WebCore {
 
45
class CertificateInfo;
 
46
}
 
47
 
 
48
namespace API {
 
49
class DebuggableInfo;
 
50
}
 
51
 
 
52
namespace WebKit {
 
53
 
 
54
class WebPageProxy;
 
55
class WebView;
 
56
 
 
57
class RemoteWebInspectorProxyClient {
 
58
public:
 
59
    virtual ~RemoteWebInspectorProxyClient() { }
 
60
    virtual void sendMessageToBackend(const String& message) = 0;
 
61
    virtual void closeFromFrontend() = 0;
 
62
};
 
63
 
 
64
class RemoteWebInspectorProxy : public RefCounted<RemoteWebInspectorProxy>, public IPC::MessageReceiver {
 
65
public:
 
66
    static Ref<RemoteWebInspectorProxy> create()
 
67
    {
 
68
        return adoptRef(*new RemoteWebInspectorProxy());
 
69
    }
 
70
 
 
71
    ~RemoteWebInspectorProxy();
 
72
 
 
73
    void setClient(RemoteWebInspectorProxyClient* client) { m_client = client; }
 
74
 
 
75
    bool isUnderTest() const { return false; }
 
76
 
 
77
    void setDiagnosticLoggingAvailable(bool);
 
78
 
 
79
    void invalidate();
 
80
 
 
81
    void load(Ref<API::DebuggableInfo>&&, const String& backendCommandsURL);
 
82
    void closeFromBackend();
 
83
    void show();
 
84
 
 
85
    void sendMessageToFrontend(const String& message);
 
86
 
 
87
#if PLATFORM(MAC)
 
88
    NSWindow *window() const { return m_window.get(); }
 
89
    WKWebView *webView() const;
 
90
 
 
91
    const WebCore::FloatRect& sheetRect() const { return m_sheetRect; }
 
92
#endif
 
93
 
 
94
#if PLATFORM(GTK)
 
95
    void updateWindowTitle(const CString&);
 
96
#endif
 
97
 
 
98
#if PLATFORM(WIN_CAIRO)
 
99
    LRESULT sizeChange();
 
100
    LRESULT onClose();
 
101
 
 
102
    static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
 
103
#endif
 
104
 
 
105
    void closeFromCrash();
 
106
 
 
107
private:
 
108
    RemoteWebInspectorProxy();
 
109
 
 
110
    // IPC::MessageReceiver
 
111
    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
 
112
 
 
113
    // RemoteWebInspectorProxy messages.
 
114
    void frontendDidClose();
 
115
    void reopen();
 
116
    void resetState();
 
117
    void bringToFront();
 
118
    void save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
 
119
    void append(const String& filename, const String& content);
 
120
    void setSheetRect(const WebCore::FloatRect&);
 
121
    void startWindowDrag();
 
122
    void openInNewTab(const String& url);
 
123
    void showCertificate(const WebCore::CertificateInfo&);
 
124
    void sendMessageToBackend(const String& message);
 
125
 
 
126
    void createFrontendPageAndWindow();
 
127
    void closeFrontendPageAndWindow();
 
128
 
 
129
    // Platform implementations.
 
130
    WebPageProxy* platformCreateFrontendPageAndWindow();
 
131
    void platformCloseFrontendPageAndWindow();
 
132
    void platformResetState();
 
133
    void platformBringToFront();
 
134
    void platformSave(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
 
135
    void platformAppend(const String& filename, const String& content);
 
136
    void platformSetSheetRect(const WebCore::FloatRect&);
 
137
    void platformStartWindowDrag();
 
138
    void platformOpenInNewTab(const String& url);
 
139
    void platformShowCertificate(const WebCore::CertificateInfo&);
 
140
 
 
141
    RemoteWebInspectorProxyClient* m_client { nullptr };
 
142
    WebPageProxy* m_inspectorPage { nullptr };
 
143
 
 
144
    Ref<API::DebuggableInfo> m_debuggableInfo;
 
145
    String m_backendCommandsURL;
 
146
 
 
147
#if PLATFORM(MAC)
 
148
    RetainPtr<WKInspectorViewController> m_inspectorView;
 
149
    RetainPtr<NSWindow> m_window;
 
150
    RetainPtr<WKRemoteWebInspectorProxyObjCAdapter> m_objCAdapter;
 
151
    HashMap<String, RetainPtr<NSURL>> m_suggestedToActualURLMap;
 
152
    WebCore::FloatRect m_sheetRect;
 
153
#endif
 
154
#if PLATFORM(GTK)
 
155
    GtkWidget* m_webView { nullptr };
 
156
    GtkWidget* m_window { nullptr };
 
157
#endif
 
158
#if PLATFORM(WIN_CAIRO)
 
159
    HWND m_frontendHandle;
 
160
    RefPtr<WebView> m_webView;
 
161
#endif
 
162
};
 
163
 
 
164
} // namespace WebKit