diff options
Diffstat (limited to 'src')
61 files changed, 1820 insertions, 550 deletions
diff --git a/src/core/clipboard_qt.h b/src/core/clipboard_qt.h index 20b51a599..2089208bf 100644 --- a/src/core/clipboard_qt.h +++ b/src/core/clipboard_qt.h @@ -82,7 +82,7 @@ public: void ReadBookmark(base::string16* title, std::string* url) const override; void ReadData(const FormatType& format, std::string* result) const override; - virtual void OnPreShutdown() Q_DECL_OVERRIDE { } + void OnPreShutdown() override { } protected: void WriteObjects(ui::ClipboardType type, const ObjectMap& objects) override; diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 3ec119e0a..328dcd38d 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -54,7 +54,6 @@ #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/client_certificate_delegate.h" #include "content/public/browser/media_observer.h" -#include "content/public/browser/quota_permission_context.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" @@ -87,7 +86,7 @@ #include "certificate_error_controller.h" #include "certificate_error_controller_p.h" #include "desktop_screen_qt.h" -#include "dev_tools_http_handler_delegate_qt.h" +#include "devtools_manager_delegate_qt.h" #ifdef QT_USE_POSITIONING #include "location_provider_qt.h" #else @@ -99,6 +98,7 @@ #include "printing_message_filter_qt.h" #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) #include "qrc_protocol_handler_qt.h" +#include "quota_permission_context_qt.h" #include "renderer_host/resource_dispatcher_host_delegate_qt.h" #include "renderer_host/user_resource_controller_host.h" #include "web_contents_delegate_qt.h" @@ -376,16 +376,6 @@ void ShareGroupQtQuick::AboutToAddFirstContext() #endif } -class QuotaPermissionContextQt : public content::QuotaPermissionContext { -public: - void RequestQuotaPermission(const content::StorageQuotaParams ¶ms, int render_process_id, const PermissionCallback &callback) override - { - Q_UNUSED(params); - Q_UNUSED(render_process_id); - callback.Run(QUOTA_PERMISSION_RESPONSE_DISALLOW); - } -}; - ContentBrowserClientQt::ContentBrowserClientQt() : m_browserMainParts(0) { @@ -508,7 +498,7 @@ void ContentBrowserClientQt::AppendExtraCommandLineSwitches(base::CommandLine* c command_line->AppendSwitchASCII(switches::kLang, GetApplicationLocale()); } -void ContentBrowserClientQt::GetAdditionalWebUISchemes(std::vector<std::string>* additional_schemes) +void ContentBrowserClientQt::GetAdditionalViewSourceSchemes(std::vector<std::string>* additional_schemes) { additional_schemes->push_back(kQrcSchemeQt); } diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index 5d5a96e0c..d810fc08a 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -113,7 +113,7 @@ public: std::string GetApplicationLocale() override; std::string GetAcceptLangs(content::BrowserContext* context) override; void AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id) override; - void GetAdditionalWebUISchemes(std::vector<std::string>* additional_schemes) override; + void GetAdditionalViewSourceSchemes(std::vector<std::string>* additional_schemes) override; void BindInterfaceRequestFromFrame(content::RenderFrameHost* render_frame_host, const std::string& interface_name, diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index 0ec6979c8..513cd4c1f 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -32,8 +32,6 @@ qtConfig(webengine-embedded-build): DEFINES += QTWEBENGINE_EMBEDDED_SWITCHES qtConfig(egl): CONFIG += egl -RESOURCES += devtools.qrc - INCLUDEPATH += $$PWD $$PWD/api SOURCES = \ @@ -61,7 +59,7 @@ SOURCES = \ custom_protocol_handler.cpp \ delegated_frame_node.cpp \ desktop_screen_qt.cpp \ - dev_tools_http_handler_delegate_qt.cpp \ + devtools_manager_delegate_qt.cpp \ download_manager_delegate_qt.cpp \ favicon_manager.cpp \ file_picker_controller.cpp \ @@ -77,6 +75,8 @@ SOURCES = \ process_main.cpp \ proxy_config_service_qt.cpp \ qrc_protocol_handler_qt.cpp \ + quota_permission_context_qt.cpp \ + quota_permission_controller.cpp \ render_view_observer_host_qt.cpp \ render_widget_host_view_qt.cpp \ renderer/content_renderer_client_qt.cpp \ @@ -106,7 +106,8 @@ SOURCES = \ web_engine_error.cpp \ web_engine_library_info.cpp \ web_engine_settings.cpp \ - web_event_factory.cpp + web_event_factory.cpp \ + webui/webui_controller_factory_qt.cpp HEADERS = \ access_token_store_qt.h \ @@ -134,7 +135,7 @@ HEADERS = \ custom_protocol_handler.h \ delegated_frame_node.h \ desktop_screen_qt.h \ - dev_tools_http_handler_delegate_qt.h \ + devtools_manager_delegate_qt.h \ download_manager_delegate_qt.h \ chromium_gpu_helper.h \ favicon_manager_p.h \ @@ -153,6 +154,9 @@ HEADERS = \ process_main.h \ proxy_config_service_qt.h \ qrc_protocol_handler_qt.h \ + quota_permission_context_qt.h \ + quota_permission_controller.h \ + quota_permission_controller_p.h \ render_view_observer_host_qt.h \ render_widget_host_view_qt.h \ render_widget_host_view_qt_delegate.h \ @@ -184,7 +188,8 @@ HEADERS = \ web_engine_error.h \ web_engine_library_info.h \ web_engine_settings.h \ - web_event_factory.h + web_event_factory.h \ + webui/webui_controller_factory_qt.h qtConfig(webengine-pepper-plugins) { diff --git a/src/core/devtools.qrc b/src/core/devtools.qrc deleted file mode 100644 index 6656304ac..000000000 --- a/src/core/devtools.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix="data"> - <file alias="discovery_page.html">resources/devtools_discovery_page.html</file> -</qresource> -</RCC> diff --git a/src/core/dev_tools_http_handler_delegate_qt.cpp b/src/core/devtools_manager_delegate_qt.cpp index 569c4c179..8ea3c2fb7 100644 --- a/src/core/dev_tools_http_handler_delegate_qt.cpp +++ b/src/core/devtools_manager_delegate_qt.cpp @@ -37,22 +37,19 @@ ** ****************************************************************************/ +// based on content/shell/browser/shell_devtools_manager_delegate.cc: // Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE.Chromium file. -#include "dev_tools_http_handler_delegate_qt.h" - -#include "type_conversion.h" - -#include <QByteArray> -#include <QFile> +#include "devtools_manager_delegate_qt.h" #include "base/command_line.h" #include "base/files/file_path.h" #include "base/memory/ptr_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/grit/qt_webengine_resources.h" #include "content/browser/devtools/devtools_http_handler.h" #include "content/public/browser/devtools_agent_host.h" #include "content/public/browser/devtools_frontend_host.h" @@ -66,8 +63,11 @@ #include "net/base/ip_endpoint.h" #include "net/base/net_errors.h" #include "net/socket/tcp_server_socket.h" +#include "ui/base/resource/resource_bundle.h" -using namespace content; +#include "type_conversion.h" + +using content::DevToolsAgentHost; namespace { @@ -181,14 +181,7 @@ void DevToolsManagerDelegateQt::Initialized(const net::IPEndPoint *ip_address) std::string DevToolsManagerDelegateQt::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; + return ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string(); } std::string DevToolsManagerDelegateQt::GetFrontendResource(const std::string& path) diff --git a/src/core/dev_tools_http_handler_delegate_qt.h b/src/core/devtools_manager_delegate_qt.h index 1b0e82bc0..1b0e82bc0 100644 --- a/src/core/dev_tools_http_handler_delegate_qt.h +++ b/src/core/devtools_manager_delegate_qt.h diff --git a/src/core/network_delegate_qt.h b/src/core/network_delegate_qt.h index 3607d8ab0..b0a8e1ef9 100644 --- a/src/core/network_delegate_qt.h +++ b/src/core/network_delegate_qt.h @@ -73,30 +73,29 @@ public: const net::CompletionCallback &callback); // net::NetworkDelegate implementation - virtual int OnBeforeURLRequest(net::URLRequest* request, const net::CompletionCallback& callback, GURL* newUrl) override; - virtual void OnURLRequestDestroyed(net::URLRequest* request) override; - virtual bool OnCanSetCookie(const net::URLRequest&, const std::string&, net::CookieOptions*) override; - virtual int OnBeforeStartTransaction(net::URLRequest *request, const net::CompletionCallback &callback, net::HttpRequestHeaders *headers) override; + int OnBeforeURLRequest(net::URLRequest* request, const net::CompletionCallback& callback, GURL* newUrl) override; + void OnURLRequestDestroyed(net::URLRequest* request) override; + bool OnCanSetCookie(const net::URLRequest&, const std::string&, net::CookieOptions*) override; + int OnBeforeStartTransaction(net::URLRequest *request, const net::CompletionCallback &callback, net::HttpRequestHeaders *headers) override; virtual void OnBeforeSendHeaders(net::URLRequest* request, const net::ProxyInfo& proxy_info, const net::ProxyRetryInfoMap& proxy_retry_info, net::HttpRequestHeaders* headers) override; - virtual void OnStartTransaction(net::URLRequest *request, const net::HttpRequestHeaders &headers) override; - virtual int OnHeadersReceived(net::URLRequest*, const net::CompletionCallback&, const net::HttpResponseHeaders*, scoped_refptr<net::HttpResponseHeaders>*, GURL*) override; - virtual void OnBeforeRedirect(net::URLRequest*, const GURL&) override; - virtual void OnResponseStarted(net::URLRequest*) override; - virtual void OnNetworkBytesReceived(net::URLRequest*, int64_t) override; - virtual void OnNetworkBytesSent(net::URLRequest *, int64_t) override; - virtual void OnCompleted(net::URLRequest*, bool) override; - virtual void OnPACScriptError(int, const base::string16&) override; - virtual net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(net::URLRequest*, const net::AuthChallengeInfo&, const AuthCallback&, net::AuthCredentials*) override; - virtual bool OnCanGetCookies(const net::URLRequest&, const net::CookieList&) override; - virtual bool OnCanAccessFile(const net::URLRequest&, const base::FilePath&, const base::FilePath&) const override; + void OnStartTransaction(net::URLRequest *request, const net::HttpRequestHeaders &headers) override; + int OnHeadersReceived(net::URLRequest*, const net::CompletionCallback&, const net::HttpResponseHeaders*, scoped_refptr<net::HttpResponseHeaders>*, GURL*) override; + void OnBeforeRedirect(net::URLRequest*, const GURL&) override; + void OnResponseStarted(net::URLRequest*) override; + void OnNetworkBytesReceived(net::URLRequest*, int64_t) override; + void OnNetworkBytesSent(net::URLRequest *, int64_t) override; + void OnCompleted(net::URLRequest*, bool) override; + void OnPACScriptError(int, const base::string16&) override; + net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(net::URLRequest*, const net::AuthChallengeInfo&, const AuthCallback&, net::AuthCredentials*) override; + bool OnCanGetCookies(const net::URLRequest&, const net::CookieList&) override; + bool OnCanAccessFile(const net::URLRequest&, const base::FilePath&, const base::FilePath&) const override; + bool OnCanEnablePrivacyMode(const GURL&, const GURL&) const override; + bool OnAreExperimentalCookieFeaturesEnabled() const override; + bool OnCancelURLRequestWithPolicyViolatingReferrerHeader(const net::URLRequest&, const GURL&, const GURL&) const override; - virtual bool OnCanEnablePrivacyMode(const GURL&, const GURL&) const override; - virtual bool OnAreExperimentalCookieFeaturesEnabled() const override; - virtual bool OnCancelURLRequestWithPolicyViolatingReferrerHeader(const net::URLRequest&, const GURL&, const GURL&) const override; - - virtual bool OnCanQueueReportingReport(const url::Origin& origin) const override; - virtual bool OnCanSendReportingReport(const url::Origin& origin) const override; + bool OnCanQueueReportingReport(const url::Origin& origin) const override; + bool OnCanSendReportingReport(const url::Origin& origin) const override; virtual bool OnCanSetReportingClient(const url::Origin& origin, const GURL& endpoint) const override; virtual bool OnCanUseReportingClient(const url::Origin& origin, diff --git a/src/core/qtwebengine.gni b/src/core/qtwebengine.gni index c9f766a36..a86e93f5b 100644 --- a/src/core/qtwebengine.gni +++ b/src/core/qtwebengine.gni @@ -17,6 +17,7 @@ deps = [ "//components/keyed_service/content", "//components/visitedlink/browser", "//components/visitedlink/renderer", + "//components/signin/core/common:signin_features", "//components/web_cache/browser", "//components/web_cache/renderer", "//components/spellcheck:build_features", diff --git a/src/core/qtwebengine_resources.gni b/src/core/qtwebengine_resources.gni index acf5f1590..6bff6a9a4 100644 --- a/src/core/qtwebengine_resources.gni +++ b/src/core/qtwebengine_resources.gni @@ -17,6 +17,9 @@ group("qtwebengine_resources") { repack("qtwebengine_repack_resources") { sources = [ "$root_gen_dir/blink/public/resources/blink_resources.pak", + "$root_gen_dir/chrome/qt_webengine_resources.pak", + "$root_gen_dir/chrome/quota_internals_resources.pak", + "$root_gen_dir/chrome/task_scheduler_internals_resources.pak", "$root_gen_dir/components/components_resources.pak", "$root_gen_dir/content/content_resources.pak", "$root_gen_dir/net/net_resources.pak", @@ -24,6 +27,9 @@ repack("qtwebengine_repack_resources") { ] output = "$root_out_dir/qtwebengine_resources.pak" deps = [ + "//chrome/browser/resources:qt_webengine_resources", + "//chrome/browser/resources:quota_internals_resources", + "//chrome/browser/resources:task_scheduler_internals_resources", "//components/resources:components_resources_grit", "//content:resources_grit", "//net:net_resources_grit", diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni index 9a2d4aee5..a21193ecd 100644 --- a/src/core/qtwebengine_sources.gni +++ b/src/core/qtwebengine_sources.gni @@ -44,8 +44,26 @@ source_set("qtwebengine_sources") { "//chrome/browser/media/webrtc/desktop_media_list.h", "//chrome/browser/media/webrtc/desktop_streams_registry.cc", "//chrome/browser/media/webrtc/desktop_streams_registry.h", + "//chrome/browser/profiles/profile.cc", + "//chrome/browser/profiles/profile.h", + "//chrome/browser/ui/webui/devtools_ui.cc", + "//chrome/browser/ui/webui/devtools_ui.h", + "//chrome/browser/ui/webui/quota_internals/quota_internals_handler.cc", + "//chrome/browser/ui/webui/quota_internals/quota_internals_handler.h", + "//chrome/browser/ui/webui/quota_internals/quota_internals_proxy.cc", + "//chrome/browser/ui/webui/quota_internals/quota_internals_proxy.h", + "//chrome/browser/ui/webui/quota_internals/quota_internals_types.cc", + "//chrome/browser/ui/webui/quota_internals/quota_internals_types.h", + "//chrome/browser/ui/webui/quota_internals/quota_internals_ui.cc", + "//chrome/browser/ui/webui/quota_internals/quota_internals_ui.h", + "//chrome/browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui.cc", + "//chrome/browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui.h", "//chrome/common/chrome_switches.cc", "//chrome/common/chrome_switches.h", + "//chrome/common/pref_names.cc", + "//chrome/common/pref_names.h", + "//chrome/common/url_constants.cc", + "//chrome/common/url_constants.h", "//components/prefs/in_memory_pref_store.cc", "//components/prefs/in_memory_pref_store.h", "//extensions/common/constants.cc", @@ -54,11 +72,14 @@ source_set("qtwebengine_sources") { "//extensions/common/url_pattern.h", ] - if (enable_spellcheck) { + if (is_linux) { sources += [ - "//chrome/common/pref_names.cc", - "//chrome/common/pref_names.h", + "//chrome/browser/ui/webui/sandbox_internals_ui.cc", + "//chrome/browser/ui/webui/sandbox_internals_ui.h", ] + } + + if (enable_spellcheck) { deps += [ ":qtwebengine_spellcheck_sources", "//chrome/tools/convert_dict", diff --git a/src/core/quota_permission_context_qt.cpp b/src/core/quota_permission_context_qt.cpp new file mode 100644 index 000000000..10249bbf0 --- /dev/null +++ b/src/core/quota_permission_context_qt.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 included in the +** 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-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "quota_permission_context_qt.h" + +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/render_frame_host.h" +#include "content/public/browser/web_contents.h" +#include "quota_permission_controller.h" +#include "quota_permission_controller_p.h" +#include "web_contents_delegate_qt.h" +#include "web_contents_view_qt.h" + +using content::QuotaPermissionContext; +using content::RenderFrameHost; +using content::StorageQuotaParams; +using content::WebContents; + +namespace QtWebEngineCore { + +void QuotaPermissionContextQt::RequestQuotaPermission(const StorageQuotaParams ¶ms, int render_process_id, const PermissionCallback &callback) +{ + if (params.storage_type != storage::kStorageTypePersistent) { + // For now we only support requesting quota with this interface + // for Persistent storage type. + callback.Run(QUOTA_PERMISSION_RESPONSE_DISALLOW); + return; + } + + if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { + content::BrowserThread::PostTask( + content::BrowserThread::UI, FROM_HERE, + base::Bind(&QuotaPermissionContextQt::RequestQuotaPermission, this, + params, render_process_id, callback)); + return; + } + + RenderFrameHost *renderFrameHost = RenderFrameHost::FromID(render_process_id, params.render_frame_id); + if (!renderFrameHost) + return; + + WebContents *webContents = WebContents::FromRenderFrameHost(renderFrameHost); + if (!webContents) + return; + + WebContentsAdapterClient *client = WebContentsViewQt::from(static_cast<content::WebContentsImpl *>(webContents)->GetView())->client(); + if (!client) + return; + + QSharedPointer<QuotaPermissionController> controller(new QuotaPermissionController(new QuotaPermissionControllerPrivate(this, params, callback))); + client->runQuotaPermissionRequest(controller); +} + +void QuotaPermissionContextQt::dispatchCallbackOnIOThread(const PermissionCallback &callback, + QuotaPermissionContext::QuotaPermissionResponse response) +{ + if (callback.is_null()) + return; + + if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { + content::BrowserThread::PostTask( + content::BrowserThread::IO, FROM_HERE, + base::Bind(&QuotaPermissionContextQt::dispatchCallbackOnIOThread, + this, callback, response)); + return; + } + + callback.Run(response); +} + +} // namespace QtWebEngineCore diff --git a/src/core/quota_permission_context_qt.h b/src/core/quota_permission_context_qt.h new file mode 100644 index 000000000..99e07eec7 --- /dev/null +++ b/src/core/quota_permission_context_qt.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 included in the +** 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-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QUOTA_PERMISSION_CONTEXT_QT_H +#define QUOTA_PERMISSION_CONTEXT_QT_H + +#include "content/public/browser/quota_permission_context.h" + +#include <QtCore/qcompilerdetection.h> // Needed for override + +namespace QtWebEngineCore { + +class QuotaPermissionContextQt : public content::QuotaPermissionContext { +public: + void RequestQuotaPermission(const content::StorageQuotaParams ¶ms, + int render_process_id, + const PermissionCallback &callback) override; + + void dispatchCallbackOnIOThread(const PermissionCallback &callback, + QuotaPermissionContext::QuotaPermissionResponse response); +}; + +} // namespace QtWebEngineCore + +#endif // QUOTA_PERMISSION_CONTEXT_QT_H diff --git a/src/core/quota_permission_controller.cpp b/src/core/quota_permission_controller.cpp new file mode 100644 index 000000000..59fc6198d --- /dev/null +++ b/src/core/quota_permission_controller.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 included in the +** 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-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "quota_permission_controller.h" +#include "quota_permission_controller_p.h" + +#include "quota_permission_context_qt.h" +#include "type_conversion.h" + +namespace QtWebEngineCore { + +QuotaPermissionControllerPrivate::QuotaPermissionControllerPrivate(QuotaPermissionContextQt *context, + const content::StorageQuotaParams ¶ms, + const content::QuotaPermissionContext::PermissionCallback &callback) + : m_context(context), + m_originUrl(toQt(params.origin_url)), + m_requestedSize(params.requested_size), + m_callback(callback) +{ +} + +QuotaPermissionControllerPrivate::~QuotaPermissionControllerPrivate() +{ +} + +QuotaPermissionController::QuotaPermissionController(QuotaPermissionControllerPrivate *controllerPrivate) + : d(controllerPrivate) + , m_answered(false) +{ +} + +QuotaPermissionController::~QuotaPermissionController() +{ +} + +void QuotaPermissionController::accept() +{ + if (!m_answered) { + d->m_context->dispatchCallbackOnIOThread(d->m_callback, QuotaPermissionContextQt::QUOTA_PERMISSION_RESPONSE_ALLOW); + m_answered = true; + } +} + +void QuotaPermissionController::cancel() +{ + if (!m_answered) { + d->m_context->dispatchCallbackOnIOThread(d->m_callback, QuotaPermissionContextQt::QUOTA_PERMISSION_RESPONSE_DISALLOW); + m_answered = true; + } +} + +QUrl QuotaPermissionController::origin() +{ + return d->m_originUrl; +} + +qint64 QuotaPermissionController::requestedSize() +{ + return d->m_requestedSize; +} + +} // namespace QtWebEngineCore diff --git a/src/core/quota_permission_controller.h b/src/core/quota_permission_controller.h new file mode 100644 index 000000000..36f751c2c --- /dev/null +++ b/src/core/quota_permission_controller.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 included in the +** 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-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QUOTA_PERMISSION_CONTROLLER_H +#define QUOTA_PERMISSION_CONTROLLER_H + +#include "qtwebenginecoreglobal.h" +#include <QtCore/qscopedpointer.h> +#include <QtCore/qurl.h> + +namespace QtWebEngineCore { + +class QuotaPermissionContextQt; +class QuotaPermissionControllerPrivate; + +class QWEBENGINE_EXPORT QuotaPermissionController { +public: + QuotaPermissionController(QuotaPermissionControllerPrivate *controllerPrivate); + ~QuotaPermissionController(); + + void accept(); + void cancel(); + + QUrl origin(); + qint64 requestedSize(); + +private: + QScopedPointer<QuotaPermissionControllerPrivate> d; + bool m_answered; +}; + +} // namespace QtWebEngineCore + +#endif // QUOTA_PERMISSION_CONTROLLER_H diff --git a/src/core/quota_permission_controller_p.h b/src/core/quota_permission_controller_p.h new file mode 100644 index 000000000..c00ae42c9 --- /dev/null +++ b/src/core/quota_permission_controller_p.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 included in the +** 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-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QUOTA_PERMISSION_CONTROLLER_P_H +#define QUOTA_PERMISSION_CONTROLLER_P_H + +#include "quota_permission_context_qt.h" +#include <QtCore/qurl.h> + +namespace QtWebEngineCore { + +class QuotaPermissionControllerPrivate { +public: + QuotaPermissionControllerPrivate(QuotaPermissionContextQt *context, + const content::StorageQuotaParams ¶ms, + const content::QuotaPermissionContext::PermissionCallback &callback); + ~QuotaPermissionControllerPrivate(); + +private: + scoped_refptr<QuotaPermissionContextQt> m_context; + QUrl m_originUrl; + qint64 m_requestedSize; + content::QuotaPermissionContext::PermissionCallback m_callback; + + friend class QuotaPermissionController; +}; + +} // namespace QtWebEngineCore + +#endif // QUOTA_PERMISSION_CONTROLLER_P_H diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 80c9121f5..e084de463 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -960,6 +960,7 @@ QSGNode *RenderWidgetHostViewQt::updatePaintNode(QSGNode *oldNode) void RenderWidgetHostViewQt::notifyResize() { m_host->WasResized(); + m_host->SendScreenRects(); } void RenderWidgetHostViewQt::notifyShown() @@ -1049,6 +1050,12 @@ bool RenderWidgetHostViewQt::forwardEvent(QEvent *event) case QEvent::TouchCancel: handleTouchEvent(static_cast<QTouchEvent*>(event)); break; + case QEvent::TabletPress: + Focus(); // Fall through. + case QEvent::TabletRelease: + case QEvent::TabletMove: + handleTabletEvent(static_cast<QTabletEvent*>(event)); + break; #ifndef QT_NO_GESTURES case QEvent::NativeGesture: handleGestureEvent(static_cast<QNativeGestureEvent *>(event)); @@ -1185,49 +1192,7 @@ void RenderWidgetHostViewQt::handleMouseEvent(QMouseEvent* event) // transformation done by Chromium. if (event->source() == Qt::MouseEventSynthesizedBySystem) return; - - blink::WebMouseEvent webEvent = WebEventFactory::toWebMouseEvent(event, dpiScale()); - if ((webEvent.GetType() == blink::WebInputEvent::kMouseDown || webEvent.GetType() == blink::WebInputEvent::kMouseUp) - && webEvent.button == blink::WebMouseEvent::Button::kNoButton) { - // Blink can only handle the 3 main mouse-buttons and may assert when processing mouse-down for no button. - return; - } - - - if (event->type() == QMouseEvent::MouseButtonPress) { - if (event->button() != m_clickHelper.lastPressButton - || (event->timestamp() - m_clickHelper.lastPressTimestamp > static_cast<ulong>(qGuiApp->styleHints()->mouseDoubleClickInterval())) - || (event->pos() - m_clickHelper.lastPressPosition).manhattanLength() > qGuiApp->styleHints()->startDragDistance()) - m_clickHelper.clickCounter = 0; - - m_clickHelper.lastPressTimestamp = event->timestamp(); - webEvent.click_count = ++m_clickHelper.clickCounter; - m_clickHelper.lastPressButton = event->button(); - m_clickHelper.lastPressPosition = QPointF(event->pos()).toPoint(); - } - - webEvent.movement_x = event->globalX() - m_previousMousePosition.x(); - webEvent.movement_y = event->globalY() - m_previousMousePosition.y(); - - if (IsMouseLocked()) - QCursor::setPos(m_previousMousePosition); - else - m_previousMousePosition = event->globalPos(); - - if (m_imeInProgress && event->type() == QMouseEvent::MouseButtonPress) { - m_imeInProgress = false; - // Tell input method to commit the pre-edit string entered so far, and finish the - // composition operation. -#ifdef Q_OS_WIN - // Yes the function name is counter-intuitive, but commit isn't actually implemented - // by the Windows QPA, and reset does exactly what is necessary in this case. - qApp->inputMethod()->reset(); -#else - qApp->inputMethod()->commit(); -#endif - } - - m_host->ForwardMouseEvent(webEvent); + handlePointerEvent<QMouseEvent>(event); } void RenderWidgetHostViewQt::handleKeyEvent(QKeyEvent *ev) @@ -1610,6 +1575,59 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) } } +void RenderWidgetHostViewQt::handleTabletEvent(QTabletEvent *event) +{ + handlePointerEvent<QTabletEvent>(event); +} + +template<class T> +void RenderWidgetHostViewQt::handlePointerEvent(T *event) +{ + // Currently WebMouseEvent is a subclass of WebPointerProperties, so basically + // tablet events are mouse events with extra properties. + blink::WebMouseEvent webEvent = WebEventFactory::toWebMouseEvent(event, dpiScale()); + if ((webEvent.GetType() == blink::WebInputEvent::kMouseDown || webEvent.GetType() == blink::WebInputEvent::kMouseUp) + && webEvent.button == blink::WebMouseEvent::Button::kNoButton) { + // Blink can only handle the 3 main mouse-buttons and may assert when processing mouse-down for no button. + return; + } + + if (webEvent.GetType() == blink::WebInputEvent::kMouseDown) { + if (event->button() != m_clickHelper.lastPressButton + || (event->timestamp() - m_clickHelper.lastPressTimestamp > static_cast<ulong>(qGuiApp->styleHints()->mouseDoubleClickInterval())) + || (event->pos() - m_clickHelper.lastPressPosition).manhattanLength() > qGuiApp->styleHints()->startDragDistance()) + m_clickHelper.clickCounter = 0; + + m_clickHelper.lastPressTimestamp = event->timestamp(); + webEvent.click_count = ++m_clickHelper.clickCounter; + m_clickHelper.lastPressButton = event->button(); + m_clickHelper.lastPressPosition = QPointF(event->pos()).toPoint(); + } + + webEvent.movement_x = event->globalX() - m_previousMousePosition.x(); + webEvent.movement_y = event->globalY() - m_previousMousePosition.y(); + + if (IsMouseLocked()) + QCursor::setPos(m_previousMousePosition); + else + m_previousMousePosition = event->globalPos(); + + if (m_imeInProgress && webEvent.GetType() == blink::WebInputEvent::kMouseDown) { + m_imeInProgress = false; + // Tell input method to commit the pre-edit string entered so far, and finish the + // composition operation. +#ifdef Q_OS_WIN + // Yes the function name is counter-intuitive, but commit isn't actually implemented + // by the Windows QPA, and reset does exactly what is necessary in this case. + qApp->inputMethod()->reset(); +#else + qApp->inputMethod()->commit(); +#endif + } + + m_host->ForwardMouseEvent(webEvent); +} + void RenderWidgetHostViewQt::handleHoverEvent(QHoverEvent *ev) { m_host->ForwardMouseEvent(WebEventFactory::toWebMouseEvent(ev, dpiScale())); diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h index 8a7665007..1ac32456a 100644 --- a/src/core/render_widget_host_view_qt.h +++ b/src/core/render_widget_host_view_qt.h @@ -118,6 +118,7 @@ public: RenderWidgetHostViewQt(content::RenderWidgetHost* widget); ~RenderWidgetHostViewQt(); + RenderWidgetHostViewQtDelegate *delegate() { return m_delegate.get(); } void setDelegate(RenderWidgetHostViewQtDelegate *delegate); void setAdapterClient(WebContentsAdapterClient *adapterClient); @@ -186,6 +187,7 @@ public: void handleKeyEvent(QKeyEvent*); void handleWheelEvent(QWheelEvent*); void handleTouchEvent(QTouchEvent*); + void handleTabletEvent(QTabletEvent *ev); #ifndef QT_NO_GESTURES void handleGestureEvent(QNativeGestureEvent *); #endif @@ -194,6 +196,8 @@ public: void handleInputMethodEvent(QInputMethodEvent*); void handleInputMethodQueryEvent(QInputMethodQueryEvent*); + template<class T> void handlePointerEvent(T*); + #if defined(OS_MACOSX) void SetActive(bool active) override { QT_NOT_YET_IMPLEMENTED } bool IsSpeaking() const override { QT_NOT_YET_IMPLEMENTED; return false; } diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp index 94a7baa1d..534ee302d 100644 --- a/src/core/renderer/web_channel_ipc_transport.cpp +++ b/src/core/renderer/web_channel_ipc_transport.cpp @@ -66,7 +66,7 @@ public: private: content::RenderView *GetRenderView(v8::Isolate *isolate); WebChannelTransport() { } - virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder(v8::Isolate *isolate) override; + gin::ObjectTemplateBuilder GetObjectTemplateBuilder(v8::Isolate *isolate) override; bool NativeQtSendMessage(gin::Arguments *args) { diff --git a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp index bf61f1851..53d3e88ba 100644 --- a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp +++ b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp @@ -138,7 +138,7 @@ void ResourceDispatcherHostLoginDelegateQt::destroy() static void LaunchURL(const GURL& url, int render_process_id, const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, - ui::PageTransition page_transition, bool is_main_frame) + ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture) { Q_UNUSED(render_process_id); Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); @@ -146,16 +146,13 @@ static void LaunchURL(const GURL& url, int render_process_id, if (!webContents) return; WebContentsDelegateQt *contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate()); - contentsDelegate->launchExternalURL(toQt(url), page_transition, is_main_frame); + contentsDelegate->launchExternalURL(toQt(url), page_transition, is_main_frame, has_user_gesture); } bool ResourceDispatcherHostDelegateQt::HandleExternalProtocol(const GURL& url, content::ResourceRequestInfo* info) { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - // We don't want to launch external applications unless it is based on a user action - if (!info->HasUserGesture()) - return false; content::BrowserThread::PostTask( content::BrowserThread::UI, @@ -164,7 +161,8 @@ bool ResourceDispatcherHostDelegateQt::HandleExternalProtocol(const GURL& url, c info->GetChildID(), info->GetWebContentsGetterForRequest(), info->GetPageTransition(), - info->IsMainFrame()) + info->IsMainFrame(), + info->HasUserGesture()) ); return true; } diff --git a/src/core/resources/devtools_discovery_page.html b/src/core/resources/devtools_discovery_page.html deleted file mode 100644 index d37dbfcf4..000000000 --- a/src/core/resources/devtools_discovery_page.html +++ /dev/null @@ -1,140 +0,0 @@ -<html> -<head> -<title>QtWebEngine Remote Debugging</title> -<style> -body { - color: #222; - font-family: Helvetica, Arial, sans-serif; - margin: 0; - text-shadow: rgba(255, 255, 255, 0.496094) 0px 1px 0px; -} - -#caption { - font-size: 16px; - margin-top: 15px; - margin-bottom: 10px; - margin-left: 20px; - height: 20px; - text-align: left; -} - -#items { - display: flex; - flex-direction: column; - margin: 10px; -} - -.item { - color: #222; - display: flex; - flex-direction: row; - text-decoration: none; - padding: 10px; - -webkit-transition-property: background-color, border-color; - -webkit-transition: background-color 0.15s, 0.15s; - -webkit-transition-delay: 0ms, 0ms; -} - -.item:not(.connected):hover { - background-color: rgba(242, 242, 242, 1); - border-color: rgba(110, 116, 128, 1); - color: black; -} - -.item.connected:hover { - border-color: rgba(184, 184, 184, 1); - color: rgb(110, 116, 128); -} - -.description { - display: flex; - flex-direction: column; -} - -.title, .subtitle { - font-size: 13px; - margin: 4px 0px 0px 6px; - overflow: hidden; - padding-left: 20px; -} - -.title { - background-repeat: no-repeat; - background-size: 16px; - font-size: 15px; -} - - -</style> - -<script> - -function onLoad() { - var tabsListRequest = new XMLHttpRequest(); - tabsListRequest.open('GET', '/json/list', true); - tabsListRequest.onreadystatechange = onReady; - tabsListRequest.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 overrideFrontendUrl(item) { - if (window.location.hash) { - var overridden_url = window.location.hash.substr(1); - var ws_suffix = item.webSocketDebuggerUrl.replace('ws://', 'ws='); - if (overridden_url.indexOf('?') == -1) - return overridden_url + '?' + ws_suffix; - else - return overridden_url + '&' + ws_suffix; - } - return item.devtoolsFrontendUrl; -} - -function appendItem(item_object) { - var item_element; - if (item_object.devtoolsFrontendUrl) { - item_element = document.createElement('a'); - item_element.href = overrideFrontendUrl(item_object); - item_element.title = item_object.title; - } else { - item_element = document.createElement('div'); - item_element.className = 'connected'; - item_element.title = 'The tab already has an active debug session'; - } - item_element.classList.add('item'); - - var description = document.createElement('div'); - description.className = 'description'; - - var title = document.createElement('div'); - title.className = 'title'; - title.textContent = item_object.description || item_object.title; - title.style.cssText = 'background-image:url(' + - item_object.faviconUrl + ')'; - description.appendChild(title); - - var subtitle = document.createElement('div'); - subtitle.className = 'subtitle'; - subtitle.textContent = (item_object.url || '').substring(0, 300); - description.appendChild(subtitle); - - item_element.appendChild(description); - - document.getElementById('items').appendChild(item_element); -} -</script> -</head> -<body onload='onLoad()'> - <div id='caption'>Inspectable pages</div> - <hr> - <div id='items'> - </div> -</body> -</html> diff --git a/src/core/ssl_host_state_delegate_qt.h b/src/core/ssl_host_state_delegate_qt.h index f04e0b492..859e98fe7 100644 --- a/src/core/ssl_host_state_delegate_qt.h +++ b/src/core/ssl_host_state_delegate_qt.h @@ -64,14 +64,14 @@ public: ~SSLHostStateDelegateQt(); // content::SSLHostStateDelegate implementation: - virtual void AllowCert(const std::string &, const net::X509Certificate &cert, net::CertStatus error) override; - virtual void Clear(const base::Callback<bool(const std::string&)>& host_filter) override; + void AllowCert(const std::string &, const net::X509Certificate &cert, net::CertStatus error) override; + void Clear(const base::Callback<bool(const std::string&)>& host_filter) override; virtual CertJudgment QueryPolicy(const std::string &host, const net::X509Certificate &cert, net::CertStatus error,bool *expired_previous_decision) override; - virtual void HostRanInsecureContent(const std::string& host, int child_id, InsecureContentType content_type) override; - virtual bool DidHostRunInsecureContent(const std::string& host, int child_id, InsecureContentType content_type) const override; - virtual void RevokeUserAllowExceptions(const std::string &host) override; - virtual bool HasAllowException(const std::string &host) const override; + void HostRanInsecureContent(const std::string& host, int child_id, InsecureContentType content_type) override; + bool DidHostRunInsecureContent(const std::string& host, int child_id, InsecureContentType content_type) const override; + void RevokeUserAllowExceptions(const std::string &host) override; + bool HasAllowException(const std::string &host) const override; private: std::map<std::string, CertPolicy> m_certPolicyforHost; diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp index 86f0c2b60..b77cd50f9 100644 --- a/src/core/url_request_context_getter_qt.cpp +++ b/src/core/url_request_context_getter_qt.cpp @@ -572,20 +572,9 @@ void URLRequestContextGetterQt::generateJobFactory() m_updateJobFactory = false; std::unique_ptr<net::URLRequestJobFactoryImpl> jobFactory(new net::URLRequestJobFactoryImpl()); - - { - // Chromium has transferred a few protocol handlers to us, only pick blob:, chrome: and filesystem:. - content::ProtocolHandlerMap::iterator it = m_protocolHandlers.find(url::kBlobScheme); - Q_ASSERT(it != m_protocolHandlers.end()); - jobFactory->SetProtocolHandler(it->first, std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(it->second.release())); - it = m_protocolHandlers.find(content::kChromeUIScheme); - Q_ASSERT(it != m_protocolHandlers.end()); - jobFactory->SetProtocolHandler(it->first, std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(it->second.release())); - it = m_protocolHandlers.find(url::kFileSystemScheme); - Q_ASSERT(it != m_protocolHandlers.end()); - jobFactory->SetProtocolHandler(it->first, std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(it->second.release())); - m_protocolHandlers.clear(); - } + for (auto &it : m_protocolHandlers) + jobFactory->SetProtocolHandler(it.first, base::WrapUnique(it.second.release())); + m_protocolHandlers.clear(); jobFactory->SetProtocolHandler(url::kDataScheme, std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(new net::DataProtocolHandler())); jobFactory->SetProtocolHandler(url::kFileScheme, std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>(new net::FileProtocolHandler( diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h index bc45a90fb..6416ab6af 100644 --- a/src/core/web_contents_adapter_client.h +++ b/src/core/web_contents_adapter_client.h @@ -64,6 +64,7 @@ class BrowserContextAdapter; class ColorChooserController; class FilePickerController; class JavaScriptDialogController; +class QuotaPermissionController; class RenderWidgetHostViewQt; class RenderWidgetHostViewQtDelegate; class RenderWidgetHostViewQtDelegateClient; @@ -411,13 +412,14 @@ public: virtual void runGeolocationPermissionRequest(const QUrl &securityOrigin) = 0; virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) = 0; virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) = 0; + virtual void runQuotaPermissionRequest(QSharedPointer<QuotaPermissionController>) = 0; virtual WebEngineSettings *webEngineSettings() const = 0; virtual void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) = 0; virtual void hideValidationMessage() = 0; virtual void moveValidationMessage(const QRect &anchor) = 0; RenderProcessTerminationStatus renderProcessExitStatus(int); virtual void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) = 0; - virtual void requestGeometryChange(const QRect &geometry) = 0; + virtual void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) = 0; virtual void allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController) = 0; virtual void updateScrollPosition(const QPointF &position) = 0; virtual void updateContentsSize(const QSizeF &size) = 0; diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 96c7c4c41..9be02806f 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -76,6 +76,7 @@ #include <QDesktopServices> #include <QTimer> +#include <QWindow> namespace QtWebEngineCore { @@ -424,8 +425,13 @@ void WebContentsDelegateQt::RequestMediaAccessPermission(content::WebContents *w void WebContentsDelegateQt::MoveContents(content::WebContents *source, const gfx::Rect &pos) { - Q_UNUSED(source) - m_viewClient->requestGeometryChange(toQt(pos)); + QRect frameGeometry(toQt(pos)); + QRect geometry; + if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt*>(web_contents()->GetRenderWidgetHostView())) { + if (rwhv->delegate() && rwhv->delegate()->window()) + geometry = frameGeometry.marginsRemoved(rwhv->delegate()->window()->frameMargins()); + } + m_viewClient->requestGeometryChange(geometry, frameGeometry); } bool WebContentsDelegateQt::IsPopupOrPanel(const content::WebContents *source) const @@ -503,14 +509,45 @@ void WebContentsDelegateQt::requestGeolocationPermission(const QUrl &requestingO extern WebContentsAdapterClient::NavigationType pageTransitionToNavigationType(ui::PageTransition transition); -void WebContentsDelegateQt::launchExternalURL(const QUrl &url, ui::PageTransition page_transition, bool is_main_frame) +void WebContentsDelegateQt::launchExternalURL(const QUrl &url, ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture) { - int navigationRequestAction = WebContentsAdapterClient::AcceptRequest; - m_viewClient->navigationRequested(pageTransitionToNavigationType(page_transition), url, navigationRequestAction, is_main_frame); + WebEngineSettings *settings = m_viewClient->webEngineSettings(); + bool navigationAllowedByPolicy = false; + bool navigationRequestAccepted = true; + + switch (settings->unknownUrlSchemePolicy()) { + case WebEngineSettings::DisallowUnknownUrlSchemes: + break; + case WebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction: + navigationAllowedByPolicy = has_user_gesture; + break; + case WebEngineSettings::AllowAllUnknownUrlSchemes: + navigationAllowedByPolicy = true; + break; + default: + Q_UNREACHABLE(); + } + + if (navigationAllowedByPolicy) { + int navigationRequestAction = WebContentsAdapterClient::AcceptRequest; + m_viewClient->navigationRequested(pageTransitionToNavigationType(page_transition), url, navigationRequestAction, is_main_frame); + navigationRequestAccepted = navigationRequestAction == WebContentsAdapterClient::AcceptRequest; #ifndef QT_NO_DESKTOPSERVICES - if (navigationRequestAction == WebContentsAdapterClient::AcceptRequest) - QDesktopServices::openUrl(url); + if (navigationRequestAccepted) + QDesktopServices::openUrl(url); #endif + } + + if (!navigationAllowedByPolicy || !navigationRequestAccepted) { + if (!navigationAllowedByPolicy) + didFailLoad(url, 420, QStringLiteral("Launching external protocol forbidden by WebEngineSettings::UnknownUrlSchemePolicy")); + else + didFailLoad(url, 420, QStringLiteral("Launching external protocol suppressed by WebContentsAdapterClient::navigationRequested")); + if (settings->testAttribute(WebEngineSettings::ErrorPageEnabled)) { + EmitLoadStarted(toQt(GURL(content::kUnreachableWebDataURL)), true); + m_viewClient->webContentsAdapter()->load(toQt(GURL(content::kUnreachableWebDataURL))); + } + } } void WebContentsDelegateQt::ShowValidationMessage(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view, const base::string16 &main_text, const base::string16 &sub_text) diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index 8440ec053..87704d3c6 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -145,7 +145,7 @@ public: void overrideWebPreferences(content::WebContents *, content::WebPreferences*); void allowCertificateError(const QSharedPointer<CertificateErrorController> &) ; void requestGeolocationPermission(const QUrl &requestingOrigin); - void launchExternalURL(const QUrl &url, ui::PageTransition page_transition, bool is_main_frame); + void launchExternalURL(const QUrl &url, ui::PageTransition page_transition, bool is_main_frame, bool has_user_gesture); FaviconManager *faviconManager(); void setSavePageInfo(const SavePageInfo &spi) { m_savePageInfo = spi; } diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index f3818b194..d1f041c56 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -82,12 +82,14 @@ #include "content_browser_client_qt.h" #include "content_client_qt.h" #include "content_main_delegate_qt.h" -#include "dev_tools_http_handler_delegate_qt.h" +#include "devtools_manager_delegate_qt.h" #include "gl_context_qt.h" #include "media_capture_devices_dispatcher.h" #include "type_conversion.h" #include "surface_factory_qt.h" #include "web_engine_library_info.h" +#include "webui/webui_controller_factory_qt.h" + #include <QFileInfo> #include <QGuiApplication> #include <QOffscreenSurface> @@ -512,6 +514,8 @@ WebEngineContext::WebEngineContext() #if BUILDFLAG(ENABLE_BASIC_PRINTING) m_printJobManager.reset(new printing::PrintJobManager()); #endif // defined(ENABLE_BASIC_PRINTING) + + content::WebUIControllerFactory::RegisterFactory(WebUIControllerFactoryQt::GetInstance()); } #if BUILDFLAG(ENABLE_BASIC_PRINTING) diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index 498c4e799..a585e7bb3 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -48,6 +48,7 @@ #include "content/browser/gpu/gpu_process_host.h" #include "content/public/common/content_switches.h" #include "content/public/common/web_preferences.h" +#include "media/base/media_switches.h" #include "ui/events/event_switches.h" #include <QFont> @@ -110,6 +111,7 @@ WebEngineSettings::WebEngineSettings(WebEngineSettings *_parentSettings) : m_adapter(0) , m_batchTimer(new BatchTimer(this)) , parentSettings(_parentSettings) + , m_unknownUrlSchemePolicy(WebEngineSettings::InheritedUnknownUrlSchemePolicy) { if (parentSettings) parentSettings->childSettings.insert(this); @@ -151,6 +153,17 @@ bool WebEngineSettings::testAttribute(WebEngineSettings::Attribute attr) const return m_attributes.value(attr, parentSettings->testAttribute(attr)); } +bool WebEngineSettings::isAttributeExplicitlySet(Attribute attr) const +{ + if (m_attributes.contains(attr)) + return true; + + if (parentSettings) + return parentSettings->isAttributeExplicitlySet(attr); + + return false; +} + void WebEngineSettings::resetAttribute(WebEngineSettings::Attribute attr) { m_attributes.remove(attr); @@ -212,6 +225,22 @@ QString WebEngineSettings::defaultTextEncoding() const return m_defaultEncoding.isEmpty()? parentSettings->defaultTextEncoding() : m_defaultEncoding; } +void WebEngineSettings::setUnknownUrlSchemePolicy(WebEngineSettings::UnknownUrlSchemePolicy policy) +{ + m_unknownUrlSchemePolicy = policy; +} + +WebEngineSettings::UnknownUrlSchemePolicy WebEngineSettings::unknownUrlSchemePolicy() const +{ + // value InheritedUnknownUrlSchemePolicy means it is taken from parent, if possible. If there + // is no parent, then AllowUnknownUrlSchemesFromUserInteraction (the default behavior) is used. + if (m_unknownUrlSchemePolicy != InheritedUnknownUrlSchemePolicy) + return m_unknownUrlSchemePolicy; + if (parentSettings) + return parentSettings->unknownUrlSchemePolicy(); + return AllowUnknownUrlSchemesFromUserInteraction; +} + void WebEngineSettings::initDefaults() { if (s_defaultAttributes.isEmpty()) { @@ -253,6 +282,10 @@ void WebEngineSettings::initDefaults() s_defaultAttributes.insert(AllowRunningInsecureContent, allowRunningInsecureContent); s_defaultAttributes.insert(AllowGeolocationOnInsecureOrigins, false); s_defaultAttributes.insert(AllowWindowActivationFromJavaScript, false); + bool playbackRequiresUserGesture = false; + if (commandLine->HasSwitch(switches::kAutoplayPolicy)) + playbackRequiresUserGesture = (commandLine->GetSwitchValueASCII(switches::kAutoplayPolicy) != switches::autoplay::kNoUserGestureRequiredPolicy); + s_defaultAttributes.insert(PlaybackRequiresUserGesture, playbackRequiresUserGesture); } if (s_defaultFontFamilies.isEmpty()) { @@ -284,6 +317,7 @@ void WebEngineSettings::initDefaults() } m_defaultEncoding = QStringLiteral("ISO-8859-1"); + m_unknownUrlSchemePolicy = InheritedUnknownUrlSchemePolicy; } void WebEngineSettings::scheduleApply() @@ -335,6 +369,11 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p prefs->allow_running_insecure_content = testAttribute(AllowRunningInsecureContent); prefs->allow_geolocation_on_insecure_origins = testAttribute(AllowGeolocationOnInsecureOrigins); prefs->hide_scrollbars = !testAttribute(ShowScrollBars); + if (isAttributeExplicitlySet(PlaybackRequiresUserGesture)) { + prefs->autoplay_policy = testAttribute(PlaybackRequiresUserGesture) + ? content::AutoplayPolicy::kUserGestureRequired + : content::AutoplayPolicy::kNoUserGestureRequired; + } // Fonts settings. prefs->standard_font_family_map[content::kCommonScript] = toString16(fontFamily(StandardFont)); diff --git a/src/core/web_engine_settings.h b/src/core/web_engine_settings.h index 18963344a..5881303a2 100644 --- a/src/core/web_engine_settings.h +++ b/src/core/web_engine_settings.h @@ -85,7 +85,8 @@ public: AllowRunningInsecureContent, AllowGeolocationOnInsecureOrigins, AllowWindowActivationFromJavaScript, - ShowScrollBars + ShowScrollBars, + PlaybackRequiresUserGesture, }; // Must match the values from the public API in qwebenginesettings.h. @@ -107,6 +108,14 @@ public: DefaultFixedFontSize }; + // Must match the values from the public API in qwebenginesettings.h. + enum UnknownUrlSchemePolicy { + InheritedUnknownUrlSchemePolicy = 0, + DisallowUnknownUrlSchemes = 1, + AllowUnknownUrlSchemesFromUserInteraction, + AllowAllUnknownUrlSchemes + }; + explicit WebEngineSettings(WebEngineSettings *parentSettings = 0); ~WebEngineSettings(); @@ -117,6 +126,7 @@ public: void setAttribute(Attribute, bool on); bool testAttribute(Attribute) const; void resetAttribute(Attribute); + bool isAttributeExplicitlySet(Attribute) const; void setFontFamily(FontFamily, const QString &); QString fontFamily(FontFamily); @@ -129,6 +139,9 @@ public: void setDefaultTextEncoding(const QString &encoding); QString defaultTextEncoding() const; + void setUnknownUrlSchemePolicy(UnknownUrlSchemePolicy policy); + UnknownUrlSchemePolicy unknownUrlSchemePolicy() const; + void initDefaults(); void scheduleApply(); @@ -155,6 +168,7 @@ private: static QHash<Attribute, bool> s_defaultAttributes; static QHash<FontFamily, QString> s_defaultFontFamilies; static QHash<FontSize, int> s_defaultFontSizes; + UnknownUrlSchemePolicy m_unknownUrlSchemePolicy; friend class BatchTimer; friend class WebContentsAdapter; diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp index 3193f885a..4241a11c2 100644 --- a/src/core/web_event_factory.cpp +++ b/src/core/web_event_factory.cpp @@ -76,6 +76,7 @@ #include <QKeyEvent> #include <QMouseEvent> #include <QStyleHints> +#include <QTabletEvent> #include <QWheelEvent> using namespace blink; @@ -1034,7 +1035,8 @@ static inline double currentTimeForEvent(const QEvent *event) return static_cast<double>(timer.elapsed()) / 1000; } -static WebMouseEvent::Button mouseButtonForEvent(QMouseEvent *event) +template<class T> +static WebMouseEvent::Button mouseButtonForEvent(T *event) { if (event->button() == Qt::LeftButton) return WebMouseEvent::Button::kLeft; @@ -1043,7 +1045,7 @@ static WebMouseEvent::Button mouseButtonForEvent(QMouseEvent *event) else if (event->button() == Qt::MidButton) return WebMouseEvent::Button::kMiddle; - if (event->type() != QEvent::MouseMove) + if (event->type() != QEvent::MouseMove && event->type() != QEvent::TabletMove) return WebMouseEvent::Button::kNoButton; // This is technically wrong, mouse move should always have ButtonNone, @@ -1149,14 +1151,17 @@ static WebInputEvent::Type webEventTypeForEvent(const QEvent* event) { switch (event->type()) { case QEvent::MouseButtonPress: + case QEvent::TabletPress: return WebInputEvent::kMouseDown; case QEvent::MouseButtonRelease: + case QEvent::TabletRelease: return WebInputEvent::kMouseUp; case QEvent::Enter: return WebInputEvent::kMouseEnter; case QEvent::Leave: return WebInputEvent::kMouseLeave; case QEvent::MouseMove: + case QEvent::TabletMove: return WebInputEvent::kMouseMove; case QEvent::Wheel: return WebInputEvent::kMouseWheel; @@ -1180,6 +1185,20 @@ static WebInputEvent::Type webEventTypeForEvent(const QEvent* event) } } +static WebPointerProperties::PointerType pointerTypeForTabletEvent(const QTabletEvent *ev) +{ + switch (ev->pointerType()) { + case QTabletEvent::UnknownPointer: + return WebPointerProperties::PointerType::kUnknown; + case QTabletEvent::Pen: + return WebPointerProperties::PointerType::kPen; + case QTabletEvent::Eraser: + return WebPointerProperties::PointerType::kEraser; + default: + return WebPointerProperties::PointerType::kMouse; + } +} + WebMouseEvent WebEventFactory::toWebMouseEvent(QMouseEvent *ev, double dpiScale) { WebMouseEvent webKitEvent(webEventTypeForEvent(ev), @@ -1190,7 +1209,7 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QMouseEvent *ev, double dpiScale) modifiersForEvent(ev), currentTimeForEvent(ev)); - webKitEvent.button = mouseButtonForEvent(ev); + webKitEvent.button = mouseButtonForEvent<QMouseEvent>(ev); webKitEvent.click_count = 0; webKitEvent.pointer_type = WebPointerProperties::PointerType::kMouse; @@ -1212,6 +1231,28 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QHoverEvent *ev, double dpiScale) return webKitEvent; } +WebMouseEvent WebEventFactory::toWebMouseEvent(QTabletEvent *ev, double dpiScale) +{ + WebMouseEvent webKitEvent(webEventTypeForEvent(ev), + ev->x() / dpiScale, + ev->y() / dpiScale, + ev->globalX(), + ev->globalY(), + modifiersForEvent(ev), + currentTimeForEvent(ev)); + + webKitEvent.force = ev->pressure(); + webKitEvent.tilt_x = ev->xTilt(); + webKitEvent.tilt_y = ev->yTilt(); + webKitEvent.tangential_pressure = ev->tangentialPressure(); + webKitEvent.twist = ev->rotation(); + webKitEvent.pointer_type = pointerTypeForTabletEvent(ev); + + webKitEvent.button = mouseButtonForEvent<QTabletEvent>(ev); + webKitEvent.click_count = 0; + return webKitEvent; +} + WebMouseEvent WebEventFactory::toWebMouseEvent(QEvent *ev) { Q_ASSERT(ev->type() == QEvent::Leave || ev->type() == QEvent::HoverLeave); diff --git a/src/core/web_event_factory.h b/src/core/web_event_factory.h index 5b8f08968..442f04054 100644 --- a/src/core/web_event_factory.h +++ b/src/core/web_event_factory.h @@ -54,6 +54,7 @@ class QEvent; class QHoverEvent; class QKeyEvent; class QMouseEvent; +class QTabletEvent; class QWheelEvent; #ifndef QT_NO_GESTURES class QNativeGestureEvent; @@ -65,6 +66,7 @@ class WebEventFactory { public: static blink::WebMouseEvent toWebMouseEvent(QMouseEvent*, double dpiScale); static blink::WebMouseEvent toWebMouseEvent(QHoverEvent*, double dpiScale); + static blink::WebMouseEvent toWebMouseEvent(QTabletEvent*, double dpiScale); static blink::WebMouseEvent toWebMouseEvent(QEvent *); #ifndef QT_NO_GESTURES static blink::WebGestureEvent toWebGestureEvent(QNativeGestureEvent *, double dpiScale); diff --git a/src/core/webui/webui_controller_factory_qt.cpp b/src/core/webui/webui_controller_factory_qt.cpp new file mode 100644 index 000000000..3b13f03b8 --- /dev/null +++ b/src/core/webui/webui_controller_factory_qt.cpp @@ -0,0 +1,219 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 included in the +** 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-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Based on chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc: +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webui_controller_factory_qt.h" + +#include "base/bind.h" +#include "base/location.h" +#include "base/threading/thread_task_runner_handle.h" +#include "build/build_config.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/webui/devtools_ui.h" +#include "chrome/browser/ui/webui/quota_internals/quota_internals_ui.h" +#include "chrome/browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui.h" +#include "chrome/common/url_constants.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_ui.h" +#include "content/public/common/content_client.h" +#include "content/public/common/url_utils.h" +#include "extensions/features/features.h" +#include "media/media_features.h" +#include "ppapi/features/features.h" +#include "printing/features/features.h" +#include "ui/web_dialogs/web_dialog_ui.h" +#include "url/gurl.h" + +#if defined(OS_LINUX) || defined(OS_ANDROID) +#include "chrome/browser/ui/webui/sandbox_internals_ui.h" +#endif + +// The Following WebUIs are disabled because they currently doesn't build +// or doesn't work, but would be interesting for us if they did: + +// #include "chrome/browser/ui/webui/inspect_ui.h" +// #include "chrome/browser/ui/webui/user_actions/user_actions_ui.h" + +// #if BUILDFLAG(ENABLE_WEBRTC) +// #include "chrome/browser/ui/webui/media/webrtc_logs_ui.h" +// #endif + +// #if BUILDFLAG(ENABLE_PRINT_PREVIEW) +// #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" +// #endif + +// #if defined(USE_NSS_CERTS) && defined(USE_AURA) +// #include "chrome/browser/ui/webui/certificate_viewer_ui.h" +// #endif + +// #if BUILDFLAG(ENABLE_EXTENSIONS) +// #include "chrome/browser/extensions/extension_web_ui.h" +// #include "chrome/browser/ui/webui/extensions/extensions_ui.h" +// #include "chrome/common/extensions/extension_constants.h" +// #include "extensions/browser/extension_registry.h" +// #include "extensions/browser/extension_system.h" +// #include "extensions/common/constants.h" +// #include "extensions/common/extension.h" +// #include "extensions/common/feature_switch.h" +// #include "extensions/common/manifest.h" +// #endif + +using content::WebUI; +using content::WebUIController; + +namespace { + +// A function for creating a new WebUI. The caller owns the return value, which +// may be NULL (for example, if the URL refers to an non-existent extension). +typedef WebUIController* (*WebUIFactoryFunction)(WebUI *web_ui, const GURL &url); + +// Template for defining WebUIFactoryFunction. +template<class T> +WebUIController *NewWebUI(WebUI *web_ui, const GURL &/*url*/) +{ + return new T(web_ui); +} + +// Returns a function that can be used to create the right type of WebUI for a +// tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated +// with it. +WebUIFactoryFunction GetWebUIFactoryFunction(WebUI *web_ui, Profile *profile, const GURL &url) +{ + // This will get called a lot to check all URLs, so do a quick check of other + // schemes to filter out most URLs. + if (!content::HasWebUIScheme(url)) + return NULL; + + // We must compare hosts only since some of the Web UIs append extra stuff + // after the host name. + if (url.host() == chrome::kChromeUIQuotaInternalsHost) + return &NewWebUI<QuotaInternalsUI>; + if (url.host_piece() == chrome::kChromeUITaskSchedulerInternalsHost) + return &NewWebUI<TaskSchedulerInternalsUI>; + + if (url.SchemeIs(content::kChromeDevToolsScheme)) { +// if (!DevToolsUIBindings::IsValidFrontendURL(url)) +// return nullptr; + return &NewWebUI<DevToolsUI>; + } + +// if (url.host_piece() == chrome::kChromeUIUserActionsHost) +// return &NewWebUI<UserActionsUI>; +// if (url.host_piece() == chrome::kChromeUIInspectHost) +// return &NewWebUI<InspectUI>; +// +//#if defined(USE_NSS_CERTS) && defined(USE_AURA) +// if (url.host_piece() == chrome::kChromeUICertificateViewerHost) +// return &NewWebUI<CertificateViewerUI>; +//#endif // USE_NSS_CERTS && USE_AURA +//#if BUILDFLAG(ENABLE_EXTENSIONS) +// if (url.host_piece() == chrome::kChromeUIExtensionsFrameHost) +// return &NewWebUI<extensions::ExtensionsUI>; +//#endif +//#if BUILDFLAG(ENABLE_PLUGINS) +// if (url.host_piece() == chrome::kChromeUIFlashHost) +// return &NewWebUI<FlashUI>; +//#endif +//#if BUILDFLAG(ENABLE_PRINT_PREVIEW) +// if (url.host_piece() == chrome::kChromeUIPrintHost && +// !profile->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled)) { +// return &NewWebUI<PrintPreviewUI>; +// } +//#endif +//#if BUILDFLAG(ENABLE_WEBRTC) +// if (url.host_piece() == chrome::kChromeUIWebRtcLogsHost) +// return &NewWebUI<WebRtcLogsUI>; +//#endif +#if defined(OS_LINUX) || defined(OS_ANDROID) + if (url.host_piece() == chrome::kChromeUISandboxHost) + return &NewWebUI<SandboxInternalsUI>; +#endif + return nullptr; +} + +} // namespace + +namespace QtWebEngineCore { + +WebUI::TypeID WebUIControllerFactoryQt::GetWebUIType(content::BrowserContext *browser_context, const GURL &url) const +{ + Profile *profile = Profile::FromBrowserContext(browser_context); + WebUIFactoryFunction function = GetWebUIFactoryFunction(nullptr, profile, url); + return function ? reinterpret_cast<WebUI::TypeID>(function) : WebUI::kNoWebUI; +} + +bool WebUIControllerFactoryQt::UseWebUIForURL(content::BrowserContext *browser_context, const GURL &url) const +{ + return GetWebUIType(browser_context, url) != WebUI::kNoWebUI; +} + +bool WebUIControllerFactoryQt::UseWebUIBindingsForURL(content::BrowserContext *browser_context, const GURL &url) const +{ + return UseWebUIForURL(browser_context, url); +} + +WebUIController *WebUIControllerFactoryQt::CreateWebUIControllerForURL(WebUI *web_ui, const GURL &url) const +{ + Profile *profile = Profile::FromWebUI(web_ui); + WebUIFactoryFunction function = GetWebUIFactoryFunction(web_ui, profile, url); + if (!function) + return nullptr; + + return (*function)(web_ui, url); +} + +// static +WebUIControllerFactoryQt *WebUIControllerFactoryQt::GetInstance() +{ + return base::Singleton<WebUIControllerFactoryQt>::get(); +} + +WebUIControllerFactoryQt::WebUIControllerFactoryQt() +{ +} + +WebUIControllerFactoryQt::~WebUIControllerFactoryQt() +{ +} + +} // namespace QtWebEngineCore diff --git a/src/core/webui/webui_controller_factory_qt.h b/src/core/webui/webui_controller_factory_qt.h new file mode 100644 index 000000000..440dd5a13 --- /dev/null +++ b/src/core/webui/webui_controller_factory_qt.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 included in the +** 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-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WEB_UI_CONTROLLER_FACTORY_QT_H_ +#define WEB_UI_CONTROLLER_FACTORY_QT_H_ + +#include "base/macros.h" +#include "base/memory/singleton.h" +#include "components/favicon_base/favicon_callback.h" +#include "content/public/browser/web_ui.h" +#include "content/public/browser/web_ui_controller_factory.h" +#include "ui/base/layout.h" + +class Profile; + +namespace base { +class RefCountedMemory; +} + +namespace QtWebEngineCore { + +class WebUIControllerFactoryQt : public content::WebUIControllerFactory { +public: + content::WebUI::TypeID GetWebUIType(content::BrowserContext *browserContext, const GURL &url) const override; + bool UseWebUIForURL(content::BrowserContext *browserContext, const GURL &url) const override; + bool UseWebUIBindingsForURL(content::BrowserContext *browserContext, const GURL &url) const override; + content::WebUIController *CreateWebUIControllerForURL(content::WebUI *webUi, const GURL &url) const override; + + static WebUIControllerFactoryQt *GetInstance(); + +protected: + WebUIControllerFactoryQt(); + ~WebUIControllerFactoryQt() override; + +private: + friend struct base::DefaultSingletonTraits<WebUIControllerFactoryQt>; + + DISALLOW_COPY_AND_ASSIGN(WebUIControllerFactoryQt); +}; + +} // namespace QtWebEngineCore + +#endif // WEB_UI_CONTROLLER_FACTORY_QT_H_ diff --git a/src/plugins/qwebengineview/qwebengineview_plugin.h b/src/plugins/qwebengineview/qwebengineview_plugin.h index 35b4a7480..dd7d38a72 100644 --- a/src/plugins/qwebengineview/qwebengineview_plugin.h +++ b/src/plugins/qwebengineview/qwebengineview_plugin.h @@ -86,17 +86,17 @@ class QWebEngineViewPlugin: public QObject, public QDesignerCustomWidgetInterfac public: explicit QWebEngineViewPlugin(QObject *parent = Q_NULLPTR); - QString name() const Q_DECL_OVERRIDE; - QString group() const Q_DECL_OVERRIDE; - QString toolTip() const Q_DECL_OVERRIDE; - QString whatsThis() const Q_DECL_OVERRIDE; - QString includeFile() const Q_DECL_OVERRIDE; - QIcon icon() const Q_DECL_OVERRIDE; - bool isContainer() const Q_DECL_OVERRIDE; - QWidget *createWidget(QWidget *parent) Q_DECL_OVERRIDE; - bool isInitialized() const Q_DECL_OVERRIDE; - void initialize(QDesignerFormEditorInterface *core) Q_DECL_OVERRIDE; - QString domXml() const Q_DECL_OVERRIDE; + QString name() const override; + QString group() const override; + QString toolTip() const override; + QString whatsThis() const override; + QString includeFile() const override; + QIcon icon() const override; + bool isContainer() const override; + QWidget *createWidget(QWidget *parent) override; + bool isInitialized() const override; + void initialize(QDesignerFormEditorInterface *core) override; + QString domXml() const override; private: bool m_initialized; diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h index 1828f8085..5be82a4f5 100644 --- a/src/webengine/api/qquickwebengineprofile_p.h +++ b/src/webengine/api/qquickwebengineprofile_p.h @@ -77,8 +77,8 @@ public: void cancelDownload(quint32 downloadId); void downloadDestroyed(quint32 downloadId); - void downloadRequested(DownloadItemInfo &info) Q_DECL_OVERRIDE; - void downloadUpdated(const DownloadItemInfo &info) Q_DECL_OVERRIDE; + void downloadRequested(DownloadItemInfo &info) override; + void downloadUpdated(const DownloadItemInfo &info) override; // QQmlListPropertyHelpers static void userScripts_append(QQmlListProperty<QQuickWebEngineScript> *p, QQuickWebEngineScript *script); diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp index 3ce53337c..b238833ad 100644 --- a/src/webengine/api/qquickwebenginesettings.cpp +++ b/src/webengine/api/qquickwebenginesettings.cpp @@ -73,6 +73,22 @@ QQuickWebEngineSettings::~QQuickWebEngineSettings() { } /*! + \enum QQuickWebEngineSettings::UnknownUrlSchemePolicy + \since WebEngine 1.7 + + This enum describes how navigation requests to URLs with unknown schemes are handled. + + \value DisallowUnknownUrlSchemes + Disallows all navigation requests to URLs with unknown schemes. + \value AllowUnknownUrlSchemesFromUserInteraction + Allows navigation requests to URLs with unknown schemes that are issued from + user-interaction (like a mouse-click), whereas other navigation requests (for example + from JavaScript) are suppressed. + \value AllowAllUnknownUrlSchemes + Allows all navigation requests to URLs with unknown schemes. +*/ + +/*! \qmlproperty bool WebEngineSettings::autoLoadImages Automatically loads images on web pages. @@ -382,6 +398,20 @@ bool QQuickWebEngineSettings::showScrollBars() const } /*! + \qmlproperty bool WebEngineSettings::playbackRequiresUserGesture + \since QtWebEngine 1.7 + Inhibits playback of media content until the user interacts with + the page. Disabled by default. + + \note The behavior is similar to Chrome on Android when enabled, + and similar to Chrome on desktops when disabled (default). +*/ +bool QQuickWebEngineSettings::playbackRequiresUserGesture() const +{ + return d_ptr->testAttribute(WebEngineSettings::PlaybackRequiresUserGesture); +} + +/*! \qmlproperty string WebEngineSettings::defaultTextEncoding \since QtWebEngine 1.2 @@ -395,6 +425,22 @@ QString QQuickWebEngineSettings::defaultTextEncoding() const return d_ptr->defaultTextEncoding(); } +ASSERT_ENUMS_MATCH(QQuickWebEngineSettings::DisallowUnknownUrlSchemes, WebEngineSettings::DisallowUnknownUrlSchemes) +ASSERT_ENUMS_MATCH(QQuickWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction, WebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction) +ASSERT_ENUMS_MATCH(QQuickWebEngineSettings::AllowAllUnknownUrlSchemes, WebEngineSettings::AllowAllUnknownUrlSchemes) + +/*! + \qmlproperty WebEngineSettings::UnknownUrlSchemePolicy WebEngineSettings::unknownUrlSchemePolicy + \since QtWebEngine 1.7 + Specifies how navigation requests to URLs with unknown schemes are handled. + + Default is \l{QWebEngineSettings::UnknownUrlSchemePolicy}{WebEngineSettings.AllowUnknownUrlSchemesFromUserInteraction}. +*/ +QQuickWebEngineSettings::UnknownUrlSchemePolicy QQuickWebEngineSettings::unknownUrlSchemePolicy() const +{ + return static_cast<QQuickWebEngineSettings::UnknownUrlSchemePolicy>(d_ptr->unknownUrlSchemePolicy()); +} + void QQuickWebEngineSettings::setAutoLoadImages(bool on) { bool wasOn = d_ptr->testAttribute(WebEngineSettings::AutoLoadImages); @@ -599,6 +645,23 @@ void QQuickWebEngineSettings::setShowScrollBars(bool on) Q_EMIT showScrollBarsChanged(); } +void QQuickWebEngineSettings::setPlaybackRequiresUserGesture(bool on) +{ + bool wasOn = d_ptr->testAttribute(WebEngineSettings::PlaybackRequiresUserGesture); + d_ptr->setAttribute(WebEngineSettings::PlaybackRequiresUserGesture, on); + if (wasOn != on) + Q_EMIT playbackRequiresUserGestureChanged(); +} + +void QQuickWebEngineSettings::setUnknownUrlSchemePolicy(QQuickWebEngineSettings::UnknownUrlSchemePolicy policy) +{ + WebEngineSettings::UnknownUrlSchemePolicy oldPolicy = d_ptr->unknownUrlSchemePolicy(); + WebEngineSettings::UnknownUrlSchemePolicy newPolicy = static_cast<WebEngineSettings::UnknownUrlSchemePolicy>(policy); + d_ptr->setUnknownUrlSchemePolicy(newPolicy); + if (oldPolicy != newPolicy) + Q_EMIT unknownUrlSchemePolicyChanged(); +} + void QQuickWebEngineSettings::setParentSettings(QQuickWebEngineSettings *parentSettings) { d_ptr->setParentSettings(parentSettings->d_ptr.data()); diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h index a8b11c769..63c397d21 100644 --- a/src/webengine/api/qquickwebenginesettings_p.h +++ b/src/webengine/api/qquickwebenginesettings_p.h @@ -88,8 +88,18 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject { Q_PROPERTY(bool allowGeolocationOnInsecureOrigins READ allowGeolocationOnInsecureOrigins WRITE setAllowGeolocationOnInsecureOrigins NOTIFY allowGeolocationOnInsecureOriginsChanged REVISION 4 FINAL) Q_PROPERTY(bool allowWindowActivationFromJavaScript READ allowWindowActivationFromJavaScript WRITE setAllowWindowActivationFromJavaScript NOTIFY allowWindowActivationFromJavaScriptChanged REVISION 5 FINAL) Q_PROPERTY(bool showScrollBars READ showScrollBars WRITE setShowScrollBars NOTIFY showScrollBarsChanged REVISION 5 FINAL) + Q_PROPERTY(UnknownUrlSchemePolicy unknownUrlSchemePolicy READ unknownUrlSchemePolicy WRITE setUnknownUrlSchemePolicy NOTIFY unknownUrlSchemePolicyChanged REVISION 6 FINAL) + Q_PROPERTY(bool playbackRequiresUserGesture READ playbackRequiresUserGesture WRITE setPlaybackRequiresUserGesture NOTIFY playbackRequiresUserGestureChanged REVISION 6 FINAL) public: + enum UnknownUrlSchemePolicy { + DisallowUnknownUrlSchemes = 1, + AllowUnknownUrlSchemesFromUserInteraction, + AllowAllUnknownUrlSchemes + }; + + Q_ENUM(UnknownUrlSchemePolicy) + ~QQuickWebEngineSettings(); bool autoLoadImages() const; @@ -117,6 +127,8 @@ public: bool allowGeolocationOnInsecureOrigins() const; bool allowWindowActivationFromJavaScript() const; bool showScrollBars() const; + UnknownUrlSchemePolicy unknownUrlSchemePolicy() const; + bool playbackRequiresUserGesture() const; void setAutoLoadImages(bool on); void setJavascriptEnabled(bool on); @@ -143,6 +155,8 @@ public: void setAllowGeolocationOnInsecureOrigins(bool on); void setAllowWindowActivationFromJavaScript(bool on); void setShowScrollBars(bool on); + void setUnknownUrlSchemePolicy(UnknownUrlSchemePolicy policy); + void setPlaybackRequiresUserGesture(bool on); signals: void autoLoadImagesChanged(); @@ -170,6 +184,8 @@ signals: Q_REVISION(4) void allowGeolocationOnInsecureOriginsChanged(); Q_REVISION(5) void allowWindowActivationFromJavaScriptChanged(); Q_REVISION(5) void showScrollBarsChanged(); + Q_REVISION(6) void unknownUrlSchemePolicyChanged(); + Q_REVISION(6) void playbackRequiresUserGestureChanged(); private: explicit QQuickWebEngineSettings(QQuickWebEngineSettings *parentSettings = 0); diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index addb7d6df..0636d8471 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -45,6 +45,7 @@ #include "certificate_error_controller.h" #include "file_picker_controller.h" #include "javascript_dialog_controller.h" +#include "quota_permission_controller.h" #include "qquickwebenginehistory_p.h" #include "qquickwebenginecertificateerror_p.h" #include "qquickwebenginecontextmenurequest_p.h" @@ -690,6 +691,13 @@ void QQuickWebEngineViewPrivate::runMouseLockPermissionRequest(const QUrl &secur adapter->grantMouseLockPermission(false); } +void QQuickWebEngineViewPrivate::runQuotaPermissionRequest(QSharedPointer<QtWebEngineCore::QuotaPermissionController> controller) +{ + Q_Q(QQuickWebEngineView); + QQuickWebEngineQuotaPermissionRequest request(controller); + Q_EMIT q->quotaPermissionRequested(request); +} + QObject *QQuickWebEngineViewPrivate::accessibilityParentObject() { Q_Q(QQuickWebEngineView); @@ -1150,6 +1158,12 @@ void QQuickWebEngineViewPrivate::renderProcessTerminated( renderProcessExitStatus(terminationStatus)), exitCode); } +void QQuickWebEngineViewPrivate::requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) +{ + Q_Q(QQuickWebEngineView); + Q_EMIT q->geometryChangeRequested(geometry, frameGeometry); +} + void QQuickWebEngineViewPrivate::startDragging(const content::DropData &dropData, Qt::DropActions allowedActions, const QPixmap &pixmap, const QPoint &offset) @@ -1829,5 +1843,34 @@ void QQuickWebEngineFullScreenRequest::reject() m_viewPrivate->setFullScreenMode(!m_toggleOn); } +QQuickWebEngineQuotaPermissionRequest::QQuickWebEngineQuotaPermissionRequest(QSharedPointer<QtWebEngineCore::QuotaPermissionController> controller) + : d_ptr(controller) +{ +} + +QQuickWebEngineQuotaPermissionRequest::~QQuickWebEngineQuotaPermissionRequest() +{ +} + +void QQuickWebEngineQuotaPermissionRequest::accept() +{ + d_ptr->accept(); +} + +void QQuickWebEngineQuotaPermissionRequest::reject() +{ + d_ptr->cancel(); +} + +QUrl QQuickWebEngineQuotaPermissionRequest::origin() const +{ + return d_ptr->origin(); +} + +qint64 QQuickWebEngineQuotaPermissionRequest::requestedSize() const +{ + return d_ptr->requestedSize(); +} + QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h index ae0523460..ee7e01f26 100644 --- a/src/webengine/api/qquickwebengineview_p.h +++ b/src/webengine/api/qquickwebengineview_p.h @@ -56,6 +56,12 @@ #include <QQuickItem> #include <QtGui/qcolor.h> + +namespace QtWebEngineCore { + class QuotaPermissionController; +} + + QT_BEGIN_NAMESPACE class QQmlWebChannel; @@ -98,6 +104,26 @@ private: const bool m_toggleOn; }; +class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineQuotaPermissionRequest { + Q_GADGET + Q_PROPERTY(QUrl origin READ origin CONSTANT FINAL) + Q_PROPERTY(qint64 requestedSize READ requestedSize CONSTANT FINAL) +public: + QQuickWebEngineQuotaPermissionRequest() {} + QQuickWebEngineQuotaPermissionRequest(QSharedPointer<QtWebEngineCore::QuotaPermissionController> controller); + ~QQuickWebEngineQuotaPermissionRequest(); + + Q_INVOKABLE void accept(); + Q_INVOKABLE void reject(); + QUrl origin() const; + qint64 requestedSize() const; + +private: + QSharedPointer<QtWebEngineCore::QuotaPermissionController> d_ptr; +}; + +#define LATEST_WEBENGINEVIEW_REVISION 7 + class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem { Q_OBJECT Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged FINAL) @@ -450,7 +476,7 @@ public: Q_ENUM(PrintedPageOrientation) // QmlParserStatus - virtual void componentComplete() Q_DECL_OVERRIDE; + void componentComplete() override; QQuickWebEngineProfile *profile() const; void setProfile(QQuickWebEngineProfile *); @@ -529,18 +555,20 @@ Q_SIGNALS: Q_REVISION(4) void fileDialogRequested(QQuickWebEngineFileDialogRequest *request); Q_REVISION(4) void formValidationMessageRequested(QQuickWebEngineFormValidationMessageRequest *request); Q_REVISION(5) void pdfPrintingFinished(const QString &filePath, bool success); + Q_REVISION(7) void quotaPermissionRequested(const QQuickWebEngineQuotaPermissionRequest &request); + Q_REVISION(7) void geometryChangeRequested(const QRect &geometry, const QRect &frameGeometry); #ifdef ENABLE_QML_TESTSUPPORT_API void testSupportChanged(); #endif protected: - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - void itemChange(ItemChange, const ItemChangeData &) Q_DECL_OVERRIDE; - void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE; - void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE; - void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE; - void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; + void itemChange(ItemChange, const ItemChangeData &) override; + void dragEnterEvent(QDragEnterEvent *e) override; + void dragLeaveEvent(QDragLeaveEvent *e) override; + void dragMoveEvent(QDragMoveEvent *e) override; + void dropEvent(QDropEvent *e) override; private: Q_DECLARE_PRIVATE(QQuickWebEngineView) @@ -557,5 +585,6 @@ QT_END_NAMESPACE QML_DECLARE_TYPE(QQuickWebEngineView) Q_DECLARE_METATYPE(QQuickWebEngineFullScreenRequest) +Q_DECLARE_METATYPE(QQuickWebEngineQuotaPermissionRequest) #endif // QQUICKWEBENGINEVIEW_P_H diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index bd9b2909b..708725787 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -89,66 +89,67 @@ public: QtWebEngineCore::UIDelegatesManager *ui(); - virtual QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) Q_DECL_OVERRIDE; - virtual QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) Q_DECL_OVERRIDE; - virtual void titleChanged(const QString&) Q_DECL_OVERRIDE; - virtual void urlChanged(const QUrl&) Q_DECL_OVERRIDE; - virtual void iconChanged(const QUrl&) Q_DECL_OVERRIDE; - virtual void loadProgressChanged(int progress) Q_DECL_OVERRIDE; - virtual void didUpdateTargetURL(const QUrl&) Q_DECL_OVERRIDE; - virtual void selectionChanged() Q_DECL_OVERRIDE { } - virtual void recentlyAudibleChanged(bool recentlyAudible) Q_DECL_OVERRIDE; - virtual QRectF viewportRect() const Q_DECL_OVERRIDE; - virtual qreal dpiScale() const Q_DECL_OVERRIDE; - virtual QColor backgroundColor() const Q_DECL_OVERRIDE; - virtual void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) Q_DECL_OVERRIDE; - virtual void loadCommitted() Q_DECL_OVERRIDE; - virtual void loadVisuallyCommitted() Q_DECL_OVERRIDE; - virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) Q_DECL_OVERRIDE; - virtual void focusContainer() Q_DECL_OVERRIDE; - virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - virtual void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &, const QUrl &targetUrl) Q_DECL_OVERRIDE; - virtual bool isBeingAdopted() Q_DECL_OVERRIDE; - virtual void close() Q_DECL_OVERRIDE; - virtual void windowCloseRejected() Q_DECL_OVERRIDE; - virtual void requestFullScreenMode(const QUrl &origin, bool fullscreen) Q_DECL_OVERRIDE; - virtual bool isFullScreenMode() const Q_DECL_OVERRIDE; - virtual bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &) Q_DECL_OVERRIDE; - virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) Q_DECL_OVERRIDE; - virtual void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) Q_DECL_OVERRIDE; - virtual void runFileChooser(QSharedPointer<QtWebEngineCore::FilePickerController>) Q_DECL_OVERRIDE; - virtual void showColorDialog(QSharedPointer<QtWebEngineCore::ColorChooserController>) Q_DECL_OVERRIDE; - virtual void didRunJavaScript(quint64, const QVariant&) Q_DECL_OVERRIDE; - virtual void didFetchDocumentMarkup(quint64, const QString&) Q_DECL_OVERRIDE { } - virtual void didFetchDocumentInnerText(quint64, const QString&) Q_DECL_OVERRIDE { } - virtual void didFindText(quint64, int) Q_DECL_OVERRIDE; - virtual void didPrintPage(quint64 requestId, const QByteArray &result) Q_DECL_OVERRIDE; - virtual void didPrintPageToPdf(const QString &filePath, bool success) Q_DECL_OVERRIDE; - virtual void passOnFocus(bool reverse) Q_DECL_OVERRIDE; - virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE; - virtual void authenticationRequired(QSharedPointer<QtWebEngineCore::AuthenticationDialogController>) Q_DECL_OVERRIDE; - virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE; - virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE; - virtual QObject *accessibilityParentObject() Q_DECL_OVERRIDE; - virtual QtWebEngineCore::WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE; - virtual void allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController) Q_DECL_OVERRIDE; - virtual void runGeolocationPermissionRequest(QUrl const&) Q_DECL_OVERRIDE; - virtual void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) Q_DECL_OVERRIDE; - virtual void hideValidationMessage() Q_DECL_OVERRIDE; - virtual void moveValidationMessage(const QRect &anchor) Q_DECL_OVERRIDE; + QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override; + QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override; + void titleChanged(const QString&) override; + void urlChanged(const QUrl&) override; + void iconChanged(const QUrl&) override; + void loadProgressChanged(int progress) override; + void didUpdateTargetURL(const QUrl&) override; + void selectionChanged() override { } + void recentlyAudibleChanged(bool recentlyAudible) override; + QRectF viewportRect() const override; + qreal dpiScale() const override; + QColor backgroundColor() const override; + void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) override; + void loadCommitted() override; + void loadVisuallyCommitted() override; + void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) override; + void focusContainer() override; + void unhandledKeyEvent(QKeyEvent *event) override; + void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &, const QUrl &targetUrl) override; + bool isBeingAdopted() override; + void close() override; + void windowCloseRejected() override; + void requestFullScreenMode(const QUrl &origin, bool fullscreen) override; + bool isFullScreenMode() const override; + bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &) override; + void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) override; + void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) override; + void runFileChooser(QSharedPointer<QtWebEngineCore::FilePickerController>) override; + void showColorDialog(QSharedPointer<QtWebEngineCore::ColorChooserController>) override; + void didRunJavaScript(quint64, const QVariant&) override; + void didFetchDocumentMarkup(quint64, const QString&) override { } + void didFetchDocumentInnerText(quint64, const QString&) override { } + void didFindText(quint64, int) override; + void didPrintPage(quint64 requestId, const QByteArray &result) override; + void didPrintPageToPdf(const QString &filePath, bool success) override; + void passOnFocus(bool reverse) override; + void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) override; + void authenticationRequired(QSharedPointer<QtWebEngineCore::AuthenticationDialogController>) override; + void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) override; + void runMouseLockPermissionRequest(const QUrl &securityOrigin) override; + void runQuotaPermissionRequest(QSharedPointer<QtWebEngineCore::QuotaPermissionController>) override; + QObject *accessibilityParentObject() override; + QtWebEngineCore::WebEngineSettings *webEngineSettings() const override; + void allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController) override; + void runGeolocationPermissionRequest(QUrl const&) override; + void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) override; + void hideValidationMessage() override; + void moveValidationMessage(const QRect &anchor) override; virtual void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, - int exitCode) Q_DECL_OVERRIDE; - virtual void requestGeometryChange(const QRect &geometry) Q_DECL_OVERRIDE { Q_UNUSED(geometry); } - virtual void updateScrollPosition(const QPointF &position) Q_DECL_OVERRIDE; - virtual void updateContentsSize(const QSizeF &size) Q_DECL_OVERRIDE; + int exitCode) override; + void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override; + void updateScrollPosition(const QPointF &position) override; + void updateContentsSize(const QSizeF &size) override; void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions, - const QPixmap &pixmap, const QPoint &offset) Q_DECL_OVERRIDE; - virtual bool isEnabled() const Q_DECL_OVERRIDE; - virtual void setToolTip(const QString &toolTipText) Q_DECL_OVERRIDE; - const QObject *holdingQObject() const Q_DECL_OVERRIDE; + const QPixmap &pixmap, const QPoint &offset) override; + bool isEnabled() const override; + void setToolTip(const QString &toolTipText) override; + const QObject *holdingQObject() const override; - virtual QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextAdapter() Q_DECL_OVERRIDE; - QtWebEngineCore::WebContentsAdapter *webContentsAdapter() Q_DECL_OVERRIDE; + QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextAdapter() override; + QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override; void setDevicePixelRatio(qreal); void adoptWebContents(QtWebEngineCore::WebContentsAdapter *webContents); @@ -200,13 +201,13 @@ class QQuickWebEngineViewAccessible : public QAccessibleObject { public: QQuickWebEngineViewAccessible(QQuickWebEngineView *o); - QAccessibleInterface *parent() const Q_DECL_OVERRIDE; - int childCount() const Q_DECL_OVERRIDE; - QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE; - int indexOfChild(const QAccessibleInterface*) const Q_DECL_OVERRIDE; - QString text(QAccessible::Text) const Q_DECL_OVERRIDE; - QAccessible::Role role() const Q_DECL_OVERRIDE; - QAccessible::State state() const Q_DECL_OVERRIDE; + QAccessibleInterface *parent() const override; + int childCount() const override; + QAccessibleInterface *child(int index) const override; + int indexOfChild(const QAccessibleInterface*) const override; + QString text(QAccessible::Text) const override; + QAccessible::Role role() const override; + QAccessible::State state() const override; private: QQuickWebEngineView *engineView() const { return static_cast<QQuickWebEngineView*>(object()); } diff --git a/src/webengine/doc/src/webengineview_lgpl.qdoc b/src/webengine/doc/src/webengineview_lgpl.qdoc index 9cd7e3f27..20db51793 100644 --- a/src/webengine/doc/src/webengineview_lgpl.qdoc +++ b/src/webengine/doc/src/webengineview_lgpl.qdoc @@ -1297,3 +1297,83 @@ /*! \qmlsignal WebEngineView::navigationRequested(WebEngineNavigationRequest request) This signal is emitted when the navigation request \a request is issued. */ + +/*! + \qmlsignal WebEngineView::quotaPermissionRequested(QuotaPermissionRequest request) + \since QtWebEngine 1.7 + + This signal is emitted when the web page requests larger persistent storage + than the application's current allocation in File System API. The default quota + is 0 bytes. + + \sa QuotaPermissionRequest +*/ + +/*! + \qmltype QuotaPermissionRequest + \instantiates QQuickWebEngineQuotaPermissionRequest + \inqmlmodule QtWebEngine + \since QtWebEngine 1.7 + + \brief A utility type for the WebEngineView::quotaPermissionRequested() signal. + + \sa WebEngineView::quotaPermissionRequested() +*/ + +/*! + \qmlproperty url QuotaPermissionRequest::origin + \readonly + + The URL of the web page that issued the quota permission request. +*/ + +/*! + \qmlproperty qint64 QuotaPermissionRequest::requestedSize + \readonly + + Contains the size of the requested disk space in bytes. +*/ + +/*! + \qmlmethod void QuotaPermissionRequest::accept() + + Accepts the quota permission request. + + \qml + WebEngineView { + onQuotaPermissionRequested: function(request) { + if (request.requestedSize <= 5 * 1024 * 1024) + request.accept(); + else + request.reject(); + } + } + \endqml +*/ + +/*! + \qmlmethod void QuotaPermissionRequest::reject() + Rejects a quota permission request. +*/ + +/*! + \qmlsignal WebEngineView::geometryChangeRequested(rect geometry, rect frameGeometry) + \since QtWebEngine 1.7 + + This signal is emitted whenever the document wants to change the position and size of the + page to \a frameGeometry. This can happen for example through JavaScript. + + While \a frameGeometry includes, \a geometry excludes the size of frame margins. + + \note Geometry related properties of QML Window expect a size excluding the window + decoration. You have to use \a geometry to handle this signal correctly. + + \qml + onGeometryChangeRequested: { + window.x = geometry.x + window.y = geometry.y + window.width = geometry.width + window.height = geometry.height + } + \endqml +*/ diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp index 5ab792699..03ce5a332 100644 --- a/src/webengine/plugin/plugin.cpp +++ b/src/webengine/plugin/plugin.cpp @@ -66,13 +66,13 @@ class QtWebEnginePlugin : public QQmlExtensionPlugin Q_OBJECT Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: - virtual void initializeEngine(QQmlEngine *engine, const char *uri) Q_DECL_OVERRIDE + void initializeEngine(QQmlEngine *engine, const char *uri) override { Q_UNUSED(uri); engine->addImageProvider(QQuickWebEngineFaviconProvider::identifier(), new QQuickWebEngineFaviconProvider); } - virtual void registerTypes(const char *uri) Q_DECL_OVERRIDE + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebEngine")); @@ -86,6 +86,7 @@ public: qmlRegisterType<QQuickWebEngineView, 4>(uri, 1, 4, "WebEngineView"); qmlRegisterType<QQuickWebEngineView, 5>(uri, 1, 5, "WebEngineView"); qmlRegisterType<QQuickWebEngineView, 6>(uri, 1, 6, "WebEngineView"); + qmlRegisterType<QQuickWebEngineView, 7>(uri, 1, 7, "WebEngineView"); qmlRegisterType<QQuickWebEngineProfile>(uri, 1, 1, "WebEngineProfile"); qmlRegisterType<QQuickWebEngineProfile, 1>(uri, 1, 2, "WebEngineProfile"); qmlRegisterType<QQuickWebEngineProfile, 2>(uri, 1, 3, "WebEngineProfile"); @@ -113,6 +114,7 @@ public: qmlRegisterUncreatableType<QQuickWebEngineSettings, 3>(uri, 1, 4, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings")); qmlRegisterUncreatableType<QQuickWebEngineSettings, 4>(uri, 1, 5, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings")); qmlRegisterUncreatableType<QQuickWebEngineSettings, 5>(uri, 1, 6, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings")); + qmlRegisterUncreatableType<QQuickWebEngineSettings, 6>(uri, 1, 7, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings")); qmlRegisterSingletonType<QQuickWebEngineSingleton>(uri, 1, 1, "WebEngine", webEngineSingletonProvider); qmlRegisterUncreatableType<QQuickWebEngineHistory>(uri, 1, 1, "NavigationHistory", tr("Cannot create a separate instance of NavigationHistory")); @@ -133,6 +135,8 @@ public: msgUncreatableType("FileDialogRequest")); qmlRegisterUncreatableType<QQuickWebEngineFormValidationMessageRequest>(uri, 1, 4, "FormValidationMessageRequest", msgUncreatableType("FormValidationMessageRequest")); + qmlRegisterUncreatableType<QQuickWebEngineQuotaPermissionRequest>(uri, 1, 7, "QuotaPermissionRequest", + tr("Cannot create a separate instance of QuotaPermissionRequest")); } private: diff --git a/src/webengine/plugin/plugin.pro b/src/webengine/plugin/plugin.pro index 1f9ef00c5..84b497e34 100644 --- a/src/webengine/plugin/plugin.pro +++ b/src/webengine/plugin/plugin.pro @@ -1,7 +1,7 @@ CXX_MODULE = qml TARGET = qtwebengineplugin TARGETPATH = QtWebEngine -IMPORT_VERSION = 1.6 +IMPORT_VERSION = 1.7 QT += webengine qml quick QT_PRIVATE += webengine-private diff --git a/src/webengine/plugin/plugins.qmltypes b/src/webengine/plugin/plugins.qmltypes index 321c462b5..b57aa4498 100644 --- a/src/webengine/plugin/plugins.qmltypes +++ b/src/webengine/plugin/plugins.qmltypes @@ -4,7 +4,7 @@ import QtQuick.tooling 1.2 // It is used for QML tooling purposes only. // // This file was auto-generated by: -// 'qmlplugindump -defaultplatform -dependencies dependencies.json -nonrelocatable QtWebEngine 1.6' +// 'qmlplugindump -defaultplatform -dependencies dependencies.json -nonrelocatable QtWebEngine 1.7' Module { dependencies: ["QtQuick 2.6"] @@ -119,10 +119,11 @@ Module { "QtWebEngine/WebEngineDownloadItem 1.2", "QtWebEngine/WebEngineDownloadItem 1.3", "QtWebEngine/WebEngineDownloadItem 1.4", - "QtWebEngine/WebEngineDownloadItem 1.5" + "QtWebEngine/WebEngineDownloadItem 1.5", + "QtWebEngine/WebEngineDownloadItem 1.6" ] isCreatable: false - exportMetaObjectRevisions: [0, 1, 2, 3, 4] + exportMetaObjectRevisions: [0, 1, 2, 3, 4, 5] Enum { name: "DownloadState" values: { @@ -195,12 +196,18 @@ Module { isReadonly: true } Property { name: "interruptReasonString"; revision: 4; type: "string"; isReadonly: true } + Property { name: "isFinished"; revision: 5; type: "bool"; isReadonly: true } + Property { name: "isPaused"; revision: 5; type: "bool"; isReadonly: true } Signal { name: "savePageFormatChanged"; revision: 2 } Signal { name: "mimeTypeChanged"; revision: 1 } Signal { name: "typeChanged"; revision: 3 } Signal { name: "interruptReasonChanged"; revision: 4 } + Signal { name: "isFinishedChanged"; revision: 5 } + Signal { name: "isPausedChanged"; revision: 5 } Method { name: "accept" } Method { name: "cancel" } + Method { name: "pause" } + Method { name: "resume" } } Component { name: "QQuickWebEngineFileDialogRequest" @@ -425,6 +432,16 @@ Module { Method { name: "clearHttpCache"; revision: 2 } } Component { + name: "QQuickWebEngineQuotaPermissionRequest" + exports: ["QtWebEngine/QuotaPermissionRequest 1.7"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { name: "origin"; type: "QUrl"; isReadonly: true } + Property { name: "requestedSize"; type: "qlonglong"; isReadonly: true } + Method { name: "accept" } + Method { name: "reject" } + } + Component { name: "QQuickWebEngineScript" prototype: "QObject" exports: ["QtWebEngine/WebEngineScript 1.1"] @@ -514,6 +531,14 @@ Module { ] isCreatable: false exportMetaObjectRevisions: [0, 1, 2, 3, 4, 5] + Enum { + name: "UnknownUrlSchemePolicy" + values: { + "DisallowUnknownUrlSchemes": 1, + "AllowUnknownUrlSchemesFromUserInteraction": 2, + "AllowAllUnknownUrlSchemes": 3 + } + } Property { name: "autoLoadImages"; type: "bool" } Property { name: "javascriptEnabled"; type: "bool" } Property { name: "javascriptCanOpenWindows"; type: "bool" } @@ -538,6 +563,8 @@ Module { Property { name: "allowRunningInsecureContent"; revision: 3; type: "bool" } Property { name: "allowGeolocationOnInsecureOrigins"; revision: 4; type: "bool" } Property { name: "allowWindowActivationFromJavaScript"; revision: 5; type: "bool" } + Property { name: "showScrollBars"; revision: 5; type: "bool" } + Property { name: "unknownUrlSchemePolicy"; revision: 6; type: "UnknownUrlSchemePolicy" } Signal { name: "fullScreenSupportEnabledChanged"; revision: 1 } Signal { name: "screenCaptureEnabledChanged"; revision: 2 } Signal { name: "webGLEnabledChanged"; revision: 2 } @@ -549,6 +576,8 @@ Module { Signal { name: "allowRunningInsecureContentChanged"; revision: 3 } Signal { name: "allowGeolocationOnInsecureOriginsChanged"; revision: 4 } Signal { name: "allowWindowActivationFromJavaScriptChanged"; revision: 5 } + Signal { name: "showScrollBarsChanged"; revision: 5 } + Signal { name: "unknownUrlSchemePolicyChanged"; revision: 6 } } Component { name: "QQuickWebEngineSingleton" @@ -892,7 +921,6 @@ Module { Property { name: "audioMuted"; revision: 3; type: "bool" } Property { name: "recentlyAudible"; revision: 3; type: "bool"; isReadonly: true } Property { name: "webChannelWorld"; revision: 3; type: "uint" } - Property { name: "testSupport"; type: "QQuickWebEngineTestSupport"; isPointer: true } Signal { name: "loadingChanged" Parameter { name: "loadRequest"; type: "QQuickWebEngineLoadRequest"; isPointer: true } @@ -1023,6 +1051,11 @@ Module { Parameter { name: "filePath"; type: "string" } Parameter { name: "success"; type: "bool" } } + Signal { + name: "quotaPermissionRequested" + revision: 7 + Parameter { name: "request"; type: "QQuickWebEngineQuotaPermissionRequest" } + } Method { name: "runJavaScript" Parameter { type: "string" } diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.h b/src/webengine/render_widget_host_view_qt_delegate_quick.h index 7426dc16d..a5101d070 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quick.h +++ b/src/webengine/render_widget_host_view_qt_delegate_quick.h @@ -52,50 +52,50 @@ class RenderWidgetHostViewQtDelegateQuick : public QQuickItem, public RenderWidg public: RenderWidgetHostViewQtDelegateQuick(RenderWidgetHostViewQtDelegateClient *client, bool isPopup); - virtual void initAsChild(WebContentsAdapterClient* container) Q_DECL_OVERRIDE; - virtual void initAsPopup(const QRect&) Q_DECL_OVERRIDE; - virtual QRectF screenRect() const Q_DECL_OVERRIDE; - virtual QRectF contentsRect() const Q_DECL_OVERRIDE; - virtual void setKeyboardFocus() Q_DECL_OVERRIDE; - virtual bool hasKeyboardFocus() Q_DECL_OVERRIDE; - virtual void lockMouse() Q_DECL_OVERRIDE; - virtual void unlockMouse() Q_DECL_OVERRIDE; - virtual void show() Q_DECL_OVERRIDE; - virtual void hide() Q_DECL_OVERRIDE; - virtual bool isVisible() const Q_DECL_OVERRIDE; - virtual QWindow* window() const Q_DECL_OVERRIDE; - virtual QSGTexture *createTextureFromImage(const QImage &) Q_DECL_OVERRIDE; - virtual QSGLayer *createLayer() Q_DECL_OVERRIDE; - virtual QSGInternalImageNode *createImageNode() Q_DECL_OVERRIDE; - virtual QSGTextureNode *createTextureNode() Q_DECL_OVERRIDE; - virtual QSGRectangleNode *createRectangleNode() Q_DECL_OVERRIDE; - virtual void update() Q_DECL_OVERRIDE; - virtual void updateCursor(const QCursor &) Q_DECL_OVERRIDE; - virtual void resize(int width, int height) Q_DECL_OVERRIDE; - virtual void move(const QPoint&) Q_DECL_OVERRIDE { } - virtual void inputMethodStateChanged(bool editorVisible, bool isPasswordInput) Q_DECL_OVERRIDE; - virtual void setInputMethodHints(Qt::InputMethodHints) Q_DECL_OVERRIDE { } + void initAsChild(WebContentsAdapterClient* container) override; + void initAsPopup(const QRect&) override; + QRectF screenRect() const override; + QRectF contentsRect() const override; + void setKeyboardFocus() override; + bool hasKeyboardFocus() override; + void lockMouse() override; + void unlockMouse() override; + void show() override; + void hide() override; + bool isVisible() const override; + QWindow* window() const override; + QSGTexture *createTextureFromImage(const QImage &) override; + QSGLayer *createLayer() override; + QSGInternalImageNode *createImageNode() override; + QSGTextureNode *createTextureNode() override; + QSGRectangleNode *createRectangleNode() override; + void update() override; + void updateCursor(const QCursor &) override; + void resize(int width, int height) override; + void move(const QPoint&) override { } + void inputMethodStateChanged(bool editorVisible, bool isPasswordInput) override; + void setInputMethodHints(Qt::InputMethodHints) override { } // The QtQuick view doesn't have a backbuffer of its own and doesn't need this - virtual void setClearColor(const QColor &) Q_DECL_OVERRIDE { } + void setClearColor(const QColor &) override { } protected: - virtual bool event(QEvent *event) Q_DECL_OVERRIDE; - virtual void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE; - virtual void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE; - virtual void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - virtual void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - virtual void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - virtual void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - virtual void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; - virtual void touchEvent(QTouchEvent *event) Q_DECL_OVERRIDE; - virtual void hoverMoveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; - virtual void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; - virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE; - virtual void inputMethodEvent(QInputMethodEvent *event) Q_DECL_OVERRIDE; - virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - virtual void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; - virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + bool event(QEvent *event) override; + void focusInEvent(QFocusEvent *event) override; + void focusOutEvent(QFocusEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; + void keyReleaseEvent(QKeyEvent *event) override; + void wheelEvent(QWheelEvent *event) override; + void touchEvent(QTouchEvent *event) override; + void hoverMoveEvent(QHoverEvent *event) override; + void hoverLeaveEvent(QHoverEvent *event) override; + QVariant inputMethodQuery(Qt::InputMethodQuery query) const override; + void inputMethodEvent(QInputMethodEvent *event) override; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; + void itemChange(ItemChange change, const ItemChangeData &value) override; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; private slots: void onWindowPosChanged(); diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h index 6244ee6ce..be4033728 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h +++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h @@ -55,30 +55,30 @@ public: RenderWidgetHostViewQtDelegateQuickWindow(RenderWidgetHostViewQtDelegate *realDelegate); ~RenderWidgetHostViewQtDelegateQuickWindow(); - virtual void initAsChild(WebContentsAdapterClient* container) Q_DECL_OVERRIDE; - virtual void initAsPopup(const QRect&) Q_DECL_OVERRIDE; - virtual QRectF screenRect() const Q_DECL_OVERRIDE; - virtual QRectF contentsRect() const Q_DECL_OVERRIDE; - virtual void setKeyboardFocus() Q_DECL_OVERRIDE {} - virtual bool hasKeyboardFocus() Q_DECL_OVERRIDE { return false; } - virtual void lockMouse() Q_DECL_OVERRIDE {} - virtual void unlockMouse() Q_DECL_OVERRIDE {} - virtual void show() Q_DECL_OVERRIDE; - virtual void hide() Q_DECL_OVERRIDE; - virtual bool isVisible() const Q_DECL_OVERRIDE; - virtual QWindow* window() const Q_DECL_OVERRIDE; - virtual QSGTexture *createTextureFromImage(const QImage &) Q_DECL_OVERRIDE; - virtual QSGLayer *createLayer() Q_DECL_OVERRIDE; - virtual QSGInternalImageNode *createImageNode() Q_DECL_OVERRIDE; - virtual QSGTextureNode *createTextureNode() Q_DECL_OVERRIDE; - virtual QSGRectangleNode *createRectangleNode() Q_DECL_OVERRIDE; - virtual void update() Q_DECL_OVERRIDE; - virtual void updateCursor(const QCursor &) Q_DECL_OVERRIDE; - virtual void resize(int width, int height) Q_DECL_OVERRIDE; - virtual void move(const QPoint &screenPos) Q_DECL_OVERRIDE; - virtual void inputMethodStateChanged(bool, bool) Q_DECL_OVERRIDE {} - virtual void setInputMethodHints(Qt::InputMethodHints) Q_DECL_OVERRIDE { } - virtual void setClearColor(const QColor &) Q_DECL_OVERRIDE { } + void initAsChild(WebContentsAdapterClient* container) override; + void initAsPopup(const QRect&) override; + QRectF screenRect() const override; + QRectF contentsRect() const override; + void setKeyboardFocus() override {} + bool hasKeyboardFocus() override { return false; } + void lockMouse() override {} + void unlockMouse() override {} + void show() override; + void hide() override; + bool isVisible() const override; + QWindow* window() const override; + QSGTexture *createTextureFromImage(const QImage &) override; + QSGLayer *createLayer() override; + QSGInternalImageNode *createImageNode() override; + QSGTextureNode *createTextureNode() override; + QSGRectangleNode *createRectangleNode() override; + void update() override; + void updateCursor(const QCursor &) override; + void resize(int width, int height) override; + void move(const QPoint &screenPos) override; + void inputMethodStateChanged(bool, bool) override {} + void setInputMethodHints(Qt::InputMethodHints) override { } + void setClearColor(const QColor &) override { } private: QScopedPointer<RenderWidgetHostViewQtDelegate> m_realDelegate; diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 420057651..4a892103d 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -53,6 +53,7 @@ #include "qwebenginehistory_p.h" #include "qwebengineprofile.h" #include "qwebengineprofile_p.h" +#include "qwebenginequotapermissionrequest.h" #include "qwebenginescriptcollection_p.h" #include "qwebenginesettings.h" #include "qwebengineview.h" @@ -566,6 +567,13 @@ void QWebEnginePagePrivate::runMouseLockPermissionRequest(const QUrl &securityOr Q_EMIT q->featurePermissionRequested(securityOrigin, QWebEnginePage::MouseLock); } +void QWebEnginePagePrivate::runQuotaPermissionRequest(QSharedPointer<QtWebEngineCore::QuotaPermissionController> controller) +{ + Q_Q(QWebEnginePage); + QWebEngineQuotaPermissionRequest request(controller); + Q_EMIT q->quotaPermissionRequested(request); +} + QObject *QWebEnginePagePrivate::accessibilityParentObject() { return view; @@ -727,6 +735,17 @@ QWebEnginePage::QWebEnginePage(QObject* parent) */ /*! + \fn QWebEnginePage::quotaPermissionRequested(QWebEngineQuotaPermissionRequest request) + \since 5.11 + + This signal is emitted when the web page requests larger persistent storage + than the application's current allocation in File System API. The default quota + is 0 bytes. + + The request object \a request can be used to accept or reject the request. +*/ + +/*! \fn void QWebEnginePage::pdfPrintingFinished(const QString &filePath, bool success) \since 5.9 @@ -1584,10 +1603,11 @@ void QWebEnginePagePrivate::renderProcessTerminated(RenderProcessTerminationStat terminationStatus), exitCode); } -void QWebEnginePagePrivate::requestGeometryChange(const QRect &geometry) +void QWebEnginePagePrivate::requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) { + Q_UNUSED(geometry); Q_Q(QWebEnginePage); - Q_EMIT q->geometryChangeRequested(geometry); + Q_EMIT q->geometryChangeRequested(frameGeometry); } void QWebEnginePagePrivate::startDragging(const content::DropData &dropData, diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index 295527e74..3fad6ca09 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -64,6 +64,7 @@ class QWebEngineHistory; class QWebEnginePage; class QWebEnginePagePrivate; class QWebEngineProfile; +class QWebEngineQuotaPermissionRequest; class QWebEngineScriptCollection; class QWebEngineSettings; @@ -330,6 +331,7 @@ Q_SIGNALS: void featurePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature feature); void featurePermissionRequestCanceled(const QUrl &securityOrigin, QWebEnginePage::Feature feature); void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest); + void quotaPermissionRequested(QWebEngineQuotaPermissionRequest quotaPermissionRequest); void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator); void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost); diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index ec84f05e1..2d44d1849 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -82,69 +82,70 @@ public: QWebEnginePagePrivate(QWebEngineProfile *profile = 0); ~QWebEnginePagePrivate(); - virtual QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) Q_DECL_OVERRIDE; - virtual QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) Q_DECL_OVERRIDE { return CreateRenderWidgetHostViewQtDelegate(client); } - virtual void titleChanged(const QString&) Q_DECL_OVERRIDE; - virtual void urlChanged(const QUrl&) Q_DECL_OVERRIDE; - virtual void iconChanged(const QUrl&) Q_DECL_OVERRIDE; - virtual void loadProgressChanged(int progress) Q_DECL_OVERRIDE; - virtual void didUpdateTargetURL(const QUrl&) Q_DECL_OVERRIDE; - virtual void selectionChanged() Q_DECL_OVERRIDE; - virtual void recentlyAudibleChanged(bool recentlyAudible) Q_DECL_OVERRIDE; - virtual QRectF viewportRect() const Q_DECL_OVERRIDE; - virtual qreal dpiScale() const Q_DECL_OVERRIDE; - virtual QColor backgroundColor() const Q_DECL_OVERRIDE; - virtual void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) Q_DECL_OVERRIDE; - virtual void loadCommitted() Q_DECL_OVERRIDE; - virtual void loadVisuallyCommitted() Q_DECL_OVERRIDE { } - virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) Q_DECL_OVERRIDE; - virtual void focusContainer() Q_DECL_OVERRIDE; - virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - virtual void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry, const QUrl &targetUrl) Q_DECL_OVERRIDE; + QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override; + QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override { return CreateRenderWidgetHostViewQtDelegate(client); } + void titleChanged(const QString&) override; + void urlChanged(const QUrl&) override; + void iconChanged(const QUrl&) override; + void loadProgressChanged(int progress) override; + void didUpdateTargetURL(const QUrl&) override; + void selectionChanged() override; + void recentlyAudibleChanged(bool recentlyAudible) override; + QRectF viewportRect() const override; + qreal dpiScale() const override; + QColor backgroundColor() const override; + void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) override; + void loadCommitted() override; + void loadVisuallyCommitted() override { } + void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) override; + void focusContainer() override; + void unhandledKeyEvent(QKeyEvent *event) override; + void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry, const QUrl &targetUrl) override; void adoptNewWindowImpl(QWebEnginePage *newPage, const QSharedPointer<QtWebEngineCore::WebContentsAdapter> &newWebContents, const QRect &initialGeometry); - virtual bool isBeingAdopted() Q_DECL_OVERRIDE; - virtual void close() Q_DECL_OVERRIDE; - virtual void windowCloseRejected() Q_DECL_OVERRIDE; - virtual bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &data) Q_DECL_OVERRIDE; - virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) Q_DECL_OVERRIDE; - virtual void requestFullScreenMode(const QUrl &origin, bool fullscreen) Q_DECL_OVERRIDE; - virtual bool isFullScreenMode() const Q_DECL_OVERRIDE; - virtual void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) Q_DECL_OVERRIDE; - virtual void runFileChooser(QSharedPointer<QtWebEngineCore::FilePickerController>) Q_DECL_OVERRIDE; - virtual void showColorDialog(QSharedPointer<QtWebEngineCore::ColorChooserController>) Q_DECL_OVERRIDE; - virtual void didRunJavaScript(quint64 requestId, const QVariant& result) Q_DECL_OVERRIDE; - virtual void didFetchDocumentMarkup(quint64 requestId, const QString& result) Q_DECL_OVERRIDE; - virtual void didFetchDocumentInnerText(quint64 requestId, const QString& result) Q_DECL_OVERRIDE; - virtual void didFindText(quint64 requestId, int matchCount) Q_DECL_OVERRIDE; - virtual void didPrintPage(quint64 requestId, const QByteArray &result) Q_DECL_OVERRIDE; - virtual void didPrintPageToPdf(const QString &filePath, bool success) Q_DECL_OVERRIDE; - virtual void passOnFocus(bool reverse) Q_DECL_OVERRIDE; - virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE; - virtual void authenticationRequired(QSharedPointer<QtWebEngineCore::AuthenticationDialogController>) Q_DECL_OVERRIDE; - virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE; - virtual void runGeolocationPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE; - virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE; - virtual QObject *accessibilityParentObject() Q_DECL_OVERRIDE; - virtual QtWebEngineCore::WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE; - virtual void allowCertificateError(const QSharedPointer<CertificateErrorController> &controller) Q_DECL_OVERRIDE; - virtual void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) Q_DECL_OVERRIDE; - virtual void hideValidationMessage() Q_DECL_OVERRIDE; - virtual void moveValidationMessage(const QRect &anchor) Q_DECL_OVERRIDE; + bool isBeingAdopted() override; + void close() override; + void windowCloseRejected() override; + bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &data) override; + void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) override; + void requestFullScreenMode(const QUrl &origin, bool fullscreen) override; + bool isFullScreenMode() const override; + void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) override; + void runFileChooser(QSharedPointer<QtWebEngineCore::FilePickerController>) override; + void showColorDialog(QSharedPointer<QtWebEngineCore::ColorChooserController>) override; + void didRunJavaScript(quint64 requestId, const QVariant& result) override; + void didFetchDocumentMarkup(quint64 requestId, const QString& result) override; + void didFetchDocumentInnerText(quint64 requestId, const QString& result) override; + void didFindText(quint64 requestId, int matchCount) override; + void didPrintPage(quint64 requestId, const QByteArray &result) override; + void didPrintPageToPdf(const QString &filePath, bool success) override; + void passOnFocus(bool reverse) override; + void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) override; + void authenticationRequired(QSharedPointer<QtWebEngineCore::AuthenticationDialogController>) override; + void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) override; + void runGeolocationPermissionRequest(const QUrl &securityOrigin) override; + void runMouseLockPermissionRequest(const QUrl &securityOrigin) override; + void runQuotaPermissionRequest(QSharedPointer<QtWebEngineCore::QuotaPermissionController>) override; + QObject *accessibilityParentObject() override; + QtWebEngineCore::WebEngineSettings *webEngineSettings() const override; + void allowCertificateError(const QSharedPointer<CertificateErrorController> &controller) override; + void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) override; + void hideValidationMessage() override; + void moveValidationMessage(const QRect &anchor) override; virtual void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, - int exitCode) Q_DECL_OVERRIDE; - virtual void requestGeometryChange(const QRect &geometry) Q_DECL_OVERRIDE; - virtual void updateScrollPosition(const QPointF &position) Q_DECL_OVERRIDE; - virtual void updateContentsSize(const QSizeF &size) Q_DECL_OVERRIDE; + int exitCode) override; + void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override; + void updateScrollPosition(const QPointF &position) override; + void updateContentsSize(const QSizeF &size) override; void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions, - const QPixmap &pixmap, const QPoint &offset) Q_DECL_OVERRIDE; - virtual bool isEnabled() const Q_DECL_OVERRIDE; - virtual void setToolTip(const QString &toolTipText) Q_DECL_OVERRIDE; - const QObject *holdingQObject() const Q_DECL_OVERRIDE; + const QPixmap &pixmap, const QPoint &offset) override; + bool isEnabled() const override; + void setToolTip(const QString &toolTipText) override; + const QObject *holdingQObject() const override; - virtual QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextAdapter() Q_DECL_OVERRIDE; - QtWebEngineCore::WebContentsAdapter *webContentsAdapter() Q_DECL_OVERRIDE; + QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextAdapter() override; + QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override; void updateAction(QWebEnginePage::WebAction) const; void updateNavigationActions(); diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h index 7f02307d3..8cbf241f3 100644 --- a/src/webenginewidgets/api/qwebengineprofile_p.h +++ b/src/webenginewidgets/api/qwebengineprofile_p.h @@ -93,8 +93,8 @@ public: void downloadDestroyed(quint32 downloadId); - void downloadRequested(DownloadItemInfo &info) Q_DECL_OVERRIDE; - void downloadUpdated(const DownloadItemInfo &info) Q_DECL_OVERRIDE; + void downloadRequested(DownloadItemInfo &info) override; + void downloadUpdated(const DownloadItemInfo &info) override; private: QWebEngineProfile *q_ptr; diff --git a/src/webenginewidgets/api/qwebenginequotapermissionrequest.cpp b/src/webenginewidgets/api/qwebenginequotapermissionrequest.cpp new file mode 100644 index 000000000..0841854ea --- /dev/null +++ b/src/webenginewidgets/api/qwebenginequotapermissionrequest.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 included in the +** 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-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwebenginequotapermissionrequest.h" + +#include "quota_permission_controller.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QWebEngineQuotaPermissionRequest + \brief The QWebEngineQuotaPermissionRequest class enables accepting or rejecting + requests for larger persistent storage than the application's current allocation + in File System API. + + \since 5.11 + + \inmodule QtWebEngineWidgets +*/ + +QWebEngineQuotaPermissionRequest::QWebEngineQuotaPermissionRequest(QSharedPointer<QtWebEngineCore::QuotaPermissionController> controller) + : d_ptr(controller) +{ +} + +/*! + Rejects a request for larger persistent storage. +*/ +void QWebEngineQuotaPermissionRequest::reject() +{ + d_ptr->cancel(); +} + +/*! + Accepts a request for larger persistent storage. +*/ +void QWebEngineQuotaPermissionRequest::accept() +{ + d_ptr->accept(); +} + +/*! + \property QWebEngineQuotaPermissionRequest::origin + \brief The URL of the web page that issued the quota permission request. +*/ + +QUrl QWebEngineQuotaPermissionRequest::origin() const +{ + return d_ptr->origin(); +} + +/*! + \property QWebEngineQuotaPermissionRequest::requestedSize + \brief Contains the size of the requested disk space in bytes. +*/ + +qint64 QWebEngineQuotaPermissionRequest::requestedSize() const +{ + return d_ptr->requestedSize(); +} + +QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebenginequotapermissionrequest.h b/src/webenginewidgets/api/qwebenginequotapermissionrequest.h new file mode 100644 index 000000000..aa0184fad --- /dev/null +++ b/src/webenginewidgets/api/qwebenginequotapermissionrequest.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 included in the +** 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-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWEBENGINEQUOTAPERMISSIONREQUEST_H +#define QWEBENGINEQUOTAPERMISSIONREQUEST_H + +#include <QtCore/qsharedpointer.h> +#include <QtCore/qurl.h> +#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> + +namespace QtWebEngineCore { + class QuotaPermissionController; +} + +QT_BEGIN_NAMESPACE + +class QWEBENGINEWIDGETS_EXPORT QWebEngineQuotaPermissionRequest { + Q_GADGET + Q_PROPERTY(QUrl origin READ origin) + Q_PROPERTY(qint64 requestedSize READ requestedSize) +public: + Q_INVOKABLE void accept(); + Q_INVOKABLE void reject(); + QUrl origin() const; + qint64 requestedSize() const; + +private: + QWebEngineQuotaPermissionRequest(QSharedPointer<QtWebEngineCore::QuotaPermissionController> controller); + QSharedPointer<QtWebEngineCore::QuotaPermissionController> d_ptr; + friend class QWebEnginePagePrivate; +}; + +QT_END_NAMESPACE + +#endif // QWEBENGINEQUOTAPERMISSIONREQUEST_H diff --git a/src/webenginewidgets/api/qwebenginesettings.cpp b/src/webenginewidgets/api/qwebenginesettings.cpp index 1def61cb6..b51f502a5 100644 --- a/src/webenginewidgets/api/qwebenginesettings.cpp +++ b/src/webenginewidgets/api/qwebenginesettings.cpp @@ -101,6 +101,8 @@ static WebEngineSettings::Attribute toWebEngineAttribute(QWebEngineSettings::Web return WebEngineSettings::AllowWindowActivationFromJavaScript; case QWebEngineSettings::ShowScrollBars: return WebEngineSettings::ShowScrollBars; + case QWebEngineSettings::PlaybackRequiresUserGesture: + return WebEngineSettings::PlaybackRequiresUserGesture; default: return WebEngineSettings::UnsupportedInCoreSettings; @@ -182,7 +184,6 @@ void QWebEngineSettings::resetFontSize(QWebEngineSettings::FontSize type) d->resetFontSize(static_cast<WebEngineSettings::FontSize>(type)); } - void QWebEngineSettings::setDefaultTextEncoding(const QString &encoding) { Q_D(QWebEngineSettings); @@ -195,6 +196,30 @@ QString QWebEngineSettings::defaultTextEncoding() const return d->defaultTextEncoding(); } +ASSERT_ENUMS_MATCH(WebEngineSettings::DisallowUnknownUrlSchemes, QWebEngineSettings::DisallowUnknownUrlSchemes) +ASSERT_ENUMS_MATCH(WebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction, QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction) +ASSERT_ENUMS_MATCH(WebEngineSettings::AllowAllUnknownUrlSchemes, QWebEngineSettings::AllowAllUnknownUrlSchemes) + +QWebEngineSettings::UnknownUrlSchemePolicy QWebEngineSettings::unknownUrlSchemePolicy() const +{ + Q_D(const QWebEngineSettings); + WebEngineSettings::UnknownUrlSchemePolicy result = d->unknownUrlSchemePolicy(); + Q_ASSERT(result != WebEngineSettings::InheritedUnknownUrlSchemePolicy); + return static_cast<QWebEngineSettings::UnknownUrlSchemePolicy>(result); +} + +void QWebEngineSettings::setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy policy) +{ + Q_D(QWebEngineSettings); + d->setUnknownUrlSchemePolicy(static_cast<WebEngineSettings::UnknownUrlSchemePolicy>(policy)); +} + +void QWebEngineSettings::resetUnknownUrlSchemePolicy() +{ + Q_D(QWebEngineSettings); + d->setUnknownUrlSchemePolicy(WebEngineSettings::InheritedUnknownUrlSchemePolicy); +} + void QWebEngineSettings::setAttribute(QWebEngineSettings::WebAttribute attr, bool on) { Q_D(QWebEngineSettings); diff --git a/src/webenginewidgets/api/qwebenginesettings.h b/src/webenginewidgets/api/qwebenginesettings.h index 470609227..ab03e207a 100644 --- a/src/webenginewidgets/api/qwebenginesettings.h +++ b/src/webenginewidgets/api/qwebenginesettings.h @@ -91,7 +91,8 @@ public: AllowRunningInsecureContent, AllowGeolocationOnInsecureOrigins, AllowWindowActivationFromJavaScript, - ShowScrollBars + ShowScrollBars, + PlaybackRequiresUserGesture }; enum FontSize { @@ -101,6 +102,12 @@ public: DefaultFixedFontSize }; + enum UnknownUrlSchemePolicy { + DisallowUnknownUrlSchemes = 1, + AllowUnknownUrlSchemesFromUserInteraction, + AllowAllUnknownUrlSchemes + }; + #if QT_DEPRECATED_SINCE(5, 5) static QWebEngineSettings *globalSettings(); #endif @@ -121,6 +128,10 @@ public: void setDefaultTextEncoding(const QString &encoding); QString defaultTextEncoding() const; + UnknownUrlSchemePolicy unknownUrlSchemePolicy() const; + void setUnknownUrlSchemePolicy(UnknownUrlSchemePolicy policy); + void resetUnknownUrlSchemePolicy(); + private: Q_DISABLE_COPY(QWebEngineSettings) typedef ::QtWebEngineCore::WebEngineSettings QWebEngineSettingsPrivate; diff --git a/src/webenginewidgets/api/qwebengineview.h b/src/webenginewidgets/api/qwebengineview.h index 487cc2316..795e011ad 100644 --- a/src/webenginewidgets/api/qwebengineview.h +++ b/src/webenginewidgets/api/qwebengineview.h @@ -103,7 +103,7 @@ public: void findText(const QString &subString, QWebEnginePage::FindFlags options = QWebEnginePage::FindFlags(), const QWebEngineCallback<bool> &resultCallback = QWebEngineCallback<bool>()); #endif - virtual QSize sizeHint() const Q_DECL_OVERRIDE; + QSize sizeHint() const override; QWebEngineSettings *settings() const; public Q_SLOTS: @@ -126,14 +126,14 @@ Q_SIGNALS: protected: virtual QWebEngineView *createWindow(QWebEnginePage::WebWindowType type); - virtual void contextMenuEvent(QContextMenuEvent*) Q_DECL_OVERRIDE; - virtual bool event(QEvent*) Q_DECL_OVERRIDE; - virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE; - virtual void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; - void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE; - void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE; - void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE; - void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE; + void contextMenuEvent(QContextMenuEvent*) override; + bool event(QEvent*) override; + void showEvent(QShowEvent *) override; + void hideEvent(QHideEvent *) override; + void dragEnterEvent(QDragEnterEvent *e) override; + void dragLeaveEvent(QDragLeaveEvent *e) override; + void dragMoveEvent(QDragMoveEvent *e) override; + void dropEvent(QDropEvent *e) override; private: Q_DISABLE_COPY(QWebEngineView) diff --git a/src/webenginewidgets/api/qwebengineview_p.h b/src/webenginewidgets/api/qwebengineview_p.h index f3a37225b..7f0cdac45 100644 --- a/src/webenginewidgets/api/qwebengineview_p.h +++ b/src/webenginewidgets/api/qwebengineview_p.h @@ -80,9 +80,9 @@ public: QWebEngineViewAccessible(QWebEngineView *o) : QAccessibleWidget(o) {} - int childCount() const Q_DECL_OVERRIDE; - QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE; - int indexOfChild(const QAccessibleInterface *child) const Q_DECL_OVERRIDE; + int childCount() const override; + QAccessibleInterface *child(int index) const override; + int indexOfChild(const QAccessibleInterface *child) const override; private: QWebEngineView *view() const { return static_cast<QWebEngineView*>(object()); } diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc index 4cad5a063..eb91d576d 100644 --- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc @@ -584,6 +584,14 @@ This signal is emitted whenever the document wants to change the position and size of the page to \a geom. This can happen for example through JavaScript. + + \note \l{QWindow::}{setGeometry()} expects a size excluding the window + decoration, while \a geom includes it. You have to remove the size of the frame margins + from \a geom to handle this signal correctly. + + \code + window->setGeometry(geom.marginsRemoved(window->frameMargins())); + \endcode */ /*! diff --git a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc index 3fe87082a..8bd8227ec 100644 --- a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc @@ -169,7 +169,29 @@ \value ShowScrollBars Shows scroll bars. Enabled by default. (Added in Qt 5.10) + \value PlaybackRequiresUserGesture + Inhibits playback of media content until the user interacts with + the page. This is similar to how Chrome on Android behaves, while + the default behavior when it is disabled is similar to Chrome on desktops. + Disabled by default. (Added in Qt 5.11) +*/ + +/*! + \enum QWebEngineSettings::UnknownUrlSchemePolicy + \since Qt 5.11 + + This enum describes how navigation requests to URLs with unknown schemes are handled. + \value DisallowUnknownUrlSchemes + Disallows all navigation requests to URLs with unknown schemes. + \value AllowUnknownUrlSchemesFromUserInteraction + Allows navigation requests to URLs with unknown schemes that are issued from + user-interaction (like a mouse-click), whereas other navigation requests (for example + from JavaScript) are suppressed. + \value AllowAllUnknownUrlSchemes + Allows all navigation requests to URLs with unknown schemes. + + \sa unknownUrlSchemePolicy setUnknownUrlSchemePolicy resetUnknownUrlSchemePolicy */ /*! @@ -225,6 +247,29 @@ */ /*! + \fn QWebEngineSettings::UnknownUrlSchemePolicy QWebEngineSettings::unknownUrlSchemePolicy() const + \since Qt 5.11 + Returns the currently selected policy for handling navigation requests to URLs with + unknown schemes. Default is \l{QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction}. + \sa setUnknownUrlSchemePolicy resetUnknownUrlSchemePolicy +*/ + +/*! + \fn void QWebEngineSettings::setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy policy) + \since Qt 5.11 + Sets the policy for handling navigation requests to URLs with unknown schemes to \a policy. + Default is \l{QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction}. + \sa unknownUrlSchemePolicy resetUnknownUrlSchemePolicy +*/ + +/*! + \fn void QWebEngineSettings::resetUnknownUrlSchemePolicy() + \since Qt 5.11 + Removes the policy for handling navigation requests to URLs with unknown schemes. + \sa unknownUrlSchemePolicy setUnknownUrlSchemePolicy +*/ + +/*! \fn void QWebEngineSettings::setAttribute(WebAttribute attribute, bool on) Enables or disables the specified \a attribute feature depending on the diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h index f3e9da2cc..79958132c 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h @@ -53,38 +53,38 @@ class RenderWidgetHostViewQtDelegateWidget : public QQuickWidget, public RenderW public: RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent = 0); - virtual void initAsChild(WebContentsAdapterClient* container) Q_DECL_OVERRIDE; - virtual void initAsPopup(const QRect&) Q_DECL_OVERRIDE; - virtual QRectF screenRect() const Q_DECL_OVERRIDE; - virtual QRectF contentsRect() const Q_DECL_OVERRIDE; - virtual void setKeyboardFocus() Q_DECL_OVERRIDE; - virtual bool hasKeyboardFocus() Q_DECL_OVERRIDE; - virtual void lockMouse() Q_DECL_OVERRIDE; - virtual void unlockMouse() Q_DECL_OVERRIDE; - virtual void show() Q_DECL_OVERRIDE; - virtual void hide() Q_DECL_OVERRIDE; - virtual bool isVisible() const Q_DECL_OVERRIDE; - virtual QWindow* window() const Q_DECL_OVERRIDE; - virtual QSGTexture *createTextureFromImage(const QImage &) Q_DECL_OVERRIDE; - virtual QSGLayer *createLayer() Q_DECL_OVERRIDE; - virtual QSGInternalImageNode *createImageNode() Q_DECL_OVERRIDE; - virtual QSGTextureNode *createTextureNode() Q_DECL_OVERRIDE; - virtual QSGRectangleNode *createRectangleNode() Q_DECL_OVERRIDE; - virtual void update() Q_DECL_OVERRIDE; - virtual void updateCursor(const QCursor &) Q_DECL_OVERRIDE; - virtual void resize(int width, int height) Q_DECL_OVERRIDE; - virtual void move(const QPoint &screenPos) Q_DECL_OVERRIDE; - virtual void inputMethodStateChanged(bool editorVisible, bool passwordInput) Q_DECL_OVERRIDE; - virtual void setInputMethodHints(Qt::InputMethodHints) Q_DECL_OVERRIDE; - virtual void setClearColor(const QColor &color) Q_DECL_OVERRIDE; + void initAsChild(WebContentsAdapterClient* container) override; + void initAsPopup(const QRect&) override; + QRectF screenRect() const override; + QRectF contentsRect() const override; + void setKeyboardFocus() override; + bool hasKeyboardFocus() override; + void lockMouse() override; + void unlockMouse() override; + void show() override; + void hide() override; + bool isVisible() const override; + QWindow* window() const override; + QSGTexture *createTextureFromImage(const QImage &) override; + QSGLayer *createLayer() override; + QSGInternalImageNode *createImageNode() override; + QSGTextureNode *createTextureNode() override; + QSGRectangleNode *createRectangleNode() override; + void update() override; + void updateCursor(const QCursor &) override; + void resize(int width, int height) override; + void move(const QPoint &screenPos) override; + void inputMethodStateChanged(bool editorVisible, bool passwordInput) override; + void setInputMethodHints(Qt::InputMethodHints) override; + void setClearColor(const QColor &color) override; protected: - bool event(QEvent *event) Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent *resizeEvent) Q_DECL_OVERRIDE; - void showEvent(QShowEvent *) Q_DECL_OVERRIDE; - void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *event) override; + void resizeEvent(QResizeEvent *resizeEvent) override; + void showEvent(QShowEvent *) override; + void hideEvent(QHideEvent *) override; - QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE; + QVariant inputMethodQuery(Qt::InputMethodQuery query) const override; private slots: void onWindowPosChanged(); diff --git a/src/webenginewidgets/ui/messagebubblewidget_p.h b/src/webenginewidgets/ui/messagebubblewidget_p.h index 8815d1ba4..6898aea13 100644 --- a/src/webenginewidgets/ui/messagebubblewidget_p.h +++ b/src/webenginewidgets/ui/messagebubblewidget_p.h @@ -73,7 +73,7 @@ public: static void moveBubble(QWebEngineView *view, const QRect &anchor); protected: - void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) override; private: void createBubble(const int maxWidth, const QString &mainText, const QString &subText); diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro index 540c4d538..37cb7a1f0 100644 --- a/src/webenginewidgets/webenginewidgets.pro +++ b/src/webenginewidgets/webenginewidgets.pro @@ -19,6 +19,7 @@ SOURCES = \ api/qwebenginehistory.cpp \ api/qwebenginepage.cpp \ api/qwebengineprofile.cpp \ + api/qwebenginequotapermissionrequest.cpp \ api/qwebenginescript.cpp \ api/qwebenginescriptcollection.cpp \ api/qwebenginesettings.cpp \ @@ -37,6 +38,7 @@ HEADERS = \ api/qwebenginepage_p.h \ api/qwebengineprofile.h \ api/qwebengineprofile_p.h \ + api/qwebenginequotapermissionrequest.h \ api/qwebenginescriptcollection.h \ api/qwebenginescriptcollection_p.h \ api/qwebenginesettings.h \ |