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 "MessageReceiver.h"
29#include "WebInspectorFrontendAPIDispatcher.h"
30#include <WebCore/InspectorFrontendClient.h>
31#include <WebCore/InspectorFrontendHost.h>
32#include <wtf/Deque.h>
33
34namespace WebCore {
35class CertificateInfo;
36class FloatRect;
37}
38
39namespace WebKit {
40
41class WebPage;
42
43class RemoteWebInspectorUI final : public RefCounted<RemoteWebInspectorUI>, public IPC::MessageReceiver, public WebCore::InspectorFrontendClient {
44public:
45 static Ref<RemoteWebInspectorUI> create(WebPage&);
46
47 // Implemented in generated RemoteWebInspectorUIMessageReceiver.cpp
48 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
49
50 // Called by RemoteWebInspectorUI messages
51 void initialize(const String& debuggableType, const String& backendCommandsURL);
52 void didSave(const String& url);
53 void didAppend(const String& url);
54 void sendMessageToFrontend(const String&);
55
56 // WebCore::InspectorFrontendClient
57 void windowObjectCleared() override;
58 void frontendLoaded() override;
59 void changeSheetRect(const WebCore::FloatRect&) override;
60 void startWindowDrag() override;
61 void moveWindowBy(float x, float y) override;
62
63 bool isRemote() const final { return true; }
64 String localizedStringsURL() override;
65 String backendCommandsURL() override { return m_backendCommandsURL; }
66 String debuggableType() override { return m_debuggableType; }
67
68 WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() const override;
69
70 void bringToFront() override;
71 void closeWindow() override;
72 void reopen() override;
73
74 void openInNewTab(const String& url) override;
75 void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs) override;
76 void append(const String& url, const String& content) override;
77 void inspectedURLChanged(const String&) override;
78 void showCertificate(const WebCore::CertificateInfo&) override;
79 void sendMessageToBackend(const String&) override;
80
81 bool canSave() override { return true; }
82 bool isUnderTest() override { return false; }
83 unsigned inspectionLevel() const override { return 1; }
84 void requestSetDockSide(DockSide) override { }
85 void changeAttachedWindowHeight(unsigned) override { }
86 void changeAttachedWindowWidth(unsigned) override { }
87
88private:
89 explicit RemoteWebInspectorUI(WebPage&);
90
91 WebPage& m_page;
92 WebInspectorFrontendAPIDispatcher m_frontendAPIDispatcher;
93 RefPtr<WebCore::InspectorFrontendHost> m_frontendHost;
94 String m_debuggableType;
95 String m_backendCommandsURL;
96};
97
98} // namespace WebKit
99