diff options
Diffstat (limited to 'src/core/content_browser_client_qt.cpp')
-rw-r--r-- | src/core/content_browser_client_qt.cpp | 146 |
1 files changed, 9 insertions, 137 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index fbc57999e..b70f8a290 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -76,10 +76,6 @@ #include "third_party/blink/public/mojom/insecure_input/insecure_input_service.mojom.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_switches.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_share_group.h" -#include "ui/gl/gpu_timing.h" #include "url/url_util_qt.h" #include "qtwebengine/browser/qtwebengine_content_browser_overlay_manifest.h" @@ -91,7 +87,6 @@ #include "browser_main_parts_qt.h" #include "browser_message_filter_qt.h" #include "certificate_error_controller.h" -#include "certificate_error_controller_p.h" #include "client_cert_select_controller.h" #include "devtools_manager_delegate_qt.h" #include "login_delegate_qt.h" @@ -101,6 +96,7 @@ #include "net/proxying_restricted_cookie_manager_qt.h" #include "net/proxying_url_loader_factory_qt.h" #include "net/system_network_context_manager.h" +#include "ozone/gl_share_context_qt.h" #include "platform_notification_service_qt.h" #include "profile_qt.h" #include "profile_io_data_qt.h" @@ -219,93 +215,6 @@ bool IsHandledProtocol(base::StringPiece scheme) namespace QtWebEngineCore { -class QtShareGLContext : public gl::GLContext { -public: - QtShareGLContext(QOpenGLContext *qtContext) - : gl::GLContext(0) - , m_handle(0) - { - QString platform = qApp->platformName().toLower(); - QPlatformNativeInterface *pni = QGuiApplication::platformNativeInterface(); - if (platform == QLatin1String("xcb") || platform == QLatin1String("offscreen")) { - if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2) - m_handle = pni->nativeResourceForContext(QByteArrayLiteral("eglcontext"), qtContext); - else - m_handle = pni->nativeResourceForContext(QByteArrayLiteral("glxcontext"), qtContext); - } else if (platform == QLatin1String("cocoa")) - m_handle = pni->nativeResourceForContext(QByteArrayLiteral("cglcontextobj"), qtContext); - else if (platform == QLatin1String("qnx")) - m_handle = pni->nativeResourceForContext(QByteArrayLiteral("eglcontext"), qtContext); - else if (platform == QLatin1String("eglfs") || platform == QLatin1String("wayland") - || platform == QLatin1String("wayland-egl")) - m_handle = pni->nativeResourceForContext(QByteArrayLiteral("eglcontext"), qtContext); - else if (platform == QLatin1String("windows")) { - if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2) - m_handle = pni->nativeResourceForContext(QByteArrayLiteral("eglContext"), qtContext); - else - m_handle = pni->nativeResourceForContext(QByteArrayLiteral("renderingcontext"), qtContext); - } else { - qFatal("%s platform not yet supported", platform.toLatin1().constData()); - // Add missing platforms once they work. - Q_UNREACHABLE(); - } - } - - void* GetHandle() override { return m_handle; } - unsigned int CheckStickyGraphicsResetStatusImpl() override - { -#if QT_CONFIG(opengl) - if (QOpenGLContext *context = qt_gl_global_share_context()) { - if (context->format().testOption(QSurfaceFormat::ResetNotification)) - return context->extraFunctions()->glGetGraphicsResetStatus(); - } -#endif - return 0 /*GL_NO_ERROR*/; - } - - // We don't care about the rest, this context shouldn't be used except for its handle. - bool Initialize(gl::GLSurface *, const gl::GLContextAttribs &) override { Q_UNREACHABLE(); return false; } - bool MakeCurrentImpl(gl::GLSurface *) override { Q_UNREACHABLE(); return false; } - void ReleaseCurrent(gl::GLSurface *) override { Q_UNREACHABLE(); } - bool IsCurrent(gl::GLSurface *) override { Q_UNREACHABLE(); return false; } - scoped_refptr<gl::GPUTimingClient> CreateGPUTimingClient() override - { - return nullptr; - } - const gfx::ExtensionSet& GetExtensions() override - { - static const gfx::ExtensionSet s_emptySet; - return s_emptySet; - } - void ResetExtensions() override - { - } - -private: - void *m_handle; -}; - -class ShareGroupQtQuick : public gl::GLShareGroup { -public: - gl::GLContext* GetContext() override { return m_shareContextQtQuick.get(); } - void AboutToAddFirstContext() override; - -private: - scoped_refptr<QtShareGLContext> m_shareContextQtQuick; -}; - -void ShareGroupQtQuick::AboutToAddFirstContext() -{ -#if QT_CONFIG(opengl) - // This currently has to be setup by ::main in all applications using QQuickWebEngineView with delegated rendering. - QOpenGLContext *shareContext = qt_gl_global_share_context(); - if (!shareContext) { - qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QtWebEngine::initialize() in your main() function before QCoreApplication is created."); - } - m_shareContextQtQuick = new QtShareGLContext(shareContext); -#endif -} - ContentBrowserClientQt::ContentBrowserClientQt() { } @@ -354,9 +263,9 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost gl::GLShareGroup *ContentBrowserClientQt::GetInProcessGpuShareGroup() { - if (!m_shareGroupQtQuick.get()) - m_shareGroupQtQuick = new ShareGroupQtQuick; - return m_shareGroupQtQuick.get(); + if (!m_shareGroupQt.get()) + m_shareGroupQt = new ShareGroupQt; + return m_shareGroupQt.get(); } content::MediaObserver *ContentBrowserClientQt::GetMediaObserver() @@ -386,55 +295,18 @@ scoped_refptr<content::QuotaPermissionContext> ContentBrowserClientQt::CreateQuo return new QuotaPermissionContextQt; } -// Copied from chrome/browser/ssl/ssl_error_handler.cc: -static int IsCertErrorFatal(int cert_error) -{ - switch (cert_error) { - case net::ERR_CERT_COMMON_NAME_INVALID: - case net::ERR_CERT_DATE_INVALID: - case net::ERR_CERT_AUTHORITY_INVALID: - case net::ERR_CERT_NO_REVOCATION_MECHANISM: - case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION: - case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM: - case net::ERR_CERT_WEAK_KEY: - case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION: - case net::ERR_CERT_VALIDITY_TOO_LONG: - case net::ERR_CERTIFICATE_TRANSPARENCY_REQUIRED: - case net::ERR_CERT_SYMANTEC_LEGACY: - case net::ERR_CERT_KNOWN_INTERCEPTION_BLOCKED: - case net::ERR_SSL_OBSOLETE_VERSION: - return false; - case net::ERR_CERT_CONTAINS_ERRORS: - case net::ERR_CERT_REVOKED: - case net::ERR_CERT_INVALID: - case net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN: - return true; - default: - NOTREACHED(); - } - return true; -} - void ContentBrowserClientQt::AllowCertificateError(content::WebContents *webContents, int cert_error, const net::SSLInfo &ssl_info, const GURL &request_url, - bool is_main_frame_request, + bool /* is_main_frame_request */, bool strict_enforcement, base::OnceCallback<void(content::CertificateRequestResultType)> callback) { WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate()); - QSharedPointer<CertificateErrorController> errorController( - new CertificateErrorController( - new CertificateErrorControllerPrivate( - cert_error, - ssl_info, - request_url, - is_main_frame_request, - IsCertErrorFatal(cert_error), - strict_enforcement, - std::move(callback)))); + QSharedPointer<CertificateErrorController> errorController(new CertificateErrorController( + cert_error, ssl_info, request_url, strict_enforcement, std::move(callback))); contentsDelegate->allowCertificateError(errorController); } @@ -1135,7 +1007,7 @@ void ContentBrowserClientQt::ConfigureNetworkContextParams( std::vector<base::FilePath> ContentBrowserClientQt::GetNetworkContextsParentDirectory() { return { - toFilePath(QStandardPaths::writableLocation(QStandardPaths::DataLocation)), + toFilePath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)), toFilePath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)) }; } @@ -1215,7 +1087,7 @@ void ContentBrowserClientQt::RegisterNonNetworkSubresourceURLLoaderFactories(int #endif if (!install_file_scheme && web_contents) { const auto *settings = static_cast<WebContentsDelegateQt *>(web_contents->GetDelegate())->webEngineSettings(); - if (settings->testAttribute(WebEngineSettings::LocalContentCanAccessFileUrls)) { + if (settings->testAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls)) { for (const auto &local_scheme : url::GetLocalSchemes()) { if (url.SchemeIs(local_scheme)) { install_file_scheme = true; |