summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2013-06-10 19:33:44 +0200
committerPierre Rossi <pierre.rossi@digia.com>2013-06-10 19:33:44 +0200
commit6555874455eb23722974b06b388c3cbde0a24f95 (patch)
treea8d3a3de82ba8c151e8667bec426cc6d21004554
parentd50a091095f49032587fef97034ba1210a1a8f0f (diff)
And shell is out !
Introduce a few more bits of our own very basic implementations (URLRequestContextGetter and NetworkDelegate subclasses). Still need to figure out the appropriate dependancies in blinq.gypi
-rw-r--r--build/qmake/mkspecs/features/default_pre.prf2
-rw-r--r--example/example.pro1
-rw-r--r--lib/browser_context_qt.h19
-rw-r--r--lib/content_browser_client_qt.cpp29
-rw-r--r--lib/content_browser_client_qt.h8
-rw-r--r--lib/lib.pro5
-rw-r--r--lib/network_delegate_qt.cpp42
-rw-r--r--lib/network_delegate_qt.h117
-rw-r--r--lib/qquickwebcontentsview.cpp4
-rw-r--r--lib/qwebcontentsview.cpp4
-rw-r--r--lib/resource_context_qt.cpp6
-rw-r--r--lib/resource_context_qt.h8
-rw-r--r--lib/url_request_context_getter_qt.cpp156
-rw-r--r--lib/url_request_context_getter_qt.h78
14 files changed, 435 insertions, 44 deletions
diff --git a/build/qmake/mkspecs/features/default_pre.prf b/build/qmake/mkspecs/features/default_pre.prf
index 027d35af9..07ec22750 100644
--- a/build/qmake/mkspecs/features/default_pre.prf
+++ b/build/qmake/mkspecs/features/default_pre.prf
@@ -8,5 +8,3 @@ CHROMIUM_SRC_DIR = $$(CHROMIUM_SRC_DIR)
isEmpty(CHROMIUM_SRC_DIR):error("please set CHROMIUM_SRC_DIR")
load(functions)
-# So that moc generated files don't end up polluting the source tree
-OUT_PWD = $$getOutDir()
diff --git a/example/example.pro b/example/example.pro
index 33a2f6182..7b98e1bf2 100644
--- a/example/example.pro
+++ b/example/example.pro
@@ -12,3 +12,4 @@ LIBS += -L$$LIBPATH -lblinq
QMAKE_RPATHDIR += $$LIBPATH
QT += widgets quick
+MOC_DIR=$$PWD
diff --git a/lib/browser_context_qt.h b/lib/browser_context_qt.h
index 79eb13f1d..5bcbd6887 100644
--- a/lib/browser_context_qt.h
+++ b/lib/browser_context_qt.h
@@ -1,19 +1,25 @@
+#ifndef BROWSER_CONTEXT_QT
+#define BROWSER_CONTEXT_QT
+
#include "content/public/browser/browser_context.h"
#include "base/files/scoped_temp_dir.h"
+
#include "base/time.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/storage_partition.h"
-#include "net/url_request/url_request_context_getter.h"
+#include "net/url_request/url_request_context.h"
+#include "net/proxy/proxy_config_service.h"
-#include "content/shell/shell_url_request_context_getter.h"
+#include <qglobal.h>
+#include <QByteArray>
#include "resource_context_qt.h"
+#include "url_request_context_getter_qt.h"
+
-#ifndef BROWSER_CONTEXT_QT
-#define BROWSER_CONTEXT_QT
class BrowserContextQt : public content::BrowserContext
{
@@ -56,8 +62,7 @@ public:
net::URLRequestContextGetter *CreateRequestContext(content::ProtocolHandlerMap* protocol_handlers)
{
- url_request_getter_ = new content::ShellURLRequestContextGetter(/*ignore_certificate_errors = */ false, GetPath(), content::BrowserThread::UnsafeGetMessageLoopForThread(content::BrowserThread::IO)
- , content::BrowserThread::UnsafeGetMessageLoopForThread(content::BrowserThread::FILE), protocol_handlers);
+ url_request_getter_ = new URLRequestContextGetterQt(GetPath());
static_cast<ResourceContextQt*>(resourceContext.get())->set_url_request_context_getter(url_request_getter_.get());
return url_request_getter_.get();
}
@@ -65,7 +70,7 @@ public:
private:
scoped_ptr<content::ResourceContext> resourceContext;
base::ScopedTempDir tempBasePath; // ### Should become permanent location.
- scoped_refptr<content::ShellURLRequestContextGetter> url_request_getter_;
+ scoped_refptr<net::URLRequestContextGetter> url_request_getter_;
DISALLOW_COPY_AND_ASSIGN(BrowserContextQt);
};
diff --git a/lib/content_browser_client_qt.cpp b/lib/content_browser_client_qt.cpp
index da8f08116..3c02d4359 100644
--- a/lib/content_browser_client_qt.cpp
+++ b/lib/content_browser_client_qt.cpp
@@ -1,17 +1,13 @@
#include "content_browser_client_qt.h"
+#include "content/public/browser/browser_main_parts.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
-#include "content/public/common/main_function_params.h"
#include "content/public/browser/render_process_host.h"
-
-// To be cleaned up
-#include "content/shell/shell.h"
-#include "content/shell/shell_browser_main_parts.h"
-#include "content/shell/shell_browser_context.h"
-#include "content/public/browser/browser_main_parts.h"
+#include "content/public/common/main_function_params.h"
#include "net/base/net_module.h"
#include "net/base/net_util.h"
+
#include "browser_context_qt.h"
#include "web_contents_view_qt.h"
@@ -44,8 +40,8 @@ public:
void PreEarlyInitialization() { }
void PreMainMessageLoopRun() {
- m_browserContext.reset(new content::ShellBrowserContext(false));
- m_offTheRecordBrowserContext.reset(new content::ShellBrowserContext(true));
+
+ m_browserContext.reset(new BrowserContextQt());
if (m_parameters.ui_task) {
m_parameters.ui_task->Run();
@@ -60,16 +56,14 @@ public:
void PostMainMessageLoopRun() {
m_browserContext.reset();
- m_offTheRecordBrowserContext.reset();
}
- content::ShellBrowserContext* browser_context() const {
+ BrowserContextQt* browser_context() const {
return m_browserContext.get();
}
private:
- scoped_ptr<content::ShellBrowserContext> m_browserContext;
- scoped_ptr<content::ShellBrowserContext> m_offTheRecordBrowserContext;
+ scoped_ptr<BrowserContextQt> m_browserContext;
// For running content_browsertests.
const content::MainFunctionParams& m_parameters;
@@ -90,20 +84,17 @@ content::WebContentsViewPort* ContentBrowserClientQt::OverrideCreateWebContentsV
content::BrowserMainParts *ContentBrowserClientQt::CreateBrowserMainParts(const content::MainFunctionParams &parameters)
{
m_browserMainParts = new BrowserMainPartsQt(parameters);
- // FIXME: We don't seem to need it yet, the ShellBrowserContext was being used.
- // m_browser_context = new BrowserContextQt();
return m_browserMainParts;
}
-content::ShellBrowserContext* ContentBrowserClientQt::browser_context() {
- return m_browserMainParts->browser_context();
- // return m_browser_context;
+BrowserContextQt* ContentBrowserClientQt::browser_context() {
+ return static_cast<BrowserMainPartsQt*>(m_browserMainParts)->browser_context();
}
net::URLRequestContextGetter* ContentBrowserClientQt::CreateRequestContext(content::BrowserContext* content_browser_context, content::ProtocolHandlerMap* protocol_handlers)
{
if (content_browser_context != browser_context())
fprintf(stderr, "Warning: off the record browser context not implemented !\n");
- return browser_context()->CreateRequestContext(protocol_handlers);
+ return static_cast<BrowserContextQt*>(browser_context())->CreateRequestContext(protocol_handlers);
}
diff --git a/lib/content_browser_client_qt.h b/lib/content_browser_client_qt.h
index 4783fa598..0cf8199e4 100644
--- a/lib/content_browser_client_qt.h
+++ b/lib/content_browser_client_qt.h
@@ -8,11 +8,10 @@ class URLRequestContextGetter;
}
namespace content {
+class BrowserContext;
class BrowserMainParts;
class RenderProcessHost;
class RenderViewHostDelegateView;
-class ShellBrowserContext;
-class ShellBrowserMainParts;
class WebContentsViewPort;
class WebContents;
struct MainFunctionParams;
@@ -27,13 +26,14 @@ public:
virtual content::WebContentsViewPort* OverrideCreateWebContentsView(content::WebContents* , content::RenderViewHostDelegateView**) /*Q_DECL_OVERRIDE*/;
virtual content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams& parameters) /*Q_DECL_OVERRIDE*/;
- content::ShellBrowserContext *browser_context();
+
+ BrowserContextQt* browser_context();
net::URLRequestContextGetter *CreateRequestContext(content::BrowserContext *content_browser_context, content::ProtocolHandlerMap *protocol_handlers);
private:
- BrowserContextQt* m_browser_context;
BrowserMainPartsQt* m_browserMainParts;
+
};
#endif // CONTENT_BROWSER_CLIENT_QT
diff --git a/lib/lib.pro b/lib/lib.pro
index 71fd95419..d8c47ef88 100644
--- a/lib/lib.pro
+++ b/lib/lib.pro
@@ -25,7 +25,9 @@ SOURCES = \
qquickwebcontentsview.cpp \
qwebcontentsview.cpp \
resource_context_qt.cpp \
+ url_request_context_getter_qt.cpp \
web_contents_delegate_qt.cpp
+ web_event_factory.cpp
HEADERS = \
blinqapplication.h \
@@ -34,4 +36,7 @@ HEADERS = \
qquickwebcontentsview.h \
qwebcontentsview.h \
resource_context_qt.h \
+ url_request_context_getter_qt.h \
web_contents_delegate_qt.h
+ web_event_factory.h
+
diff --git a/lib/network_delegate_qt.cpp b/lib/network_delegate_qt.cpp
new file mode 100644
index 000000000..27807c499
--- /dev/null
+++ b/lib/network_delegate_qt.cpp
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** 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 "network_delegate_qt.h"
diff --git a/lib/network_delegate_qt.h b/lib/network_delegate_qt.h
new file mode 100644
index 000000000..f31b98212
--- /dev/null
+++ b/lib/network_delegate_qt.h
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** 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 NETWORK_DELEGATE_QT_H
+#define NETWORK_DELEGATE_QT_H
+
+#include "net/base/network_delegate.h"
+
+class NetworkDelegateQt : public net::NetworkDelegate {
+ public:
+ NetworkDelegateQt() {}
+ virtual ~NetworkDelegateQt() {}
+
+
+ private:
+ // net::NetworkDelegate implementation.
+ virtual int OnBeforeURLRequest(net::URLRequest* request, const net::CompletionCallback& callback, GURL* new_url) /*Q_DECL_OVERRIDE*/
+ {
+ return net::OK;
+ }
+ virtual int OnBeforeSendHeaders(net::URLRequest* request,
+ const net::CompletionCallback& callback,
+ net::HttpRequestHeaders* headers) /*Q_DECL_OVERRIDE*/ {
+ return net::OK;
+ }
+ virtual void OnSendHeaders(net::URLRequest* request,
+ const net::HttpRequestHeaders& headers) /*Q_DECL_OVERRIDE*/ {}
+ virtual int OnHeadersReceived(
+ net::URLRequest* request,
+ const net::CompletionCallback& callback,
+ const net::HttpResponseHeaders* original_response_headers,
+ scoped_refptr<net::HttpResponseHeaders>* override_response_headers) /*Q_DECL_OVERRIDE*/ {
+ return net::OK;
+ }
+ virtual void OnBeforeRedirect(net::URLRequest* request,
+ const GURL& new_location) /*Q_DECL_OVERRIDE*/ {}
+ virtual void OnResponseStarted(net::URLRequest* request) /*Q_DECL_OVERRIDE*/ {}
+ virtual void OnRawBytesRead(const net::URLRequest& request,
+ int bytes_read) /*Q_DECL_OVERRIDE*/ {}
+ virtual void OnCompleted(net::URLRequest* request, bool started) /*Q_DECL_OVERRIDE*/ {}
+ virtual void OnURLRequestDestroyed(net::URLRequest* request) /*Q_DECL_OVERRIDE*/ {}
+
+ virtual void OnPACScriptError(int line_number,
+ const base::string16& error) /*Q_DECL_OVERRIDE*/ {
+ }
+ virtual AuthRequiredResponse OnAuthRequired(
+ net::URLRequest* request,
+ const net::AuthChallengeInfo& auth_info,
+ const AuthCallback& callback,
+ net::AuthCredentials* credentials) /*Q_DECL_OVERRIDE*/ {
+ return AUTH_REQUIRED_RESPONSE_NO_ACTION;
+ }
+ virtual bool OnCanGetCookies(const net::URLRequest& request,
+ const net::CookieList& cookie_list) /*Q_DECL_OVERRIDE*/ {
+ return true;
+ }
+ virtual bool OnCanSetCookie(const net::URLRequest& request,
+ const std::string& cookie_line,
+ net::CookieOptions* options) /*Q_DECL_OVERRIDE*/ {
+ return true;
+ }
+ virtual bool OnCanAccessFile(const net::URLRequest& request,
+ const base::FilePath& path) const /*Q_DECL_OVERRIDE*/ {
+ return true;
+ }
+ virtual bool OnCanThrottleRequest(const net::URLRequest& request) const /*Q_DECL_OVERRIDE*/ {
+ return false;
+ }
+ virtual int OnBeforeSocketStreamConnect(
+ net::SocketStream* stream,
+ const net::CompletionCallback& callback) /*Q_DECL_OVERRIDE*/ {
+ return net::OK;
+ }
+ virtual void OnRequestWaitStateChange(const net::URLRequest& request,
+ RequestWaitState state) /*Q_DECL_OVERRIDE*/ {
+ }
+
+};
+
+#endif // NETWORK_DELEGATE_QT_H
diff --git a/lib/qquickwebcontentsview.cpp b/lib/qquickwebcontentsview.cpp
index 3e20e90f7..1d7357cd0 100644
--- a/lib/qquickwebcontentsview.cpp
+++ b/lib/qquickwebcontentsview.cpp
@@ -46,9 +46,9 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
-#include "content/shell/shell.h"
-#include "content/shell/shell_browser_context.h"
+#include "ipc/ipc_message.h"
+#include "browser_context_qt.h"
#include "content_browser_client_qt.h"
#include "web_contents_delegate_qt.h"
diff --git a/lib/qwebcontentsview.cpp b/lib/qwebcontentsview.cpp
index 2ce75f3a6..64bdb9c36 100644
--- a/lib/qwebcontentsview.cpp
+++ b/lib/qwebcontentsview.cpp
@@ -46,9 +46,9 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
-#include "content/shell/shell.h"
-#include "content/shell/shell_browser_context.h"
+#include "ipc/ipc_message.h"
+#include "browser_context_qt.h"
#include "content_browser_client_qt.h"
#include "web_contents_delegate_qt.h"
diff --git a/lib/resource_context_qt.cpp b/lib/resource_context_qt.cpp
index ca680e6c1..52892feab 100644
--- a/lib/resource_context_qt.cpp
+++ b/lib/resource_context_qt.cpp
@@ -2,14 +2,12 @@
#include "net/url_request/url_request_context_getter.h"
-#include "content/shell/shell_url_request_context_getter.h"
-
#include "browser_context_qt.h"
net::HostResolver *ResourceContextQt::GetHostResolver()
{
CHECK(getter_);
- return getter_->host_resolver();
+ return getter_->GetURLRequestContext()->host_resolver();
}
net::URLRequestContext* ResourceContextQt::GetRequestContext()
@@ -19,7 +17,7 @@ net::URLRequestContext* ResourceContextQt::GetRequestContext()
return context->GetRequestContext()->GetURLRequestContext();
}
-void ResourceContextQt::set_url_request_context_getter(content::ShellURLRequestContextGetter *getter)
+void ResourceContextQt::set_url_request_context_getter(net::URLRequestContextGetter *getter)
{
getter_ = getter;
}
diff --git a/lib/resource_context_qt.h b/lib/resource_context_qt.h
index c4c3faca4..c42c00cd4 100644
--- a/lib/resource_context_qt.h
+++ b/lib/resource_context_qt.h
@@ -3,8 +3,8 @@
#ifndef RESOURCE_CONTEXT_QT
#define RESOURCE_CONTEXT_QT
-namespace content {
-class ShellURLRequestContextGetter;
+namespace net {
+class URLRequestContextGetter;
}
class BrowserContextQt;
@@ -21,11 +21,11 @@ public:
virtual net::URLRequestContext* GetRequestContext();
- void set_url_request_context_getter(content::ShellURLRequestContextGetter* getter);
+ void set_url_request_context_getter(net::URLRequestContextGetter* getter);
private:
BrowserContextQt *context;
- content::ShellURLRequestContextGetter* getter_;
+ net::URLRequestContextGetter* getter_;
DISALLOW_COPY_AND_ASSIGN(ResourceContextQt);
};
diff --git a/lib/url_request_context_getter_qt.cpp b/lib/url_request_context_getter_qt.cpp
new file mode 100644
index 000000000..1b523697d
--- /dev/null
+++ b/lib/url_request_context_getter_qt.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** 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 "url_request_context_getter_qt.h"
+
+#include "base/string_util.h"
+#include "base/threading/worker_pool.h"
+#include "content/public/browser/browser_thread.h"
+#include "net/base/cache_type.h"
+#include "net/cert/cert_verifier.h"
+#include "net/cookies/cookie_monster.h"
+#include "net/dns/host_resolver.h"
+#include "net/dns/mapped_host_resolver.h"
+#include "net/http/http_auth_handler_factory.h"
+#include "net/http/http_cache.h"
+#include "net/http/http_network_session.h"
+#include "net/http/http_server_properties_impl.h"
+#include "net/proxy/proxy_service.h"
+#include "net/ssl/default_server_bound_cert_store.h"
+#include "net/ssl/server_bound_cert_service.h"
+#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 "network_delegate_qt.h"
+
+using content::BrowserThread;
+
+URLRequestContextGetterQt::URLRequestContextGetterQt(const base::FilePath &basePath)
+ : m_ignoreCertificateErrors(false)
+ , m_basePath(basePath)
+{
+
+ // We must create the proxy config service on the UI loop on Linux because it
+ // must synchronously run on the glib message loop. This will be passed to
+ // the URLRequestContextStorage on the IO thread in GetURLRequestContext().
+//#ifdef Q_OS_LINUX
+ m_proxyConfigService.reset(net::ProxyService::CreateSystemProxyConfigService(BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO)->message_loop_proxy()
+ , BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE)));
+//#endif
+}
+
+net::URLRequestContext *URLRequestContextGetterQt::GetURLRequestContext()
+{
+ if (!m_urlRequestContext) {
+
+ m_urlRequestContext.reset(new net::URLRequestContext());
+ m_networkDelegate.reset(new NetworkDelegateQt);
+
+ m_urlRequestContext->set_network_delegate(m_networkDelegate.get());
+ m_storage.reset(new net::URLRequestContextStorage(m_urlRequestContext.get()));
+ m_storage->set_cookie_store(new net::CookieMonster(NULL, NULL));
+ m_storage->set_server_bound_cert_service(new net::ServerBoundCertService(
+ new net::DefaultServerBoundCertStore(NULL),
+ base::WorkerPool::GetTaskRunner(true)));
+ m_storage->set_http_user_agent_settings(
+ new net::StaticHttpUserAgentSettings("en-us,en", EmptyString()));
+
+ scoped_ptr<net::HostResolver> host_resolver(
+ net::HostResolver::CreateDefaultResolver(NULL));
+
+ m_storage->set_cert_verifier(net::CertVerifier::CreateDefault());
+
+ m_storage->set_proxy_service(net::ProxyService::CreateUsingSystemProxyResolver(m_proxyConfigService.release(), 0, NULL));
+
+ m_storage->set_ssl_config_service(new net::SSLConfigServiceDefaults);
+ m_storage->set_http_auth_handler_factory(
+ net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
+ m_storage->set_http_server_properties(new net::HttpServerPropertiesImpl);
+
+ base::FilePath cache_path = m_basePath.Append(FILE_PATH_LITERAL("Cache"));
+ net::HttpCache::DefaultBackend* main_backend =
+ new net::HttpCache::DefaultBackend(
+ net::DISK_CACHE,
+ net::CACHE_BACKEND_DEFAULT,
+ cache_path,
+ 0,
+ BrowserThread::GetMessageLoopProxyForThread(
+ BrowserThread::CACHE));
+
+ net::HttpNetworkSession::Params network_session_params;
+ network_session_params.cert_verifier =
+ m_urlRequestContext->cert_verifier();
+ network_session_params.server_bound_cert_service =
+ m_urlRequestContext->server_bound_cert_service();
+ network_session_params.proxy_service =
+ m_urlRequestContext->proxy_service();
+ network_session_params.ssl_config_service =
+ m_urlRequestContext->ssl_config_service();
+ network_session_params.http_auth_handler_factory =
+ m_urlRequestContext->http_auth_handler_factory();
+ network_session_params.network_delegate =
+ m_networkDelegate.get();
+ network_session_params.http_server_properties =
+ m_urlRequestContext->http_server_properties();
+ network_session_params.ignore_certificate_errors =
+ m_ignoreCertificateErrors;
+
+ // Give |m_storage| ownership at the end in case it's |mapped_host_resolver|.
+ m_storage->set_host_resolver(host_resolver.Pass());
+ network_session_params.host_resolver =
+ m_urlRequestContext->host_resolver();
+
+ net::HttpCache* main_cache = new net::HttpCache(
+ network_session_params, main_backend);
+ m_storage->set_http_transaction_factory(main_cache);
+
+ // FIXME: add protocol handling
+ }
+
+ return m_urlRequestContext.get();
+}
+
+
+scoped_refptr<base::SingleThreadTaskRunner> URLRequestContextGetterQt::GetNetworkTaskRunner() const
+{
+ return content::BrowserThread::GetMessageLoopProxyForThread(content::BrowserThread::IO);
+}
diff --git a/lib/url_request_context_getter_qt.h b/lib/url_request_context_getter_qt.h
new file mode 100644
index 000000000..bd9bae723
--- /dev/null
+++ b/lib/url_request_context_getter_qt.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** 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 URL_REQUEST_CONTEXT_GETTER_QT_H
+#define URL_REQUEST_CONTEXT_GETTER_QT_H
+
+#include "net/url_request/url_request_context_getter.h"
+
+#include "base/files/file_path.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/single_thread_task_runner.h"
+#include "net/url_request/url_request_context_storage.h"
+
+namespace net {
+class HostResolver;
+class MappedHostResolver;
+class NetworkDelegate;
+class ProxyConfigService;
+}
+
+class URLRequestContextGetterQt : public net::URLRequestContextGetter {
+public:
+ explicit URLRequestContextGetterQt(const base::FilePath&);
+
+ virtual net::URLRequestContext* GetURLRequestContext() /*OVERRIDE*/;
+
+ virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const /*OVERRIDE*/;
+
+private:
+ virtual ~URLRequestContextGetterQt() {}
+
+ bool m_ignoreCertificateErrors;
+ base::FilePath m_basePath;
+
+ scoped_ptr<net::ProxyConfigService> m_proxyConfigService;
+ scoped_ptr<net::URLRequestContext> m_urlRequestContext;
+ scoped_ptr<net::NetworkDelegate> m_networkDelegate;
+ scoped_ptr<net::URLRequestContextStorage> m_storage;
+};
+
+#endif // URL_REQUEST_CONTEXT_GETTER_QT_H