From 052e79299f4ada27eacc89ab36ddafda2e91a4db Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 27 Sep 2017 17:35:58 +0200 Subject: Clean up remote devtools implementation Rename the file after the contents has been refactored being different classes, and switch to using Chromium discover HTML page which we now have available and which works. Change-Id: Ic04a56471be3a49e5d1dd4b1f914eda927272d89 Reviewed-by: Viktor Engelmann --- mkspecs/features/gn_generator.prf | 36 +++-- src/core/content_browser_client_qt.cpp | 2 +- src/core/core_chromium.pri | 6 +- src/core/dev_tools_http_handler_delegate_qt.cpp | 199 ------------------------ src/core/dev_tools_http_handler_delegate_qt.h | 86 ---------- src/core/devtools.qrc | 5 - src/core/devtools_manager_delegate_qt.cpp | 192 +++++++++++++++++++++++ src/core/devtools_manager_delegate_qt.h | 86 ++++++++++ src/core/resources/devtools_discovery_page.html | 140 ----------------- src/core/web_engine_context.cpp | 2 +- 10 files changed, 301 insertions(+), 453 deletions(-) delete mode 100644 src/core/dev_tools_http_handler_delegate_qt.cpp delete mode 100644 src/core/dev_tools_http_handler_delegate_qt.h delete mode 100644 src/core/devtools.qrc create mode 100644 src/core/devtools_manager_delegate_qt.cpp create mode 100644 src/core/devtools_manager_delegate_qt.h delete mode 100644 src/core/resources/devtools_discovery_page.html diff --git a/mkspecs/features/gn_generator.prf b/mkspecs/features/gn_generator.prf index b2b749154..c59bc0d98 100644 --- a/mkspecs/features/gn_generator.prf +++ b/mkspecs/features/gn_generator.prf @@ -82,23 +82,25 @@ GN_CONTENTS += "}" CLEAN_QMAKE_RCC = $$clean_path($$QMAKE_RCC) -GN_CONTENTS += "action_foreach(\"generate_resources\") {"\ - " script = \"$$GN_RUN_BINARY_SCRIPT\"" -GN_CONTENTS += " sources = [" -for (sourcefile, RESOURCES): GN_CONTENTS += " \"$$GN_SRC_DIR/$$sourcefile\"," -GN_CONTENTS += " ]" \ - " outputs = [ \"$target_gen_dir/.rcc/qrc_{{source_name_part}}.cpp\" ]" -GN_CONTENTS += " inputs = [ \"$$system_path($$_PRO_FILE_)\" ]" \ - " args = [" \ - " \"$$replace(CLEAN_QMAKE_RCC,\",\\\")\"," -for(resource_flag, $$QMAKE_RESOURCE_FLAGS): GN_CONTENTS += " \"$$resource_flag\"" -GN_CONTENTS += " \"-name\"," \ - " \"{{source_name_part}}\"," \ - " \"{{source}}\"," \ - " \"-o\"," \ - " rebase_path(\"$target_gen_dir/.rcc/qrc_{{source_name_part}}.cpp\")"\ - " ]" -GN_CONTENTS += "}" +!isEmpty(RESOURCES) { + GN_CONTENTS += "action_foreach(\"generate_resources\") {"\ + " script = \"$$GN_RUN_BINARY_SCRIPT\"" + GN_CONTENTS += " sources = [" + for (sourcefile, RESOURCES): GN_CONTENTS += " \"$$GN_SRC_DIR/$$sourcefile\"," + GN_CONTENTS += " ]" \ + " outputs = [ \"$target_gen_dir/.rcc/qrc_{{source_name_part}}.cpp\" ]" + GN_CONTENTS += " inputs = [ \"$$system_path($$_PRO_FILE_)\" ]" \ + " args = [" \ + " \"$$replace(CLEAN_QMAKE_RCC,\",\\\")\"," + for(resource_flag, $$QMAKE_RESOURCE_FLAGS): GN_CONTENTS += " \"$$resource_flag\"" + GN_CONTENTS += " \"-name\"," \ + " \"{{source_name_part}}\"," \ + " \"{{source}}\"," \ + " \"-o\"," \ + " rebase_path(\"$target_gen_dir/.rcc/qrc_{{source_name_part}}.cpp\")"\ + " ]" + GN_CONTENTS += "}" +} # TARGET SETUP diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index a422c63a3..85cca235a 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -85,7 +85,7 @@ #include "certificate_error_controller.h" #include "certificate_error_controller_p.h" #include "desktop_screen_qt.h" -#include "dev_tools_http_handler_delegate_qt.h" +#include "devtools_manager_delegate_qt.h" #ifdef QT_USE_POSITIONING #include "location_provider_qt.h" #else diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index 6b43b08b7..179266900 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -32,8 +32,6 @@ qtConfig(embedded): DEFINES += QTWEBENGINE_EMBEDDED_SWITCHES qtConfig(egl): CONFIG += egl -RESOURCES += devtools.qrc - INCLUDEPATH += $$PWD $$PWD/api SOURCES = \ @@ -61,7 +59,7 @@ SOURCES = \ custom_protocol_handler.cpp \ delegated_frame_node.cpp \ desktop_screen_qt.cpp \ - dev_tools_http_handler_delegate_qt.cpp \ + devtools_manager_delegate_qt.cpp \ download_manager_delegate_qt.cpp \ favicon_manager.cpp \ file_picker_controller.cpp \ @@ -138,7 +136,7 @@ HEADERS = \ custom_protocol_handler.h \ delegated_frame_node.h \ desktop_screen_qt.h \ - dev_tools_http_handler_delegate_qt.h \ + devtools_manager_delegate_qt.h \ download_manager_delegate_qt.h \ chromium_gpu_helper.h \ favicon_manager_p.h \ diff --git a/src/core/dev_tools_http_handler_delegate_qt.cpp b/src/core/dev_tools_http_handler_delegate_qt.cpp deleted file mode 100644 index 468c5f05f..000000000 --- a/src/core/dev_tools_http_handler_delegate_qt.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "dev_tools_http_handler_delegate_qt.h" - -#include "type_conversion.h" - -#include -#include - -#include "base/command_line.h" -#include "base/files/file_path.h" -#include "base/memory/ptr_util.h" -#include "base/strings/string_number_conversions.h" -#include "base/strings/utf_string_conversions.h" -#include "content/browser/devtools/devtools_http_handler.h" -#include "content/public/browser/devtools_agent_host.h" -#include "content/public/browser/devtools_frontend_host.h" -#include "content/public/browser/devtools_socket_factory.h" -#include "content/public/browser/favicon_status.h" -#include "content/public/browser/navigation_entry.h" -#include "content/public/browser/render_view_host.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_delegate.h" -#include "content/public/common/content_switches.h" -#include "net/base/ip_endpoint.h" -#include "net/base/net_errors.h" -#include "net/socket/tcp_server_socket.h" - -using namespace content; - -namespace { - -class TCPServerSocketFactory : public content::DevToolsSocketFactory { -public: - TCPServerSocketFactory(const std::string& address, int port, int backlog) - : m_address(address), m_port(port), m_backlog(backlog) - {} -private: - std::unique_ptr CreateForHttpServer() override { - std::unique_ptr socket(new net::TCPServerSocket(nullptr, net::NetLogSource())); - if (socket->ListenWithAddressAndPort(m_address, m_port, m_backlog) != net::OK) - return std::unique_ptr(); - - return socket; - } - std::unique_ptr CreateForTethering(std::string* out_name) override - { - return nullptr; - } - - const std::string m_address; - int m_port; - int m_backlog; - DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory); -}; - -} // namespace - -namespace QtWebEngineCore { - -DevToolsServerQt::DevToolsServerQt() - : m_bindAddress(QLatin1String("127.0.0.1")) - , m_port(0) - , m_valid(false) - , m_isStarted(false) -{ } - -DevToolsServerQt::~DevToolsServerQt() -{ - stop(); -} - -void DevToolsServerQt::parseAddressAndPort() -{ - const QString inspectorEnv = QString::fromUtf8(qgetenv("QTWEBENGINE_REMOTE_DEBUGGING")); - const base::CommandLine &commandLine = *base::CommandLine::ForCurrentProcess(); - QString portStr; - - if (commandLine.HasSwitch(switches::kRemoteDebuggingPort)) { - portStr = QString::fromStdString(commandLine.GetSwitchValueASCII(switches::kRemoteDebuggingPort)); - } else if (!inspectorEnv.isEmpty()) { - int portColonPos = inspectorEnv.lastIndexOf(':'); - if (portColonPos != -1) { - portStr = inspectorEnv.mid(portColonPos + 1); - m_bindAddress = inspectorEnv.mid(0, portColonPos); - } else - portStr = inspectorEnv; - } else - return; - - m_port = portStr.toInt(&m_valid); - m_valid = m_valid && (m_port > 0 && m_port < 65535); - if (!m_valid) - qWarning("Invalid port given for the inspector server \"%s\". Examples of valid input: \"12345\" or \"192.168.2.14:12345\" (with the address of one of this host's network interface).", qPrintable(portStr)); -} - -std::unique_ptr DevToolsServerQt::CreateSocketFactory() -{ - if (!m_valid) - return nullptr; - return std::unique_ptr( - new TCPServerSocketFactory(m_bindAddress.toStdString(), m_port, 1)); -} - - -void DevToolsServerQt::start() -{ - if (m_isStarted) - return; - - if (!m_valid) - parseAddressAndPort(); - - std::unique_ptr socketFactory = CreateSocketFactory(); - if (!socketFactory) - return; - - m_isStarted = true; - DevToolsAgentHost::StartRemoteDebuggingServer( - std::move(socketFactory), std::string(), - base::FilePath(), base::FilePath(), - std::string(), std::string()); -} - -void DevToolsServerQt::stop() -{ - DevToolsAgentHost::StopRemoteDebuggingServer(); - m_isStarted = false; -} - -void DevToolsManagerDelegateQt::Initialized(const net::IPEndPoint *ip_address) -{ - if (ip_address && ip_address->address().size()) { - QString addressAndPort = QString::fromStdString(ip_address->ToString()); - qWarning("Remote debugging server started successfully. Try pointing a Chromium-based browser to http://%s", qPrintable(addressAndPort)); - } - else - qWarning("Couldn't start the inspector server on bind address. In case of invalid input, try something like: \"12345\" or \"192.168.2.14:12345\" (with the address of one of this host's interface)."); -} - -std::string DevToolsManagerDelegateQt::GetDiscoveryPageHTML() -{ - static std::string html; - if (html.empty()) { - QFile html_file(":/data/discovery_page.html"); - html_file.open(QIODevice::ReadOnly); - QByteArray contents = html_file.readAll(); - html = contents.data(); - } - return html; -} - -std::string DevToolsManagerDelegateQt::GetFrontendResource(const std::string& path) -{ - return content::DevToolsFrontendHost::GetFrontendResource(path).as_string(); -} - -} //namespace QtWebEngineCore diff --git a/src/core/dev_tools_http_handler_delegate_qt.h b/src/core/dev_tools_http_handler_delegate_qt.h deleted file mode 100644 index 1b0e82bc0..000000000 --- a/src/core/dev_tools_http_handler_delegate_qt.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DEV_TOOLS_HTTP_HANDLER_DELEGATE_QT_H -#define DEV_TOOLS_HTTP_HANDLER_DELEGATE_QT_H - -#include "content/public/browser/devtools_manager_delegate.h" - -#include - -namespace content { -class DevToolsSocketFactory; -} - -namespace QtWebEngineCore { - -class DevToolsServerQt { -public: - DevToolsServerQt(); - ~DevToolsServerQt(); - - bool isValid() const { return m_valid; } - QString bindAddress() const { return m_bindAddress; } - int port() const { return m_port; } - - void start(); - void stop(); - bool isStarted() const { return m_isStarted; } - -private: - void parseAddressAndPort(); - std::unique_ptr CreateSocketFactory(); - - QString m_bindAddress; - int m_port; - bool m_valid; - bool m_isStarted; -}; - - -class DevToolsManagerDelegateQt : public content::DevToolsManagerDelegate { -public: - std::string GetDiscoveryPageHTML() override; - std::string GetFrontendResource(const std::string& path) override; - void Initialized(const net::IPEndPoint *ip_address) override; -}; - -} // namespace QtWebEngineCore - -#endif // DEV_TOOLS_HTTP_HANDLER_DELEGATE_QT_H diff --git a/src/core/devtools.qrc b/src/core/devtools.qrc deleted file mode 100644 index 6656304ac..000000000 --- a/src/core/devtools.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - resources/devtools_discovery_page.html - - diff --git a/src/core/devtools_manager_delegate_qt.cpp b/src/core/devtools_manager_delegate_qt.cpp new file mode 100644 index 000000000..4fad2f514 --- /dev/null +++ b/src/core/devtools_manager_delegate_qt.cpp @@ -0,0 +1,192 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// based on content/shell/browser/shell_devtools_manager_delegate.cc: +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "devtools_manager_delegate_qt.h" + +#include "base/command_line.h" +#include "base/files/file_path.h" +#include "base/memory/ptr_util.h" +#include "base/strings/string_number_conversions.h" +#include "base/strings/utf_string_conversions.h" +#include "chrome/grit/qt_webengine_resources.h" +#include "content/browser/devtools/devtools_http_handler.h" +#include "content/public/browser/devtools_agent_host.h" +#include "content/public/browser/devtools_frontend_host.h" +#include "content/public/browser/devtools_socket_factory.h" +#include "content/public/browser/favicon_status.h" +#include "content/public/browser/navigation_entry.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_delegate.h" +#include "content/public/common/content_switches.h" +#include "net/base/ip_endpoint.h" +#include "net/base/net_errors.h" +#include "net/socket/tcp_server_socket.h" +#include "ui/base/resource/resource_bundle.h" + +#include "type_conversion.h" + +using content::DevToolsAgentHost; + +namespace { + +class TCPServerSocketFactory : public content::DevToolsSocketFactory { +public: + TCPServerSocketFactory(const std::string& address, int port, int backlog) + : m_address(address), m_port(port), m_backlog(backlog) + {} +private: + std::unique_ptr CreateForHttpServer() override { + std::unique_ptr socket(new net::TCPServerSocket(nullptr, net::NetLogSource())); + if (socket->ListenWithAddressAndPort(m_address, m_port, m_backlog) != net::OK) + return std::unique_ptr(); + + return socket; + } + std::unique_ptr CreateForTethering(std::string* out_name) override + { + return nullptr; + } + + const std::string m_address; + int m_port; + int m_backlog; + DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory); +}; + +} // namespace + +namespace QtWebEngineCore { + +DevToolsServerQt::DevToolsServerQt() + : m_bindAddress(QLatin1String("127.0.0.1")) + , m_port(0) + , m_valid(false) + , m_isStarted(false) +{ } + +DevToolsServerQt::~DevToolsServerQt() +{ + stop(); +} + +void DevToolsServerQt::parseAddressAndPort() +{ + const QString inspectorEnv = QString::fromUtf8(qgetenv("QTWEBENGINE_REMOTE_DEBUGGING")); + const base::CommandLine &commandLine = *base::CommandLine::ForCurrentProcess(); + QString portStr; + + if (commandLine.HasSwitch(switches::kRemoteDebuggingPort)) { + portStr = QString::fromStdString(commandLine.GetSwitchValueASCII(switches::kRemoteDebuggingPort)); + } else if (!inspectorEnv.isEmpty()) { + int portColonPos = inspectorEnv.lastIndexOf(':'); + if (portColonPos != -1) { + portStr = inspectorEnv.mid(portColonPos + 1); + m_bindAddress = inspectorEnv.mid(0, portColonPos); + } else + portStr = inspectorEnv; + } else + return; + + m_port = portStr.toInt(&m_valid); + m_valid = m_valid && (m_port > 0 && m_port < 65535); + if (!m_valid) + qWarning("Invalid port given for the inspector server \"%s\". Examples of valid input: \"12345\" or \"192.168.2.14:12345\" (with the address of one of this host's network interface).", qPrintable(portStr)); +} + +std::unique_ptr DevToolsServerQt::CreateSocketFactory() +{ + if (!m_valid) + return nullptr; + return std::unique_ptr( + new TCPServerSocketFactory(m_bindAddress.toStdString(), m_port, 1)); +} + + +void DevToolsServerQt::start() +{ + if (m_isStarted) + return; + + if (!m_valid) + parseAddressAndPort(); + + std::unique_ptr socketFactory = CreateSocketFactory(); + if (!socketFactory) + return; + + m_isStarted = true; + DevToolsAgentHost::StartRemoteDebuggingServer( + std::move(socketFactory), std::string(), + base::FilePath(), base::FilePath(), + std::string(), std::string()); +} + +void DevToolsServerQt::stop() +{ + DevToolsAgentHost::StopRemoteDebuggingServer(); + m_isStarted = false; +} + +void DevToolsManagerDelegateQt::Initialized(const net::IPEndPoint *ip_address) +{ + if (ip_address && ip_address->address().size()) { + QString addressAndPort = QString::fromStdString(ip_address->ToString()); + qWarning("Remote debugging server started successfully. Try pointing a Chromium-based browser to http://%s", qPrintable(addressAndPort)); + } + else + qWarning("Couldn't start the inspector server on bind address. In case of invalid input, try something like: \"12345\" or \"192.168.2.14:12345\" (with the address of one of this host's interface)."); +} + +std::string DevToolsManagerDelegateQt::GetDiscoveryPageHTML() +{ + return ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string(); +} + +std::string DevToolsManagerDelegateQt::GetFrontendResource(const std::string& path) +{ + return content::DevToolsFrontendHost::GetFrontendResource(path).as_string(); +} + +} //namespace QtWebEngineCore diff --git a/src/core/devtools_manager_delegate_qt.h b/src/core/devtools_manager_delegate_qt.h new file mode 100644 index 000000000..1b0e82bc0 --- /dev/null +++ b/src/core/devtools_manager_delegate_qt.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DEV_TOOLS_HTTP_HANDLER_DELEGATE_QT_H +#define DEV_TOOLS_HTTP_HANDLER_DELEGATE_QT_H + +#include "content/public/browser/devtools_manager_delegate.h" + +#include + +namespace content { +class DevToolsSocketFactory; +} + +namespace QtWebEngineCore { + +class DevToolsServerQt { +public: + DevToolsServerQt(); + ~DevToolsServerQt(); + + bool isValid() const { return m_valid; } + QString bindAddress() const { return m_bindAddress; } + int port() const { return m_port; } + + void start(); + void stop(); + bool isStarted() const { return m_isStarted; } + +private: + void parseAddressAndPort(); + std::unique_ptr CreateSocketFactory(); + + QString m_bindAddress; + int m_port; + bool m_valid; + bool m_isStarted; +}; + + +class DevToolsManagerDelegateQt : public content::DevToolsManagerDelegate { +public: + std::string GetDiscoveryPageHTML() override; + std::string GetFrontendResource(const std::string& path) override; + void Initialized(const net::IPEndPoint *ip_address) override; +}; + +} // namespace QtWebEngineCore + +#endif // DEV_TOOLS_HTTP_HANDLER_DELEGATE_QT_H diff --git a/src/core/resources/devtools_discovery_page.html b/src/core/resources/devtools_discovery_page.html deleted file mode 100644 index d37dbfcf4..000000000 --- a/src/core/resources/devtools_discovery_page.html +++ /dev/null @@ -1,140 +0,0 @@ - - -QtWebEngine Remote Debugging - - - - - -
Inspectable pages
-
-
-
- - diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 8eb9075bc..f7557ebf4 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -82,7 +82,7 @@ #include "content_browser_client_qt.h" #include "content_client_qt.h" #include "content_main_delegate_qt.h" -#include "dev_tools_http_handler_delegate_qt.h" +#include "devtools_manager_delegate_qt.h" #include "gl_context_qt.h" #include "media_capture_devices_dispatcher.h" #include "type_conversion.h" -- cgit v1.2.3