summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/qmake/mkspecs/features/gyp_generator.prf7
-rw-r--r--build/qtwebengine_extras.gypi3
-rw-r--r--lib/content_browser_client_qt.cpp22
-rw-r--r--lib/content_browser_client_qt.h2
-rw-r--r--lib/lib.pro4
-rw-r--r--lib/lib_resources.qrc5
-rw-r--r--lib/resource_bundle_qt.cpp159
-rw-r--r--lib/url_request_context_getter_qt.cpp7
-rw-r--r--lib/url_request_context_getter_qt.h3
9 files changed, 211 insertions, 1 deletions
diff --git a/build/qmake/mkspecs/features/gyp_generator.prf b/build/qmake/mkspecs/features/gyp_generator.prf
index 9df87c4ec..02de2ecc7 100644
--- a/build/qmake/mkspecs/features/gyp_generator.prf
+++ b/build/qmake/mkspecs/features/gyp_generator.prf
@@ -104,6 +104,13 @@ GYP_CONTENTS += " 'sources': ["
for (sourcefile, SOURCES): GYP_CONTENTS += " '$$sourcefile',"
for (headerfile, HEADERS): GYP_CONTENTS += " '$$headerfile',"
+# Add Sources generated by rcc from qrc files.
+for (resourcefile, RESOURCES) {
+ RCC_CPP = $$replace(resourcefile, .qrc, .cpp)
+ RCC_CPP = $$join(RCC_CPP, "qrc_", qrc_)
+ GYP_CONTENTS += " '$$RCC_DIR/$$RCC_CPP',"
+}
+
# Add moc output files to compile that aren't included at the end of any other source
MOC_OUT_PATH = $$absolute_path($$MOC_DIR, $$OUT_PWD)$${QMAKE_DIR_SEP}
for (mocable_header, MOCABLE_HEADERS) {
diff --git a/build/qtwebengine_extras.gypi b/build/qtwebengine_extras.gypi
index d37c1bd65..954677744 100644
--- a/build/qtwebengine_extras.gypi
+++ b/build/qtwebengine_extras.gypi
@@ -2,6 +2,9 @@
'target_defaults': {
# patterns used to exclude chromium files from the build when we have a drop-in replacement
'sources/': [
+ ['exclude', 'ui/base/resource/resource_bundle_gtk.cc$'],
+ ['exclude', 'ui/base/resource/resource_bundle_mac.mm$'],
+ ['exclude', 'ui/base/resource/resource_bundle_win.cc$'],
['exclude', 'browser/web_contents/web_contents_view_gtk\\.(cc|h)$'],
['exclude', 'browser/web_contents/web_contents_view_mac\\.(mm|h)$'],
['exclude', 'browser/web_contents/web_contents_view_win\\.(cc|h)$'],
diff --git a/lib/content_browser_client_qt.cpp b/lib/content_browser_client_qt.cpp
index 80e855afb..2ba888e68 100644
--- a/lib/content_browser_client_qt.cpp
+++ b/lib/content_browser_client_qt.cpp
@@ -45,6 +45,11 @@
#include "base/threading/thread_restrictions.h"
#include "content/public/browser/browser_main_parts.h"
#include "content/public/common/main_function_params.h"
+#include "content/public/browser/child_process_security_policy.h"
+#include "content/public/common/url_constants.h"
+#include "grit/net_resources.h"
+#include "net/base/net_module.h"
+#include "ui/base/resource/resource_bundle.h"
#include "browser_context_qt.h"
#include "web_contents_view_qt.h"
@@ -86,7 +91,6 @@ public:
{
// FIXME: This could be needed if we want to run Chromium tests.
// We could run a QEventLoop here.
- Q_UNREACHABLE();
}
virtual void Quit()
@@ -149,6 +153,14 @@ base::MessagePump* messagePumpFactory()
} // namespace
+static base::StringPiece PlatformResourceProvider(int key) {
+ if (key == IDR_DIR_HEADER_HTML) {
+ base::StringPiece html_data = ui::ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_DIR_HEADER_HTML);
+ return html_data;
+ }
+ return base::StringPiece();
+}
+
class BrowserMainPartsQt : public content::BrowserMainParts
{
public:
@@ -158,6 +170,8 @@ public:
void PreMainMessageLoopStart() Q_DECL_OVERRIDE
{
+ net::NetModule::SetResourceProvider(PlatformResourceProvider);
+ ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL);
base::MessageLoop::InitMessagePumpForUIFactory(::messagePumpFactory);
}
@@ -218,6 +232,12 @@ content::BrowserMainParts *ContentBrowserClientQt::CreateBrowserMainParts(const
return m_browserMainParts;
}
+void ContentBrowserClientQt::RenderProcessHostCreated(content::RenderProcessHost* host)
+{
+ // FIXME: Add a settings variable to enable/disable the file scheme.
+ content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(host->GetID(), chrome::kFileScheme);
+}
+
BrowserContextQt* ContentBrowserClientQt::browser_context() {
Q_ASSERT(m_browserMainParts);
diff --git a/lib/content_browser_client_qt.h b/lib/content_browser_client_qt.h
index 5359d9b3a..a1e897e75 100644
--- a/lib/content_browser_client_qt.h
+++ b/lib/content_browser_client_qt.h
@@ -52,6 +52,7 @@ class URLRequestContextGetter;
namespace content {
class BrowserContext;
class BrowserMainParts;
+class RenderProcessHost;
class RenderViewHostDelegateView;
class WebContentsViewPort;
class WebContents;
@@ -69,6 +70,7 @@ public:
static ContentBrowserClientQt* Get();
virtual content::WebContentsViewPort* OverrideCreateWebContentsView(content::WebContents* , content::RenderViewHostDelegateView**) Q_DECL_OVERRIDE;
virtual content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams&) Q_DECL_OVERRIDE;
+ virtual void RenderProcessHostCreated(content::RenderProcessHost* host) Q_DECL_OVERRIDE;
BrowserContextQt* browser_context();
diff --git a/lib/lib.pro b/lib/lib.pro
index ca45e6897..45d8675fd 100644
--- a/lib/lib.pro
+++ b/lib/lib.pro
@@ -3,6 +3,7 @@
# 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 += ../chromium/net/net.gyp:net_resources
GYPINCLUDES += ../qtwebengine.gypi
TEMPLATE = lib
@@ -20,6 +21,8 @@ CONFIG(release, debug|release): DEFINES += NDEBUG
QT += widgets quick
+RESOURCES += lib_resources.qrc
+
SOURCES = \
backing_store_qt.cpp \
content_browser_client_qt.cpp \
@@ -29,6 +32,7 @@ SOURCES = \
render_widget_host_view_qt_delegate_quick.cpp \
render_widget_host_view_qt_delegate_widget.cpp \
resource_context_qt.cpp \
+ resource_bundle_qt.cpp \
url_request_context_getter_qt.cpp \
web_contents_delegate_qt.cpp \
web_contents_view_qt.cpp \
diff --git a/lib/lib_resources.qrc b/lib/lib_resources.qrc
new file mode 100644
index 000000000..4e6fce92a
--- /dev/null
+++ b/lib/lib_resources.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="data">
+ <file alias="resources.pak">/Users/zeno/work/qtwebengine/out/Release/gen/net/net_resources.pak</file>
+</qresource>
+</RCC> \ No newline at end of file
diff --git a/lib/resource_bundle_qt.cpp b/lib/resource_bundle_qt.cpp
new file mode 100644
index 000000000..4df349eda
--- /dev/null
+++ b/lib/resource_bundle_qt.cpp
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** 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 "ui/base/resource/resource_bundle.h"
+#include "ui/base/resource/data_pack.h"
+
+#include <QFile>
+
+namespace ui {
+
+// ********************* data_pack.cc *********************
+// This is duplicated code originating from data_pack.cc.
+// It should instead be moved to a header file and be included
+// in both places.
+
+static const uint32 kFileFormatVersion = 4;
+static const size_t kHeaderLength = 2 * sizeof(uint32) + sizeof(uint8);
+
+#pragma pack(push,2)
+struct DataPackEntry {
+ uint16 resource_id;
+ uint32 file_offset;
+
+ static int CompareById(const void* void_key, const void* void_entry) {
+ uint16 key = *reinterpret_cast<const uint16*>(void_key);
+ const DataPackEntry* entry =
+ reinterpret_cast<const DataPackEntry*>(void_entry);
+ if (key < entry->resource_id) {
+ return -1;
+ } else if (key > entry->resource_id) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+};
+#pragma pack(pop)
+// ******************* data_pack.cc end *******************
+
+class UI_EXPORT DataPackQt : public DataPack {
+ public:
+ DataPackQt(ui::ScaleFactor scale_factor)
+ : DataPack(scale_factor)
+ , m_data(NULL)
+ , m_resourceCount(0) { }
+
+ virtual ~DataPackQt() { }
+
+ bool LoadFromByteArray(const QByteArray& data)
+ {
+ m_data = data;
+
+ if (kHeaderLength > m_data.size())
+ return false;
+
+ const uint32* ptr = reinterpret_cast<const uint32*>(m_data.data());
+ uint32 version = ptr[0];
+ if (version != kFileFormatVersion) {
+ LOG(ERROR) << "Bad data pack version: got " << version << ", expected " << kFileFormatVersion;
+ return false;
+ }
+
+ m_resourceCount = ptr[1];
+ return true;
+ }
+
+ virtual bool HasResource(uint16 resource_id) const OVERRIDE
+ {
+ return !!bsearch(&resource_id, m_data.data() + kHeaderLength, m_resourceCount, sizeof(DataPackEntry), DataPackEntry::CompareById);
+ }
+
+ virtual bool GetStringPiece(uint16 resource_id, base::StringPiece* data) const OVERRIDE
+ {
+ #if defined(__BYTE_ORDER) // Linux check
+ COMPILE_ASSERT(__BYTE_ORDER == __LITTLE_ENDIAN, datapack_assumes_little_endian);
+ #elif defined(__BIG_ENDIAN__) // Mac check
+ #error DataPack assumes little endian
+ #endif
+
+ const DataPackEntry* target = reinterpret_cast<const DataPackEntry*>(bsearch(&resource_id, m_data.data() + kHeaderLength, m_resourceCount, sizeof(DataPackEntry), DataPackEntry::CompareById));
+ if (!target)
+ return false;
+
+ const DataPackEntry* next_entry = target + 1;
+ size_t length = next_entry->file_offset - target->file_offset;
+
+ data->set(m_data.data() + target->file_offset, length);
+ return true;
+ }
+
+ private:
+ QByteArray m_data;
+ size_t m_resourceCount;
+ DISALLOW_COPY_AND_ASSIGN(DataPackQt);
+};
+
+
+void ResourceBundle::LoadCommonResources()
+{
+ QFile pak_file(":/data/resources.pak");
+ if (!pak_file.open(QIODevice::ReadOnly))
+ return;
+
+ scoped_ptr<DataPackQt> data_pack(new DataPackQt(SCALE_FACTOR_100P));
+ if (data_pack->LoadFromByteArray(pak_file.readAll()))
+ AddDataPack(data_pack.release());
+}
+
+base::FilePath ResourceBundle::GetLocaleFilePath(const std::string& /*app_locale*/, bool /*test_file_exists*/)
+{
+ return base::FilePath();
+}
+
+gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl)
+{
+ LOG(WARNING) << "Unable to load image with id " << resource_id;
+ NOTREACHED(); // Want to assert in debug mode.
+ return GetEmptyImage();
+}
+
+} // namespace ui
diff --git a/lib/url_request_context_getter_qt.cpp b/lib/url_request_context_getter_qt.cpp
index 2f2d89e30..18a8b0082 100644
--- a/lib/url_request_context_getter_qt.cpp
+++ b/lib/url_request_context_getter_qt.cpp
@@ -59,6 +59,8 @@
#include "net/ssl/ssl_config_service_defaults.h"
#include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request_context.h"
+#include "net/url_request/data_protocol_handler.h"
+#include "net/url_request/file_protocol_handler.h"
#include "network_delegate_qt.h"
@@ -148,6 +150,11 @@ net::URLRequestContext *URLRequestContextGetterQt::GetURLRequestContext()
m_storage->set_http_transaction_factory(main_cache);
// FIXME: add protocol handling
+
+ m_jobFactory.reset(new net::URLRequestJobFactoryImpl());
+ m_jobFactory->SetProtocolHandler(chrome::kDataScheme, new net::DataProtocolHandler());
+ m_jobFactory->SetProtocolHandler(chrome::kFileScheme, new net::FileProtocolHandler());
+ m_urlRequestContext->set_job_factory(m_jobFactory.get());
}
return m_urlRequestContext.get();
diff --git a/lib/url_request_context_getter_qt.h b/lib/url_request_context_getter_qt.h
index bd9bae723..4ffc57a66 100644
--- a/lib/url_request_context_getter_qt.h
+++ b/lib/url_request_context_getter_qt.h
@@ -47,6 +47,8 @@
#include "base/memory/scoped_ptr.h"
#include "base/single_thread_task_runner.h"
#include "net/url_request/url_request_context_storage.h"
+#include "net/url_request/url_request_job_factory_impl.h"
+#include "content/public/common/url_constants.h"
namespace net {
class HostResolver;
@@ -73,6 +75,7 @@ private:
scoped_ptr<net::URLRequestContext> m_urlRequestContext;
scoped_ptr<net::NetworkDelegate> m_networkDelegate;
scoped_ptr<net::URLRequestContextStorage> m_storage;
+ scoped_ptr<net::URLRequestJobFactoryImpl> m_jobFactory;
};
#endif // URL_REQUEST_CONTEXT_GETTER_QT_H