2
* Copyright (C) 2016 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
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.
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.
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>
39
OBJC_CLASS WKInspectorViewController;
40
OBJC_CLASS WKRemoteWebInspectorProxyObjCAdapter;
45
class CertificateInfo;
57
class RemoteWebInspectorProxyClient {
59
virtual ~RemoteWebInspectorProxyClient() { }
60
virtual void sendMessageToBackend(const String& message) = 0;
61
virtual void closeFromFrontend() = 0;
64
class RemoteWebInspectorProxy : public RefCounted<RemoteWebInspectorProxy>, public IPC::MessageReceiver {
66
static Ref<RemoteWebInspectorProxy> create()
68
return adoptRef(*new RemoteWebInspectorProxy());
71
~RemoteWebInspectorProxy();
73
void setClient(RemoteWebInspectorProxyClient* client) { m_client = client; }
75
bool isUnderTest() const { return false; }
77
void setDiagnosticLoggingAvailable(bool);
81
void load(Ref<API::DebuggableInfo>&&, const String& backendCommandsURL);
82
void closeFromBackend();
85
void sendMessageToFrontend(const String& message);
88
NSWindow *window() const { return m_window.get(); }
89
WKWebView *webView() const;
91
const WebCore::FloatRect& sheetRect() const { return m_sheetRect; }
95
void updateWindowTitle(const CString&);
98
#if PLATFORM(WIN_CAIRO)
102
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
105
void closeFromCrash();
108
RemoteWebInspectorProxy();
110
// IPC::MessageReceiver
111
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
113
// RemoteWebInspectorProxy messages.
114
void frontendDidClose();
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);
126
void createFrontendPageAndWindow();
127
void closeFrontendPageAndWindow();
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&);
141
RemoteWebInspectorProxyClient* m_client { nullptr };
142
WebPageProxy* m_inspectorPage { nullptr };
144
Ref<API::DebuggableInfo> m_debuggableInfo;
145
String m_backendCommandsURL;
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;
155
GtkWidget* m_webView { nullptr };
156
GtkWidget* m_window { nullptr };
158
#if PLATFORM(WIN_CAIRO)
159
HWND m_frontendHandle;
160
RefPtr<WebView> m_webView;
164
} // namespace WebKit