diff options
-rw-r--r-- | build/qmake/mkspecs/features/gyp_generator.prf | 20 | ||||
-rw-r--r-- | lib/content_browser_client_qt.cpp | 10 | ||||
-rw-r--r-- | lib/content_browser_client_qt.h | 5 | ||||
-rw-r--r-- | lib/content_client_qt.cpp | 50 | ||||
-rw-r--r-- | lib/content_client_qt.h | 55 | ||||
-rw-r--r-- | lib/dev_tools_http_handler_delegate_qt.cpp | 108 | ||||
-rw-r--r-- | lib/dev_tools_http_handler_delegate_qt.h | 80 | ||||
-rw-r--r-- | lib/devtools.qrc | 6 | ||||
-rw-r--r-- | lib/lib.pro | 11 | ||||
-rw-r--r-- | lib/quick/qquickwebengineview.cpp | 14 | ||||
-rw-r--r-- | lib/quick/qquickwebengineview_p.h | 3 | ||||
-rw-r--r-- | lib/quick/qquickwebengineview_p_p.h | 1 | ||||
-rw-r--r-- | lib/web_contents_adapter.cpp | 5 | ||||
-rw-r--r-- | lib/web_contents_adapter.h | 1 | ||||
-rw-r--r-- | lib/web_engine_context.cpp | 7 | ||||
-rw-r--r-- | resources/devtools_discovery_page.html | 57 | ||||
-rw-r--r-- | shared/resource_bundle_qt.cpp | 19 |
17 files changed, 441 insertions, 11 deletions
diff --git a/build/qmake/mkspecs/features/gyp_generator.prf b/build/qmake/mkspecs/features/gyp_generator.prf index d75372d10..768fe43d4 100644 --- a/build/qmake/mkspecs/features/gyp_generator.prf +++ b/build/qmake/mkspecs/features/gyp_generator.prf @@ -167,13 +167,27 @@ GYP_CONTENTS += " ]," GYP_CONTENTS += " ]," } -# Generate the actions for moc +# Some needed files (like devtools_resources.pak) are both _generated_ as part of the build process and are _needed_ as part of the build process. +!isEmpty(COPY_FILES) { + GYP_CONTENTS += " 'copies': [" + for (index, 0..$$size(COPY_FILES)) { + copyFile = $$member(COPY_FILES, $$index) + !isEmpty(copyFile) { + copyDestination = $$member(COPY_DESTINATIONS, $$index) + GYP_CONTENTS += " {'destination': '$$copyDestination', 'files': ['$$copyFile']}," + } + } + GYP_CONTENTS += " ]," +} + +# Generate the actions for moc, copy GYP_CONTENTS += " 'actions': [" for(resourcefile, RESOURCES): GYP_CONTENTS += $$rccAction($$resourcefile) for(header, MOCABLE_HEADERS): GYP_CONTENTS += $$mocAction($$header) GYP_CONTENTS += " ]," \ - " }," \ - " ]," \ + " }," + +GYP_CONTENTS += " ]," \ "}" write_file($$GYPI_FILE, GYP_CONTENTS) diff --git a/lib/content_browser_client_qt.cpp b/lib/content_browser_client_qt.cpp index 2ba888e68..4ff15d3b1 100644 --- a/lib/content_browser_client_qt.cpp +++ b/lib/content_browser_client_qt.cpp @@ -52,6 +52,7 @@ #include "ui/base/resource/resource_bundle.h" #include "browser_context_qt.h" +#include "dev_tools_http_handler_delegate_qt.h" #include "web_contents_view_qt.h" #include <QCoreApplication> @@ -250,3 +251,12 @@ net::URLRequestContextGetter* ContentBrowserClientQt::CreateRequestContext(conte fprintf(stderr, "Warning: off the record browser context not implemented !\n"); return static_cast<BrowserContextQt*>(browser_context())->CreateRequestContext(protocol_handlers); } + +void ContentBrowserClientQt::enableInspector(bool enable) +{ + if (enable && !m_devtools) { + m_devtools.reset(new DevToolsHttpHandlerDelegateQt(browser_context())); + } else if (!enable && m_devtools) { + m_devtools.reset(); + } +} diff --git a/lib/content_browser_client_qt.h b/lib/content_browser_client_qt.h index 6ba2b7c4d..f8c42e569 100644 --- a/lib/content_browser_client_qt.h +++ b/lib/content_browser_client_qt.h @@ -42,6 +42,7 @@ #ifndef CONTENT_BROWSER_CLIENT_QT_H #define CONTENT_BROWSER_CLIENT_QT_H +#include "base/memory/scoped_ptr.h" #include "content/public/browser/content_browser_client.h" #include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE @@ -61,6 +62,7 @@ struct MainFunctionParams; class BrowserContextQt; class BrowserMainPartsQt; +class DevToolsHttpHandlerDelegateQt; class ContentBrowserClientQt : public content::ContentBrowserClient { @@ -76,8 +78,11 @@ public: net::URLRequestContextGetter *CreateRequestContext(content::BrowserContext *content_browser_context, content::ProtocolHandlerMap *protocol_handlers); + void enableInspector(bool); + private: BrowserMainPartsQt* m_browserMainParts; + scoped_ptr<DevToolsHttpHandlerDelegateQt> m_devtools; }; diff --git a/lib/content_client_qt.cpp b/lib/content_client_qt.cpp new file mode 100644 index 000000000..46a3e9870 --- /dev/null +++ b/lib/content_client_qt.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "content_client_qt.h" + +#include "base/strings/string_piece.h" +#include "ui/base/layout.h" +#include "ui/base/resource/resource_bundle.h" + +base::StringPiece ContentClientQt::GetDataResource(int resource_id, ui::ScaleFactor scale_factor) const { + return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(resource_id, scale_factor); +} diff --git a/lib/content_client_qt.h b/lib/content_client_qt.h new file mode 100644 index 000000000..059e9423b --- /dev/null +++ b/lib/content_client_qt.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CONTENT_CLIENT_QT_H +#define CONTENT_CLIENT_QT_H + +#include "base/strings/string_piece.h" +#include "content/public/common/content_client.h" +#include "ui/base/layout.h" +#include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE + +class ContentClientQt : public content::ContentClient { +public: + virtual base::StringPiece GetDataResource(int, ui::ScaleFactor) const Q_DECL_OVERRIDE; +}; + +#endif // CONTENT_CLIENT_QT_H diff --git a/lib/dev_tools_http_handler_delegate_qt.cpp b/lib/dev_tools_http_handler_delegate_qt.cpp new file mode 100644 index 000000000..0603f5dcc --- /dev/null +++ b/lib/dev_tools_http_handler_delegate_qt.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "dev_tools_http_handler_delegate_qt.h" + +#include <QByteArray> +#include <QFile> + +#include "base/files/file_path.h" +#include "content/public/browser/devtools_http_handler.h" +#include "net/socket/stream_listen_socket.h" +#include "net/socket/tcp_listen_socket.h" + +DevToolsHttpHandlerDelegateQt::DevToolsHttpHandlerDelegateQt(content::BrowserContext* browser_context) + : m_browserContext(browser_context) +{ + m_devtoolsHttpHandler = content::DevToolsHttpHandler::Start(new net::TCPListenSocketFactory("0.0.0.0", 1337), std::string(), this); +} + +DevToolsHttpHandlerDelegateQt::~DevToolsHttpHandlerDelegateQt() +{ + m_devtoolsHttpHandler->Stop(); +} + +std::string DevToolsHttpHandlerDelegateQt::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; +} + +bool DevToolsHttpHandlerDelegateQt::BundlesFrontendResources() +{ + return true; +} + +base::FilePath DevToolsHttpHandlerDelegateQt::GetDebugFrontendDir() +{ + return base::FilePath(); +} + +std::string DevToolsHttpHandlerDelegateQt::GetPageThumbnailData(const GURL& url) +{ + return std::string(); +} + +content::RenderViewHost* DevToolsHttpHandlerDelegateQt::CreateNewTarget() +{ + return NULL; +} + +content::DevToolsHttpHandlerDelegate::TargetType DevToolsHttpHandlerDelegateQt::GetTargetType(content::RenderViewHost*) +{ + return kTargetTypeTab; +} + +std::string DevToolsHttpHandlerDelegateQt::GetViewDescription(content::RenderViewHost*) +{ + return std::string(); +} + +scoped_refptr<net::StreamListenSocket> DevToolsHttpHandlerDelegateQt::CreateSocketForTethering(net::StreamListenSocket::Delegate* delegate, std::string* name) +{ + return NULL; +} diff --git a/lib/dev_tools_http_handler_delegate_qt.h b/lib/dev_tools_http_handler_delegate_qt.h new file mode 100644 index 000000000..e866f0765 --- /dev/null +++ b/lib/dev_tools_http_handler_delegate_qt.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.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_http_handler_delegate.h" + +#include <QtCore/qcompilerdetection.h> // needed for Q_DECL_OVERRIDE + +namespace net { +class StreamListenSocket; +} + +namespace content { +class BrowserContext; +class DevToolsHttpHandler; +class RenderViewHost; +} + +class DevToolsHttpHandlerDelegateQt : public content::DevToolsHttpHandlerDelegate { +public: + + explicit DevToolsHttpHandlerDelegateQt(content::BrowserContext* browser_context); + virtual ~DevToolsHttpHandlerDelegateQt(); + + // content::DevToolsHttpHandlerDelegate Overrides + virtual std::string GetDiscoveryPageHTML() Q_DECL_OVERRIDE; + virtual bool BundlesFrontendResources() Q_DECL_OVERRIDE; + virtual base::FilePath GetDebugFrontendDir() Q_DECL_OVERRIDE; + virtual std::string GetPageThumbnailData(const GURL& url) Q_DECL_OVERRIDE; + virtual content::RenderViewHost* CreateNewTarget() Q_DECL_OVERRIDE; + virtual TargetType GetTargetType(content::RenderViewHost*) Q_DECL_OVERRIDE; + virtual std::string GetViewDescription(content::RenderViewHost*) Q_DECL_OVERRIDE; + virtual scoped_refptr<net::StreamListenSocket> CreateSocketForTethering(net::StreamListenSocket::Delegate* delegate, std::string* name) Q_DECL_OVERRIDE; + +private: + content::BrowserContext* m_browserContext; + content::DevToolsHttpHandler* m_devtoolsHttpHandler; +}; + +#endif // DEV_TOOLS_HTTP_HANDLER_DELEGATE_QT_H diff --git a/lib/devtools.qrc b/lib/devtools.qrc new file mode 100644 index 000000000..225f88f65 --- /dev/null +++ b/lib/devtools.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="data"> + <file alias="devtools.pak">../resources/devtools_resources.pak</file> + <file alias="discovery_page.html">../resources/devtools_discovery_page.html</file> +</qresource> +</RCC> diff --git a/lib/lib.pro b/lib/lib.pro index cbbb84a4a..a0f4116fe 100644 --- a/lib/lib.pro +++ b/lib/lib.pro @@ -2,7 +2,7 @@ # We want the gyp generation step to happen after all the other config steps. For that we need to prepend # our gyp_generator.prf feature to the CONFIG variable since it is processed backwards CONFIG = gyp_generator $$CONFIG -GYPDEPENDENCIES += ../shared/shared.gyp:qtwebengine_shared +GYPDEPENDENCIES += ../shared/shared.gyp:qtwebengine_shared <(chromium_src_dir)/content/browser/devtools/devtools_resources.gyp:devtools_resources GYPINCLUDES += ../qtwebengine.gypi TEMPLATE = lib @@ -13,6 +13,9 @@ QT += qml quick QT_PRIVATE += qml-private quick-private gui-private core-private qtHaveModule(v8): QT_PRIVATE += v8-private +COPY_FILES = <(SHARED_INTERMEDIATE_DIR)/webkit/devtools_resources.pak +COPY_DESTINATIONS = ../resources/ + # Defining keywords such as 'signal' clashes with the chromium code base. DEFINES += QT_NO_KEYWORDS \ Q_FORWARD_DECLARE_OBJC_CLASS=QT_FORWARD_DECLARE_CLASS @@ -23,7 +26,7 @@ PER_CONFIG_DEFINES = QTWEBENGINEPROCESS_PATH=\\\"$$getOutDir()/%config/$$QTWEBEN # Keep Skia happy CONFIG(release, debug|release): DEFINES += NDEBUG -RESOURCES += lib_resources.qrc +RESOURCES += lib_resources.qrc devtools.qrc # We need this to find the include files generated for the .pak resource files. INCLUDEPATH += $$absolute_path(../resources, $$PWD) @@ -32,7 +35,9 @@ INCLUDEPATH += $$[QT_INSTALL_HEADERS] SOURCES = \ backing_store_qt.cpp \ + content_client_qt.cpp \ content_browser_client_qt.cpp \ + dev_tools_http_handler_delegate_qt.cpp \ download_manager_delegate_qt.cpp \ javascript_dialog_manager_qt.cpp \ render_widget_host_view_qt.cpp \ @@ -48,7 +53,9 @@ SOURCES = \ HEADERS = \ backing_store_qt.h \ browser_context_qt.h \ + content_client_qt.h \ content_browser_client_qt.h \ + dev_tools_http_handler_delegate_qt.h \ download_manager_delegate_qt.h \ javascript_dialog_manager_qt.h \ render_widget_host_view_qt.h \ diff --git a/lib/quick/qquickwebengineview.cpp b/lib/quick/qquickwebengineview.cpp index 08ad688ec..4b58c6c04 100644 --- a/lib/quick/qquickwebengineview.cpp +++ b/lib/quick/qquickwebengineview.cpp @@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate() : adapter(new WebContentsAdapter) , loadProgress(0) + , inspectable(false) { adapter->initialize(this); } @@ -211,6 +212,19 @@ bool QQuickWebEngineView::canGoForward() const return d->adapter->canGoForward(); } +bool QQuickWebEngineView::inspectable() const +{ + Q_D(const QQuickWebEngineView); + return d->inspectable; +} + +void QQuickWebEngineView::setInspectable(bool enable) +{ + Q_D(QQuickWebEngineView); + d->inspectable = enable; + d->adapter->enableInspector(enable); +} + void QQuickWebEngineView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { QQuickItem::geometryChanged(newGeometry, oldGeometry); diff --git a/lib/quick/qquickwebengineview_p.h b/lib/quick/qquickwebengineview_p.h index 87e7403d6..d1fa4ceaa 100644 --- a/lib/quick/qquickwebengineview_p.h +++ b/lib/quick/qquickwebengineview_p.h @@ -57,6 +57,7 @@ class QQuickWebEngineView : public QQuickItem { Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY loadingStateChanged) Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY loadingStateChanged) + Q_PROPERTY(bool inspectable READ inspectable WRITE setInspectable) public: QQuickWebEngineView(QQuickItem *parent = 0); @@ -70,6 +71,8 @@ public: QString title() const; bool canGoBack() const; bool canGoForward() const; + bool inspectable() const; + void setInspectable(bool); public Q_SLOTS: void goBack(); diff --git a/lib/quick/qquickwebengineview_p_p.h b/lib/quick/qquickwebengineview_p_p.h index 902dc2488..e32ac5c63 100644 --- a/lib/quick/qquickwebengineview_p_p.h +++ b/lib/quick/qquickwebengineview_p_p.h @@ -75,6 +75,7 @@ public: QExplicitlySharedDataPointer<WebContentsAdapter> adapter; QUrl icon; int loadProgress; + bool inspectable; }; QT_END_NAMESPACE diff --git a/lib/web_contents_adapter.cpp b/lib/web_contents_adapter.cpp index 01e525291..9f895d2eb 100644 --- a/lib/web_contents_adapter.cpp +++ b/lib/web_contents_adapter.cpp @@ -240,3 +240,8 @@ qreal WebContentsAdapter::currentZoomFactor() const Q_D(const WebContentsAdapter); return static_cast<qreal>(content::ZoomLevelToZoomFactor(d->webContents->GetZoomLevel())); } + +void WebContentsAdapter::enableInspector(bool enable) +{ + ContentBrowserClientQt::Get()->enableInspector(enable); +} diff --git a/lib/web_contents_adapter.h b/lib/web_contents_adapter.h index 0b48dc81b..306e55e45 100644 --- a/lib/web_contents_adapter.h +++ b/lib/web_contents_adapter.h @@ -81,6 +81,7 @@ public: void clearNavigationHistory(); void setZoomFactor(qreal); qreal currentZoomFactor() const; + void enableInspector(bool); private: Q_DISABLE_COPY(WebContentsAdapter); diff --git a/lib/web_engine_context.cpp b/lib/web_engine_context.cpp index 95a3f93ec..62adf43ef 100644 --- a/lib/web_engine_context.cpp +++ b/lib/web_engine_context.cpp @@ -58,6 +58,7 @@ #include "webkit/common/user_agent/user_agent_util.h" #include "content_browser_client_qt.h" +#include "content_client_qt.h" #include "type_conversion.h" #include <QCoreApplication> #include <QStringList> @@ -104,6 +105,12 @@ public: return m_browserClient.get(); } + bool BasicStartupComplete(int* exit_code) Q_DECL_OVERRIDE + { + SetContentClient(new ContentClientQt); + return false; + } + private: scoped_ptr<ContentBrowserClientQt> m_browserClient; }; diff --git a/resources/devtools_discovery_page.html b/resources/devtools_discovery_page.html new file mode 100644 index 000000000..de848d348 --- /dev/null +++ b/resources/devtools_discovery_page.html @@ -0,0 +1,57 @@ +<!-- +Copyright (c) 2013 BlackBerry Limited. All rights reserved. +--> +<html> +<head> +<title>Content shell remote debugging</title> +<style> +</style> + +<script> +function onLoad() { + var tabs_list_request = new XMLHttpRequest(); + tabs_list_request.open('GET', '/json/list?t=' + new Date().getTime(), true); + tabs_list_request.onreadystatechange = onReady; + tabs_list_request.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 appendItem(item_object) { + var frontend_ref; + if (item_object.devtoolsFrontendUrl) { + frontend_ref = document.createElement('a'); + frontend_ref.href = item_object.devtoolsFrontendUrl; + frontend_ref.title = item_object.title; + } else { + frontend_ref = document.createElement('div'); + frontend_ref.title = 'The tab already has active debugging session'; + } + + var text = document.createElement('div'); + if (item_object.title) + text.innerText = item_object.title; + else + text.innerText = '(untitled tab)'; + text.style.cssText = 'background-image:url(' + item_object.faviconUrl + ')'; + frontend_ref.appendChild(text); + + var item = document.createElement('p'); + item.appendChild(frontend_ref); + + document.getElementById('items').appendChild(item); +} +</script> +</head> +<body onload='onLoad()'> + <div id='caption'>Inspectable WebContents</div> + <div id='items'></div> +</body> +</html> diff --git a/shared/resource_bundle_qt.cpp b/shared/resource_bundle_qt.cpp index af26a488a..044d00511 100644 --- a/shared/resource_bundle_qt.cpp +++ b/shared/resource_bundle_qt.cpp @@ -43,6 +43,7 @@ #include "ui/base/resource/data_pack.h" #include <QFile> +#include <QStringList> namespace ui { @@ -135,13 +136,19 @@ class UI_EXPORT DataPackQt : public DataPack { void ResourceBundle::LoadCommonResources() { - QFile pak_file(":/data/resources.pak"); - if (!pak_file.open(QIODevice::ReadOnly)) - return; + QStringList resources; + resources << ":/data/resources.pak" << ":/data/devtools.pak"; + Q_FOREACH (const QString& pak, resources) { + QFile pak_file(pak); + if (!pak_file.open(QIODevice::ReadOnly)) { + qWarning("Resource file %s not loaded", qPrintable(pak)); + continue; + } - scoped_ptr<DataPackQt> data_pack(new DataPackQt(SCALE_FACTOR_100P)); - if (data_pack->LoadFromByteArray(pak_file.readAll())) - AddDataPack(data_pack.release()); + scoped_ptr<DataPackQt> data_pack(new DataPackQt(SCALE_FACTOR_100P)); + if (data_pack->LoadFromByteArray(pak_file.readAll())) + AddDataPack(data_pack.release()); + } } // As GetLocaleFilePath is excluded for Mac in resource_bundle.cc, |