summaryrefslogtreecommitdiffstats
path: root/src/core/content_browser_client_qt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/content_browser_client_qt.cpp')
-rw-r--r--src/core/content_browser_client_qt.cpp127
1 files changed, 76 insertions, 51 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 4948d1d8d..a6a133271 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
**
@@ -10,15 +10,15 @@
** 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.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 included in the
-** packaging of this file. Please review the following information to
+** 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.html.
**
@@ -26,7 +26,7 @@
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or later 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
+** the packaging of this file. Please review the following information to
** ensure the GNU General Public License version 2.0 requirements will be
** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
@@ -55,17 +55,23 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_share_group.h"
+#include "access_token_store_qt.h"
+#include "browser_context_adapter.h"
#include "browser_context_qt.h"
#include "certificate_error_controller.h"
#include "certificate_error_controller_p.h"
#include "desktop_screen_qt.h"
#include "dev_tools_http_handler_delegate_qt.h"
+#ifdef QT_USE_POSITIONING
+#include "location_provider_qt.h"
+#endif
#include "media_capture_devices_dispatcher.h"
#include "resource_dispatcher_host_delegate_qt.h"
+#include "user_script_controller_host.h"
#include "web_contents_delegate_qt.h"
-#include "access_token_store_qt.h"
#include <QGuiApplication>
+#include <QLocale>
#include <QOpenGLContext>
#include <qpa/qplatformnativeinterface.h>
@@ -73,6 +79,8 @@ QT_BEGIN_NAMESPACE
Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
QT_END_NAMESPACE
+namespace QtWebEngineCore {
+
namespace {
ContentBrowserClientQt* gBrowserClient = 0; // Owned by ContentMainDelegateQt.
@@ -198,17 +206,15 @@ public:
void PreMainMessageLoopStart() Q_DECL_OVERRIDE
{
- base::MessageLoop::InitMessagePumpForUIFactory(::messagePumpFactory);
+ base::MessageLoop::InitMessagePumpForUIFactory(messagePumpFactory);
}
void PreMainMessageLoopRun() Q_DECL_OVERRIDE
{
- m_browserContext.reset(new BrowserContextQt());
}
void PostMainMessageLoopRun()
{
- m_browserContext.reset();
}
int PreCreateThreads() Q_DECL_OVERRIDE
@@ -219,13 +225,7 @@ public:
return 0;
}
- BrowserContextQt* browser_context() const {
- return m_browserContext.get();
- }
-
private:
- scoped_ptr<BrowserContextQt> m_browserContext;
-
DISALLOW_COPY_AND_ASSIGN(BrowserMainPartsQt);
};
@@ -246,7 +246,7 @@ public:
m_handle = pni->nativeResourceForContext(QByteArrayLiteral("cglcontextobj"), qtContext);
else if (platform == QLatin1String("qnx"))
m_handle = pni->nativeResourceForContext(QByteArrayLiteral("eglcontext"), qtContext);
- else if (platform == QLatin1String("eglfs"))
+ else if (platform == QLatin1String("eglfs") || platform == QLatin1String("wayland"))
m_handle = pni->nativeResourceForContext(QByteArrayLiteral("eglcontext"), qtContext);
else if (platform == QLatin1String("windows")) {
if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2)
@@ -332,6 +332,7 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost*
{
// FIXME: Add a settings variable to enable/disable the file scheme.
content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(host->GetID(), url::kFileScheme);
+ static_cast<BrowserContextQt*>(host->GetBrowserContext())->m_adapter->userScriptController()->renderProcessHostCreated(host);
}
void ContentBrowserClientQt::ResourceDispatcherHostCreated()
@@ -342,7 +343,7 @@ void ContentBrowserClientQt::ResourceDispatcherHostCreated()
gfx::GLShareGroup *ContentBrowserClientQt::GetInProcessGpuShareGroup()
{
- if (!m_shareGroupQtQuick)
+ if (!m_shareGroupQtQuick.get())
m_shareGroupQtQuick = new ShareGroupQtQuick;
return m_shareGroupQtQuick.get();
}
@@ -352,7 +353,7 @@ content::MediaObserver *ContentBrowserClientQt::GetMediaObserver()
return MediaCaptureDevicesDispatcher::GetInstance();
}
-void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, const GURL &url, WebPreferences *web_prefs)
+void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, const GURL &url, content::WebPreferences *web_prefs)
{
Q_UNUSED(url);
if (content::WebContents *webContents = rvh->GetDelegate()->GetAsWebContents())
@@ -364,25 +365,9 @@ content::AccessTokenStore *ContentBrowserClientQt::CreateAccessTokenStore()
return new AccessTokenStoreQt;
}
-BrowserContextQt* ContentBrowserClientQt::browser_context() {
- Q_ASSERT(m_browserMainParts);
- return static_cast<BrowserMainPartsQt*>(m_browserMainParts)->browser_context();
-}
-
-net::URLRequestContextGetter* ContentBrowserClientQt::CreateRequestContext(content::BrowserContext* content_browser_context, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors)
+net::URLRequestContextGetter* ContentBrowserClientQt::CreateRequestContext(content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors)
{
- if (content_browser_context != browser_context())
- 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();
- }
+ return static_cast<BrowserContextQt*>(browser_context)->CreateRequestContext(protocol_handlers);
}
content::QuotaPermissionContext *ContentBrowserClientQt::CreateQuotaPermissionContext()
@@ -392,8 +377,9 @@ content::QuotaPermissionContext *ContentBrowserClientQt::CreateQuotaPermissionCo
void ContentBrowserClientQt::AllowCertificateError(int render_process_id, int render_frame_id, int cert_error,
const net::SSLInfo& ssl_info, const GURL& request_url,
- ResourceType::Type resource_type,
+ content::ResourceType resource_type,
bool overridable, bool strict_enforcement,
+ bool expired_previous_decision,
const base::Callback<void(bool)>& callback,
content::CertificateRequestResultType* result)
{
@@ -405,23 +391,62 @@ void ContentBrowserClientQt::AllowCertificateError(int render_process_id, int re
if (content::WebContents *webContents = frameHost->GetRenderViewHost()->GetDelegate()->GetAsWebContents())
contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate());
- QExplicitlySharedDataPointer<CertificateErrorController> errorController(new CertificateErrorController(new CertificateErrorControllerPrivate(cert_error, ssl_info, request_url, resource_type, overridable, strict_enforcement, callback)));
+ QSharedPointer<CertificateErrorController> errorController(new CertificateErrorController(new CertificateErrorControllerPrivate(cert_error, ssl_info, request_url, resource_type, overridable, strict_enforcement, callback)));
contentsDelegate->allowCertificateError(errorController);
}
-void ContentBrowserClientQt::RequestGeolocationPermission(content::WebContents *webContents,
- int bridge_id,
- const GURL &requesting_frame,
- bool user_gesture,
- base::Callback<void(bool)> result_callback,
- base::Closure *cancel_callback)
+void ContentBrowserClientQt::RequestPermission(content::PermissionType permission,
+ content::WebContents* web_contents,
+ int bridge_id,
+ const GURL& requesting_frame,
+ bool user_gesture,
+ const base::Callback<void(bool)>& result_callback)
{
- Q_UNUSED(webContents);
Q_UNUSED(bridge_id);
- Q_UNUSED(requesting_frame);
Q_UNUSED(user_gesture);
- Q_UNUSED(cancel_callback);
+ WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(web_contents->GetDelegate());
+ Q_ASSERT(contentsDelegate);
+ if (permission == content::PERMISSION_GEOLOCATION)
+ contentsDelegate->requestGeolocationPermission(requesting_frame, result_callback);
+ else
+ result_callback.Run(false);
+}
+
- // TODO: Add geolocation support
- result_callback.Run(false);
+void ContentBrowserClientQt::CancelPermissionRequest(content::PermissionType permission,
+ content::WebContents* web_contents,
+ int bridge_id,
+ const GURL& requesting_frame)
+{
+ Q_UNUSED(bridge_id);
+ WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(web_contents->GetDelegate());
+ Q_ASSERT(contentsDelegate);
+ if (permission == content::PERMISSION_GEOLOCATION)
+ contentsDelegate->cancelGeolocationPermissionRequest(requesting_frame);
+}
+
+blink::WebNotificationPermission ContentBrowserClientQt::CheckDesktopNotificationPermission(const GURL&, content::ResourceContext *, int )
+{
+ return blink::WebNotificationPermission::WebNotificationPermissionDenied;
+}
+
+content::LocationProvider *ContentBrowserClientQt::OverrideSystemLocationProvider()
+{
+#ifdef QT_USE_POSITIONING
+ return new LocationProviderQt;
+#else
+ return 0; // Leave it up to Chromium to figure something out.
+#endif
}
+
+std::string ContentBrowserClientQt::GetApplicationLocale()
+{
+ return QLocale().bcp47Name().toStdString();
+}
+
+content::DevToolsManagerDelegate* ContentBrowserClientQt::GetDevToolsManagerDelegate()
+{
+ return new DevToolsManagerDelegateQt;
+}
+
+} // namespace QtWebEngineCore