summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-04-13 17:25:16 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-04-13 17:25:16 +0200
commit2dce0008ce53d27d281ad2dc00eb32d25ae5fc84 (patch)
tree55d97b68f56b78f3388cdaaa4ae69648b7057f68
parent919dd97e835f469609a0710eb91f829a6d70e88c (diff)
parent8fe660ecbbe1f126ce0da694adff956ad7159870 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
m---------src/3rdparty0
-rw-r--r--src/core/content_browser_client_qt.cpp13
-rw-r--r--src/core/core_chromium.pri4
-rw-r--r--src/core/devtools_frontend_qt.cpp2
-rw-r--r--src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp219
-rw-r--r--src/core/extensions/pdf_iframe_navigation_throttle_qt.h (renamed from src/core/renderer/plugins/plugin_placeholder_qt.h)54
-rw-r--r--src/core/net/webui_controller_factory_qt.cpp6
-rw-r--r--src/core/qtwebengine_resources.gni2
-rw-r--r--src/core/qtwebengine_sources.gni2
-rw-r--r--src/core/renderer/content_renderer_client_qt.cpp1
-rw-r--r--src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp2
-rw-r--r--src/core/renderer/plugins/plugin_placeholder_qt.cpp75
-rw-r--r--src/core/web_contents_adapter.cpp1
-rw-r--r--src/pdf/config/common.pri11
-rw-r--r--src/pdf/pdfcore.pro8
-rw-r--r--src/pdf/quick/qquickpdfsearchmodel.cpp4
-rw-r--r--src/webenginequick/api/qquickwebengineview.cpp5
-rw-r--r--src/webenginequick/api/qquickwebengineview_p.h6
-rw-r--r--src/webenginequick/api/qtwebengineglobal.cpp3
-rw-r--r--tests/auto/quick/publicapi/tst_publicapi.cpp2
-rw-r--r--tests/auto/quick/qmltests/data/tst_navigationHistory.qml48
-rw-r--r--tests/auto/quick/qquickwebengineprofile/qquickwebengineprofile.pro1
-rw-r--r--tests/auto/quick/qquickwebengineprofile/tst_qquickwebengineprofile.cpp73
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp24
24 files changed, 373 insertions, 193 deletions
diff --git a/src/3rdparty b/src/3rdparty
-Subproject 7c8217b36a95e29f7a7832b177e3df8a3308365
+Subproject d13920f28c2f3922e0cf793996ea33d02b81a0a
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index fa960c58c..3bf381a6d 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -163,6 +163,7 @@
#include "extensions/common/manifest_handlers/mime_types_handler.h"
#include "extensions/extension_web_contents_observer_qt.h"
#include "extensions/extensions_browser_client_qt.h"
+#include "extensions/pdf_iframe_navigation_throttle_qt.h"
#include "net/plugin_response_interceptor_url_loader_throttle.h"
#endif
@@ -218,6 +219,13 @@ bool IsHandledProtocol(base::StringPiece scheme)
namespace QtWebEngineCore {
+void MaybeAddThrottle(
+ std::unique_ptr<content::NavigationThrottle> maybe_throttle,
+ std::vector<std::unique_ptr<content::NavigationThrottle>>* throttles) {
+ if (maybe_throttle)
+ throttles->push_back(std::move(maybe_throttle));
+}
+
ContentBrowserClientQt::ContentBrowserClientQt()
{
}
@@ -884,6 +892,11 @@ std::vector<std::unique_ptr<content::NavigationThrottle>> ContentBrowserClientQt
navigation_handle,
base::BindRepeating(&navigationThrottleCallback),
navigation_interception::SynchronyMode::kSync));
+
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+ MaybeAddThrottle(extensions::PDFIFrameNavigationThrottleQt::MaybeCreateThrottleFor(navigation_handle), &throttles);
+#endif
+
return throttles;
}
diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri
index a42ee4aff..90c44b69c 100644
--- a/src/core/core_chromium.pri
+++ b/src/core/core_chromium.pri
@@ -115,7 +115,6 @@ SOURCES = \
renderer/web_engine_page_render_frame.cpp \
renderer/render_configuration.cpp \
renderer/user_resource_controller.cpp \
- renderer/plugins/plugin_placeholder_qt.cpp \
renderer_host/web_engine_page_host.cpp \
renderer_host/user_resource_controller_host.cpp \
resource_bundle_qt.cpp \
@@ -221,7 +220,6 @@ HEADERS = \
renderer/web_engine_page_render_frame.h \
renderer/render_configuration.h \
renderer/user_resource_controller.h \
- renderer/plugins/plugin_placeholder_qt.h \
renderer_host/web_engine_page_host.h \
renderer_host/user_resource_controller_host.h \
request_controller.h \
@@ -331,6 +329,7 @@ qtConfig(webengine-extensions) {
extensions/extensions_browser_client_qt.cpp \
extensions/messaging_delegate_qt.cpp \
extensions/mime_handler_view_guest_delegate_qt.cpp \
+ extensions/pdf_iframe_navigation_throttle_qt.cpp \
extensions/plugin_service_filter_qt.cpp \
net/plugin_response_interceptor_url_loader_throttle.cpp \
renderer/extensions/extensions_dispatcher_delegate_qt.cpp \
@@ -350,6 +349,7 @@ qtConfig(webengine-extensions) {
extensions/extensions_browser_client_qt.h \
extensions/messaging_delegate_qt.h \
extensions/mime_handler_view_guest_delegate_qt.h \
+ extensions/pdf_iframe_navigation_throttle_qt.h \
extensions/plugin_service_filter_qt.h \
net/plugin_response_interceptor_url_loader_throttle.h \
renderer/extensions/extensions_dispatcher_delegate_qt.h \
diff --git a/src/core/devtools_frontend_qt.cpp b/src/core/devtools_frontend_qt.cpp
index 553757fbb..440c52d33 100644
--- a/src/core/devtools_frontend_qt.cpp
+++ b/src/core/devtools_frontend_qt.cpp
@@ -118,7 +118,7 @@ std::unique_ptr<base::DictionaryValue> BuildObjectForResponse(const net::HttpRes
static std::string GetFrontendURL()
{
- return "devtools://devtools/bundled/devtools_app.html";
+ return "devtools://devtools/bundled/inspector.html";
}
} // namespace
diff --git a/src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp b/src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp
new file mode 100644
index 000000000..7c2fe75f0
--- /dev/null
+++ b/src/core/extensions/pdf_iframe_navigation_throttle_qt.cpp
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 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/plugins/pdf_iframe_navigation_throttle.cc
+// Copyright 2017 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 "extensions/pdf_iframe_navigation_throttle_qt.h"
+
+#include "chrome/grit/renderer_resources.h"
+#include "components/strings/grit/components_strings.h"
+#include "content/public/browser/download_utils.h"
+#include "content/public/browser/navigation_handle.h"
+#include "content/public/browser/plugin_service.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_user_data.h"
+#include "content/public/common/webplugininfo.h"
+#include "net/base/escape.h"
+#include "net/http/http_response_headers.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/webui/jstemplate_builder.h"
+#include "ui/base/webui/web_ui_util.h"
+
+namespace extensions {
+
+constexpr char kPDFMimeType[] = "application/pdf";
+
+// Used to scope the posted navigation task to the lifetime of |web_contents|.
+class PdfWebContentsLifetimeHelper : public content::WebContentsUserData<PdfWebContentsLifetimeHelper>
+{
+public:
+ explicit PdfWebContentsLifetimeHelper(content::WebContents *web_contents)
+ : web_contents_(web_contents)
+ {}
+
+ base::WeakPtr<PdfWebContentsLifetimeHelper> GetWeakPtr()
+ {
+ return weak_factory_.GetWeakPtr();
+ }
+
+ void NavigateIFrameToPlaceholder(const content::OpenURLParams &url_params)
+ {
+ web_contents_->OpenURL(url_params);
+ }
+
+private:
+ friend class content::WebContentsUserData<PdfWebContentsLifetimeHelper>;
+
+ content::WebContents* const web_contents_;
+ base::WeakPtrFactory<PdfWebContentsLifetimeHelper> weak_factory_{this};
+
+ WEB_CONTENTS_USER_DATA_KEY_DECL();
+};
+
+WEB_CONTENTS_USER_DATA_KEY_IMPL(PdfWebContentsLifetimeHelper)
+
+bool IsPDFPluginEnabled(content::NavigationHandle *navigation_handle, bool *is_stale)
+{
+ content::WebContents *web_contents = navigation_handle->GetWebContents();
+ int process_id = web_contents->GetMainFrame()->GetProcess()->GetID();
+ int routing_id = web_contents->GetMainFrame()->GetRoutingID();
+ content::WebPluginInfo plugin_info;
+ // Will check WebEngineSettings by PluginServiceFilterQt
+ return content::PluginService::GetInstance()->GetPluginInfo(
+ process_id, routing_id, navigation_handle->GetURL(),
+ web_contents->GetMainFrame()->GetLastCommittedOrigin(), kPDFMimeType,
+ false /* allow_wildcard */, is_stale, &plugin_info,
+ nullptr /* actual_mime_type */);
+}
+
+std::string GetPDFPlaceholderHTML(const GURL &pdf_url)
+{
+ std::string template_html = ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(IDR_PDF_PLUGIN_HTML);
+ webui::AppendWebUiCssTextDefaults(&template_html);
+
+ base::DictionaryValue values;
+ values.SetString("fileName", pdf_url.ExtractFileName());
+ values.SetString("open", l10n_util::GetStringUTF8(IDS_ACCNAME_OPEN));
+ values.SetString("pdfUrl", pdf_url.spec());
+
+ return webui::GetI18nTemplateHtml(template_html, &values);
+}
+
+// static
+std::unique_ptr<content::NavigationThrottle>
+PDFIFrameNavigationThrottleQt::MaybeCreateThrottleFor(content::NavigationHandle *handle)
+{
+ if (handle->IsInMainFrame())
+ return nullptr;
+ return std::make_unique<PDFIFrameNavigationThrottleQt>(handle);
+}
+
+PDFIFrameNavigationThrottleQt::PDFIFrameNavigationThrottleQt(content::NavigationHandle *handle)
+ : content::NavigationThrottle(handle)
+{
+}
+
+PDFIFrameNavigationThrottleQt::~PDFIFrameNavigationThrottleQt()
+{
+}
+
+content::NavigationThrottle::ThrottleCheckResult PDFIFrameNavigationThrottleQt::WillProcessResponse()
+{
+ const net::HttpResponseHeaders *response_headers = navigation_handle()->GetResponseHeaders();
+ if (!response_headers)
+ return content::NavigationThrottle::PROCEED;
+
+ std::string mime_type;
+ response_headers->GetMimeType(&mime_type);
+ if (mime_type != kPDFMimeType)
+ return content::NavigationThrottle::PROCEED;
+
+ // We MUST download responses marked as attachments rather than showing
+ // a placeholder.
+ if (content::download_utils::MustDownload(navigation_handle()->GetURL(), response_headers, mime_type))
+ return content::NavigationThrottle::PROCEED;
+
+ bool is_stale = false;
+ bool pdf_plugin_enabled = IsPDFPluginEnabled(navigation_handle(), &is_stale);
+
+ if (is_stale) {
+ // On browser start, the plugin list may not be ready yet.
+ content::PluginService::GetInstance()->GetPlugins(
+ base::BindOnce(&PDFIFrameNavigationThrottleQt::OnPluginsLoaded,
+ weak_factory_.GetWeakPtr()));
+ return content::NavigationThrottle::DEFER;
+ }
+
+ // If the plugin was found, proceed on the navigation. Otherwise fall through
+ // to the placeholder case.
+ if (pdf_plugin_enabled)
+ return content::NavigationThrottle::PROCEED;
+
+ LoadPlaceholderHTML();
+ return content::NavigationThrottle::CANCEL_AND_IGNORE;
+}
+
+const char *PDFIFrameNavigationThrottleQt::GetNameForLogging()
+{
+ return "PDFIFrameNavigationThrottleQt";
+}
+
+void PDFIFrameNavigationThrottleQt::OnPluginsLoaded(
+ const std::vector<content::WebPluginInfo> &plugins)
+{
+ if (IsPDFPluginEnabled(navigation_handle(), nullptr /* is_stale */)) {
+ Resume();
+ } else {
+ LoadPlaceholderHTML();
+ CancelDeferredNavigation(content::NavigationThrottle::CANCEL_AND_IGNORE);
+ }
+}
+
+void PDFIFrameNavigationThrottleQt::LoadPlaceholderHTML()
+{
+ // Prepare the params to navigate to the placeholder.
+ std::string html = GetPDFPlaceholderHTML(navigation_handle()->GetURL());
+ GURL data_url("data:text/html," + net::EscapePath(html));
+ content::OpenURLParams params = content::OpenURLParams::FromNavigationHandle(navigation_handle());
+ params.url = data_url;
+ params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
+
+ // Post a task to navigate to the placeholder HTML. We don't navigate
+ // synchronously here, as starting a navigation within a navigation is
+ // an antipattern. Use a helper object scoped to the WebContents lifetime to
+ // scope the navigation task to the WebContents lifetime.
+ content::WebContents *web_contents = navigation_handle()->GetWebContents();
+ if (!web_contents)
+ return;
+
+ PdfWebContentsLifetimeHelper::CreateForWebContents(web_contents);
+ PdfWebContentsLifetimeHelper *helper = PdfWebContentsLifetimeHelper::FromWebContents(web_contents);
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::BindOnce(&PdfWebContentsLifetimeHelper::NavigateIFrameToPlaceholder,
+ helper->GetWeakPtr(), std::move(params)));
+}
+
+} // namespace extensions
diff --git a/src/core/renderer/plugins/plugin_placeholder_qt.h b/src/core/extensions/pdf_iframe_navigation_throttle_qt.h
index a99c0d045..37f5bf1d6 100644
--- a/src/core/renderer/plugins/plugin_placeholder_qt.h
+++ b/src/core/extensions/pdf_iframe_navigation_throttle_qt.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -37,42 +37,46 @@
**
****************************************************************************/
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// based on //chrome/browser/plugins/pdf_iframe_navigation_throttle.h
+// Copyright 2017 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.
-#ifndef PLUGIN_PLACEHOLDER_QT_H
-#define PLUGIN_PLACEHOLDER_QT_H
+#ifndef PDF_IFRAME_NAVIGATION_THROTTLE_QT
+#define PDF_IFRAME_NAVIGATION_THROTTLE_QT
-#include "base/macros.h"
-#include "components/plugins/renderer/plugin_placeholder.h"
-#include "gin/handle.h"
-#include "gin/wrappable.h"
-#include "third_party/blink/public/web/web_plugin_params.h"
+#include "content/public/browser/navigation_throttle.h"
-namespace QtWebEngineCore {
+#include "base/memory/weak_ptr.h"
-// A basic placeholder that supports only hiding.
-class PluginPlaceholderQt final : public plugins::PluginPlaceholderBase
- , public gin::Wrappable<PluginPlaceholderQt>
+namespace content {
+class NavigationHandle;
+struct WebPluginInfo;
+}
+
+namespace extensions {
+
+// This class prevents automatical download of PDFs when they are embedded
+// in subframes and plugins are disabled in API.
+class PDFIFrameNavigationThrottleQt : public content::NavigationThrottle
{
public:
- static gin::WrapperInfo kWrapperInfo;
+ static std::unique_ptr<content::NavigationThrottle> MaybeCreateThrottleFor(content::NavigationHandle *handle);
+
+ explicit PDFIFrameNavigationThrottleQt(content::NavigationHandle *handle);
+ ~PDFIFrameNavigationThrottleQt() override;
- PluginPlaceholderQt(content::RenderFrame* render_frame,
- const blink::WebPluginParams& params,
- const std::string& html_data);
- ~PluginPlaceholderQt() override;
+ // content::NavigationThrottle
+ content::NavigationThrottle::ThrottleCheckResult WillProcessResponse() override;
+ const char *GetNameForLogging() override;
private:
- // WebViewPlugin::Delegate methods:
- v8::Local<v8::Value> GetV8Handle(v8::Isolate* isolate) final;
+ void OnPluginsLoaded(const std::vector<content::WebPluginInfo> &plugins);
+ void LoadPlaceholderHTML();
- // gin::Wrappable method:
- gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
- v8::Isolate* isolate) override;
+ base::WeakPtrFactory<PDFIFrameNavigationThrottleQt> weak_factory_{this};
};
-} // namespace QtWebEngineCore
+} // namespace extensions
-#endif // PLUGIN_PLACEHOLDER_QT_H
+#endif // PDF_IFRAME_NAVIGATION_THROTTLE_QT
diff --git a/src/core/net/webui_controller_factory_qt.cpp b/src/core/net/webui_controller_factory_qt.cpp
index 59c5ca205..b645a6d72 100644
--- a/src/core/net/webui_controller_factory_qt.cpp
+++ b/src/core/net/webui_controller_factory_qt.cpp
@@ -51,6 +51,7 @@
#include "chrome/browser/accessibility/accessibility_ui.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/devtools_ui.h"
+#include "chrome/browser/ui/webui/net_internals/net_internals_ui.h"
#include "chrome/browser/ui/webui/quota_internals/quota_internals_ui.h"
#include "chrome/browser/ui/webui/user_actions/user_actions_ui.h"
#include "chrome/common/url_constants.h"
@@ -116,6 +117,8 @@ std::unique_ptr<WebUIController> NewWebUI(WebUI *web_ui, const GURL & /*url*/)
// with it.
WebUIFactoryFunction GetWebUIFactoryFunction(WebUI *web_ui, Profile *profile, const GURL &url)
{
+ Q_UNUSED(web_ui);
+ Q_UNUSED(profile);
// 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))
@@ -123,6 +126,9 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI *web_ui, Profile *profile, co
// We must compare hosts only since some of the Web UIs append extra stuff
// after the host name.
+ if (url.host() == chrome::kChromeUINetInternalsHost)
+ return &NewWebUI<NetInternalsUI>;
+
if (url.host() == chrome::kChromeUIQuotaInternalsHost)
return &NewWebUI<QuotaInternalsUI>;
diff --git a/src/core/qtwebengine_resources.gni b/src/core/qtwebengine_resources.gni
index 8eee4ada0..3bf1a5d57 100644
--- a/src/core/qtwebengine_resources.gni
+++ b/src/core/qtwebengine_resources.gni
@@ -22,6 +22,7 @@ repack("qtwebengine_repack_resources") {
sources = [
"$root_gen_dir/qtwebengine/qt_webengine_resources.pak",
"$root_gen_dir/chrome/common_resources.pak",
+ "$root_gen_dir/chrome/net_internals_resources.pak",
"$root_gen_dir/chrome/quota_internals_resources.pak",
"$root_gen_dir/components/components_resources.pak",
"$root_gen_dir/components/dev_ui_components_resources.pak",
@@ -37,6 +38,7 @@ repack("qtwebengine_repack_resources") {
output = "$root_out_dir/qtwebengine_resources.pak"
deps = [
"//qtwebengine/browser:qt_webengine_resources",
+ "//chrome/browser/resources/net_internals:net_internals_resources",
"//chrome/browser/resources/quota_internals:quota_internals_resources",
"//chrome/common:resources_grit",
"//components/resources:components_resources_grit",
diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni
index b14fc1049..8f3c1ae20 100644
--- a/src/core/qtwebengine_sources.gni
+++ b/src/core/qtwebengine_sources.gni
@@ -90,6 +90,8 @@ source_set("qtwebengine_sources") {
"//chrome/browser/ui/webui/devtools_ui.h",
"//chrome/browser/ui/webui/devtools_ui_data_source.cc",
"//chrome/browser/ui/webui/devtools_ui_data_source.h",
+ "//chrome/browser/ui/webui/net_internals/net_internals_ui.cc",
+ "//chrome/browser/ui/webui/net_internals/net_internals_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",
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp
index ed7f98f23..ad559ae54 100644
--- a/src/core/renderer/content_renderer_client_qt.cpp
+++ b/src/core/renderer/content_renderer_client_qt.cpp
@@ -96,7 +96,6 @@
#if BUILDFLAG(ENABLE_PLUGINS)
#include "plugins/loadable_plugin_placeholder_qt.h"
-#include "plugins/plugin_placeholder_qt.h"
#include "content/common/frame_messages.h"
#endif // ENABLE_PLUGINS
diff --git a/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp b/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp
index b43d9a24b..9dc5fbd94 100644
--- a/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp
+++ b/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp
@@ -77,7 +77,7 @@ LoadablePluginPlaceholderQt::~LoadablePluginPlaceholderQt()
LoadablePluginPlaceholderQt* LoadablePluginPlaceholderQt::CreateLoadableMissingPlugin(content::RenderFrame* render_frame,
const blink::WebPluginParams& params)
{
- const base::StringPiece template_html(ui::ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_BLOCKED_PLUGIN_HTML));
+ std::string template_html(ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(IDR_BLOCKED_PLUGIN_HTML));
base::DictionaryValue values;
values.SetString("name", "");
diff --git a/src/core/renderer/plugins/plugin_placeholder_qt.cpp b/src/core/renderer/plugins/plugin_placeholder_qt.cpp
deleted file mode 100644
index a72c29873..000000000
--- a/src/core/renderer/plugins/plugin_placeholder_qt.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 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$
-**
-****************************************************************************/
-
-// 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 file.
-
-#include "plugin_placeholder_qt.h"
-
-#include "content/public/renderer/render_frame.h"
-#include "content/public/renderer/v8_value_converter.h"
-#include "gin/object_template_builder.h"
-
-namespace QtWebEngineCore {
-
-// static
-gin::WrapperInfo PluginPlaceholderQt::kWrapperInfo = {gin::kEmbedderNativeGin};
-
-PluginPlaceholderQt::PluginPlaceholderQt(content::RenderFrame* render_frame,
- const blink::WebPluginParams& params,
- const std::string& html_data)
- : PluginPlaceholderBase(render_frame, params, html_data)
-{}
-
-PluginPlaceholderQt::~PluginPlaceholderQt() {}
-
-v8::Local<v8::Value> PluginPlaceholderQt::GetV8Handle(v8::Isolate* isolate)
-{
- return gin::CreateHandle(isolate, this).ToV8();
-}
-
-gin::ObjectTemplateBuilder PluginPlaceholderQt::GetObjectTemplateBuilder(v8::Isolate* isolate)
-{
- return gin::Wrappable<PluginPlaceholderQt>::GetObjectTemplateBuilder(isolate)
- .SetMethod<void (QtWebEngineCore::PluginPlaceholderQt::*)()>(
- "hide", &PluginPlaceholderQt::HideCallback);
-}
-
-} // namespace QtWebEngineCore
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 0f41a53cb..ca39faf7d 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -382,6 +382,7 @@ void Navigate(WebContentsAdapter *adapter, const content::NavigationController::
adapter->webContents()->GetController().LoadURLWithParams(params);
adapter->focusIfNecessary();
adapter->resetSelection();
+ adapter->findTextHelper()->stopFinding();
}
void NavigateTask(QWeakPointer<WebContentsAdapter> weakAdapter, const content::NavigationController::LoadURLParams &params)
diff --git a/src/pdf/config/common.pri b/src/pdf/config/common.pri
index afd96c881..7e5459a2a 100644
--- a/src/pdf/config/common.pri
+++ b/src/pdf/config/common.pri
@@ -24,12 +24,21 @@ qtConfig(webengine-qt-freetype) {
}
qtConfig(webengine-qt-zlib) {
+ win32 {
+ CONFIG(debug, debug|release) {
+ qtzlib = Qt5Cored.lib
+ } else {
+ qtzlib = Qt5Core.lib
+ }
+
+ } else { qtzlib = libQt5Core.a
+ }
gn_args += use_qt_zlib = true
gn_args += "qt_zlib_includes=\["\
"\"$$system_path($$[QT_INSTALL_HEADERS])\"," \
"\"$$system_path($$[QT_INSTALL_HEADERS]/QtCore)\"," \
"\"$$system_path($$[QT_INSTALL_HEADERS]/QtZlib)\"\]"
- gn_args += "qt_zlib=\"$$system_path($$[QT_INSTALL_LIBS]/libQt5Core.a)\""
+ gn_args += "qt_zlib=\"$$system_path($$[QT_INSTALL_LIBS]/$$qtzlib)\""
}
qtConfig(pdf-v8) {
diff --git a/src/pdf/pdfcore.pro b/src/pdf/pdfcore.pro
index 998cddb7d..bb7146853 100644
--- a/src/pdf/pdfcore.pro
+++ b/src/pdf/pdfcore.pro
@@ -78,10 +78,10 @@ HEADERS += \
api/qpdfselection_p.h \
-qtConfig(webengine-qt-freetype): QMAKE_USE_PRIVATE+= freetype
-qtConfig(webengine-qt-png): QMAKE_USE_PRIVATE+= libpng
-qtConfig(webengine-qt-harfbuzz): QMAKE_USE_PRIVATE+= harfbuzz
-#qtConfig(webengine-qt-jpeg): QMAKE_USE_PRIVATE+= libjpeg
+qtConfig(webengine-qt-freetype): QMAKE_USE += freetype
+qtConfig(webengine-qt-png): QMAKE_USE += libpng
+qtConfig(webengine-qt-harfbuzz): QMAKE_USE += harfbuzz
+#qtConfig(webengine-qt-jpeg): QMAKE_USE += libjpeg
qtConfig(webengine-qt-zlib){} #qtzlib is a part of QtCore
load(qt_module)
diff --git a/src/pdf/quick/qquickpdfsearchmodel.cpp b/src/pdf/quick/qquickpdfsearchmodel.cpp
index a39178ba3..d91ca69f8 100644
--- a/src/pdf/quick/qquickpdfsearchmodel.cpp
+++ b/src/pdf/quick/qquickpdfsearchmodel.cpp
@@ -39,7 +39,7 @@
QT_BEGIN_NAMESPACE
-Q_LOGGING_CATEGORY(qLcS, "qt.pdf.search")
+Q_LOGGING_CATEGORY(qLcSearch, "qt.pdf.search")
/*!
\qmltype PdfSearchModel
@@ -282,7 +282,7 @@ void QQuickPdfSearchModel::setCurrentResult(int currentResult)
currentResult = 0;
}
}
- qCDebug(qLcS) << "currentResult was" << m_currentResult
+ qCDebug(qLcSearch) << "currentResult was" << m_currentResult
<< "requested" << currentResultWas << "on page" << currentPageWas
<< "->" << currentResult << "on page" << m_currentPage;
diff --git a/src/webenginequick/api/qquickwebengineview.cpp b/src/webenginequick/api/qquickwebengineview.cpp
index 5456219fa..494e26090 100644
--- a/src/webenginequick/api/qquickwebengineview.cpp
+++ b/src/webenginequick/api/qquickwebengineview.cpp
@@ -888,6 +888,11 @@ QQuickWebEngineView::QQuickWebEngineView(QQuickItem *parent)
d->q_ptr = this;
this->setActiveFocusOnTab(true);
this->setFlags(QQuickItem::ItemIsFocusScope | QQuickItem::ItemAcceptsDrops);
+
+ connect(action(WebAction::Back), &QQuickWebEngineAction::enabledChanged,
+ this, &QQuickWebEngineView::canGoBackChanged);
+ connect(action(WebAction::Forward), &QQuickWebEngineAction::enabledChanged,
+ this, &QQuickWebEngineView::canGoForwardChanged);
}
QQuickWebEngineView::~QQuickWebEngineView()
diff --git a/src/webenginequick/api/qquickwebengineview_p.h b/src/webenginequick/api/qquickwebengineview_p.h
index bb89d23bb..df5880e73 100644
--- a/src/webenginequick/api/qquickwebengineview_p.h
+++ b/src/webenginequick/api/qquickwebengineview_p.h
@@ -103,8 +103,8 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(bool loading READ isLoading NOTIFY loadingChanged FINAL)
Q_PROPERTY(int loadProgress READ loadProgress NOTIFY loadProgressChanged FINAL)
Q_PROPERTY(QString title READ title NOTIFY titleChanged FINAL)
- Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY urlChanged FINAL)
- Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY urlChanged FINAL)
+ Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY canGoBackChanged FINAL)
+ Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY canGoForwardChanged FINAL)
Q_PROPERTY(bool isFullScreen READ isFullScreen NOTIFY isFullScreenChanged REVISION 1 FINAL)
Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged REVISION 1 FINAL)
Q_PROPERTY(QQuickWebEngineProfile *profile READ profile WRITE setProfile NOTIFY profileChanged FINAL REVISION 1)
@@ -570,6 +570,8 @@ Q_SIGNALS:
Q_REVISION(10) void recommendedStateChanged(LifecycleState state);
Q_REVISION(10) void findTextFinished(const QWebEngineFindTextResult &result);
Q_REVISION(11) void renderProcessPidChanged(qint64 pid);
+ Q_REVISION(11) void canGoBackChanged();
+ Q_REVISION(11) void canGoForwardChanged();
#if QT_CONFIG(webenginequick_testsupport)
void testSupportChanged();
diff --git a/src/webenginequick/api/qtwebengineglobal.cpp b/src/webenginequick/api/qtwebengineglobal.cpp
index 825805888..7d2b91e90 100644
--- a/src/webenginequick/api/qtwebengineglobal.cpp
+++ b/src/webenginequick/api/qtwebengineglobal.cpp
@@ -73,8 +73,7 @@ namespace QtWebEngine {
*/
void initialize()
{
- QCoreApplication *app = QCoreApplication::instance();
- if (app) {
+ if (!QCoreApplication::startingUp()) {
qWarning("QtWebEngine::initialize() called with QCoreApplication object already created and should be call before. "\
"This is depreciated and may fail in the future.");
QtWebEngineCore::initialize();
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp
index a4c478991..1b4d06aac 100644
--- a/tests/auto/quick/publicapi/tst_publicapi.cpp
+++ b/tests/auto/quick/publicapi/tst_publicapi.cpp
@@ -680,7 +680,9 @@ static const QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.backgroundColor --> QColor"
<< "QQuickWebEngineView.backgroundColorChanged() --> void"
<< "QQuickWebEngineView.canGoBack --> bool"
+ << "QQuickWebEngineView.canGoBackChanged() --> void"
<< "QQuickWebEngineView.canGoForward --> bool"
+ << "QQuickWebEngineView.canGoForwardChanged() --> void"
<< "QQuickWebEngineView.certificateError(QWebEngineCertificateError) --> void"
<< "QQuickWebEngineView.colorDialogRequested(QQuickWebEngineColorDialogRequest*) --> void"
<< "QQuickWebEngineView.contentsSize --> QSizeF"
diff --git a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
index 6ed232589..47be2f47d 100644
--- a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
+++ b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
@@ -26,7 +26,8 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.15
+import QtQuick.Controls 2.15
import QtTest 1.0
import QtWebEngine 1.2
@@ -59,11 +60,25 @@ TestWebEngineView {
}
}
+ Button {
+ id: backButton
+ text: "Back"
+ enabled: webEngineView.canGoBack
+ onClicked: webEngineView.goBack()
+ }
+
+ Button {
+ id: forwardButton
+ text: "Forward"
+ enabled: webEngineView.canGoForward
+ onClicked: webEngineView.goForward()
+ }
+
TestCase {
name: "WebEngineViewNavigationHistory"
function test_navigationHistory() {
- compare(webEngineView.loadProgress, 0)
+ webEngineView.navigationHistory.clear()
webEngineView.url = Qt.resolvedUrl("test1.html")
verify(webEngineView.waitForLoadSucceeded())
@@ -142,5 +157,34 @@ TestWebEngineView {
compare(backItemsList.count, 0)
compare(forwardItemsList.count, 0)
}
+
+ function test_navigationButtons() {
+ webEngineView.navigationHistory.clear()
+
+ webEngineView.url = Qt.resolvedUrl("test1.html")
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, false)
+ compare(forwardButton.enabled, false)
+
+ webEngineView.url = Qt.resolvedUrl("test2.html")
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, true)
+ compare(forwardButton.enabled, false)
+
+ webEngineView.url = Qt.resolvedUrl("test3.html")
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, true)
+ compare(forwardButton.enabled, false)
+
+ backButton.clicked()
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, true)
+ compare(forwardButton.enabled, true)
+
+ webEngineView.url = Qt.resolvedUrl("test1.html")
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(backButton.enabled, true)
+ compare(forwardButton.enabled, false)
+ }
}
}
diff --git a/tests/auto/quick/qquickwebengineprofile/qquickwebengineprofile.pro b/tests/auto/quick/qquickwebengineprofile/qquickwebengineprofile.pro
deleted file mode 100644
index e99c7f493..000000000
--- a/tests/auto/quick/qquickwebengineprofile/qquickwebengineprofile.pro
+++ /dev/null
@@ -1 +0,0 @@
-include(../tests.pri)
diff --git a/tests/auto/quick/qquickwebengineprofile/tst_qquickwebengineprofile.cpp b/tests/auto/quick/qquickwebengineprofile/tst_qquickwebengineprofile.cpp
deleted file mode 100644
index ea0469aef..000000000
--- a/tests/auto/quick/qquickwebengineprofile/tst_qquickwebengineprofile.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtQml/QQmlEngine>
-#include <QtTest/QtTest>
-#include <QtWebEngineQuick/QQuickWebEngineProfile>
-
-class tst_QQuickWebEngineProfile : public QObject {
- Q_OBJECT
-public:
- tst_QQuickWebEngineProfile();
-
- // TODO: Many tests missings
- void usedForGlobalCertificateVerification();
-
-private Q_SLOTS:
- void init();
- void cleanup();
-};
-
-tst_QQuickWebEngineProfile::tst_QQuickWebEngineProfile()
-{
- QtWebEngine::initialize();
- QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true);
-}
-
-
-void tst_QQuickWebEngineProfile::init()
-{
-}
-
-void tst_QQuickWebEngineProfile::cleanup()
-{
-}
-
-void tst_QQuickWebEngineProfile::usedForGlobalCertificateVerification()
-{
- QQuickWebEngineProfile *profile1 = new QQuickWebEngineProfile();
- QQuickWebEngineProfile *profile2 = new QQuickWebEngineProfile();
- QVERIFY(!profile1->isUsedForGlobalVerification());
- QVERIFY(!profile2->isUsedForGlobalVerification());
-
-
-}
-
-
-QTEST_MAIN(tst_QQuickWebEngineProfile)
-#include "tst_qquickwebengineprofile.moc"
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index fd17f401b..7af08dbde 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -42,6 +42,7 @@
#include <QQuickItem>
#include <QQuickWidget>
#include <QtWebEngineCore/qwebenginehttprequest.h>
+#include <QScopeGuard>
#include <QTcpServer>
#include <QTcpSocket>
#include <QStyle>
@@ -161,6 +162,7 @@ private Q_SLOTS:
void jsKeyboardEvent_data();
void jsKeyboardEvent();
void deletePage();
+ void autoDeleteOnExternalPageDelete();
void closeOpenerTab();
void switchPage();
void setPageDeletesImplicitPage();
@@ -3137,7 +3139,7 @@ void tst_QWebEngineView::webUIURLs_data()
QTest::newRow("media-engagement") << QUrl("chrome://media-engagement") << false;
QTest::newRow("media-internals") << QUrl("chrome://media-internals") << true;
QTest::newRow("net-export") << QUrl("chrome://net-export") << false;
- QTest::newRow("net-internals") << QUrl("chrome://net-internals") << false;
+ QTest::newRow("net-internals") << QUrl("chrome://net-internals") << true;
QTest::newRow("network-error") << QUrl("chrome://network-error") << false;
QTest::newRow("network-errors") << QUrl("chrome://network-errors") << true;
QTest::newRow("ntp-tiles-internals") << QUrl("chrome://ntp-tiles-internals") << false;
@@ -3288,6 +3290,26 @@ void tst_QWebEngineView::deletePage()
QTRY_VERIFY(spy.count());
}
+void tst_QWebEngineView::autoDeleteOnExternalPageDelete()
+{
+ QPointer<QWebEngineView> view = new QWebEngineView;
+ QPointer<QWebEnginePage> page = new QWebEnginePage;
+ auto sg = qScopeGuard([&] () { delete view; delete page; });
+
+ QSignalSpy spy(page, &QWebEnginePage::loadFinished);
+ view->setPage(page);
+ view->show();
+ view->resize(320, 240);
+ page->load(QUrl("about:blank"));
+ QTRY_VERIFY(spy.count());
+ QVERIFY(page->parent() != view);
+
+ auto sc = QObject::connect(page, &QWebEnginePage::destroyed, view, &QWebEngineView::deleteLater);
+ QTimer::singleShot(0, page, &QObject::deleteLater);
+ QTRY_VERIFY(!page);
+ QTRY_VERIFY(!view);
+}
+
class TestView : public QWebEngineView {
Q_OBJECT
public: