diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-09-27 17:35:58 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-10-13 12:26:54 +0000 |
commit | 052e79299f4ada27eacc89ab36ddafda2e91a4db (patch) | |
tree | ff2e1d7d8e4eb69c902cc69d4914282cc3be25f7 | |
parent | 4c1cde9a1909162fbddeabd958a5f5acc43c83d6 (diff) |
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 <viktor.engelmann@qt.io>
-rw-r--r-- | mkspecs/features/gn_generator.prf | 36 | ||||
-rw-r--r-- | src/core/content_browser_client_qt.cpp | 2 | ||||
-rw-r--r-- | src/core/core_chromium.pri | 6 | ||||
-rw-r--r-- | src/core/devtools.qrc | 5 | ||||
-rw-r--r-- | src/core/devtools_manager_delegate_qt.cpp (renamed from src/core/dev_tools_http_handler_delegate_qt.cpp) | 23 | ||||
-rw-r--r-- | src/core/devtools_manager_delegate_qt.h (renamed from src/core/dev_tools_http_handler_delegate_qt.h) | 0 | ||||
-rw-r--r-- | src/core/resources/devtools_discovery_page.html | 140 | ||||
-rw-r--r-- | src/core/web_engine_context.cpp | 2 |
8 files changed, 31 insertions, 183 deletions
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/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 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix="data"> - <file alias="discovery_page.html">resources/devtools_discovery_page.html</file> -</qresource> -</RCC> diff --git a/src/core/dev_tools_http_handler_delegate_qt.cpp b/src/core/devtools_manager_delegate_qt.cpp index 468c5f05f..4fad2f514 100644 --- a/src/core/dev_tools_http_handler_delegate_qt.cpp +++ b/src/core/devtools_manager_delegate_qt.cpp @@ -37,22 +37,19 @@ ** ****************************************************************************/ +// 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 "dev_tools_http_handler_delegate_qt.h" - -#include "type_conversion.h" - -#include <QByteArray> -#include <QFile> +#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" @@ -66,8 +63,11 @@ #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" -using namespace content; +#include "type_conversion.h" + +using content::DevToolsAgentHost; namespace { @@ -181,14 +181,7 @@ void DevToolsManagerDelegateQt::Initialized(const net::IPEndPoint *ip_address) 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; + return ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string(); } std::string DevToolsManagerDelegateQt::GetFrontendResource(const std::string& path) diff --git a/src/core/dev_tools_http_handler_delegate_qt.h b/src/core/devtools_manager_delegate_qt.h index 1b0e82bc0..1b0e82bc0 100644 --- a/src/core/dev_tools_http_handler_delegate_qt.h +++ b/src/core/devtools_manager_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 @@ -<html> -<head> -<title>QtWebEngine Remote Debugging</title> -<style> -body { - color: #222; - font-family: Helvetica, Arial, sans-serif; - margin: 0; - text-shadow: rgba(255, 255, 255, 0.496094) 0px 1px 0px; -} - -#caption { - font-size: 16px; - margin-top: 15px; - margin-bottom: 10px; - margin-left: 20px; - height: 20px; - text-align: left; -} - -#items { - display: flex; - flex-direction: column; - margin: 10px; -} - -.item { - color: #222; - display: flex; - flex-direction: row; - text-decoration: none; - padding: 10px; - -webkit-transition-property: background-color, border-color; - -webkit-transition: background-color 0.15s, 0.15s; - -webkit-transition-delay: 0ms, 0ms; -} - -.item:not(.connected):hover { - background-color: rgba(242, 242, 242, 1); - border-color: rgba(110, 116, 128, 1); - color: black; -} - -.item.connected:hover { - border-color: rgba(184, 184, 184, 1); - color: rgb(110, 116, 128); -} - -.description { - display: flex; - flex-direction: column; -} - -.title, .subtitle { - font-size: 13px; - margin: 4px 0px 0px 6px; - overflow: hidden; - padding-left: 20px; -} - -.title { - background-repeat: no-repeat; - background-size: 16px; - font-size: 15px; -} - - -</style> - -<script> - -function onLoad() { - var tabsListRequest = new XMLHttpRequest(); - tabsListRequest.open('GET', '/json/list', true); - tabsListRequest.onreadystatechange = onReady; - tabsListRequest.send(); -} - -function onReady() { - if(this.readyState == 4 && this.status == 200) { - if(this.response != null) - var responseJSON = JSON.parse(this.response); - for (var i = 0; i < responseJSON.length; ++i) - appendItem(responseJSON[i]); - } -} - -function overrideFrontendUrl(item) { - if (window.location.hash) { - var overridden_url = window.location.hash.substr(1); - var ws_suffix = item.webSocketDebuggerUrl.replace('ws://', 'ws='); - if (overridden_url.indexOf('?') == -1) - return overridden_url + '?' + ws_suffix; - else - return overridden_url + '&' + ws_suffix; - } - return item.devtoolsFrontendUrl; -} - -function appendItem(item_object) { - var item_element; - if (item_object.devtoolsFrontendUrl) { - item_element = document.createElement('a'); - item_element.href = overrideFrontendUrl(item_object); - item_element.title = item_object.title; - } else { - item_element = document.createElement('div'); - item_element.className = 'connected'; - item_element.title = 'The tab already has an active debug session'; - } - item_element.classList.add('item'); - - var description = document.createElement('div'); - description.className = 'description'; - - var title = document.createElement('div'); - title.className = 'title'; - title.textContent = item_object.description || item_object.title; - title.style.cssText = 'background-image:url(' + - item_object.faviconUrl + ')'; - description.appendChild(title); - - var subtitle = document.createElement('div'); - subtitle.className = 'subtitle'; - subtitle.textContent = (item_object.url || '').substring(0, 300); - description.appendChild(subtitle); - - item_element.appendChild(description); - - document.getElementById('items').appendChild(item_element); -} -</script> -</head> -<body onload='onLoad()'> - <div id='caption'>Inspectable pages</div> - <hr> - <div id='items'> - </div> -</body> -</html> 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" |