summaryrefslogtreecommitdiffstats
path: root/src/core/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/renderer')
-rw-r--r--src/core/renderer/content_renderer_client_qt.cpp687
-rw-r--r--src/core/renderer/content_renderer_client_qt.h116
-rw-r--r--src/core/renderer/content_settings_observer_qt.cpp111
-rw-r--r--src/core/renderer/content_settings_observer_qt.h61
-rw-r--r--src/core/renderer/extensions/extensions_dispatcher_delegate_qt.cpp49
-rw-r--r--src/core/renderer/extensions/extensions_dispatcher_delegate_qt.h44
-rw-r--r--src/core/renderer/extensions/extensions_renderer_client_qt.cpp81
-rw-r--r--src/core/renderer/extensions/extensions_renderer_client_qt.h62
-rw-r--r--src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.cpp40
-rw-r--r--src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.h44
-rw-r--r--src/core/renderer/extensions/resource_request_policy_qt.cpp58
-rw-r--r--src/core/renderer/extensions/resource_request_policy_qt.h48
-rw-r--r--src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp432
-rw-r--r--src/core/renderer/pepper/pepper_flash_renderer_host_qt.h107
-rw-r--r--src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp97
-rw-r--r--src/core/renderer/pepper/pepper_renderer_host_factory_qt.h42
-rw-r--r--src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp55
-rw-r--r--src/core/renderer/plugins/loadable_plugin_placeholder_qt.h49
-rw-r--r--src/core/renderer/plugins/plugin_placeholder_qt.cpp75
-rw-r--r--src/core/renderer/plugins/plugin_placeholder_qt.h78
-rw-r--r--src/core/renderer/print_web_view_helper_delegate_qt.cpp72
-rw-r--r--src/core/renderer/print_web_view_helper_delegate_qt.h51
-rw-r--r--src/core/renderer/render_configuration.cpp41
-rw-r--r--src/core/renderer/render_configuration.h42
-rw-r--r--src/core/renderer/render_frame_observer_qt.cpp56
-rw-r--r--src/core/renderer/render_frame_observer_qt.h54
-rw-r--r--src/core/renderer/render_thread_observer_qt.cpp75
-rw-r--r--src/core/renderer/render_thread_observer_qt.h80
-rw-r--r--src/core/renderer/render_view_observer_qt.cpp94
-rw-r--r--src/core/renderer/render_view_observer_qt.h63
-rw-r--r--src/core/renderer/user_resource_controller.cpp325
-rw-r--r--src/core/renderer/user_resource_controller.h92
-rw-r--r--src/core/renderer/web_channel_ipc_transport.cpp162
-rw-r--r--src/core/renderer/web_channel_ipc_transport.h50
-rw-r--r--src/core/renderer/web_engine_page_render_frame.cpp66
-rw-r--r--src/core/renderer/web_engine_page_render_frame.h41
36 files changed, 1023 insertions, 2677 deletions
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp
index b2138a82a..cc127e55f 100644
--- a/src/core/renderer/content_renderer_client_qt.cpp
+++ b/src/core/renderer/content_renderer_client_qt.cpp
@@ -1,91 +1,56 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "renderer/content_renderer_client_qt.h"
-#include "extensions/buildflags/buildflags.h"
-#include "printing/buildflags/buildflags.h"
#include "renderer/content_settings_observer_qt.h"
-#include "base/strings/string_split.h"
-#if QT_CONFIG(webengine_spellchecker)
-#include "components/spellcheck/renderer/spellcheck.h"
-#include "components/spellcheck/renderer/spellcheck_provider.h"
-#endif
-#include "components/cdm/renderer/external_clear_key_key_system_properties.h"
-#include "components/cdm/renderer/widevine_key_system_properties.h"
+#include "renderer/render_configuration.h"
+#include "renderer/render_frame_observer_qt.h"
+#include "renderer/user_resource_controller.h"
+#include "renderer/web_engine_page_render_frame.h"
+#include "web_engine_library_info.h"
+
+#include "base/task/sequenced_task_runner.h"
+#include "components/autofill/content/renderer/autofill_agent.h"
+#include "components/autofill/content/renderer/password_autofill_agent.h"
+#include "components/autofill/content/renderer/password_generation_agent.h"
+#include "components/cdm/renderer/external_clear_key_key_system_info.h"
+#include "components/cdm/renderer/widevine_key_system_info.h"
#include "components/error_page/common/error.h"
-#include "components/error_page/common/error_page_params.h"
#include "components/error_page/common/localized_error.h"
+#include "components/grit/components_resources.h"
#include "components/network_hints/renderer/web_prescient_networking_impl.h"
-#if QT_CONFIG(webengine_printing_and_pdf)
-#include "components/printing/renderer/print_render_frame_helper.h"
-#endif
#include "components/visitedlink/renderer/visitedlink_reader.h"
#include "components/web_cache/renderer/web_cache_impl.h"
#include "content/public/renderer/render_frame.h"
-#include "content/public/child/child_thread.h"
#include "content/public/common/url_constants.h"
#include "content/public/renderer/render_thread.h"
-#include "content/public/renderer/render_view.h"
-#include "media/base/key_system_properties.h"
+#include "extensions/buildflags/buildflags.h"
+#include "media/base/key_system_info.h"
+#include "media/cdm/cdm_capability.h"
#include "media/media_buildflags.h"
#include "mojo/public/cpp/bindings/binder_map.h"
#include "net/base/net_errors.h"
-#include "services/service_manager/public/cpp/connector.h"
-#include "services/service_manager/public/cpp/interface_provider.h"
+#include "ppapi/buildflags/buildflags.h"
+#include "printing/buildflags/buildflags.h"
+#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/platform/web_url_error.h"
-#include "third_party/blink/public/platform/web_url_request.h"
-#include "third_party/blink/public/web/web_security_policy.h"
-#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/jstemplate_builder.h"
-#include "content/public/common/web_preferences.h"
+
+#if QT_CONFIG(webengine_spellchecker)
+#include "components/spellcheck/renderer/spellcheck.h"
+#include "components/spellcheck/renderer/spellcheck_provider.h"
+#endif
#if QT_CONFIG(webengine_printing_and_pdf)
#include "renderer/print_web_view_helper_delegate_qt.h"
+
+#include "components/pdf/renderer/internal_plugin_renderer_helpers.h"
+#include "components/pdf/renderer/pdf_internal_plugin_delegate.h"
+#include "components/printing/renderer/print_render_frame_helper.h"
#endif
-#include "common/qt_messages.h"
-#include "renderer/render_frame_observer_qt.h"
-#include "renderer/render_view_observer_qt.h"
-#include "renderer/render_thread_observer_qt.h"
-#include "renderer/user_resource_controller.h"
#if QT_CONFIG(webengine_webchannel)
#include "renderer/web_channel_ipc_transport.h"
#endif
@@ -93,32 +58,36 @@
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "common/extensions/extensions_client_qt.h"
#include "extensions/extensions_renderer_client_qt.h"
-#endif //ENABLE_EXTENSIONS
+
+#include "extensions/common/constants.h"
+#include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container_manager.h"
+#include "mojo/public/cpp/bindings/associated_remote.h"
+#include "services/service_manager/public/cpp/binder_registry.h"
+#include "third_party/blink/public/web/web_security_policy.h"
+#endif // ENABLE_EXTENSIONS
#if BUILDFLAG(ENABLE_PLUGINS)
+#include "content/renderer/render_frame_impl.h"
#include "plugins/loadable_plugin_placeholder_qt.h"
-#include "plugins/plugin_placeholder_qt.h"
-#include "content/common/frame_messages.h"
#endif // ENABLE_PLUGINS
-#include "services/service_manager/public/cpp/binder_registry.h"
-#include "services/service_manager/public/cpp/connector.h"
-#include "services/service_manager/public/cpp/service_binding.h"
-
-#include "components/grit/components_resources.h"
-
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
#include "base/feature_list.h"
#include "content/public/renderer/key_system_support.h"
#include "media/base/media_switches.h"
#include "media/base/video_codecs.h"
+#include "media/cdm/clear_key_cdm_common.h"
#include "third_party/widevine/cdm/buildflags.h"
+#if BUILDFLAG(ENABLE_WIDEVINE)
#include "third_party/widevine/cdm/widevine_cdm_common.h"
#endif
+#endif
-namespace QtWebEngineCore {
+#if QT_CONFIG(webengine_webrtc) && QT_CONFIG(webengine_extensions)
+#include "chrome/renderer/media/webrtc_logging_agent_impl.h"
+#endif
-static const char kHttpErrorDomain[] = "http";
+namespace QtWebEngineCore {
ContentRendererClientQt::ContentRendererClientQt()
{
@@ -132,31 +101,24 @@ ContentRendererClientQt::~ContentRendererClientQt() {}
void ContentRendererClientQt::RenderThreadStarted()
{
+ base::i18n::SetICUDefaultLocale(WebEngineLibraryInfo::getApplicationLocale());
content::RenderThread *renderThread = content::RenderThread::Get();
- m_renderThreadObserver.reset(new RenderThreadObserverQt());
+ m_renderConfiguration.reset(new RenderConfiguration());
+ m_userResourceController.reset(new UserResourceController());
m_visitedLinkReader.reset(new visitedlink::VisitedLinkReader);
m_webCacheImpl.reset(new web_cache::WebCacheImpl());
- renderThread->AddObserver(m_renderThreadObserver.data());
- renderThread->AddObserver(UserResourceController::instance());
+ renderThread->AddObserver(m_renderConfiguration.data());
+ renderThread->AddObserver(m_userResourceController.data());
#if QT_CONFIG(webengine_spellchecker)
if (!m_spellCheck)
InitSpellCheck();
#endif
- // Allow XMLHttpRequests from qrc to file.
- // ### consider removing for Qt6
- blink::WebURL qrc(blink::KURL("qrc:"));
- blink::WebString file(blink::WebString::FromASCII("file"));
- blink::WebSecurityPolicy::AddOriginAccessAllowListEntry(
- qrc, file, blink::WebString(), 0, network::mojom::CorsDomainMatchMode::kAllowSubdomains,
- network::mojom::CorsPortMatchMode::kAllowAnyPort,
- network::mojom::CorsOriginAccessMatchPriority::kDefaultPriority);
-
#if BUILDFLAG(ENABLE_EXTENSIONS)
// Allow the pdf viewer extension to access chrome resources
- blink::WebURL pdfViewerExtension(blink::KURL("chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"));
+ blink::WebURL pdfViewerExtension(GURL("chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"));
blink::WebString chromeResources(blink::WebString::FromASCII("chrome"));
blink::WebSecurityPolicy::AddOriginAccessAllowListEntry(
pdfViewerExtension, chromeResources, blink::WebString(), 0,
@@ -169,41 +131,49 @@ void ContentRendererClientQt::RenderThreadStarted()
void ContentRendererClientQt::ExposeInterfacesToBrowser(mojo::BinderMap* binders)
{
- binders->Add(m_visitedLinkReader->GetBindCallback(), base::SequencedTaskRunnerHandle::Get());
+ binders->Add<visitedlink::mojom::VisitedLinkNotificationSink>(
+ m_visitedLinkReader->GetBindCallback(), base::SingleThreadTaskRunner::GetCurrentDefault());
- binders->Add(base::BindRepeating(&web_cache::WebCacheImpl::BindReceiver,
- base::Unretained(m_webCacheImpl.get())),
- base::SequencedTaskRunnerHandle::Get());
+ binders->Add<web_cache::mojom::WebCache>(
+ base::BindRepeating(&web_cache::WebCacheImpl::BindReceiver,
+ base::Unretained(m_webCacheImpl.get())),
+ base::SingleThreadTaskRunner::GetCurrentDefault());
#if QT_CONFIG(webengine_spellchecker)
- binders->Add(base::BindRepeating(
+ binders->Add<spellcheck::mojom::SpellChecker>(
+ base::BindRepeating(
[](ContentRendererClientQt *client,
mojo::PendingReceiver<spellcheck::mojom::SpellChecker> receiver) {
if (!client->m_spellCheck)
client->InitSpellCheck();
client->m_spellCheck->BindReceiver(std::move(receiver));
}, this),
- base::SequencedTaskRunnerHandle::Get());
+ base::SingleThreadTaskRunner::GetCurrentDefault());
#endif
-}
-void ContentRendererClientQt::RenderViewCreated(content::RenderView *render_view)
-{
- // RenderViewObservers destroy themselves with their RenderView.
- new RenderViewObserverQt(render_view);
- UserResourceController::instance()->renderViewCreated(render_view);
+#if QT_CONFIG(webengine_webrtc) && QT_CONFIG(webengine_extensions)
+ binders->Add<chrome::mojom::WebRtcLoggingAgent>(
+ base::BindRepeating(
+ [](ContentRendererClientQt *client,
+ mojo::PendingReceiver<chrome::mojom::WebRtcLoggingAgent> receiver) {
+ client->GetWebRtcLoggingAgent()->AddReceiver(std::move(receiver));
+ }, this),
+ base::SingleThreadTaskRunner::GetCurrentDefault());
+#endif
}
void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame *render_frame)
{
QtWebEngineCore::RenderFrameObserverQt *render_frame_observer =
new QtWebEngineCore::RenderFrameObserverQt(render_frame, m_webCacheImpl.data());
+ if (render_frame->IsMainFrame()) {
#if QT_CONFIG(webengine_webchannel)
- if (render_frame->IsMainFrame())
new WebChannelIPCTransport(render_frame);
#endif
+ new WebEnginePageRenderFrame(render_frame);
+ }
- UserResourceController::instance()->renderFrameCreated(render_frame);
+ m_userResourceController->renderFrameCreated(render_frame);
new QtWebEngineCore::ContentSettingsObserverQt(render_frame);
@@ -213,10 +183,37 @@ void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame *render_fr
#if QT_CONFIG(webengine_printing_and_pdf)
new printing::PrintRenderFrameHelper(render_frame, base::WrapUnique(new PrintWebViewHelperDelegateQt()));
#endif // QT_CONFIG(webengine_printing_and_pdf)
+
+ blink::AssociatedInterfaceRegistry *associated_interfaces = render_frame_observer->associatedInterfaces();
+
#if BUILDFLAG(ENABLE_EXTENSIONS)
+ associated_interfaces->AddInterface<extensions::mojom::MimeHandlerViewContainerManager>(
+ base::BindRepeating(
+ &extensions::MimeHandlerViewContainerManager::BindReceiver,
+ render_frame->GetRoutingID()));
+
auto registry = std::make_unique<service_manager::BinderRegistry>();
ExtensionsRendererClientQt::GetInstance()->RenderFrameCreated(render_frame, render_frame_observer->registry());
#endif
+
+ autofill::PasswordAutofillAgent *password_autofill_agent =
+ new autofill::PasswordAutofillAgent(render_frame, associated_interfaces);
+ autofill::PasswordGenerationAgent *password_generation_agent =
+ new autofill::PasswordGenerationAgent(render_frame, password_autofill_agent,
+ associated_interfaces);
+
+ new autofill::AutofillAgent(render_frame, password_autofill_agent, password_generation_agent,
+ associated_interfaces);
+}
+
+void ContentRendererClientQt::WebViewCreated(blink::WebView *web_view,
+ bool was_created_by_renderer,
+ const url::Origin *outermost_origin)
+{
+ Q_UNUSED(was_created_by_renderer);
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+ ExtensionsRendererClientQt::GetInstance()->WebViewCreated(web_view, outermost_origin);
+#endif
}
void ContentRendererClientQt::RunScriptsAtDocumentStart(content::RenderFrame *render_frame)
@@ -234,7 +231,7 @@ void ContentRendererClientQt::RunScriptsAtDocumentEnd(content::RenderFrame *rend
RenderFrameObserverQt *render_frame_observer = RenderFrameObserverQt::Get(render_frame);
if (render_frame_observer && !render_frame_observer->isFrameDetached())
- UserResourceController::instance()->RunScriptsAtDocumentEnd(render_frame);
+ m_userResourceController->RunScriptsAtDocumentEnd(render_frame);
#if BUILDFLAG(ENABLE_EXTENSIONS)
ExtensionsRendererClientQt::GetInstance()->RunScriptsAtDocumentEnd(render_frame);
@@ -250,40 +247,29 @@ void ContentRendererClientQt::RunScriptsAtDocumentIdle(content::RenderFrame *ren
#endif
}
-bool ContentRendererClientQt::HasErrorPage(int httpStatusCode)
-{
- // Use an internal error page, if we have one for the status code.
- if (!error_page::LocalizedError::HasStrings(error_page::Error::kHttpErrorDomain, httpStatusCode)) {
- return false;
- }
-
- return true;
-}
-
-bool ContentRendererClientQt::ShouldSuppressErrorPage(content::RenderFrame *frame, const GURL &)
-{
- return !(frame->GetWebkitPreferences().enable_error_page);
-}
-
// To tap into the chromium localized strings. Ripped from the chrome layer (highly simplified).
void ContentRendererClientQt::PrepareErrorPage(content::RenderFrame *renderFrame,
const blink::WebURLError &web_error,
const std::string &httpMethod,
+ content::mojom::AlternativeErrorPageOverrideInfoPtr alternative_error_page_info,
std::string *errorHtml)
{
GetNavigationErrorStringsInternal(
renderFrame, httpMethod,
- error_page::Error::NetError(web_error.url(), web_error.reason(), web_error.has_copy_in_cache()), errorHtml);
+ error_page::Error::NetError((GURL)web_error.url(), web_error.reason(), web_error.extended_reason(),
+ net::ResolveErrorInfo(), web_error.has_copy_in_cache()),
+ errorHtml);
}
void ContentRendererClientQt::PrepareErrorPageForHttpStatusError(content::RenderFrame *renderFrame,
- const GURL &unreachable_url,
+ const blink::WebURLError &error,
const std::string &httpMethod,
int http_status,
+ content::mojom::AlternativeErrorPageOverrideInfoPtr alternative_error_page_info,
std::string *errorHtml)
{
GetNavigationErrorStringsInternal(renderFrame, httpMethod,
- error_page::Error::HttpError(unreachable_url, http_status),
+ error_page::Error::HttpError(error.url(), http_status),
errorHtml);
}
@@ -292,7 +278,7 @@ void ContentRendererClientQt::GetNavigationErrorStringsInternal(content::RenderF
const error_page::Error &error,
std::string *errorHtml)
{
- Q_UNUSED(renderFrame)
+ Q_UNUSED(renderFrame);
const bool isPost = QByteArray::fromStdString(httpMethod) == QByteArrayLiteral("POST");
if (errorHtml) {
@@ -303,11 +289,12 @@ void ContentRendererClientQt::GetNavigationErrorStringsInternal(content::RenderF
// TODO(elproxy): We could potentially get better diagnostics here by first calling
// NetErrorHelper::GetErrorStringsForDnsProbe, but that one is harder to untangle.
+ base::Value::Dict error_page_params;
error_page::LocalizedError::PageState errorPageState =
- error_page::LocalizedError::GetPageState(
- error.reason(), error.domain(), error.url(), isPost,
- error.stale_copy_in_cache(), false, RenderThreadObserverQt::is_incognito_process(), false,
- false, locale, std::unique_ptr<error_page::ErrorPageParams>());
+ error_page::LocalizedError::GetPageState(
+ error.reason(), error.domain(), error.url(), isPost, false,
+ error.stale_copy_in_cache(), false,
+ RenderConfiguration::is_incognito_process(), false, false, false, locale, false, &error_page_params);
resourceId = IDR_NET_ERROR_HTML;
@@ -316,7 +303,7 @@ void ContentRendererClientQt::GetNavigationErrorStringsInternal(content::RenderF
if (template_html.empty())
NOTREACHED() << "unable to load template. ID: " << resourceId;
else // "t" is the id of the templates root node.
- *errorHtml = webui::GetTemplatesHtml(template_html, &errorPageState.strings, "t");
+ *errorHtml = webui::GetTemplatesHtml(template_html, errorPageState.strings, "t");
}
}
@@ -335,6 +322,92 @@ std::unique_ptr<blink::WebPrescientNetworking> ContentRendererClientQt::CreatePr
return std::make_unique<network_hints::WebPrescientNetworkingImpl>(render_frame);
}
+namespace {
+bool IsPdfExtensionOrigin(const url::Origin &origin)
+{
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+ return origin.scheme() == extensions::kExtensionScheme &&
+ origin.host() == extension_misc::kPdfExtensionId;
+#else
+ return false;
+#endif
+}
+
+#if BUILDFLAG(ENABLE_PLUGINS)
+void AppendParams(const std::vector<content::WebPluginMimeType::Param> &additional_params,
+ blink::WebVector<blink::WebString> *existing_names,
+ blink::WebVector<blink::WebString> *existing_values)
+{
+ DCHECK(existing_names->size() == existing_values->size());
+ size_t existing_size = existing_names->size();
+ size_t total_size = existing_size + additional_params.size();
+
+ blink::WebVector<blink::WebString> names(total_size);
+ blink::WebVector<blink::WebString> values(total_size);
+
+ for (size_t i = 0; i < existing_size; ++i) {
+ names[i] = (*existing_names)[i];
+ values[i] = (*existing_values)[i];
+ }
+
+ for (size_t i = 0; i < additional_params.size(); ++i) {
+ names[existing_size + i] = blink::WebString::FromUTF16(additional_params[i].name);
+ values[existing_size + i] = blink::WebString::FromUTF16(additional_params[i].value);
+ }
+
+ existing_names->Swap(names);
+ existing_values->Swap(values);
+}
+#endif // BUILDFLAG(ENABLE_PLUGINS)
+
+#if QT_CONFIG(webengine_printing_and_pdf)
+// based on chrome/renderer/pdf/chrome_pdf_internal_plugin_delegate.cc:
+class PdfInternalPluginDelegateQt final
+ : public pdf::PdfInternalPluginDelegate
+{
+public:
+ PdfInternalPluginDelegateQt() = default;
+ PdfInternalPluginDelegateQt(const PdfInternalPluginDelegateQt &) = delete;
+ PdfInternalPluginDelegateQt& operator=(const PdfInternalPluginDelegateQt &) = delete;
+ ~PdfInternalPluginDelegateQt() override = default;
+
+ // `pdf::PdfInternalPluginDelegate`:
+ bool IsAllowedOrigin(const url::Origin &origin) const override;
+};
+
+bool PdfInternalPluginDelegateQt::IsAllowedOrigin(const url::Origin &origin) const
+{
+ return IsPdfExtensionOrigin(origin);
+}
+#endif
+} // namespace
+
+bool ContentRendererClientQt::IsPluginHandledExternally(content::RenderFrame *render_frame,
+ const blink::WebElement &plugin_element,
+ const GURL &original_url,
+ const std::string &original_mime_type)
+{
+#if BUILDFLAG(ENABLE_EXTENSIONS) && BUILDFLAG(ENABLE_PLUGINS)
+ bool found = false;
+ content::WebPluginInfo plugin_info;
+ std::string mime_type;
+
+ static_cast<content::RenderFrameImpl *>(render_frame)->GetPepperHost()->GetPluginInfo(
+ original_url, original_mime_type, &found, &plugin_info, &mime_type);
+ if (!found)
+ return false;
+ if (IsPdfExtensionOrigin(render_frame->GetWebFrame()->GetSecurityOrigin()))
+ return true;
+ return extensions::MimeHandlerViewContainerManager::Get(
+ content::RenderFrame::FromWebFrame(
+ plugin_element.GetDocument().GetFrame()),
+ true /* create_if_does_not_exist */)
+ ->CreateFrameContainer(plugin_element, original_url, mime_type, plugin_info);
+#else
+ return false;
+#endif
+}
+
bool ContentRendererClientQt::OverrideCreatePlugin(content::RenderFrame *render_frame,
const blink::WebPluginParams &params,
blink::WebPlugin **plugin)
@@ -342,56 +415,52 @@ bool ContentRendererClientQt::OverrideCreatePlugin(content::RenderFrame *render_
#if BUILDFLAG(ENABLE_EXTENSIONS)
if (!ExtensionsRendererClientQt::GetInstance()->OverrideCreatePlugin(render_frame, params))
return false;
-#endif //ENABLE_EXTENSIONS
+#endif // ENABLE_EXTENSIONS
#if BUILDFLAG(ENABLE_PLUGINS)
- chrome::mojom::PluginInfoPtr plugin_info = chrome::mojom::PluginInfo::New();
content::WebPluginInfo info;
std::string mime_type;
bool found = false;
- render_frame->Send(new FrameHostMsg_GetPluginInfo(render_frame->GetRoutingID(), params.url,
- render_frame->GetWebFrame()->Top()->GetSecurityOrigin(),
- params.mime_type.Utf8(), &found, &info, &mime_type));
+ static_cast<content::RenderFrameImpl *>(render_frame)->GetPepperHost()->GetPluginInfo(
+ params.url, params.mime_type.Utf8(), &found, &info, &mime_type);
if (!found) {
- *plugin = CreatePlugin(render_frame, params, *plugin_info);
+ *plugin = LoadablePluginPlaceholderQt::CreateLoadableMissingPlugin(render_frame, params)->plugin();
return true;
}
-#endif // BUILDFLAG(ENABLE_PLUGINS)
- return content::ContentRendererClient::OverrideCreatePlugin(render_frame, params, plugin);
-}
+ if (info.name == u"Chromium PDF Viewer") {
+ blink::WebPluginParams new_params(params);
+ for (const auto& mime_type : info.mime_types) {
+ if (mime_type.mime_type == params.mime_type.Utf8()) {
+ AppendParams(mime_type.additional_params, &new_params.attribute_names,
+ &new_params.attribute_values);
+ break;
+ }
+ }
-#if BUILDFLAG(ENABLE_PLUGINS)
-// static
-blink::WebPlugin* ContentRendererClientQt::CreatePlugin(content::RenderFrame* render_frame,
- const blink::WebPluginParams& original_params,
- const chrome::mojom::PluginInfo& plugin_info)
-{
- // If the browser plugin is to be enabled, this should be handled by the
- // renderer, so the code won't reach here due to the early exit in OverrideCreatePlugin.
- return LoadablePluginPlaceholderQt::CreateLoadableMissingPlugin(render_frame, original_params)->plugin();
+ *plugin = pdf::CreateInternalPlugin(std::move(new_params), render_frame, std::make_unique<PdfInternalPluginDelegateQt>());
+ return true;
+ }
+ *plugin = render_frame->CreatePlugin(info, params);
+#endif // BUILDFLAG(ENABLE_PLUGINS)
+ return true;
}
-#endif //BUILDFLAG(ENABLE_PLUGINS)
-content::BrowserPluginDelegate *ContentRendererClientQt::CreateBrowserPluginDelegate(content::RenderFrame *render_frame,
- const content::WebPluginInfo &info,
- const std::string &mime_type,
- const GURL &original_url)
+bool ContentRendererClientQt::IsOriginIsolatedPepperPlugin(const base::FilePath& plugin_path)
{
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- return ExtensionsRendererClientQt::GetInstance()->CreateBrowserPluginDelegate(render_frame, info, mime_type,
- original_url);
-#else
- return nullptr;
-#endif
+ return plugin_path.value() == FILE_PATH_LITERAL("internal-pdf-viewer");
}
-void ContentRendererClientQt::BindReceiverOnMainThread(mojo::GenericPendingReceiver receiver)
+#if QT_CONFIG(webengine_webrtc) && QT_CONFIG(webengine_extensions)
+chrome::WebRtcLoggingAgentImpl *ContentRendererClientQt::GetWebRtcLoggingAgent()
{
- std::string interface_name = *receiver.interface_name();
- auto pipe = receiver.PassPipe();
- m_registry.TryBindInterface(interface_name, &pipe);
+ if (!m_webrtcLoggingAgentImpl) {
+ m_webrtcLoggingAgentImpl = std::make_unique<chrome::WebRtcLoggingAgentImpl>();
+ }
+
+ return m_webrtcLoggingAgentImpl.get();
}
+#endif // QT_CONFIG(webengine_webrtc) && QT_CONFIG(webengine_extensions)
void ContentRendererClientQt::GetInterface(const std::string &interface_name, mojo::ScopedMessagePipeHandle interface_pipe)
{
@@ -405,129 +474,125 @@ void ContentRendererClientQt::GetInterface(const std::string &interface_name, mo
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
// External Clear Key (used for testing).
-static void AddExternalClearKey(std::vector<std::unique_ptr<media::KeySystemProperties>> *concrete_key_systems)
-{
- // TODO(xhwang): Move these into an array so we can use a for loop to add
- // supported key systems below.
- static const char kExternalClearKeyKeySystem[] =
- "org.chromium.externalclearkey";
- static const char kExternalClearKeyDecryptOnlyKeySystem[] =
- "org.chromium.externalclearkey.decryptonly";
- static const char kExternalClearKeyMessageTypeTestKeySystem[] =
- "org.chromium.externalclearkey.messagetypetest";
- static const char kExternalClearKeyFileIOTestKeySystem[] =
- "org.chromium.externalclearkey.fileiotest";
- static const char kExternalClearKeyOutputProtectionTestKeySystem[] =
- "org.chromium.externalclearkey.outputprotectiontest";
- static const char kExternalClearKeyPlatformVerificationTestKeySystem[] =
- "org.chromium.externalclearkey.platformverificationtest";
- static const char kExternalClearKeyInitializeFailKeySystem[] =
- "org.chromium.externalclearkey.initializefail";
- static const char kExternalClearKeyCrashKeySystem[] =
- "org.chromium.externalclearkey.crash";
- static const char kExternalClearKeyVerifyCdmHostTestKeySystem[] =
- "org.chromium.externalclearkey.verifycdmhosttest";
- static const char kExternalClearKeyStorageIdTestKeySystem[] =
- "org.chromium.externalclearkey.storageidtest";
- static const char kExternalClearKeyDifferentGuidTestKeySystem[] =
- "org.chromium.externalclearkey.differentguid";
- static const char kExternalClearKeyCdmProxyTestKeySystem[] =
- "org.chromium.externalclearkey.cdmproxytest";
-
- media::mojom::KeySystemCapabilityPtr capability;
- if (!content::IsKeySystemSupported(kExternalClearKeyKeySystem, &capability)) {
- DVLOG(1) << "External Clear Key not supported";
+static void AddExternalClearKey(const media::mojom::KeySystemCapabilityPtr &capability,
+ media::KeySystemInfos* key_systems)
+{
+ Q_UNUSED(capability);
+ if (!base::FeatureList::IsEnabled(media::kExternalClearKeyForTesting)) {
+ DLOG(ERROR) << "ExternalClearKey supported despite not enabled.";
return;
}
- concrete_key_systems->emplace_back(
- new cdm::ExternalClearKeyProperties(kExternalClearKeyKeySystem));
-
- // Add support of decrypt-only mode in ClearKeyCdm.
- concrete_key_systems->emplace_back(
- new cdm::ExternalClearKeyProperties(kExternalClearKeyDecryptOnlyKeySystem));
-
- // A key system that triggers various types of messages in ClearKeyCdm.
- concrete_key_systems->emplace_back(
- new cdm::ExternalClearKeyProperties(kExternalClearKeyMessageTypeTestKeySystem));
-
- // A key system that triggers the FileIO test in ClearKeyCdm.
- concrete_key_systems->emplace_back(
- new cdm::ExternalClearKeyProperties(kExternalClearKeyFileIOTestKeySystem));
-
- // A key system that triggers the output protection test in ClearKeyCdm.
- concrete_key_systems->emplace_back(
- new cdm::ExternalClearKeyProperties(kExternalClearKeyOutputProtectionTestKeySystem));
-
- // A key system that triggers the platform verification test in ClearKeyCdm.
- concrete_key_systems->emplace_back(
- new cdm::ExternalClearKeyProperties(kExternalClearKeyPlatformVerificationTestKeySystem));
+ // TODO(xhwang): Actually use `capability` to determine capabilities.
+ key_systems->push_back(std::make_unique<cdm::ExternalClearKeyKeySystemInfo>());
+}
- // A key system that Chrome thinks is supported by ClearKeyCdm, but actually
- // will be refused by ClearKeyCdm. This is to test the CDM initialization
- // failure case.
- concrete_key_systems->emplace_back(
- new cdm::ExternalClearKeyProperties(kExternalClearKeyInitializeFailKeySystem));
+#if BUILDFLAG(ENABLE_WIDEVINE)
+media::SupportedCodecs GetVP9Codecs(const base::flat_set<media::VideoCodecProfile> &profiles)
+{
+ if (profiles.empty()) {
+ // If no profiles are specified, then all are supported.
+ return media::EME_CODEC_VP9_PROFILE0 | media::EME_CODEC_VP9_PROFILE2;
+ }
- // A key system that triggers a crash in ClearKeyCdm.
- concrete_key_systems->emplace_back(
- new cdm::ExternalClearKeyProperties(kExternalClearKeyCrashKeySystem));
+ media::SupportedCodecs supported_vp9_codecs = media::EME_CODEC_NONE;
+ for (const auto& profile : profiles) {
+ switch (profile) {
+ case media::VP9PROFILE_PROFILE0:
+ supported_vp9_codecs |= media::EME_CODEC_VP9_PROFILE0;
+ break;
+ case media::VP9PROFILE_PROFILE2:
+ supported_vp9_codecs |= media::EME_CODEC_VP9_PROFILE2;
+ break;
+ default:
+ DVLOG(1) << "Unexpected " << media::GetCodecName(media::VideoCodec::kVP9)
+ << " profile: " << media::GetProfileName(profile);
+ break;
+ }
+ }
- // A key system that triggers the verify host files test in ClearKeyCdm.
- concrete_key_systems->emplace_back(
- new cdm::ExternalClearKeyProperties(kExternalClearKeyVerifyCdmHostTestKeySystem));
+ return supported_vp9_codecs;
+}
- // A key system that fetches the Storage ID in ClearKeyCdm.
- concrete_key_systems->emplace_back(
- new cdm::ExternalClearKeyProperties(kExternalClearKeyStorageIdTestKeySystem));
+#if BUILDFLAG(ENABLE_PLATFORM_HEVC)
+media::SupportedCodecs GetHevcCodecs(const base::flat_set<media::VideoCodecProfile> &profiles)
+{
+ // If no profiles are specified, then all are supported.
+ if (profiles.empty()) {
+ return media::EME_CODEC_HEVC_PROFILE_MAIN |
+ media::EME_CODEC_HEVC_PROFILE_MAIN10;
+ }
- // A key system that is registered with a different CDM GUID.
- concrete_key_systems->emplace_back(
- new cdm::ExternalClearKeyProperties(kExternalClearKeyDifferentGuidTestKeySystem));
+ media::SupportedCodecs supported_hevc_codecs = media::EME_CODEC_NONE;
+ for (const auto& profile : profiles) {
+ switch (profile) {
+ case media::HEVCPROFILE_MAIN:
+ supported_hevc_codecs |= media::EME_CODEC_HEVC_PROFILE_MAIN;
+ break;
+ case media::HEVCPROFILE_MAIN10:
+ supported_hevc_codecs |= media::EME_CODEC_HEVC_PROFILE_MAIN10;
+ break;
+ default:
+ DVLOG(1) << "Unexpected " << media::GetCodecName(media::VideoCodec::kHEVC)
+ << " profile: " << media::GetProfileName(profile);
+ break;
+ }
+ }
- // A key system that triggers CDM Proxy test in ClearKeyCdm.
- concrete_key_systems->emplace_back(
- new cdm::ExternalClearKeyProperties(kExternalClearKeyCdmProxyTestKeySystem));
+ return supported_hevc_codecs;
}
+#endif // BUILDFLAG(ENABLE_PLATFORM_HEVC)
-#if BUILDFLAG(ENABLE_WIDEVINE)
-static media::SupportedCodecs GetSupportedCodecs(const std::vector<media::VideoCodec> &supported_video_codecs,
+static media::SupportedCodecs GetSupportedCodecs(const media::CdmCapability& capability,
bool is_secure)
{
media::SupportedCodecs supported_codecs = media::EME_CODEC_NONE;
- // Audio codecs are always supported because the CDM only does decrypt-only
- // for audio. The only exception is when |is_secure| is true and there's no
- // secure video decoder available, which is a signal that secure hardware
- // decryption is not available either.
- // TODO(sandersd): Distinguish these from those that are directly supported,
- // as those may offer a higher level of protection.
- if (!supported_video_codecs.empty() || !is_secure) {
- supported_codecs |= media::EME_CODEC_OPUS;
- supported_codecs |= media::EME_CODEC_VORBIS;
- supported_codecs |= media::EME_CODEC_FLAC;
+ for (const auto& codec : capability.audio_codecs) {
+ switch (codec) {
+ case media::AudioCodec::kOpus:
+ supported_codecs |= media::EME_CODEC_OPUS;
+ break;
+ case media::AudioCodec::kVorbis:
+ supported_codecs |= media::EME_CODEC_VORBIS;
+ break;
+ case media::AudioCodec::kFLAC:
+ supported_codecs |= media::EME_CODEC_FLAC;
+ break;
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
- supported_codecs |= media::EME_CODEC_AAC;
-#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
+ case media::AudioCodec::kAAC:
+ supported_codecs |= media::EME_CODEC_AAC;
+ break;
+#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
+ default:
+ DVLOG(1) << "Unexpected supported codec: " << GetCodecName(codec);
+ break;
+ }
}
- // Video codecs are determined by what was registered for the CDM.
- for (const auto &codec : supported_video_codecs) {
- switch (codec) {
- case media::VideoCodec::kCodecVP8:
+ for (const auto &codec : capability.video_codecs) {
+ switch (codec.first) {
+ case media::VideoCodec::kVP8:
supported_codecs |= media::EME_CODEC_VP8;
break;
- case media::VideoCodec::kCodecVP9:
- supported_codecs |= media::EME_CODEC_VP9_PROFILE0;
- supported_codecs |= media::EME_CODEC_VP9_PROFILE2;
+ case media::VideoCodec::kVP9:
+ supported_codecs |= GetVP9Codecs(codec.second.supported_profiles);
+ break;
+ case media::VideoCodec::kAV1:
+ supported_codecs |= media::EME_CODEC_AV1;
break;
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
- case media::VideoCodec::kCodecH264:
+ case media::VideoCodec::kH264:
supported_codecs |= media::EME_CODEC_AVC1;
break;
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
+#if BUILDFLAG(ENABLE_PLATFORM_HEVC)
+ case media::VideoCodec::kHEVC:
+ supported_codecs |= GetHevcCodecs(codec.second.supported_profiles);
+ break;
+#endif // BUILDFLAG(ENABLE_PLATFORM_HEVC)
default:
- DVLOG(1) << "Unexpected supported codec: " << GetCodecName(codec);
+ DVLOG(1) << "Unexpected supported codec: " << GetCodecName(codec.first);
break;
}
}
@@ -535,23 +600,36 @@ static media::SupportedCodecs GetSupportedCodecs(const std::vector<media::VideoC
return supported_codecs;
}
-static void AddWidevine(std::vector<std::unique_ptr<media::KeySystemProperties>> *concrete_key_systems)
+static void AddWidevine(const media::mojom::KeySystemCapabilityPtr &capability,
+ media::KeySystemInfos *key_systems)
{
- media::mojom::KeySystemCapabilityPtr capability;
- if (!content::IsKeySystemSupported(kWidevineKeySystem, &capability)) {
- DVLOG(1) << "Widevine CDM is not currently available.";
- return;
+ // Codecs and encryption schemes.
+ media::SupportedCodecs codecs = media::EME_CODEC_NONE;
+ media::SupportedCodecs hw_secure_codecs = media::EME_CODEC_NONE;
+ base::flat_set<media::EncryptionScheme> encryption_schemes;
+ base::flat_set<media::EncryptionScheme> hw_secure_encryption_schemes;
+ base::flat_set<media::CdmSessionType> session_types;
+ base::flat_set<media::CdmSessionType> hw_secure_session_types;
+ if (capability->sw_secure_capability) {
+ codecs = GetSupportedCodecs(capability->sw_secure_capability.value(), /*is_secure=*/false);
+ encryption_schemes = capability->sw_secure_capability->encryption_schemes;
+ if (!base::Contains(capability->sw_secure_capability->session_types, media::CdmSessionType::kTemporary)) {
+ DVLOG(1) << "Temporary sessions must be supported.";
+ return;
+ }
}
- // Codecs and encryption schemes.
- auto codecs = GetSupportedCodecs(capability->video_codecs, /*is_secure=*/false);
- const auto &encryption_schemes = capability->encryption_schemes;
- auto hw_secure_codecs = GetSupportedCodecs(capability->hw_secure_video_codecs,
- /*is_secure=*/true);
- const auto &hw_secure_encryption_schemes = capability->hw_secure_encryption_schemes;
+ if (capability->hw_secure_capability) {
+ hw_secure_codecs = GetSupportedCodecs(capability->hw_secure_capability.value(), /*is_secure=*/true);
+ hw_secure_encryption_schemes = capability->hw_secure_capability->encryption_schemes;
+ if (!base::Contains(capability->hw_secure_capability->session_types, media::CdmSessionType::kTemporary)) {
+ DVLOG(1) << "Temporary sessions must be supported.";
+ return;
+ }
+ }
// Robustness.
- using Robustness = cdm::WidevineKeySystemProperties::Robustness;
+ using Robustness = cdm::WidevineKeySystemInfo::Robustness;
auto max_audio_robustness = Robustness::SW_SECURE_CRYPTO;
auto max_video_robustness = Robustness::SW_SECURE_DECODE;
@@ -560,40 +638,52 @@ static void AddWidevine(std::vector<std::unique_ptr<media::KeySystemProperties>>
max_video_robustness = Robustness::HW_SECURE_ALL;
}
- // Session types.
- bool cdm_supports_temporary_session = base::Contains(capability->session_types, media::CdmSessionType::kTemporary);
- if (!cdm_supports_temporary_session) {
- DVLOG(1) << "Temporary session must be supported.";
- return;
- }
-
- auto persistent_license_support = media::EmeSessionTypeSupport::NOT_SUPPORTED;
- auto persistent_usage_record_support = media::EmeSessionTypeSupport::NOT_SUPPORTED;
-
// Others.
auto persistent_state_support = media::EmeFeatureSupport::REQUESTABLE;
auto distinctive_identifier_support = media::EmeFeatureSupport::NOT_SUPPORTED;
- concrete_key_systems->emplace_back(new cdm::WidevineKeySystemProperties(
- codecs, encryption_schemes, hw_secure_codecs,
- hw_secure_encryption_schemes, max_audio_robustness, max_video_robustness,
- persistent_license_support, persistent_usage_record_support,
- persistent_state_support, distinctive_identifier_support));
+ key_systems->emplace_back(new cdm::WidevineKeySystemInfo(
+ codecs, std::move(encryption_schemes), std::move(session_types),
+ hw_secure_codecs, std::move(hw_secure_encryption_schemes),
+ std::move(hw_secure_session_types),
+ max_audio_robustness, max_video_robustness,
+ persistent_state_support,
+ distinctive_identifier_support));
}
#endif // BUILDFLAG(ENABLE_WIDEVINE)
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
-void ContentRendererClientQt::AddSupportedKeySystems(std::vector<std::unique_ptr<media::KeySystemProperties>> *key_systems)
+void OnKeySystemSupportUpdated(media::GetSupportedKeySystemsCB cb,
+ content::KeySystemCapabilityPtrMap key_system_capabilities)
{
+ media::KeySystemInfos key_systems;
+ for (const auto &entry : key_system_capabilities) {
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
- if (base::FeatureList::IsEnabled(media::kExternalClearKeyForTesting))
- AddExternalClearKey(key_systems);
-
+ const auto &key_system = entry.first;
+ const auto &capability = entry.second;
#if BUILDFLAG(ENABLE_WIDEVINE)
- AddWidevine(key_systems);
+ if (key_system == kWidevineKeySystem) {
+ AddWidevine(capability, &key_systems);
+ continue;
+ }
#endif // BUILDFLAG(ENABLE_WIDEVINE)
+ if (key_system == media::kExternalClearKeyKeySystem) {
+ AddExternalClearKey(capability, &key_systems);
+ continue;
+ }
+
+ DLOG(ERROR) << "Unrecognized key system: " << key_system;
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
+ }
+
+ cb.Run(std::move(key_systems));
+}
+
+void ContentRendererClientQt::GetSupportedKeySystems(media::GetSupportedKeySystemsCB cb)
+{
+ content::ObserveKeySystemSupportUpdate(
+ base::BindRepeating(&OnKeySystemSupportUpdated, std::move(cb)));
}
#if QT_CONFIG(webengine_spellchecker)
@@ -606,25 +696,16 @@ void ContentRendererClientQt::InitSpellCheck()
void ContentRendererClientQt::WillSendRequest(blink::WebLocalFrame *frame,
ui::PageTransition transition_type,
const blink::WebURL &url,
- const blink::WebURL &site_for_cookies,
+ const net::SiteForCookies &site_for_cookies,
const url::Origin *initiator_origin,
- GURL *new_url,
- bool *attach_same_site_cookies)
+ GURL *new_url)
{
#if BUILDFLAG(ENABLE_EXTENSIONS)
- ExtensionsRendererClientQt::GetInstance()->WillSendRequest(frame, transition_type, url, /*site_for_cookies,*/
- initiator_origin, new_url, attach_same_site_cookies);
+ ExtensionsRendererClientQt::GetInstance()->WillSendRequest(frame, transition_type, url, site_for_cookies,
+ initiator_origin, new_url);
if (!new_url->is_empty())
return;
#endif
}
-bool ContentRendererClientQt::RequiresWebComponentsV0(const GURL &url)
-{
- Q_UNUSED(url);
- // Google services still presents pages using these features
- // to Chromium 80 based browsers (YouTube in particular).
- return true;
-}
-
} // namespace QtWebEngineCore
diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h
index f2e725453..b2231f00a 100644
--- a/src/core/renderer/content_renderer_client_qt.h
+++ b/src/core/renderer/content_renderer_client_qt.h
@@ -1,58 +1,24 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef CONTENT_RENDERER_CLIENT_QT_H
#define CONTENT_RENDERER_CLIENT_QT_H
#include "qtwebenginecoreglobal_p.h"
#include "content/public/renderer/content_renderer_client.h"
-#include "components/spellcheck/spellcheck_buildflags.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/local_interface_provider.h"
-#include "ppapi/buildflags/buildflags.h"
-
-#if BUILDFLAG(ENABLE_PLUGINS)
-#include "qtwebengine/browser/plugin.mojom.h"
-#include "third_party/blink/public/web/web_plugin_params.h"
-#endif
#include <QScopedPointer>
+namespace blink {
+class WebPlugin;
+struct WebPluginParams;
+}
+
+namespace chrome {
+class WebRtcLoggingAgentImpl;
+}
+
namespace error_page {
class Error;
}
@@ -69,14 +35,10 @@ class WebCacheImpl;
class SpellCheck;
#endif
-namespace content {
-struct WebPluginInfo;
-}
-
namespace QtWebEngineCore {
-class RenderThreadObserverQt;
-
+class UserResourceController;
+class RenderConfiguration;
class ContentRendererClientQt
: public content::ContentRendererClient
, public service_manager::LocalInterfaceProvider
@@ -88,56 +50,52 @@ public:
// content::ContentRendererClient:
void RenderThreadStarted() override;
void ExposeInterfacesToBrowser(mojo::BinderMap* binders) override;
- void RenderViewCreated(content::RenderView *render_view) override;
void RenderFrameCreated(content::RenderFrame *render_frame) override;
- bool ShouldSuppressErrorPage(content::RenderFrame *, const GURL &) override;
- bool HasErrorPage(int http_status_code) override;
+ void WebViewCreated(blink::WebView *web_view,
+ bool was_created_by_renderer,
+ const url::Origin *outermost_origin) override;
void PrepareErrorPage(content::RenderFrame *render_frame,
const blink::WebURLError &error,
const std::string &http_method,
+ content::mojom::AlternativeErrorPageOverrideInfoPtr alternative_error_page_info,
std::string *error_html) override;
void PrepareErrorPageForHttpStatusError(content::RenderFrame *render_frame,
- const GURL &unreachable_url,
+ const blink::WebURLError &error,
const std::string &http_method,
int http_status,
- std::string *error_html) override;
-
+ content::mojom::AlternativeErrorPageOverrideInfoPtr alternative_error_page_info,
+ std::string *error_html) override;
uint64_t VisitedLinkHash(const char *canonical_url, size_t length) override;
bool IsLinkVisited(uint64_t linkHash) override;
std::unique_ptr<blink::WebPrescientNetworking> CreatePrescientNetworking(content::RenderFrame *render_frame) override;
- void AddSupportedKeySystems(std::vector<std::unique_ptr<media::KeySystemProperties>> *key_systems) override;
-
+ void GetSupportedKeySystems(media::GetSupportedKeySystemsCB cb) override;
void RunScriptsAtDocumentStart(content::RenderFrame *render_frame) override;
void RunScriptsAtDocumentEnd(content::RenderFrame *render_frame) override;
void RunScriptsAtDocumentIdle(content::RenderFrame *render_frame) override;
+ bool IsPluginHandledExternally(content::RenderFrame *embedder_frame,
+ const blink::WebElement &plugin_element,
+ const GURL &original_url,
+ const std::string &original_mime_type) override;
bool OverrideCreatePlugin(content::RenderFrame *render_frame,
const blink::WebPluginParams &params,
blink::WebPlugin **plugin) override;
- content::BrowserPluginDelegate *CreateBrowserPluginDelegate(content::RenderFrame *render_frame,
- const content::WebPluginInfo &info,
- const std::string &mime_type,
- const GURL &original_url) override;
+ bool IsOriginIsolatedPepperPlugin(const base::FilePath& plugin_path) override;
void WillSendRequest(blink::WebLocalFrame *frame,
ui::PageTransition transition_type,
const blink::WebURL &url,
- const blink::WebURL &site_for_cookies,
+ const net::SiteForCookies &site_for_cookies,
const url::Origin *initiator_origin,
- GURL *new_url,
- bool *attach_same_site_cookies) override;
+ GURL *new_url) override;
- void BindReceiverOnMainThread(mojo::GenericPendingReceiver receiver) override;
- bool RequiresWebComponentsV0(const GURL &url) override;
-
-#if BUILDFLAG(ENABLE_PLUGINS)
- static blink::WebPlugin* CreatePlugin(content::RenderFrame* render_frame,
- const blink::WebPluginParams& params,
- const chrome::mojom::PluginInfo& plugin_info);
+#if QT_CONFIG(webengine_webrtc) && QT_CONFIG(webengine_extensions)
+ chrome::WebRtcLoggingAgentImpl *GetWebRtcLoggingAgent();
#endif
+
private:
-#if BUILDFLAG(ENABLE_SPELLCHECK)
+#if QT_CONFIG(webengine_spellchecker)
void InitSpellCheck();
#endif
// service_manager::LocalInterfaceProvider:
@@ -146,16 +104,16 @@ private:
void GetNavigationErrorStringsInternal(content::RenderFrame *renderFrame, const std::string &httpMethod,
const error_page::Error &error, std::string *errorHtml);
- QScopedPointer<RenderThreadObserverQt> m_renderThreadObserver;
+ QScopedPointer<RenderConfiguration> m_renderConfiguration;
+ QScopedPointer<UserResourceController> m_userResourceController;
QScopedPointer<visitedlink::VisitedLinkReader> m_visitedLinkReader;
QScopedPointer<web_cache::WebCacheImpl> m_webCacheImpl;
#if QT_CONFIG(webengine_spellchecker)
QScopedPointer<SpellCheck> m_spellCheck;
#endif
-
- service_manager::BinderRegistry m_registry;
-
- DISALLOW_COPY_AND_ASSIGN(ContentRendererClientQt);
+#if QT_CONFIG(webengine_webrtc) && QT_CONFIG(webengine_extensions)
+ std::unique_ptr<chrome::WebRtcLoggingAgentImpl> m_webrtcLoggingAgentImpl;
+#endif
};
} // namespace
diff --git a/src/core/renderer/content_settings_observer_qt.cpp b/src/core/renderer/content_settings_observer_qt.cpp
index df9b77037..3e3c159f5 100644
--- a/src/core/renderer/content_settings_observer_qt.cpp
+++ b/src/core/renderer/content_settings_observer_qt.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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 (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// Based on chrome/renderer/content_settings_observer.cc:
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
@@ -46,15 +10,12 @@
#include "content/public/renderer/render_frame.h"
#include "third_party/blink/public/platform/web_security_origin.h"
-#include "third_party/blink/public/web/web_plugin_document.h"
+#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "url/origin.h"
#include "common/qt_messages.h"
-using blink::WebSecurityOrigin;
-using blink::WebString;
-
namespace {
bool IsUniqueFrame(blink::WebFrame *frame)
@@ -82,21 +43,20 @@ bool ContentSettingsObserverQt::OnMessageReceived(const IPC::Message &message)
{
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserverQt, message)
- IPC_MESSAGE_HANDLER(QtWebEngineMsg_RequestFileSystemAccessAsyncResponse, OnRequestFileSystemAccessAsyncResponse)
+ IPC_MESSAGE_HANDLER(QtWebEngineMsg_RequestStorageAccessAsyncResponse, OnRequestStorageAccessAsyncResponse)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
-void ContentSettingsObserverQt::DidCommitProvisionalLoad(bool is_same_document_navigation, ui::PageTransition /*transition*/)
+void ContentSettingsObserverQt::DidCommitProvisionalLoad(ui::PageTransition /*transition*/)
{
blink::WebLocalFrame *frame = render_frame()->GetWebFrame();
if (frame->Parent())
return; // Not a top-level navigation.
- if (!is_same_document_navigation)
- ClearBlockedContentSettings();
+ ClearBlockedContentSettings();
GURL url = frame->GetDocument().Url();
// If we start failing this DCHECK, please makes sure we don't regress
@@ -109,68 +69,51 @@ void ContentSettingsObserverQt::OnDestruct()
delete this;
}
-bool ContentSettingsObserverQt::AllowDatabase()
-{
- blink::WebFrame *frame = render_frame()->GetWebFrame();
- if (IsUniqueFrame(frame))
- return false;
-
- bool result = false;
- Send(new QtWebEngineHostMsg_AllowDatabase(routing_id(), url::Origin(frame->GetSecurityOrigin()).GetURL(),
- url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), &result));
- return result;
-}
-
-void ContentSettingsObserverQt::RequestFileSystemAccessAsync(base::OnceCallback<void(bool)> callback)
+void ContentSettingsObserverQt::AllowStorageAccess(StorageType storage_type,
+ base::OnceCallback<void(bool)> callback)
{
blink::WebFrame *frame = render_frame()->GetWebFrame();
if (IsUniqueFrame(frame)) {
std::move(callback).Run(false);
return;
}
+
++m_currentRequestId;
bool inserted = m_permissionRequests.insert(std::make_pair(m_currentRequestId, std::move(callback))).second;
// Verify there are no duplicate insertions.
DCHECK(inserted);
- Send(new QtWebEngineHostMsg_RequestFileSystemAccessAsync(routing_id(), m_currentRequestId,
- url::Origin(frame->GetSecurityOrigin()).GetURL(),
- url::Origin(frame->Top()->GetSecurityOrigin()).GetURL()));
+ Send(new QtWebEngineHostMsg_RequestStorageAccessAsync(routing_id(), m_currentRequestId,
+ url::Origin(frame->GetSecurityOrigin()).GetURL(),
+ url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(),
+ int(storage_type)));
}
-bool ContentSettingsObserverQt::AllowIndexedDB()
-{
- blink::WebFrame *frame = render_frame()->GetWebFrame();
- if (IsUniqueFrame(frame))
- return false;
-
- bool result = false;
- Send(new QtWebEngineHostMsg_AllowIndexedDB(routing_id(),
- url::Origin(frame->GetSecurityOrigin()).GetURL(),
- url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), &result));
- return result;
-}
-
-bool ContentSettingsObserverQt::AllowStorage(bool local)
+bool ContentSettingsObserverQt::AllowStorageAccessSync(StorageType storage_type)
{
blink::WebLocalFrame *frame = render_frame()->GetWebFrame();
if (IsUniqueFrame(frame))
return false;
- StoragePermissionsKey key(url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL(), local);
- const auto permissions = m_cachedStoragePermissions.find(key);
- if (permissions != m_cachedStoragePermissions.end())
- return permissions->second;
+ bool sameOrigin = url::Origin(frame->Top()->GetSecurityOrigin()).IsSameOriginWith(url::Origin(frame->GetSecurityOrigin()));
+ StoragePermissionsKey key(url::Origin(frame->GetSecurityOrigin()).GetURL(), int(storage_type));
+ if (sameOrigin) {
+ const auto permissions = m_cachedStoragePermissions.find(key);
+ if (permissions != m_cachedStoragePermissions.end())
+ return permissions->second;
+ }
bool result = false;
- Send(new QtWebEngineHostMsg_AllowDOMStorage(routing_id(), url::Origin(frame->GetSecurityOrigin()).GetURL(),
- url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), local, &result));
- m_cachedStoragePermissions[key] = result;
+ Send(new QtWebEngineHostMsg_AllowStorageAccess(routing_id(), url::Origin(frame->GetSecurityOrigin()).GetURL(),
+ url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(),
+ int(storage_type), &result));
+ if (sameOrigin)
+ m_cachedStoragePermissions[key] = result;
return result;
}
-void ContentSettingsObserverQt::OnRequestFileSystemAccessAsyncResponse(int request_id, bool allowed)
+void ContentSettingsObserverQt::OnRequestStorageAccessAsyncResponse(int request_id, bool allowed)
{
auto it = m_permissionRequests.find(request_id);
if (it == m_permissionRequests.end())
diff --git a/src/core/renderer/content_settings_observer_qt.h b/src/core/renderer/content_settings_observer_qt.h
index 0c69d289c..415d0b6b7 100644
--- a/src/core/renderer/content_settings_observer_qt.h
+++ b/src/core/renderer/content_settings_observer_qt.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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 (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
@@ -50,10 +14,6 @@
#include "third_party/blink/public/platform/web_content_settings_client.h"
#include "url/gurl.h"
-namespace blink {
-class WebSecurityOrigin;
-}
-
namespace QtWebEngineCore {
// Handles blocking content per content settings for each RenderFrame.
@@ -67,33 +27,30 @@ public:
~ContentSettingsObserverQt() override;
// blink::WebContentSettingsClient:
- bool AllowDatabase() override;
- void RequestFileSystemAccessAsync(base::OnceCallback<void(bool)> callback) override;
- bool AllowIndexedDB() override;
- bool AllowStorage(bool local) override;
+ void AllowStorageAccess(StorageType storage_type,
+ base::OnceCallback<void(bool)> callback) override;
+ bool AllowStorageAccessSync(StorageType storage_type) override;
private:
// RenderFrameObserver implementation:
bool OnMessageReceived(const IPC::Message &message) override;
- void DidCommitProvisionalLoad(bool is_same_document_navigation, ui::PageTransition transition) override;
+ void DidCommitProvisionalLoad(ui::PageTransition transition) override;
void OnDestruct() override;
// Message handlers.
- void OnRequestFileSystemAccessAsyncResponse(int request_id, bool allowed);
+ void OnRequestStorageAccessAsyncResponse(int request_id, bool allowed);
// Clears m_cachedStoragePermissions
void ClearBlockedContentSettings();
// Caches the result of AllowStorage.
- using StoragePermissionsKey = std::pair<GURL, bool>;
+ using StoragePermissionsKey = std::pair<GURL, int>;
base::flat_map<StoragePermissionsKey, bool> m_cachedStoragePermissions;
int m_currentRequestId;
base::flat_map<int, base::OnceCallback<void(bool)>> m_permissionRequests;
-
- DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserverQt);
};
} // namespace QtWebEngineCore
-#endif // RENDERER_CONTENT_SETTINGS_OBSERVER_QT_H
+#endif // CONTENT_SETTINGS_OBSERVER_QT_H
diff --git a/src/core/renderer/extensions/extensions_dispatcher_delegate_qt.cpp b/src/core/renderer/extensions/extensions_dispatcher_delegate_qt.cpp
index 418429330..191e36d04 100644
--- a/src/core/renderer/extensions/extensions_dispatcher_delegate_qt.cpp
+++ b/src/core/renderer/extensions/extensions_dispatcher_delegate_qt.cpp
@@ -1,44 +1,11 @@
-/****************************************************************************
-**
-** 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: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 (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "extensions_dispatcher_delegate_qt.h"
+#include "chrome/grit/renderer_resources.h"
+#include "extensions/renderer/resource_bundle_source_map.h"
+
namespace QtWebEngineCore {
ExtensionsDispatcherDelegateQt::ExtensionsDispatcherDelegateQt()
@@ -49,4 +16,10 @@ ExtensionsDispatcherDelegateQt::~ExtensionsDispatcherDelegateQt()
{
}
+void ExtensionsDispatcherDelegateQt::PopulateSourceMap(extensions::ResourceBundleSourceMap *source_map)
+{
+ // Custom binding for hangout services extension.
+ source_map->RegisterSource("webrtcDesktopCapturePrivate", IDR_WEBRTC_DESKTOP_CAPTURE_PRIVATE_CUSTOM_BINDINGS_JS);
+}
+
} //namespace QtWebEngineCore
diff --git a/src/core/renderer/extensions/extensions_dispatcher_delegate_qt.h b/src/core/renderer/extensions/extensions_dispatcher_delegate_qt.h
index 25aa18e71..42ae165d1 100644
--- a/src/core/renderer/extensions/extensions_dispatcher_delegate_qt.h
+++ b/src/core/renderer/extensions/extensions_dispatcher_delegate_qt.h
@@ -1,46 +1,9 @@
-/****************************************************************************
-**
-** 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: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 (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef EXTENSIONSDISPATCHERDELEGATEQT_H
#define EXTENSIONSDISPATCHERDELEGATEQT_H
-#include "base/macros.h"
#include "extensions/renderer/dispatcher_delegate.h"
namespace QtWebEngineCore {
@@ -52,7 +15,8 @@ public:
~ExtensionsDispatcherDelegateQt() override;
private:
- DISALLOW_COPY_AND_ASSIGN(ExtensionsDispatcherDelegateQt);
+ // extensions::DispatcherDelegate implementation.
+ void PopulateSourceMap(extensions::ResourceBundleSourceMap *source_map) override;
};
} // namespace QtWebEngineCore
diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp
index 7d4c9a83c..b36ed9e8b 100644
--- a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp
+++ b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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 (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// based on chrome/renderer/extensions/chrome_extensions_renderer_client.cc:
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
@@ -45,12 +9,14 @@
#include "extensions_renderer_client_qt.h"
#include "extensions_dispatcher_delegate_qt.h"
-#include "renderer/render_thread_observer_qt.h"
+#include "renderer/render_configuration.h"
#include "renderer_permissions_policy_delegate_qt.h"
#include "resource_request_policy_qt.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
+#include "base/stl_util.h"
+#include "base/types/optional_util.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
#include "content/public/renderer/render_frame.h"
@@ -61,10 +27,8 @@
#include "extensions/common/switches.h"
#include "extensions/renderer/dispatcher.h"
#include "extensions/renderer/extension_frame_helper.h"
+#include "extensions/renderer/extension_web_view_helper.h"
#include "extensions/renderer/extensions_render_frame_observer.h"
-#include "extensions/renderer/guest_view/extensions_guest_view_container.h"
-#include "extensions/renderer/guest_view/extensions_guest_view_container_dispatcher.h"
-#include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h"
#include "extensions/renderer/renderer_extension_registry.h"
#include "extensions/renderer/script_context.h"
#include "third_party/blink/public/platform/web_url.h"
@@ -72,7 +36,6 @@
namespace chrome {
const char kExtensionInvalidRequestURL[] = "chrome-extension://invalid/";
-const char kExtensionResourceInvalidRequestURL[] = "chrome-extension-resource://invalid/";
}
namespace QtWebEngineCore {
@@ -88,7 +51,7 @@ ExtensionsRendererClientQt::~ExtensionsRendererClientQt()
// Returns true if the current render process was launched incognito.
bool ExtensionsRendererClientQt::IsIncognitoProcess() const
{
- return RenderThreadObserverQt::is_incognito_process();
+ return RenderConfiguration::is_incognito_process();
}
// Returns the lowest isolated world ID available to extensions.
@@ -127,9 +90,6 @@ bool ExtensionsRendererClientQt::ExtensionAPIEnabledForServiceWorkerScript(const
if (!script_url.SchemeIs(extensions::kExtensionScheme))
return false;
- if (!extensions::ExtensionsClient::Get()->ExtensionAPIEnabledInExtensionServiceWorkers())
- return false;
-
const extensions::Extension* extension =
extensions::RendererExtensionRegistry::Get()->GetExtensionOrAppByURL(script_url);
@@ -147,17 +107,18 @@ bool ExtensionsRendererClientQt::ExtensionAPIEnabledForServiceWorkerScript(const
void ExtensionsRendererClientQt::RenderThreadStarted()
{
content::RenderThread *thread = content::RenderThread::Get();
- // ChromeRenderViewTest::SetUp() creates its own ExtensionDispatcher and
- // injects it using SetExtensionDispatcher(). Don't overwrite it.
if (!extension_dispatcher_)
extension_dispatcher_.reset(new extensions::Dispatcher(std::make_unique<ExtensionsDispatcherDelegateQt>()));
extension_dispatcher_->OnRenderThreadStarted(thread);
permissions_policy_delegate_.reset(new RendererPermissionsPolicyDelegateQt(extension_dispatcher_.get()));
resource_request_policy_.reset(new extensions::ResourceRequestPolicyQt(extension_dispatcher_.get()));
- guest_view_container_dispatcher_.reset(new extensions::ExtensionsGuestViewContainerDispatcher());
thread->AddObserver(extension_dispatcher_.get());
- thread->AddObserver(guest_view_container_dispatcher_.get());
+}
+
+void ExtensionsRendererClientQt::WebViewCreated(blink::WebView *web_view, const url::Origin *outermost_origin)
+{
+ new extensions::ExtensionWebViewHelper(web_view, outermost_origin);
}
void ExtensionsRendererClientQt::RenderFrameCreated(content::RenderFrame *render_frame,
@@ -181,12 +142,14 @@ bool ExtensionsRendererClientQt::OverrideCreatePlugin(content::RenderFrame *rend
void ExtensionsRendererClientQt::WillSendRequest(blink::WebLocalFrame *frame,
ui::PageTransition transition_type,
const blink::WebURL &url,
+ const net::SiteForCookies &site_for_cookies,
const url::Origin *initiator_origin,
- GURL *new_url,
- bool *attach_same_site_cookies)
+ GURL *new_url)
{
if (url.ProtocolIs(extensions::kExtensionScheme) &&
- !resource_request_policy_->CanRequestResource(url, frame, transition_type)) {
+ !resource_request_policy_->CanRequestResource(url, frame,
+ transition_type,
+ base::OptionalFromPtr(initiator_origin))) {
*new_url = GURL(chrome::kExtensionInvalidRequestURL);
}
}
@@ -200,16 +163,6 @@ bool ExtensionsRendererClientQt::ShouldFork(blink::WebLocalFrame *frame,
return false; // TODO: Fix this to a sensible value
}
-content::BrowserPluginDelegate *ExtensionsRendererClientQt::CreateBrowserPluginDelegate(content::RenderFrame *render_frame,
- const content::WebPluginInfo &info,
- const std::string &mime_type,
- const GURL &original_url)
-{
- if (mime_type == content::kBrowserPluginMimeType)
- return new extensions::ExtensionsGuestViewContainer(render_frame);
- return new extensions::MimeHandlerViewContainer(render_frame, info, mime_type, original_url);
-}
-
void ExtensionsRendererClientQt::RunScriptsAtDocumentStart(content::RenderFrame *render_frame)
{
extension_dispatcher_->RunScriptsAtDocumentStart(render_frame);
diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.h b/src/core/renderer/extensions/extensions_renderer_client_qt.h
index 87e324213..163819cbc 100644
--- a/src/core/renderer/extensions/extensions_renderer_client_qt.h
+++ b/src/core/renderer/extensions/extensions_renderer_client_qt.h
@@ -1,49 +1,11 @@
-/****************************************************************************
-**
-** 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: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 (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef EXTENSIONSRENDERERCLIENTQT_H
#define EXTENSIONSRENDERERCLIENTQT_H
#include <memory>
-#include <string>
-#include "base/macros.h"
#include "extensions/renderer/extensions_renderer_client.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "ui/base/page_transition_types.h"
@@ -54,13 +16,15 @@ namespace blink {
class WebLocalFrame;
struct WebPluginParams;
class WebURL;
+class WebView;
}
namespace content {
-class BrowserPluginDelegate;
class RenderFrame;
-class RenderView;
-struct WebPluginInfo;
+}
+
+namespace net {
+class SiteForCookies;
}
namespace url {
@@ -69,7 +33,6 @@ class Origin;
namespace extensions {
class Dispatcher;
-class ExtensionsGuestViewContainerDispatcher;
class ResourceRequestPolicyQt;
}
@@ -93,25 +56,23 @@ public:
// Match ContentRendererClientQt's method names...
void RenderThreadStarted();
+ void WebViewCreated(blink::WebView *web_view,
+ const url::Origin *outermost_origin);
void RenderFrameCreated(content::RenderFrame *, service_manager::BinderRegistry *);
bool OverrideCreatePlugin(content::RenderFrame *render_frame,
const blink::WebPluginParams &params);
void WillSendRequest(blink::WebLocalFrame *frame,
ui::PageTransition transition_type,
const blink::WebURL &url,
+ const net::SiteForCookies &site_for_cookies,
const url::Origin *initiator_origin,
- GURL *new_url,
- bool *attach_same_site_cookies);
+ GURL *new_url);
static bool ShouldFork(blink::WebLocalFrame *frame,
const GURL &url,
bool is_initial_navigation,
bool is_server_redirect,
bool *send_referrer);
- static content::BrowserPluginDelegate *CreateBrowserPluginDelegate(content::RenderFrame *render_frame,
- const content::WebPluginInfo &info,
- const std::string &mime_type,
- const GURL &original_url);
bool ExtensionAPIEnabledForServiceWorkerScript(const GURL &scope, const GURL &script_url) const override;
@@ -128,7 +89,6 @@ private:
std::unique_ptr<ExtensionsDispatcherDelegateQt> extension_dispatcher_delegate_;
std::unique_ptr<RendererPermissionsPolicyDelegateQt> permissions_policy_delegate_;
std::unique_ptr<extensions::Dispatcher> extension_dispatcher_;
- std::unique_ptr<extensions::ExtensionsGuestViewContainerDispatcher> guest_view_container_dispatcher_;
std::unique_ptr<extensions::ResourceRequestPolicyQt> resource_request_policy_;
};
diff --git a/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.cpp b/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.cpp
index aef4903b7..fdfbe463b 100644
--- a/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.cpp
+++ b/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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 (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "renderer_permissions_policy_delegate_qt.h"
diff --git a/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.h b/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.h
index 385b7a4b0..23bfa8c88 100644
--- a/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.h
+++ b/src/core/renderer/extensions/renderer_permissions_policy_delegate_qt.h
@@ -1,46 +1,9 @@
-/****************************************************************************
-**
-** 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: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 (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef RENDERERPERMISSIONSPOLICYDELEGATEQT_H
#define RENDERERPERMISSIONSPOLICYDELEGATEQT_H
-#include "base/macros.h"
#include "extensions/common/permissions/permissions_data.h"
namespace extensions {
@@ -56,9 +19,6 @@ public:
~RendererPermissionsPolicyDelegateQt() override;
bool IsRestrictedUrl(const GURL &, std::string *) override;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(RendererPermissionsPolicyDelegateQt);
};
} // namespace QtWebEngineCore
diff --git a/src/core/renderer/extensions/resource_request_policy_qt.cpp b/src/core/renderer/extensions/resource_request_policy_qt.cpp
index efe44521d..a61e53310 100644
--- a/src/core/renderer/extensions/resource_request_policy_qt.cpp
+++ b/src/core/renderer/extensions/resource_request_policy_qt.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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: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 (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// based on chrome/renderer/extensions/resource_request_policy.cc:
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
@@ -63,8 +27,9 @@ ResourceRequestPolicyQt::ResourceRequestPolicyQt(Dispatcher *dispatcher)
void ResourceRequestPolicyQt::OnExtensionLoaded(const Extension &extension)
{
- if (WebAccessibleResourcesInfo::HasWebAccessibleResources(&extension)
- || WebviewInfo::HasWebviewAccessibleResources(extension, m_dispatcher->webview_partition_id())
+ if (WebAccessibleResourcesInfo::HasWebAccessibleResources(&extension) ||
+ WebviewInfo::HasWebviewAccessibleResources(extension,
+ m_dispatcher->webview_partition_id().value_or(std::string()))
// // Hosted app icons are accessible.
// // TODO(devlin): Should we incorporate this into
// // WebAccessibleResourcesInfo?
@@ -85,7 +50,8 @@ void ResourceRequestPolicyQt::OnExtensionUnloaded(const ExtensionId &extension_i
// than those triggered through UI.
bool ResourceRequestPolicyQt::CanRequestResource(const GURL &resource_url,
blink::WebLocalFrame *frame,
- ui::PageTransition transition_type)
+ ui::PageTransition transition_type,
+ const absl::optional<url::Origin>& initiator_origin)
{
CHECK(resource_url.SchemeIs(kExtensionScheme));
@@ -96,7 +62,7 @@ bool ResourceRequestPolicyQt::CanRequestResource(const GURL &resource_url,
// current extension or has a devtools scheme.
GURL page_origin = url::Origin(frame->Top()->GetSecurityOrigin()).GetURL();
- GURL extension_origin = resource_url.GetOrigin();
+ GURL extension_origin = resource_url.DeprecatedGetOriginAsURL();
// We always allow loads in the following cases, regardless of web accessible
// resources:
@@ -112,7 +78,7 @@ bool ResourceRequestPolicyQt::CanRequestResource(const GURL &resource_url,
// of the frame, to account for about:blank subframes being scripted by an
// extension parent (though we'll still need the frame origin check for
// sandboxed frames).
- if (frame_url.GetOrigin() == extension_origin || page_origin == extension_origin)
+ if (frame_url.DeprecatedGetOriginAsURL() == extension_origin || page_origin == extension_origin)
return true;
if (!ui::PageTransitionIsWebTriggerable(transition_type))
@@ -165,8 +131,10 @@ bool ResourceRequestPolicyQt::CanRequestResource(const GURL &resource_url,
// Disallow loading of extension resources which are not explicitly listed
// as web or WebView accessible if the manifest version is 2 or greater.
- if (!WebAccessibleResourcesInfo::IsResourceWebAccessible(extension, resource_url.path()) &&
- !WebviewInfo::IsResourceWebviewAccessible(extension, m_dispatcher->webview_partition_id(), resource_url.path()))
+ if (!WebAccessibleResourcesInfo::IsResourceWebAccessible(extension, resource_url.path(), initiator_origin) &&
+ !WebviewInfo::IsResourceWebviewAccessible(extension,
+ m_dispatcher->webview_partition_id().value_or(std::string()),
+ resource_url.path()))
{
std::string message = base::StringPrintf(
"Denying load of %s. Resources must be listed in the "
diff --git a/src/core/renderer/extensions/resource_request_policy_qt.h b/src/core/renderer/extensions/resource_request_policy_qt.h
index e6d4e79bb..ec108519f 100644
--- a/src/core/renderer/extensions/resource_request_policy_qt.h
+++ b/src/core/renderer/extensions/resource_request_policy_qt.h
@@ -1,50 +1,15 @@
-/****************************************************************************
-**
-** 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: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 (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef RESOURCEREQUESTPOLICYQT_H
#define RESOURCEREQUESTPOLICYQT_H
#include <set>
-#include "base/macros.h"
#include "extensions/common/extension_id.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/base/page_transition_types.h"
+#include "url/origin.h"
class GURL;
@@ -73,7 +38,8 @@ public:
// than those triggered through UI.
bool CanRequestResource(const GURL &resource_url,
blink::WebLocalFrame *frame,
- ui::PageTransition transition_type);
+ ui::PageTransition transition_type,
+ const absl::optional<url::Origin> &initiator_origin);
private:
Dispatcher *m_dispatcher;
@@ -81,8 +47,6 @@ private:
// The set of extension IDs with any potentially web- or webview-accessible
// resources.
std::set<ExtensionId> m_web_accessible_ids;
-
- DISALLOW_COPY_AND_ASSIGN(ResourceRequestPolicyQt);
};
} // namespace extensions
diff --git a/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp b/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp
deleted file mode 100644
index 9af05fd08..000000000
--- a/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp
+++ /dev/null
@@ -1,432 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
-
-// This is based on chrome/renderer/pepper/pepper_flash_renderer_host.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.Chromium file.
-
-#include "pepper_flash_renderer_host_qt.h"
-
-#include <map>
-#include <vector>
-
-#include "base/lazy_instance.h"
-#include "base/macros.h"
-#include "base/metrics/histogram_macros.h"
-#include "base/strings/string_util.h"
-#include "content/public/renderer/pepper_plugin_instance.h"
-#include "content/public/renderer/render_thread.h"
-#include "content/public/renderer/renderer_ppapi_host.h"
-#include "ipc/ipc_message_macros.h"
-#include "net/http/http_util.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/trusted/ppb_browser_font_trusted.h"
-#include "ppapi/host/dispatch_host_message.h"
-#include "ppapi/proxy/host_dispatcher.h"
-#include "ppapi/proxy/ppapi_messages.h"
-#include "ppapi/proxy/resource_message_params.h"
-#include "ppapi/proxy/serialized_structs.h"
-#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/ppb_image_data_api.h"
-#include "skia/ext/platform_canvas.h"
-#include "third_party/skia/include/core/SkCanvas.h"
-#include "third_party/skia/include/core/SkMatrix.h"
-#include "third_party/skia/include/core/SkPaint.h"
-#include "third_party/skia/include/core/SkPoint.h"
-#include "third_party/skia/include/core/SkTextBlob.h"
-#include "third_party/skia/include/core/SkTypeface.h"
-#include "third_party/skia/include/private/SkTemplates.h"
-#include "ui/gfx/geometry/rect.h"
-#include "url/gurl.h"
-
-using ppapi::thunk::EnterResourceNoLock;
-using ppapi::thunk::PPB_ImageData_API;
-
-namespace {
-
-// Some non-simple HTTP request headers that Flash may set.
-// (Please see http://www.w3.org/TR/cors/#simple-header for the definition of
-// simple headers.)
-//
-// The list and the enum defined below are used to collect data about request
-// headers used in PPB_Flash.Navigate() calls, in order to understand the impact
-// of rejecting PPB_Flash.Navigate() requests with non-simple headers.
-//
-// TODO(yzshen): We should be able to remove the histogram recording code once
-// we get the answer.
-const char* const kRejectedHttpRequestHeaders[] = {
- "authorization", //
- "cache-control", //
- "content-encoding", //
- "content-md5", //
- "content-type", // If the media type is not one of those covered by the
- // simple header definition.
- "expires", //
- "from", //
- "if-match", //
- "if-none-match", //
- "if-range", //
- "if-unmodified-since", //
- "pragma", //
- "referer" //
-};
-
-// Please note that new entries should be added right above
-// FLASH_NAVIGATE_USAGE_ENUM_COUNT, and existing entries shouldn't be re-ordered
-// or removed, since this ordering is used in a histogram.
-enum FlashNavigateUsage {
- // This section must be in the same order as kRejectedHttpRequestHeaders.
- REJECT_AUTHORIZATION = 0,
- REJECT_CACHE_CONTROL,
- REJECT_CONTENT_ENCODING,
- REJECT_CONTENT_MD5,
- REJECT_CONTENT_TYPE,
- REJECT_EXPIRES,
- REJECT_FROM,
- REJECT_IF_MATCH,
- REJECT_IF_NONE_MATCH,
- REJECT_IF_RANGE,
- REJECT_IF_UNMODIFIED_SINCE,
- REJECT_PRAGMA,
- REJECT_REFERER,
-
- // The navigate request is rejected because of headers not listed above
- // (e.g., custom headers).
- REJECT_OTHER_HEADERS,
-
- // Total number of rejected navigate requests.
- TOTAL_REJECTED_NAVIGATE_REQUESTS,
-
- // Total number of navigate requests.
- TOTAL_NAVIGATE_REQUESTS,
- FLASH_NAVIGATE_USAGE_ENUM_COUNT
-};
-
-static base::LazyInstance<std::map<std::string, FlashNavigateUsage>>::
- DestructorAtExit g_rejected_headers = LAZY_INSTANCE_INITIALIZER;
-
-bool IsSimpleHeader(const std::string& lower_case_header_name,
- const std::string& header_value)
-{
- if (lower_case_header_name == "accept" ||
- lower_case_header_name == "accept-language" ||
- lower_case_header_name == "content-language")
- return true;
-
- if (lower_case_header_name == "content-type") {
- std::string lower_case_mime_type;
- std::string lower_case_charset;
- bool had_charset = false;
- net::HttpUtil::ParseContentType(header_value,
- &lower_case_mime_type,
- &lower_case_charset,
- &had_charset,
- NULL);
- return lower_case_mime_type == "application/x-www-form-urlencoded" ||
- lower_case_mime_type == "multipart/form-data" ||
- lower_case_mime_type == "text/plain";
- }
-
- return false;
-}
-
-void RecordFlashNavigateUsage(FlashNavigateUsage usage)
-{
- DCHECK_NE(FLASH_NAVIGATE_USAGE_ENUM_COUNT, usage);
- UMA_HISTOGRAM_ENUMERATION(
- "Plugin.FlashNavigateUsage",
- usage,
- FLASH_NAVIGATE_USAGE_ENUM_COUNT);
-}
-
-} // namespace
-
-namespace QtWebEngineCore {
-
-PepperFlashRendererHostQt::PepperFlashRendererHostQt(
- content::RendererPpapiHost* host,
- PP_Instance instance,
- PP_Resource resource)
- : ResourceHost(host->GetPpapiHost(), instance, resource),
- host_(host),
- weak_factory_(this)
-{
-}
-
-PepperFlashRendererHostQt::~PepperFlashRendererHostQt() {
- // This object may be destroyed in the middle of a sync message. If that is
- // the case, make sure we respond to all the pending navigate calls.
- std::vector<ppapi::host::ReplyMessageContext>::reverse_iterator it;
- for (it = navigate_replies_.rbegin(); it != navigate_replies_.rend(); ++it)
- SendReply(*it, IPC::Message());
-}
-
-int32_t PepperFlashRendererHostQt::OnResourceMessageReceived(
- const IPC::Message& msg,
- ppapi::host::HostMessageContext* context)
-{
- PPAPI_BEGIN_MESSAGE_MAP(PepperFlashRendererHostQt, msg)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_GetProxyForURL,
- OnGetProxyForURL)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_SetInstanceAlwaysOnTop,
- OnSetInstanceAlwaysOnTop)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_DrawGlyphs,
- OnDrawGlyphs)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_Navigate, OnNavigate)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_IsRectTopmost,
- OnIsRectTopmost)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Flash_InvokePrinting,
- OnInvokePrinting)
- PPAPI_END_MESSAGE_MAP()
- return PP_ERROR_FAILED;
-}
-
-int32_t PepperFlashRendererHostQt::OnGetProxyForURL(
- ppapi::host::HostMessageContext* host_context,
- const std::string& url)
-{
- GURL gurl(url);
- if (!gurl.is_valid())
- return PP_ERROR_FAILED;
- std::string proxy;
- bool result = content::RenderThread::Get()->ResolveProxy(gurl, &proxy);
- if (!result)
- return PP_ERROR_FAILED;
- host_context->reply_msg = PpapiPluginMsg_Flash_GetProxyForURLReply(proxy);
- return PP_OK;
-}
-
-int32_t PepperFlashRendererHostQt::OnSetInstanceAlwaysOnTop(
- ppapi::host::HostMessageContext* host_context,
- bool on_top)
-{
- content::PepperPluginInstance* plugin_instance =
- host_->GetPluginInstance(pp_instance());
- if (plugin_instance)
- plugin_instance->SetAlwaysOnTop(on_top);
- return PP_OK;
-}
-
-int32_t PepperFlashRendererHostQt::OnDrawGlyphs(
- ppapi::host::HostMessageContext* host_context,
- ppapi::proxy::PPBFlash_DrawGlyphs_Params params)
-{
- if (params.glyph_indices.size() != params.glyph_advances.size() ||
- params.glyph_indices.empty())
- return PP_ERROR_FAILED;
-
- int weight = (params.font_desc.weight + 1) * 100;
- SkFontStyle::Slant slant = SkFontStyle::kUpright_Slant;
- if (params.font_desc.italic)
- slant = SkFontStyle::kItalic_Slant;
- SkFontStyle style(weight, SkFontStyle::kNormal_Width, slant);
- sk_sp<SkTypeface> typeface(
- SkTypeface::MakeFromName(params.font_desc.face.c_str(), style));
- if (!typeface)
- return PP_ERROR_FAILED;
-
- EnterResourceNoLock<PPB_ImageData_API> enter(params.image_data.host_resource(), true);
- if (enter.failed())
- return PP_ERROR_FAILED;
-
- PPB_ImageData_API* image = static_cast<PPB_ImageData_API*>(enter.object());
- SkCanvas* canvas = image->GetCanvas();
- bool needs_unmapping = false;
- if (!canvas) {
- needs_unmapping = true;
- image->Map();
- canvas = image->GetCanvas();
- if (!canvas)
- return PP_ERROR_FAILED; // Failure mapping.
- }
-
- SkAutoCanvasRestore acr(canvas, true);
-
- // Clip is applied in pixels before the transform.
- SkRect clip_rect = {
- SkIntToScalar(params.clip.point.x), SkIntToScalar(params.clip.point.y),
- SkIntToScalar(params.clip.point.x + params.clip.size.width),
- SkIntToScalar(params.clip.point.y + params.clip.size.height)};
- canvas->clipRect(clip_rect);
-
- SkMatrix matrix;
- matrix.set(SkMatrix::kMScaleX, SkFloatToScalar(params.transformation[0][0]));
- matrix.set(SkMatrix::kMSkewX, SkFloatToScalar(params.transformation[0][1]));
- matrix.set(SkMatrix::kMTransX, SkFloatToScalar(params.transformation[0][2]));
- matrix.set(SkMatrix::kMSkewY, SkFloatToScalar(params.transformation[1][0]));
- matrix.set(SkMatrix::kMScaleY, SkFloatToScalar(params.transformation[1][1]));
- matrix.set(SkMatrix::kMTransY, SkFloatToScalar(params.transformation[1][2]));
- matrix.set(SkMatrix::kMPersp0, SkFloatToScalar(params.transformation[2][0]));
- matrix.set(SkMatrix::kMPersp1, SkFloatToScalar(params.transformation[2][1]));
- matrix.set(SkMatrix::kMPersp2, SkFloatToScalar(params.transformation[2][2]));
- canvas->concat(matrix);
-
- SkPaint paint;
- paint.setColor(params.color);
-
- SkFont font(std::move(typeface), SkIntToScalar(params.font_desc.size));
- font.setHinting(SkFontHinting::kFull);
- if (params.allow_subpixel_aa) {
- font.setSubpixel(true);
- font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
- }
-
- SkScalar x = SkIntToScalar(params.position.x);
- SkScalar y = SkIntToScalar(params.position.y);
-
- // Build up the skia advances.
- size_t glyph_count = params.glyph_indices.size();
- if (glyph_count) {
- SkTextBlobBuilder builder;
- auto rec = builder.allocRunPos(font, glyph_count);
- memcpy(rec.glyphs, &params.glyph_indices[0], glyph_count * 2);
- SkPoint* pos = reinterpret_cast<SkPoint*>(rec.pos);
- for (uint32_t i = 0; i < glyph_count; i++) {
- pos[i].set(x, y);
- x += SkFloatToScalar(params.glyph_advances[i].x);
- y += SkFloatToScalar(params.glyph_advances[i].y);
- }
- canvas->drawTextBlob(builder.make(), 0, 0, paint);
- }
-
- if (needs_unmapping)
- image->Unmap();
-
- return PP_OK;
-}
-
-// CAUTION: This code is subtle because Navigate is a sync call which may
-// cause re-entrancy or cause the instance to be destroyed. If the instance
-// is destroyed we need to ensure that we respond to all outstanding sync
-// messages so that the plugin process does not remain blocked.
-int32_t PepperFlashRendererHostQt::OnNavigate(
- ppapi::host::HostMessageContext* host_context,
- const ppapi::URLRequestInfoData& data,
- const std::string& target,
- bool from_user_action)
-{
- // If our PepperPluginInstance is already destroyed, just return a failure.
- content::PepperPluginInstance* plugin_instance =
- host_->GetPluginInstance(pp_instance());
- if (!plugin_instance)
- return PP_ERROR_FAILED;
-
- std::map<std::string, FlashNavigateUsage>& rejected_headers =
- g_rejected_headers.Get();
- if (rejected_headers.empty()) {
- for (size_t i = 0; i < base::size(kRejectedHttpRequestHeaders); ++i)
- rejected_headers[kRejectedHttpRequestHeaders[i]] =
- static_cast<FlashNavigateUsage>(i);
- }
-
- net::HttpUtil::HeadersIterator header_iter(
- data.headers.begin(), data.headers.end(), "\n\r");
- bool rejected = false;
- while (header_iter.GetNext()) {
- std::string lower_case_header_name =
- base::ToLowerASCII(header_iter.name());
- if (!IsSimpleHeader(lower_case_header_name, header_iter.values())) {
- rejected = true;
-
- std::map<std::string, FlashNavigateUsage>::const_iterator iter =
- rejected_headers.find(lower_case_header_name);
- FlashNavigateUsage usage =
- iter != rejected_headers.end() ? iter->second : REJECT_OTHER_HEADERS;
- RecordFlashNavigateUsage(usage);
- }
- }
-
- RecordFlashNavigateUsage(TOTAL_NAVIGATE_REQUESTS);
- if (rejected) {
- RecordFlashNavigateUsage(TOTAL_REJECTED_NAVIGATE_REQUESTS);
- return PP_ERROR_NOACCESS;
- }
-
- // Navigate may call into Javascript (e.g. with a "javascript:" URL),
- // or do things like navigate away from the page, either one of which will
- // need to re-enter into the plugin. It is safe, because it is essentially
- // equivalent to NPN_GetURL, where Flash would expect re-entrancy.
- ppapi::proxy::HostDispatcher* host_dispatcher =
- ppapi::proxy::HostDispatcher::GetForInstance(pp_instance());
- host_dispatcher->set_allow_plugin_reentrancy();
-
- // Grab a weak pointer to ourselves on the stack so we can check if we are
- // still alive.
- base::WeakPtr<PepperFlashRendererHostQt> weak_ptr = weak_factory_.GetWeakPtr();
- // Keep track of reply contexts in case we are destroyed during a Navigate
- // call. Even if we are destroyed, we still need to send these replies to
- // unblock the plugin process.
- navigate_replies_.push_back(host_context->MakeReplyMessageContext());
- plugin_instance->Navigate(data, target.c_str(), from_user_action);
- // This object might have been destroyed by this point. If it is destroyed
- // the reply will be sent in the destructor. Otherwise send the reply here.
- if (weak_ptr.get()) {
- SendReply(navigate_replies_.back(), IPC::Message());
- navigate_replies_.pop_back();
- }
-
- // Return PP_OK_COMPLETIONPENDING so that no reply is automatically sent.
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t PepperFlashRendererHostQt::OnIsRectTopmost(
- ppapi::host::HostMessageContext* host_context,
- const PP_Rect& rect)
-{
- content::PepperPluginInstance* plugin_instance =
- host_->GetPluginInstance(pp_instance());
- if (plugin_instance &&
- plugin_instance->IsRectTopmost(
- gfx::Rect(
- rect.point.x,
- rect.point.y,
- rect.size.width,
- rect.size.height)))
- return PP_OK;
- return PP_ERROR_FAILED;
-}
-
-int32_t PepperFlashRendererHostQt::OnInvokePrinting(
- ppapi::host::HostMessageContext* host_context)
-{
- return PP_ERROR_FAILED;
-}
-
-} //QtWebEngineCore
diff --git a/src/core/renderer/pepper/pepper_flash_renderer_host_qt.h b/src/core/renderer/pepper/pepper_flash_renderer_host_qt.h
deleted file mode 100644
index ae6bc0876..000000000
--- a/src/core/renderer/pepper/pepper_flash_renderer_host_qt.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 PEPPER_FLASH_RENDERER_HOST_QT_H
-#define PEPPER_FLASH_RENDERER_HOST_QT_H
-
-#include <string>
-#include <vector>
-
-#include "base/memory/weak_ptr.h"
-#include "ppapi/host/host_message_context.h"
-#include "ppapi/host/resource_host.h"
-
-struct PP_Rect;
-
-namespace ppapi {
-struct URLRequestInfoData;
-}
-
-namespace ppapi {
-namespace proxy {
-struct PPBFlash_DrawGlyphs_Params;
-}
-}
-
-namespace content {
-class RendererPpapiHost;
-}
-
-namespace QtWebEngineCore {
-
-class PepperFlashRendererHostQt : public ppapi::host::ResourceHost {
-public:
- PepperFlashRendererHostQt(content::RendererPpapiHost* host,
- PP_Instance instance,
- PP_Resource resource);
- ~PepperFlashRendererHostQt() override;
-
- // ppapi::host::ResourceHost override.
- int32_t OnResourceMessageReceived(
- const IPC::Message& msg,
- ppapi::host::HostMessageContext* context) override;
-
-private:
- int32_t OnGetProxyForURL(ppapi::host::HostMessageContext* host_context,
- const std::string& url);
- int32_t OnSetInstanceAlwaysOnTop(
- ppapi::host::HostMessageContext* host_context,
- bool on_top);
- int32_t OnDrawGlyphs(ppapi::host::HostMessageContext* host_context,
- ppapi::proxy::PPBFlash_DrawGlyphs_Params params);
- int32_t OnNavigate(ppapi::host::HostMessageContext* host_context,
- const ppapi::URLRequestInfoData& data,
- const std::string& target,
- bool from_user_action);
- int32_t OnIsRectTopmost(ppapi::host::HostMessageContext* host_context,
- const PP_Rect& rect);
- int32_t OnInvokePrinting(ppapi::host::HostMessageContext* host_context);
-
- // A stack of ReplyMessageContexts to track Navigate() calls which have not
- // yet been replied to.
- std::vector<ppapi::host::ReplyMessageContext> navigate_replies_;
-
- content::RendererPpapiHost* host_;
- base::WeakPtrFactory<PepperFlashRendererHostQt> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(PepperFlashRendererHostQt);
-};
-
-} //QtWebEngineCore
-#endif // PEPPER_FLASH_RENDERER_HOST_QT_H
diff --git a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp
index 33c744f13..d0daea8c2 100644
--- a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp
+++ b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// This is based on chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc:
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
@@ -43,20 +7,12 @@
// found in the LICENSE.Chromium file.
#include "pepper_renderer_host_factory_qt.h"
-#include "pepper_flash_renderer_host_qt.h"
#include "qtwebenginecoreglobal_p.h"
-#include "base/memory/ptr_util.h"
-#include "chrome/renderer/pepper/pepper_flash_font_file_host.h"
-#if QT_CONFIG(webengine_printing_and_pdf)
-#include "components/pdf/renderer/pepper_pdf_host.h"
-#endif // QT_CONFIG(webengine_printing_and_pdf)
#include "content/public/renderer/renderer_ppapi_host.h"
#include "ppapi/host/ppapi_host.h"
#include "ppapi/host/resource_host.h"
#include "ppapi/proxy/ppapi_messages.h"
-#include "ppapi/proxy/ppapi_message_utils.h"
-#include "ppapi/shared_impl/ppapi_permissions.h"
namespace QtWebEngineCore {
@@ -81,52 +37,13 @@ std::unique_ptr<ppapi::host::ResourceHost> PepperRendererHostFactoryQt::CreateRe
if (!host_->IsValidInstance(instance))
return nullptr;
- if (host_->GetPpapiHost()->permissions().HasPermission(ppapi::PERMISSION_FLASH)) {
- switch (message.type()) {
- case PpapiHostMsg_Flash_Create::ID:
- return base::WrapUnique(new PepperFlashRendererHostQt(host_, instance, resource));
- case PpapiHostMsg_FlashMenu_Create::ID: {
- ppapi::host::ReplyMessageContext reply_context(
- ppapi::proxy::ResourceMessageReplyParams(resource, 0),
- NULL,
- MSG_ROUTING_NONE);
- reply_context.params.set_result(PP_ERROR_USERCANCEL);
- host_->GetPpapiHost()->SendReply(reply_context, PpapiPluginMsg_FlashMenu_ShowReply(-1));
- break;
- }
- case PpapiHostMsg_FlashFullscreen_Create::ID:
- // Not implemented
- break;
- }
+ // Create a default ResourceHost for this message type to suppress
+ // "Failed to create PPAPI resource host" console error message.
+ switch (message.type()) {
+ case PpapiHostMsg_UMA_Create::ID:
+ return std::make_unique<ppapi::host::ResourceHost>(host_->GetPpapiHost(), instance, resource);
}
- // TODO(raymes): PDF also needs access to the FlashFontFileHost currently.
- // We should either rename PPB_FlashFont_File to PPB_FontFile_Private or get
- // rid of its use in PDF if possible.
- if (host_->GetPpapiHost()->permissions().HasPermission(ppapi::PERMISSION_FLASH)
- || host_->GetPpapiHost()->permissions().HasPermission(ppapi::PERMISSION_PDF)) {
- switch (message.type()) {
- case PpapiHostMsg_FlashFontFile_Create::ID: {
- ppapi::proxy::SerializedFontDescription description;
- PP_PrivateFontCharset charset;
- if (ppapi::UnpackMessage<PpapiHostMsg_FlashFontFile_Create>(message, &description, &charset))
- return base::WrapUnique(new PepperFlashFontFileHost(host_, instance, resource, description, charset));
- break;
- }
- case PpapiHostMsg_FlashDRM_Create::ID:
- // Not implemented
- break;
- }
- }
-
-#if QT_CONFIG(webengine_printing_and_pdf)
- if (host_->GetPpapiHost()->permissions().HasPermission(ppapi::PERMISSION_PDF)) {
- switch (message.type()) {
- case PpapiHostMsg_PDF_Create::ID:
- return std::make_unique<pdf::PepperPDFHost>(host_, instance, resource);
- }
- }
-#endif // QT_CONFIG(webengine_printing_and_pdf)
return nullptr;
}
diff --git a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h
index ec3440a08..c31aa23d7 100644
--- a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h
+++ b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef PEPPER_RENDERER_HOST_FACTORY_QT_H
#define PEPPER_RENDERER_HOST_FACTORY_QT_H
@@ -65,8 +29,6 @@ public:
private:
// Not owned by this object.
content::RendererPpapiHost* host_;
-
- DISALLOW_COPY_AND_ASSIGN(PepperRendererHostFactoryQt);
};
} // namespace QtWebEngineCore
diff --git a/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp b/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp
index b43d9a24b..06fd4f71f 100644
--- a/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp
+++ b/src/core/renderer/plugins/loadable_plugin_placeholder_qt.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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 (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
@@ -61,15 +25,12 @@ gin::WrapperInfo LoadablePluginPlaceholderQt::kWrapperInfo = {gin::kEmbedderNati
LoadablePluginPlaceholderQt::LoadablePluginPlaceholderQt(content::RenderFrame* render_frame,
const blink::WebPluginParams& params,
const std::string& html_data,
- const base::string16& title)
+ const std::u16string& title)
: plugins::LoadablePluginPlaceholder(render_frame, params, html_data)
- , context_menu_request_id_(0)
{}
LoadablePluginPlaceholderQt::~LoadablePluginPlaceholderQt()
{
- if (context_menu_request_id_ && render_frame())
- render_frame()->CancelContextMenu(context_menu_request_id_);
}
// TODO(bauerb): Move this method to NonLoadablePluginPlaceholder?
@@ -77,13 +38,13 @@ 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", "");
- values.SetString("message", l10n_util::GetStringUTF8(IDS_PLUGIN_NOT_SUPPORTED));
+ base::Value::Dict values;
+ values.Set("name", "");
+ values.Set("message", l10n_util::GetStringUTF8(IDS_PLUGIN_NOT_SUPPORTED));
- const std::string html_data = webui::GetI18nTemplateHtml(template_html, &values);
+ const std::string html_data = webui::GetI18nTemplateHtml(template_html, std::move(values));
// Will destroy itself when its WebViewPlugin is going away.
return new LoadablePluginPlaceholderQt(render_frame, params, html_data, params.mime_type.Utf16());
diff --git a/src/core/renderer/plugins/loadable_plugin_placeholder_qt.h b/src/core/renderer/plugins/loadable_plugin_placeholder_qt.h
index 7bcad2d96..9b9d1bca8 100644
--- a/src/core/renderer/plugins/loadable_plugin_placeholder_qt.h
+++ b/src/core/renderer/plugins/loadable_plugin_placeholder_qt.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** 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 (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
@@ -44,7 +8,6 @@
#ifndef LOADALBLE_PLUGIN_PLACEHOLDER_QT_H
#define LOADALBLE_PLUGIN_PLACEHOLDER_QT_H
-#include "base/macros.h"
#include "components/plugins/renderer/loadable_plugin_placeholder.h"
namespace QtWebEngineCore {
@@ -63,20 +26,14 @@ private:
LoadablePluginPlaceholderQt(content::RenderFrame* render_frame,
const blink::WebPluginParams& params,
const std::string& html_data,
- const base::string16& title);
+ const std::u16string& title);
~LoadablePluginPlaceholderQt() override;
// content::LoadablePluginPlaceholder overrides.
blink::WebPlugin* CreatePlugin() override;
- void OnBlockedContent(content::RenderFrame::PeripheralContentStatus status,
- bool is_same_origin) override {}
// WebViewPlugin::Delegate (via PluginPlaceholder) methods:
v8::Local<v8::Value> GetV8Handle(v8::Isolate* isolate) override;
-
- int context_menu_request_id_; // Nonzero when request pending.
-
- DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholderQt);
};
} // namespace QtWebEngineCore
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/renderer/plugins/plugin_placeholder_qt.h b/src/core/renderer/plugins/plugin_placeholder_qt.h
deleted file mode 100644
index a99c0d045..000000000
--- a/src/core/renderer/plugins/plugin_placeholder_qt.h
+++ /dev/null
@@ -1,78 +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.
-
-#ifndef PLUGIN_PLACEHOLDER_QT_H
-#define PLUGIN_PLACEHOLDER_QT_H
-
-#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"
-
-namespace QtWebEngineCore {
-
-// A basic placeholder that supports only hiding.
-class PluginPlaceholderQt final : public plugins::PluginPlaceholderBase
- , public gin::Wrappable<PluginPlaceholderQt>
-{
-public:
- static gin::WrapperInfo kWrapperInfo;
-
- PluginPlaceholderQt(content::RenderFrame* render_frame,
- const blink::WebPluginParams& params,
- const std::string& html_data);
- ~PluginPlaceholderQt() override;
-
-private:
- // WebViewPlugin::Delegate methods:
- v8::Local<v8::Value> GetV8Handle(v8::Isolate* isolate) final;
-
- // gin::Wrappable method:
- gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
- v8::Isolate* isolate) override;
-};
-
-} // namespace QtWebEngineCore
-
-#endif // PLUGIN_PLACEHOLDER_QT_H
diff --git a/src/core/renderer/print_web_view_helper_delegate_qt.cpp b/src/core/renderer/print_web_view_helper_delegate_qt.cpp
index b85ff7249..f01568e65 100644
--- a/src/core/renderer/print_web_view_helper_delegate_qt.cpp
+++ b/src/core/renderer/print_web_view_helper_delegate_qt.cpp
@@ -1,74 +1,40 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// Copyright 2015 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 "content/public/renderer/render_frame.h"
-#include "content/public/renderer/render_view.h"
+#include "extensions/buildflags/buildflags.h"
#include "extensions/common/constants.h"
-#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_element.h"
#include "third_party/blink/public/web/web_local_frame.h"
+#include "url/origin.h"
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+#include "chrome/common/webui_url_constants.h"
+#include "extensions/common/constants.h"
+#include "third_party/blink/public/web/web_document.h"
+#include "extensions/renderer/guest_view/mime_handler_view/post_message_support.h"
+#endif // BUILDFLAG(ENABLE_EXTENSIONS)
+
+#include "pdf_util_qt.h"
#include "print_web_view_helper_delegate_qt.h"
#include "web_engine_library_info.h"
namespace QtWebEngineCore {
-PrintWebViewHelperDelegateQt::~PrintWebViewHelperDelegateQt() {}
-bool PrintWebViewHelperDelegateQt::CancelPrerender(content::RenderFrame *)
-{
- return false;
-}
+PrintWebViewHelperDelegateQt::~PrintWebViewHelperDelegateQt() {}
blink::WebElement PrintWebViewHelperDelegateQt::GetPdfElement(blink::WebLocalFrame *frame)
{
- GURL url = frame->GetDocument().Url();
- if (url.SchemeIs(extensions::kExtensionScheme) && url.host() == extension_misc::kPdfExtensionId) {
- // <object> with id="plugin" is created in
- // chrome/browser/resources/pdf/pdf.js.
- auto plugin_element = frame->GetDocument().GetElementById("plugin");
- CHECK(!plugin_element.IsNull());
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+ if (frame->Parent() && IsPdfInternalPluginAllowedOrigin(frame->Parent()->GetSecurityOrigin())) {
+ auto plugin_element = frame->GetDocument().QuerySelector("embed");
+ DCHECK(!plugin_element.IsNull());
return plugin_element;
}
+#endif // BUILDFLAG(ENABLE_EXTENSIONS)
return blink::WebElement();
}
@@ -82,7 +48,7 @@ bool PrintWebViewHelperDelegateQt::OverridePrint(blink::WebLocalFrame *frame)
return false;
}
-}
+} // namespace QtWebEngineCore
namespace printing {
// std::string PrintingContextDelegate::GetAppLocale()
diff --git a/src/core/renderer/print_web_view_helper_delegate_qt.h b/src/core/renderer/print_web_view_helper_delegate_qt.h
index f02580b91..5c7dd2431 100644
--- a/src/core/renderer/print_web_view_helper_delegate_qt.h
+++ b/src/core/renderer/print_web_view_helper_delegate_qt.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
@@ -46,8 +10,8 @@
#include "components/printing/renderer/print_render_frame_helper.h"
-namespace content {
-class RenderView;
+namespace blink {
+class WebLocalFrame;
}
namespace QtWebEngineCore {
@@ -57,14 +21,13 @@ class PrintWebViewHelperDelegateQt : public printing::PrintRenderFrameHelper::De
public:
~PrintWebViewHelperDelegateQt() override;
- bool CancelPrerender(content::RenderFrame *render_frame) override;
-
blink::WebElement GetPdfElement(blink::WebLocalFrame *frame) override;
bool IsPrintPreviewEnabled() override;
bool OverridePrint(blink::WebLocalFrame *frame) override;
-}; // class PrintWebViewHelperDelegateQt
-}
+};
+
+} // namespace QtWebEngineCore
#endif // PRINT_WEB_VIEW_HELPER_DELEGATE_QT_H
diff --git a/src/core/renderer/render_configuration.cpp b/src/core/renderer/render_configuration.cpp
new file mode 100644
index 000000000..7b35cdd48
--- /dev/null
+++ b/src/core/renderer/render_configuration.cpp
@@ -0,0 +1,41 @@
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+// based on chrome/renderer/chrome_render_thread_observer.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 "renderer/render_configuration.h"
+#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
+
+namespace QtWebEngineCore {
+
+bool RenderConfiguration::m_isIncognitoProcess = false;
+
+void RenderConfiguration::RegisterMojoInterfaces(
+ blink::AssociatedInterfaceRegistry *associated_interfaces)
+{
+ associated_interfaces->AddInterface<qtwebengine::mojom::RendererConfiguration>(
+ base::BindRepeating(&RenderConfiguration::OnRendererConfigurationAssociatedRequest,
+ base::Unretained(this)));
+}
+
+void RenderConfiguration::UnregisterMojoInterfaces(
+ blink::AssociatedInterfaceRegistry *associated_interfaces)
+{
+ associated_interfaces->RemoveInterface(qtwebengine::mojom::RendererConfiguration::Name_);
+}
+
+void RenderConfiguration::SetInitialConfiguration(bool is_incognito_process)
+{
+ m_isIncognitoProcess = is_incognito_process;
+}
+
+void RenderConfiguration::OnRendererConfigurationAssociatedRequest(
+ mojo::PendingAssociatedReceiver<qtwebengine::mojom::RendererConfiguration> receiver)
+{
+ m_rendererConfigurationReceivers.Add(this, std::move(receiver));
+}
+
+} // namespace
diff --git a/src/core/renderer/render_configuration.h b/src/core/renderer/render_configuration.h
new file mode 100644
index 000000000..d9c867e02
--- /dev/null
+++ b/src/core/renderer/render_configuration.h
@@ -0,0 +1,42 @@
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef RENDER_CONFIGURATION_H
+#define RENDER_CONFIGURATION_H
+
+#include "content/public/renderer/render_thread_observer.h"
+#include "mojo/public/cpp/bindings/associated_receiver_set.h"
+#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
+#include "qtwebengine/common/renderer_configuration.mojom.h"
+
+namespace QtWebEngineCore {
+
+class RenderConfiguration : public content::RenderThreadObserver,
+ public qtwebengine::mojom::RendererConfiguration
+{
+public:
+ RenderConfiguration() = default;
+ ~RenderConfiguration() override = default;
+
+ static bool is_incognito_process() { return m_isIncognitoProcess; }
+
+private:
+ // content::RenderThreadObserver:
+ void RegisterMojoInterfaces(blink::AssociatedInterfaceRegistry *associated_interfaces) override;
+ void UnregisterMojoInterfaces(blink::AssociatedInterfaceRegistry *associated_interfaces) override;
+
+ // qtwebengine::mojom::RendererConfiguration:
+ void SetInitialConfiguration(bool is_incognito_process) override;
+
+ void OnRendererConfigurationAssociatedRequest(
+ mojo::PendingAssociatedReceiver<qtwebengine::mojom::RendererConfiguration> receiver);
+
+ static bool m_isIncognitoProcess;
+
+ mojo::AssociatedReceiverSet<qtwebengine::mojom::RendererConfiguration>
+ m_rendererConfigurationReceivers;
+};
+
+} // namespace QtWebEngineCore
+
+#endif // RENDER_CONFIGURATION_H
diff --git a/src/core/renderer/render_frame_observer_qt.cpp b/src/core/renderer/render_frame_observer_qt.cpp
index cc01acec6..e6489eefb 100644
--- a/src/core/renderer/render_frame_observer_qt.cpp
+++ b/src/core/renderer/render_frame_observer_qt.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// This is based on chrome/renderer/pepper/pepper_helper.cc:
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
@@ -44,14 +8,18 @@
#include "render_frame_observer_qt.h"
-#include "base/memory/ptr_util.h"
-#include "chrome/renderer/pepper/pepper_shared_memory_message_filter.h"
#include "components/web_cache/renderer/web_cache_impl.h"
#include "content/public/renderer/render_frame.h"
+#include "third_party/blink/public/web/web_document_loader.h"
+
+#if QT_CONFIG(webengine_pepper_plugins)
+#include "base/memory/ptr_util.h"
+#include "chrome/renderer/pepper/pepper_shared_memory_message_filter.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "ppapi/host/ppapi_host.h"
#include "renderer/pepper/pepper_renderer_host_factory_qt.h"
+#endif
namespace QtWebEngineCore {
@@ -77,7 +45,13 @@ void RenderFrameObserverQt::DidCreatePepperPlugin(content::RendererPpapiHost *ho
}
#endif
-void RenderFrameObserverQt::FrameDetached()
+bool RenderFrameObserverQt::OnAssociatedInterfaceRequestForFrame(const std::string &interface_name,
+ mojo::ScopedInterfaceEndpointHandle *handle)
+{
+ return m_associated_interfaces.TryBindInterface(interface_name, handle);
+}
+
+void RenderFrameObserverQt::WillDetach()
{
m_isFrameDetached = true;
}
diff --git a/src/core/renderer/render_frame_observer_qt.h b/src/core/renderer/render_frame_observer_qt.h
index 6bdf4ad23..8cab3bd9a 100644
--- a/src/core/renderer/render_frame_observer_qt.h
+++ b/src/core/renderer/render_frame_observer_qt.h
@@ -1,51 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef RENDER_FRAME_OBSERVER_QT_H
#define RENDER_FRAME_OBSERVER_QT_H
#include "qtwebenginecoreglobal_p.h"
-#include "base/compiler_specific.h"
#include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_frame_observer_tracker.h"
-#include "ppapi/buildflags/buildflags.h"
#include "services/service_manager/public/cpp/binder_registry.h"
+#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
namespace content {
class RenderFrame;
@@ -67,20 +30,25 @@ public:
#if QT_CONFIG(webengine_pepper_plugins)
void DidCreatePepperPlugin(content::RendererPpapiHost *host) override;
#endif
+ bool OnAssociatedInterfaceRequestForFrame(
+ const std::string &interface_name,
+ mojo::ScopedInterfaceEndpointHandle *handle) override;
void OnDestruct() override;
- void FrameDetached() override;
+ void WillDetach() override;
bool isFrameDetached() const;
service_manager::BinderRegistry *registry() { return &registry_; }
+ blink::AssociatedInterfaceRegistry *associatedInterfaces() {
+ return &m_associated_interfaces;
+ }
private:
- DISALLOW_COPY_AND_ASSIGN(RenderFrameObserverQt);
-
void ReadyToCommitNavigation(blink::WebDocumentLoader *) override;
bool m_isFrameDetached;
service_manager::BinderRegistry registry_;
+ blink::AssociatedInterfaceRegistry m_associated_interfaces;
web_cache::WebCacheImpl *m_web_cache_impl;
};
diff --git a/src/core/renderer/render_thread_observer_qt.cpp b/src/core/renderer/render_thread_observer_qt.cpp
deleted file mode 100644
index 4912ebfc2..000000000
--- a/src/core/renderer/render_thread_observer_qt.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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/renderer/chrome_render_thread_observer.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 "renderer/render_thread_observer_qt.h"
-
-#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
-
-namespace QtWebEngineCore {
-
-bool RenderThreadObserverQt::m_isIncognitoProcess = false;
-
-void RenderThreadObserverQt::RegisterMojoInterfaces(blink::AssociatedInterfaceRegistry *associated_interfaces)
-{
- associated_interfaces->AddInterface(
- base::Bind(&RenderThreadObserverQt::OnRendererConfigurationAssociatedRequest, base::Unretained(this)));
-}
-
-void RenderThreadObserverQt::UnregisterMojoInterfaces(blink::AssociatedInterfaceRegistry *associated_interfaces)
-{
- associated_interfaces->RemoveInterface(qtwebengine::mojom::RendererConfiguration::Name_);
-}
-
-void RenderThreadObserverQt::SetInitialConfiguration(bool is_incognito_process)
-{
- m_isIncognitoProcess = is_incognito_process;
-}
-
-void RenderThreadObserverQt::OnRendererConfigurationAssociatedRequest(
- mojo::PendingAssociatedReceiver<qtwebengine::mojom::RendererConfiguration> receiver)
-{
- m_rendererConfigurationReceivers.Add(this, std::move(receiver));
-}
-
-} // namespace
diff --git a/src/core/renderer/render_thread_observer_qt.h b/src/core/renderer/render_thread_observer_qt.h
deleted file mode 100644
index 05372049b..000000000
--- a/src/core/renderer/render_thread_observer_qt.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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 RENDER_THREAD_OBSERVER_QT_H
-#define RENDER_THREAD_OBSERVER_QT_H
-
-#include "content/public/renderer/render_thread_observer.h"
-#include "mojo/public/cpp/bindings/associated_receiver_set.h"
-#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
-#include "qtwebengine/common/renderer_configuration.mojom.h"
-
-namespace QtWebEngineCore {
-
-class RenderThreadObserverQt
- : public content::RenderThreadObserver
- , public qtwebengine::mojom::RendererConfiguration
-{
-public:
- RenderThreadObserverQt() = default;
- ~RenderThreadObserverQt() override = default;
-
- static bool is_incognito_process() { return m_isIncognitoProcess; }
-
-private:
- // content::RenderThreadObserver:
- void RegisterMojoInterfaces(blink::AssociatedInterfaceRegistry *associated_interfaces) override;
- void UnregisterMojoInterfaces(blink::AssociatedInterfaceRegistry *associated_interfaces) override;
-
- // qtwebengine::mojom::RendererConfiguration:
- void SetInitialConfiguration(bool is_incognito_process) override;
-
- void OnRendererConfigurationAssociatedRequest(
- mojo::PendingAssociatedReceiver<qtwebengine::mojom::RendererConfiguration> receiver);
-
- static bool m_isIncognitoProcess;
-
- mojo::AssociatedReceiverSet<qtwebengine::mojom::RendererConfiguration> m_rendererConfigurationReceivers;
-
- DISALLOW_COPY_AND_ASSIGN(RenderThreadObserverQt);
-};
-
-} // namespace QtWebEngineCore
-
-#endif // RENDER_THREAD_OBSERVER_QT_H
diff --git a/src/core/renderer/render_view_observer_qt.cpp b/src/core/renderer/render_view_observer_qt.cpp
deleted file mode 100644
index 5b0b9a77d..000000000
--- a/src/core/renderer/render_view_observer_qt.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "renderer/render_view_observer_qt.h"
-
-#include "common/qt_messages.h"
-
-#include "content/public/renderer/render_view.h"
-#include "third_party/blink/public/web/web_document.h"
-#include "third_party/blink/public/web/web_element.h"
-#include "third_party/blink/public/web/web_frame.h"
-#include "third_party/blink/public/web/web_frame_content_dumper.h"
-#include "third_party/blink/public/web/web_frame_widget.h"
-#include "third_party/blink/public/web/web_local_frame.h"
-#include "third_party/blink/public/web/web_view.h"
-
-RenderViewObserverQt::RenderViewObserverQt(content::RenderView *render_view) : content::RenderViewObserver(render_view)
-{}
-
-void RenderViewObserverQt::onFetchDocumentMarkup(quint64 requestId)
-{
- blink::WebString markup;
- if (render_view()->GetWebView()->MainFrame()->IsWebLocalFrame())
- markup = blink::WebFrameContentDumper::DumpAsMarkup(
- static_cast<blink::WebLocalFrame *>(render_view()->GetWebView()->MainFrame()));
- Send(new RenderViewObserverHostQt_DidFetchDocumentMarkup(routing_id(), requestId, markup.Utf16()));
-}
-
-void RenderViewObserverQt::onFetchDocumentInnerText(quint64 requestId)
-{
- blink::WebString text;
- if (render_view()->GetWebView()->MainFrame()->IsWebLocalFrame())
- text = blink::WebFrameContentDumper::DumpWebViewAsText(render_view()->GetWebView(),
- std::numeric_limits<std::size_t>::max());
- Send(new RenderViewObserverHostQt_DidFetchDocumentInnerText(routing_id(), requestId, text.Utf16()));
-}
-
-void RenderViewObserverQt::onSetBackgroundColor(quint32 color)
-{
- render_view()->GetWebView()->SetBaseBackgroundColorOverride(color);
-}
-
-void RenderViewObserverQt::OnDestruct()
-{
- delete this;
-}
-
-bool RenderViewObserverQt::OnMessageReceived(const IPC::Message &message)
-{
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(RenderViewObserverQt, message)
- IPC_MESSAGE_HANDLER(RenderViewObserverQt_FetchDocumentMarkup, onFetchDocumentMarkup)
- IPC_MESSAGE_HANDLER(RenderViewObserverQt_FetchDocumentInnerText, onFetchDocumentInnerText)
- IPC_MESSAGE_HANDLER(RenderViewObserverQt_SetBackgroundColor, onSetBackgroundColor)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
diff --git a/src/core/renderer/render_view_observer_qt.h b/src/core/renderer/render_view_observer_qt.h
deleted file mode 100644
index 5c555b222..000000000
--- a/src/core/renderer/render_view_observer_qt.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 RENDER_VIEW_OBSERVER_QT_H
-#define RENDER_VIEW_OBSERVER_QT_H
-
-#include "content/public/renderer/render_view_observer.h"
-
-#include <QtGlobal>
-
-class RenderViewObserverQt : public content::RenderViewObserver
-{
-public:
- RenderViewObserverQt(content::RenderView *render_view);
-
-private:
- void onFetchDocumentMarkup(quint64 requestId);
- void onFetchDocumentInnerText(quint64 requestId);
- void onSetBackgroundColor(quint32 color);
-
- void OnDestruct() override;
-
- bool OnMessageReceived(const IPC::Message &message) override;
-
- DISALLOW_COPY_AND_ASSIGN(RenderViewObserverQt);
-};
-
-#endif // RENDER_VIEW_OBSERVER_QT_H
diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp
index 5c1bd301f..eff304981 100644
--- a/src/core/renderer/user_resource_controller.cpp
+++ b/src/core/renderer/user_resource_controller.cpp
@@ -1,60 +1,20 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "user_resource_controller.h"
#include "base/memory/weak_ptr.h"
-#include "base/pending_task.h"
#include "base/strings/pattern.h"
+#include "base/task/single_thread_task_runner.h"
#include "content/public/renderer/render_frame.h"
-#include "content/public/renderer/render_view.h"
#include "content/public/renderer/render_frame_observer.h"
-#include "content/public/renderer/render_view_observer.h"
#include "extensions/common/url_pattern.h"
-#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_script_source.h"
-#include "third_party/blink/public/web/web_view.h"
-#include "v8/include/v8.h"
+#include "mojo/public/cpp/bindings/associated_receiver.h"
+#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
-#include "common/qt_messages.h"
-#include "common/user_script_data.h"
+#include "qtwebengine/userscript/user_script_data.h"
#include "type_conversion.h"
#include "user_script.h"
@@ -62,9 +22,9 @@
#include <bitset>
-Q_GLOBAL_STATIC(UserResourceController, qt_webengine_userResourceController)
+namespace QtWebEngineCore {
-static content::RenderView *const globalScriptsIndex = nullptr;
+static content::RenderFrame *const globalScriptsIndex = nullptr;
// Scripts meant to run after the load event will be run 500ms after DOMContentLoaded if the load event doesn't come within that delay.
static const int afterLoadTimeout = 500;
@@ -97,7 +57,7 @@ static bool includeRuleMatchesURL(const std::string &pat, const GURL &url)
return false;
}
-static bool scriptMatchesURL(const UserScriptData &scriptData, const GURL &url)
+static bool scriptMatchesURL(const QtWebEngineCore::UserScriptData &scriptData, const GURL &url)
{
// Logic taken from Chromium (extensions/common/user_script.cc)
bool matchFound;
@@ -132,26 +92,34 @@ static bool scriptMatchesURL(const UserScriptData &scriptData, const GURL &url)
return true;
}
-class UserResourceController::RenderFrameObserverHelper : public content::RenderFrameObserver
+// using UserScriptDataPtr = mojo::StructPtr<qtwebengine::mojom::UserScriptData>;
+
+class UserResourceController::RenderFrameObserverHelper
+ : public content::RenderFrameObserver,
+ public qtwebengine::mojom::UserResourceControllerRenderFrame
{
public:
- RenderFrameObserverHelper(content::RenderFrame *render_frame);
+ RenderFrameObserverHelper(content::RenderFrame *render_frame,
+ UserResourceController *controller);
+ void BindReceiver(
+ mojo::PendingAssociatedReceiver<qtwebengine::mojom::UserResourceControllerRenderFrame>
+ receiver);
private:
// RenderFrameObserver implementation.
- void DidCommitProvisionalLoad(bool is_same_document_navigation, ui::PageTransition transition) override;
- void DidFinishDocumentLoad() override;
+ void DidCommitProvisionalLoad(ui::PageTransition transition) override;
+ void DidDispatchDOMContentLoadedEvent() override;
void DidFinishLoad() override;
- void FrameDetached() override;
+ void WillDetach() override;
void OnDestruct() override;
- bool OnMessageReceived(const IPC::Message &message) override;
-
- void onUserScriptAdded(const UserScriptData &);
- void onUserScriptRemoved(const UserScriptData &);
- void onScriptsCleared();
+ void AddScript(const QtWebEngineCore::UserScriptData &data) override;
+ void RemoveScript(const QtWebEngineCore::UserScriptData &data) override;
+ void ClearScripts() override;
class Runner;
QScopedPointer<Runner> m_runner;
+ mojo::AssociatedReceiver<qtwebengine::mojom::UserResourceControllerRenderFrame> m_binding;
+ UserResourceController *m_userResourceController;
};
// Helper class to create WeakPtrs so the AfterLoad tasks can be canceled and to
@@ -159,13 +127,16 @@ private:
class UserResourceController::RenderFrameObserverHelper::Runner : public base::SupportsWeakPtr<Runner>
{
public:
- explicit Runner(blink::WebLocalFrame *frame) : m_frame(frame) {}
+ explicit Runner(blink::WebLocalFrame *frame, UserResourceController *controller)
+ : m_frame(frame), m_userResourceController(controller)
+ {
+ }
- void run(UserScriptData::InjectionPoint p)
+ void run(QtWebEngineCore::UserScriptData::InjectionPoint p)
{
DCHECK_LT(p, m_ran.size());
if (!m_ran[p]) {
- UserResourceController::instance()->runScripts(p, m_frame);
+ m_userResourceController->runScripts(p, m_frame);
m_ran[p] = true;
}
}
@@ -173,42 +144,29 @@ public:
private:
blink::WebLocalFrame *m_frame;
std::bitset<3> m_ran;
+ UserResourceController *m_userResourceController;
};
-// Used only for script cleanup on RenderView destruction.
-class UserResourceController::RenderViewObserverHelper : public content::RenderViewObserver
-{
-public:
- RenderViewObserverHelper(content::RenderView *render_view);
-
-private:
- // RenderViewObserver implementation.
- void OnDestruct() override;
-};
-
-void UserResourceController::runScripts(UserScriptData::InjectionPoint p, blink::WebLocalFrame *frame)
+void UserResourceController::runScripts(QtWebEngineCore::UserScriptData::InjectionPoint p,
+ blink::WebLocalFrame *frame)
{
content::RenderFrame *renderFrame = content::RenderFrame::FromWebFrame(frame);
if (!renderFrame)
return;
const bool isMainFrame = renderFrame->IsMainFrame();
- content::RenderView *renderView = renderFrame->GetRenderView();
- if (!renderView)
- return;
-
- QList<uint64_t> scriptsToRun = m_viewUserScriptMap.value(0).toList();
- scriptsToRun.append(m_viewUserScriptMap.value(renderView).toList());
+ QList<uint64_t> scriptsToRun = m_frameUserScriptMap.value(globalScriptsIndex);
+ scriptsToRun.append(m_frameUserScriptMap.value(renderFrame));
- for (uint64_t id : qAsConst(scriptsToRun)) {
- const UserScriptData &script = m_scripts.value(id);
+ for (uint64_t id : std::as_const(scriptsToRun)) {
+ const QtWebEngineCore::UserScriptData &script = m_scripts.value(id);
if (script.injectionPoint != p || (!script.injectForSubframes && !isMainFrame))
continue;
if (!scriptMatchesURL(script, frame->GetDocument().Url()))
continue;
blink::WebScriptSource source(blink::WebString::FromUTF8(script.source), script.url);
if (script.worldId)
- frame->ExecuteScriptInIsolatedWorld(script.worldId, source);
+ frame->ExecuteScriptInIsolatedWorld(script.worldId, source, blink::BackForwardCacheAware::kAllow); // FIXME, check
else
frame->ExecuteScript(source);
}
@@ -216,119 +174,103 @@ void UserResourceController::runScripts(UserScriptData::InjectionPoint p, blink:
void UserResourceController::RunScriptsAtDocumentEnd(content::RenderFrame *render_frame)
{
- runScripts(UserScriptData::DocumentLoadFinished, render_frame->GetWebFrame());
+ runScripts(QtWebEngineCore::UserScriptData::DocumentLoadFinished, render_frame->GetWebFrame());
}
-UserResourceController::RenderFrameObserverHelper::RenderFrameObserverHelper(content::RenderFrame *render_frame)
+UserResourceController::RenderFrameObserverHelper::RenderFrameObserverHelper(
+ content::RenderFrame *render_frame, UserResourceController *controller)
: content::RenderFrameObserver(render_frame)
-{}
+ , m_binding(this)
+ , m_userResourceController(controller)
+{
+ render_frame->GetAssociatedInterfaceRegistry()->AddInterface<qtwebengine::mojom::UserResourceControllerRenderFrame>(
+ base::BindRepeating(&UserResourceController::RenderFrameObserverHelper::BindReceiver,
+ base::Unretained(this)));
+}
-UserResourceController::RenderViewObserverHelper::RenderViewObserverHelper(content::RenderView *render_view)
- : content::RenderViewObserver(render_view)
-{}
-void UserResourceController::RenderFrameObserverHelper::DidCommitProvisionalLoad(bool is_same_document_navigation,
- ui::PageTransition /*transitionbool*/)
+void UserResourceController::RenderFrameObserverHelper::BindReceiver(
+ mojo::PendingAssociatedReceiver<qtwebengine::mojom::UserResourceControllerRenderFrame>
+ receiver)
{
- if (is_same_document_navigation)
- return;
+ m_binding.Bind(std::move(receiver));
+}
+void UserResourceController::RenderFrameObserverHelper::DidCommitProvisionalLoad(ui::PageTransition /*transition*/)
+{
// We are almost ready to run scripts. We still have to wait until the host
// process has been notified of the DidCommitProvisionalLoad event to ensure
// that the WebChannelTransportHost is ready to receive messages.
- m_runner.reset(new Runner(render_frame()->GetWebFrame()));
+ m_runner.reset(new Runner(render_frame()->GetWebFrame(), m_userResourceController));
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindOnce(&Runner::run, m_runner->AsWeakPtr(), UserScriptData::DocumentElementCreation));
+ base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
+ FROM_HERE,
+ base::BindOnce(&Runner::run, m_runner->AsWeakPtr(),
+ QtWebEngineCore::UserScriptData::DocumentElementCreation));
}
-void UserResourceController::RenderFrameObserverHelper::DidFinishDocumentLoad()
+void UserResourceController::RenderFrameObserverHelper::DidDispatchDOMContentLoadedEvent()
{
// Don't run scripts if provisional load failed (DidFailProvisionalLoad
// called instead of DidCommitProvisionalLoad).
if (m_runner)
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, base::BindOnce(&Runner::run, m_runner->AsWeakPtr(), UserScriptData::AfterLoad),
- base::TimeDelta::FromMilliseconds(afterLoadTimeout));
+ base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
+ FROM_HERE,
+ base::BindOnce(&Runner::run, m_runner->AsWeakPtr(),
+ QtWebEngineCore::UserScriptData::AfterLoad),
+ base::Milliseconds(afterLoadTimeout));
}
void UserResourceController::RenderFrameObserverHelper::DidFinishLoad()
{
if (m_runner)
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindOnce(&Runner::run, m_runner->AsWeakPtr(), UserScriptData::AfterLoad));
+ base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
+ FROM_HERE,
+ base::BindOnce(&Runner::run, m_runner->AsWeakPtr(),
+ QtWebEngineCore::UserScriptData::AfterLoad));
}
-void UserResourceController::RenderFrameObserverHelper::FrameDetached()
+void UserResourceController::RenderFrameObserverHelper::WillDetach()
{
m_runner.reset();
}
void UserResourceController::RenderFrameObserverHelper::OnDestruct()
{
+ if (content::RenderFrame *frame = render_frame()) {
+ m_userResourceController->renderFrameDestroyed(frame);
+ }
delete this;
}
-void UserResourceController::RenderViewObserverHelper::OnDestruct()
-{
- // Remove all scripts associated with the render view.
- if (content::RenderView *view = render_view())
- UserResourceController::instance()->renderViewDestroyed(view);
- delete this;
-}
-
-bool UserResourceController::RenderFrameObserverHelper::OnMessageReceived(const IPC::Message &message)
-{
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(UserResourceController::RenderFrameObserverHelper, message)
- IPC_MESSAGE_HANDLER(RenderFrameObserverHelper_AddScript, onUserScriptAdded)
- IPC_MESSAGE_HANDLER(RenderFrameObserverHelper_RemoveScript, onUserScriptRemoved)
- IPC_MESSAGE_HANDLER(RenderFrameObserverHelper_ClearScripts, onScriptsCleared)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void UserResourceController::RenderFrameObserverHelper::onUserScriptAdded(const UserScriptData &script)
+void UserResourceController::RenderFrameObserverHelper::AddScript(
+ const QtWebEngineCore::UserScriptData &script)
{
if (content::RenderFrame *frame = render_frame())
- if (content::RenderView *view = frame->GetRenderView())
- UserResourceController::instance()->addScriptForView(script, view);
+ m_userResourceController->addScriptForFrame(script, frame);
}
-void UserResourceController::RenderFrameObserverHelper::onUserScriptRemoved(const UserScriptData &script)
+void UserResourceController::RenderFrameObserverHelper::RemoveScript(
+ const QtWebEngineCore::UserScriptData &script)
{
if (content::RenderFrame *frame = render_frame())
- if (content::RenderView *view = frame->GetRenderView())
- UserResourceController::instance()->removeScriptForView(script, view);
+ m_userResourceController->removeScriptForFrame(script, frame);
}
-void UserResourceController::RenderFrameObserverHelper::onScriptsCleared()
+void UserResourceController::RenderFrameObserverHelper::ClearScripts()
{
if (content::RenderFrame *frame = render_frame())
- if (content::RenderView *view = frame->GetRenderView())
- UserResourceController::instance()->clearScriptsForView(view);
+ m_userResourceController->clearScriptsForFrame(frame);
}
-UserResourceController *UserResourceController::instance()
+void UserResourceController::BindReceiver(
+ mojo::PendingAssociatedReceiver<qtwebengine::mojom::UserResourceController> receiver)
{
- return qt_webengine_userResourceController();
+ m_binding.Bind(std::move(receiver));
}
-bool UserResourceController::OnControlMessageReceived(const IPC::Message &message)
-{
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(UserResourceController, message)
- IPC_MESSAGE_HANDLER(UserResourceController_AddScript, onAddScript)
- IPC_MESSAGE_HANDLER(UserResourceController_RemoveScript, onRemoveScript)
- IPC_MESSAGE_HANDLER(UserResourceController_ClearScripts, onClearScripts)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-UserResourceController::UserResourceController()
+UserResourceController::UserResourceController() : m_binding(this)
{
#if !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS)
static bool onlyCalledOnce = true;
@@ -340,68 +282,85 @@ UserResourceController::UserResourceController()
void UserResourceController::renderFrameCreated(content::RenderFrame *renderFrame)
{
// Will destroy itself when the RenderFrame is destroyed.
- new RenderFrameObserverHelper(renderFrame);
+ new RenderFrameObserverHelper(renderFrame, this);
}
-void UserResourceController::renderViewCreated(content::RenderView *renderView)
+void UserResourceController::renderFrameDestroyed(content::RenderFrame *renderFrame)
{
- // Will destroy itself when the RenderView is destroyed.
- new RenderViewObserverHelper(renderView);
+ FrameUserScriptMap::iterator it = m_frameUserScriptMap.find(renderFrame);
+ if (it == m_frameUserScriptMap.end()) // ASSERT maybe?
+ return;
+ if (renderFrame->IsMainFrame()) {
+ for (uint64_t id : std::as_const(it.value()))
+ m_scripts.remove(id);
+ }
+ m_frameUserScriptMap.erase(it);
}
-void UserResourceController::renderViewDestroyed(content::RenderView *renderView)
+void UserResourceController::addScriptForFrame(const QtWebEngineCore::UserScriptData &script,
+ content::RenderFrame *frame)
{
- ViewUserScriptMap::iterator it = m_viewUserScriptMap.find(renderView);
- if (it == m_viewUserScriptMap.end()) // ASSERT maybe?
- return;
- for (uint64_t id : qAsConst(it.value())) {
- m_scripts.remove(id);
- }
- m_viewUserScriptMap.remove(renderView);
+ FrameUserScriptMap::iterator it = m_frameUserScriptMap.find(frame);
+ if (it == m_frameUserScriptMap.end())
+ it = m_frameUserScriptMap.insert(frame, UserScriptList());
+
+ if (!(*it).contains(script.scriptId))
+ (*it).append(script.scriptId);
+ if (!frame || frame->IsMainFrame())
+ m_scripts.insert(script.scriptId, script);
}
-void UserResourceController::addScriptForView(const UserScriptData &script, content::RenderView *view)
+void UserResourceController::removeScriptForFrame(const QtWebEngineCore::UserScriptData &script,
+ content::RenderFrame *frame)
{
- ViewUserScriptMap::iterator it = m_viewUserScriptMap.find(view);
- if (it == m_viewUserScriptMap.end())
- it = m_viewUserScriptMap.insert(view, UserScriptSet());
+ FrameUserScriptMap::iterator it = m_frameUserScriptMap.find(frame);
+ if (it == m_frameUserScriptMap.end())
+ return;
- (*it).insert(script.scriptId);
- m_scripts.insert(script.scriptId, script);
+ (*it).removeOne(script.scriptId);
+ if (!frame || frame->IsMainFrame())
+ m_scripts.remove(script.scriptId);
}
-void UserResourceController::removeScriptForView(const UserScriptData &script, content::RenderView *view)
+void UserResourceController::clearScriptsForFrame(content::RenderFrame *frame)
{
- ViewUserScriptMap::iterator it = m_viewUserScriptMap.find(view);
- if (it == m_viewUserScriptMap.end())
+ FrameUserScriptMap::iterator it = m_frameUserScriptMap.find(frame);
+ if (it == m_frameUserScriptMap.end())
return;
+ if (!frame || frame->IsMainFrame()) {
+ for (uint64_t id : std::as_const(it.value()))
+ m_scripts.remove(id);
+ }
- (*it).remove(script.scriptId);
- m_scripts.remove(script.scriptId);
+ m_frameUserScriptMap.remove(frame);
}
-void UserResourceController::clearScriptsForView(content::RenderView *view)
+void UserResourceController::AddScript(const QtWebEngineCore::UserScriptData &script)
{
- ViewUserScriptMap::iterator it = m_viewUserScriptMap.find(view);
- if (it == m_viewUserScriptMap.end())
- return;
- for (uint64_t id : qAsConst(it.value()))
- m_scripts.remove(id);
+ addScriptForFrame(script, globalScriptsIndex);
+}
- m_viewUserScriptMap.remove(view);
+void UserResourceController::RemoveScript(const QtWebEngineCore::UserScriptData &script)
+{
+ removeScriptForFrame(script, globalScriptsIndex);
}
-void UserResourceController::onAddScript(const UserScriptData &script)
+void UserResourceController::ClearScripts()
{
- addScriptForView(script, globalScriptsIndex);
+ clearScriptsForFrame(globalScriptsIndex);
}
-void UserResourceController::onRemoveScript(const UserScriptData &script)
+void UserResourceController::RegisterMojoInterfaces(
+ blink::AssociatedInterfaceRegistry *associated_interfaces)
{
- removeScriptForView(script, globalScriptsIndex);
+ associated_interfaces->AddInterface<qtwebengine::mojom::UserResourceController>(
+ base::BindRepeating(&UserResourceController::BindReceiver, base::Unretained(this)));
}
-void UserResourceController::onClearScripts()
+void UserResourceController::UnregisterMojoInterfaces(
+ blink::AssociatedInterfaceRegistry *associated_interfaces)
{
- clearScriptsForView(globalScriptsIndex);
+ associated_interfaces->RemoveInterface(qtwebengine::mojom::UserResourceController::Name_);
}
+
+} // namespace
diff --git a/src/core/renderer/user_resource_controller.h b/src/core/renderer/user_resource_controller.h
index 3a493b9b7..a5dab73f1 100644
--- a/src/core/renderer/user_resource_controller.h
+++ b/src/core/renderer/user_resource_controller.h
@@ -1,51 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef USER_RESOURCE_CONTROLLER_H
#define USER_RESOURCE_CONTROLLER_H
#include "content/public/renderer/render_thread_observer.h"
-
-#include "common/user_script_data.h"
+#include "qtwebengine/userscript/userscript.mojom.h"
+#include "qtwebengine/userscript/user_script_data.h"
+#include "mojo/public/cpp/bindings/associated_receiver.h"
#include <QtCore/QHash>
-#include <QtCore/QSet>
+#include <QtCore/QList>
namespace blink {
class WebLocalFrame;
@@ -53,45 +18,48 @@ class WebLocalFrame;
namespace content {
class RenderFrame;
-class RenderView;
}
-class UserResourceController : public content::RenderThreadObserver
+namespace QtWebEngineCore {
+
+class UserResourceController : public content::RenderThreadObserver,
+ qtwebengine::mojom::UserResourceController
{
public:
- static UserResourceController *instance();
UserResourceController();
void renderFrameCreated(content::RenderFrame *);
- void renderViewCreated(content::RenderView *);
- void renderViewDestroyed(content::RenderView *renderView);
- void addScriptForView(const UserScriptData &, content::RenderView *);
- void removeScriptForView(const UserScriptData &, content::RenderView *);
- void clearScriptsForView(content::RenderView *);
+ void renderFrameDestroyed(content::RenderFrame *);
+ void addScriptForFrame(const QtWebEngineCore::UserScriptData &, content::RenderFrame *);
+ void removeScriptForFrame(const QtWebEngineCore::UserScriptData &, content::RenderFrame *);
+ void clearScriptsForFrame(content::RenderFrame *);
void RunScriptsAtDocumentEnd(content::RenderFrame *render_frame);
+ void BindReceiver(
+ mojo::PendingAssociatedReceiver<qtwebengine::mojom::UserResourceController> receiver);
private:
Q_DISABLE_COPY(UserResourceController)
- class RenderFrameObserverHelper;
- class RenderViewObserverHelper;
+ // content::RenderThreadObserver:
+ void RegisterMojoInterfaces(blink::AssociatedInterfaceRegistry *associated_interfaces) override;
+ void UnregisterMojoInterfaces(blink::AssociatedInterfaceRegistry *associated_interfaces) override;
- // RenderProcessObserver implementation.
- bool OnControlMessageReceived(const IPC::Message &message) override;
-
- void onAddScript(const UserScriptData &);
- void onRemoveScript(const UserScriptData &);
- void onClearScripts();
+ class RenderFrameObserverHelper;
- void runScripts(UserScriptData::InjectionPoint, blink::WebLocalFrame *);
+ void AddScript(const QtWebEngineCore::UserScriptData &data) override;
+ void RemoveScript(const QtWebEngineCore::UserScriptData &data) override;
+ void ClearScripts() override;
- typedef QSet<uint64_t> UserScriptSet;
- typedef QHash<const content::RenderView *, UserScriptSet> ViewUserScriptMap;
- ViewUserScriptMap m_viewUserScriptMap;
- QHash<uint64_t, UserScriptData> m_scripts;
+ void runScripts(QtWebEngineCore::UserScriptData::InjectionPoint, blink::WebLocalFrame *);
+ typedef QList<uint64_t> UserScriptList;
+ typedef QHash<const content::RenderFrame *, UserScriptList> FrameUserScriptMap;
+ FrameUserScriptMap m_frameUserScriptMap;
+ QHash<uint64_t, QtWebEngineCore::UserScriptData> m_scripts;
+ mojo::AssociatedReceiver<qtwebengine::mojom::UserResourceController> m_binding;
friend class RenderFrameObserverHelper;
};
+} // namespace QtWebEngineCore
#endif // USER_RESOURCE_CONTROLLER_H
diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp
index 1fb3bc678..89b20c7d1 100644
--- a/src/core/renderer/web_channel_ipc_transport.cpp
+++ b/src/core/renderer/web_channel_ipc_transport.cpp
@@ -1,49 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// 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.Chromium file.
#include "renderer/web_channel_ipc_transport.h"
-#include "common/qt_messages.h"
-
#include "content/public/renderer/render_frame.h"
#include "gin/arguments.h"
#include "gin/handle.h"
@@ -54,11 +16,8 @@
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "v8/include/v8.h"
-#include "services/service_manager/public/cpp/interface_provider.h"
#include "qtwebengine/browser/qtwebchannel.mojom.h"
-#include <QJsonDocument>
-
namespace QtWebEngineCore {
class WebChannelTransport : public gin::Wrappable<WebChannelTransport>
@@ -74,8 +33,8 @@ private:
// gin::WrappableBase
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(v8::Isolate *isolate) override;
-
- DISALLOW_COPY_AND_ASSIGN(WebChannelTransport);
+ mojo::AssociatedRemote<qtwebchannel::mojom::WebChannelTransportHost> m_remote;
+ content::RenderFrame *m_renderFrame = nullptr;
};
gin::WrapperInfo WebChannelTransport::kWrapperInfo = { gin::kEmbedderNativeGin };
@@ -89,23 +48,23 @@ void WebChannelTransport::Install(blink::WebLocalFrame *frame, uint worldId)
context = frame->MainWorldScriptContext();
else
context = frame->IsolatedWorldScriptContext(worldId);
+ if (context.IsEmpty())
+ return;
v8::Context::Scope contextScope(context);
gin::Handle<WebChannelTransport> transport = gin::CreateHandle(isolate, new WebChannelTransport);
+ if (transport.IsEmpty())
+ return;
v8::Local<v8::Object> global = context->Global();
- v8::MaybeLocal<v8::Value> qtObjectValue = global->Get(context, gin::StringToV8(isolate, "qt"));
v8::Local<v8::Object> qtObject;
- if (qtObjectValue.IsEmpty() || !qtObjectValue.ToLocalChecked()->IsObject()) {
- qtObject = v8::Object::New(isolate);
- auto whocares = global->Set(context, gin::StringToV8(isolate, "qt"), qtObject);
- // FIXME: Perhaps error out, but the return value is V8 internal...
- Q_UNUSED(whocares);
- } else {
- qtObject = v8::Local<v8::Object>::Cast(qtObjectValue.ToLocalChecked());
- }
- auto whocares = qtObject->Set(context, gin::StringToV8(isolate, "webChannelTransport"), transport.ToV8());
- Q_UNUSED(whocares);
+ qtObject = v8::Object::New(isolate);
+ global->CreateDataProperty(context,
+ gin::StringToSymbol(isolate, "qt"),
+ qtObject).Check();
+ qtObject->CreateDataProperty(context,
+ gin::StringToSymbol(isolate, "webChannelTransport"),
+ transport.ToV8()).Check();
}
void WebChannelTransport::Uninstall(blink::WebLocalFrame *frame, uint worldId)
@@ -117,16 +76,16 @@ void WebChannelTransport::Uninstall(blink::WebLocalFrame *frame, uint worldId)
context = frame->MainWorldScriptContext();
else
context = frame->IsolatedWorldScriptContext(worldId);
+ if (context.IsEmpty())
+ return;
v8::Context::Scope contextScope(context);
v8::Local<v8::Object> global(context->Global());
- v8::MaybeLocal<v8::Value> qtObjectValue = global->Get(context, gin::StringToV8(isolate, "qt"));
- if (qtObjectValue.IsEmpty() || !qtObjectValue.ToLocalChecked()->IsObject())
+ v8::Local<v8::Value> qtObjectValue;
+ if (!global->Get(context, gin::StringToV8(isolate, "qt")).ToLocal(&qtObjectValue) || !qtObjectValue->IsObject())
return;
- v8::Local<v8::Object> qtObject = v8::Local<v8::Object>::Cast(qtObjectValue.ToLocalChecked());
- // FIXME: We can't do anything about a failure, so why the .. is it nodiscard?
- auto whocares = qtObject->Delete(context, gin::StringToV8(isolate, "webChannelTransport"));
- Q_UNUSED(whocares);
+ v8::Local<v8::Object> qtObject = v8::Local<v8::Object>::Cast(qtObjectValue);
+ qtObject->Delete(context, gin::StringToV8(isolate, "webChannelTransport")).Check();
}
void WebChannelTransport::NativeQtSendMessage(gin::Arguments *args)
@@ -152,22 +111,17 @@ void WebChannelTransport::NativeQtSendMessage(gin::Arguments *args)
return;
}
v8::Local<v8::String> jsonString = v8::Local<v8::String>::Cast(jsonValue);
+ std::vector<uint8_t> json(jsonString->Utf8Length(isolate), 0);
+ jsonString->WriteUtf8(isolate, reinterpret_cast<char *>(json.data()), json.size(), nullptr,
+ v8::String::REPLACE_INVALID_UTF8);
- QByteArray json(jsonString->Utf8Length(isolate), 0);
- jsonString->WriteUtf8(isolate, json.data(), json.size(), nullptr, v8::String::REPLACE_INVALID_UTF8);
-
- QJsonParseError error;
- QJsonDocument doc = QJsonDocument::fromJson(json, &error);
- if (error.error != QJsonParseError::NoError) {
- args->ThrowTypeError("Invalid JSON");
- return;
+ if (!m_remote) {
+ renderFrame->GetRemoteAssociatedInterfaces()->GetInterface(&m_remote);
+ m_renderFrame = renderFrame;
}
+ DCHECK(renderFrame == m_renderFrame);
- int size = 0;
- const char *rawData = doc.rawData(&size);
- mojo::AssociatedRemote<qtwebchannel::mojom::WebChannelTransportHost> webChannelTransport;
- renderFrame->GetRemoteAssociatedInterfaces()->GetInterface(&webChannelTransport);
- webChannelTransport->DispatchWebChannelMessage(std::vector<uint8_t>(rawData, rawData + size));
+ m_remote->DispatchWebChannelMessage(json);
}
gin::ObjectTemplateBuilder WebChannelTransport::GetObjectTemplateBuilder(v8::Isolate *isolate)
@@ -177,16 +131,19 @@ gin::ObjectTemplateBuilder WebChannelTransport::GetObjectTemplateBuilder(v8::Iso
}
WebChannelIPCTransport::WebChannelIPCTransport(content::RenderFrame *renderFrame)
- : content::RenderFrameObserver(renderFrame), m_worldId(0), m_worldInitialized(false)
+ : content::RenderFrameObserver(renderFrame)
+ , m_worldId(0)
+ , m_worldInitialized(false)
+ , m_binding(this)
{
- renderFrame->GetAssociatedInterfaceRegistry()->AddInterface(
+ renderFrame->GetAssociatedInterfaceRegistry()->AddInterface<qtwebchannel::mojom::WebChannelTransportRender>(
base::BindRepeating(&WebChannelIPCTransport::BindReceiver, base::Unretained(this)));
}
void WebChannelIPCTransport::BindReceiver(
mojo::PendingAssociatedReceiver<qtwebchannel::mojom::WebChannelTransportRender> receiver)
{
- m_receivers.Add(this, std::move(receiver));
+ m_binding.Bind(std::move(receiver));
}
void WebChannelIPCTransport::SetWorldId(uint32_t worldId)
@@ -213,18 +170,14 @@ void WebChannelIPCTransport::ResetWorldId()
m_worldId = 0;
}
-void WebChannelIPCTransport::DispatchWebChannelMessage(const std::vector<uint8_t> &binaryJson, uint32_t worldId)
+void WebChannelIPCTransport::DispatchWebChannelMessage(const std::vector<uint8_t> &json,
+ uint32_t worldId)
{
DCHECK(m_worldId == worldId);
if (!m_canUseContext)
return;
- QJsonDocument doc = QJsonDocument::fromRawData(reinterpret_cast<const char *>(binaryJson.data()), binaryJson.size(),
- QJsonDocument::BypassValidation);
- DCHECK(doc.isObject());
- QByteArray json = doc.toJson(QJsonDocument::Compact);
-
blink::WebLocalFrame *frame = render_frame()->GetWebFrame();
v8::Isolate *isolate = blink::MainThreadIsolate();
v8::HandleScope handleScope(isolate);
@@ -236,17 +189,18 @@ void WebChannelIPCTransport::DispatchWebChannelMessage(const std::vector<uint8_t
v8::Context::Scope contextScope(context);
v8::Local<v8::Object> global(context->Global());
- v8::MaybeLocal<v8::Value> qtObjectValue(global->Get(context, gin::StringToV8(isolate, "qt")));
- if (qtObjectValue.IsEmpty() || !qtObjectValue.ToLocalChecked()->IsObject())
+ v8::Local<v8::Value> qtObjectValue;
+ if (!global->Get(context, gin::StringToV8(isolate, "qt")).ToLocal(&qtObjectValue) || !qtObjectValue->IsObject())
return;
- v8::Local<v8::Object> qtObject = v8::Local<v8::Object>::Cast(qtObjectValue.ToLocalChecked());
- v8::MaybeLocal<v8::Value> webChannelObjectValue(
- qtObject->Get(context, gin::StringToV8(isolate, "webChannelTransport")));
- if (webChannelObjectValue.IsEmpty() || !webChannelObjectValue.ToLocalChecked()->IsObject())
+ v8::Local<v8::Object> qtObject = v8::Local<v8::Object>::Cast(qtObjectValue);
+ v8::Local<v8::Value> webChannelObjectValue;
+ if (!qtObject->Get(context, gin::StringToV8(isolate, "webChannelTransport")).ToLocal(&webChannelObjectValue)
+ || !webChannelObjectValue->IsObject())
return;
- v8::Local<v8::Object> webChannelObject = v8::Local<v8::Object>::Cast(webChannelObjectValue.ToLocalChecked());
- v8::MaybeLocal<v8::Value> callbackValue(webChannelObject->Get(context, gin::StringToV8(isolate, "onmessage")));
- if (callbackValue.IsEmpty() || !callbackValue.ToLocalChecked()->IsFunction()) {
+ v8::Local<v8::Object> webChannelObject = v8::Local<v8::Object>::Cast(webChannelObjectValue);
+ v8::Local<v8::Value> callbackValue;
+ if (!webChannelObject->Get(context, gin::StringToV8(isolate, "onmessage")).ToLocal(&callbackValue)
+ || !callbackValue->IsFunction()) {
LOG(WARNING) << "onmessage is not a callable property of qt.webChannelTransport. Some things might not work as "
"expected.";
return;
@@ -255,30 +209,32 @@ void WebChannelIPCTransport::DispatchWebChannelMessage(const std::vector<uint8_t
v8::Local<v8::Object> messageObject(v8::Object::New(isolate));
v8::Maybe<bool> wasSet = messageObject->DefineOwnProperty(
context, v8::String::NewFromUtf8(isolate, "data").ToLocalChecked(),
- v8::String::NewFromUtf8(isolate, json.constData(), v8::NewStringType::kNormal, json.size()).ToLocalChecked(),
+ v8::String::NewFromUtf8(isolate, reinterpret_cast<const char *>(json.data()),
+ v8::NewStringType::kNormal, json.size())
+ .ToLocalChecked(),
v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
DCHECK(!wasSet.IsNothing() && wasSet.FromJust());
- v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(callbackValue.ToLocalChecked());
+ v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(callbackValue);
v8::Local<v8::Value> argv[] = { messageObject };
frame->CallFunctionEvenIfScriptDisabled(callback, webChannelObject, 1, argv);
}
-void WebChannelIPCTransport::WillReleaseScriptContext(v8::Local<v8::Context> context, int worldId)
-{
- if (static_cast<uint>(worldId) == m_worldId)
- m_canUseContext = false;
-}
-
-void WebChannelIPCTransport::DidClearWindowObject()
+void WebChannelIPCTransport::DidCreateScriptContext(v8::Local<v8::Context> context, int32_t worldId)
{
- if (!m_canUseContext) {
+ if (static_cast<uint>(worldId) == m_worldId && !m_canUseContext) {
m_canUseContext = true;
if (m_worldInitialized)
WebChannelTransport::Install(render_frame()->GetWebFrame(), m_worldId);
}
}
+void WebChannelIPCTransport::WillReleaseScriptContext(v8::Local<v8::Context> context, int worldId)
+{
+ if (static_cast<uint>(worldId) == m_worldId)
+ m_canUseContext = false;
+}
+
void WebChannelIPCTransport::OnDestruct()
{
delete this;
diff --git a/src/core/renderer/web_channel_ipc_transport.h b/src/core/renderer/web_channel_ipc_transport.h
index 15778a7bc..95aa39850 100644
--- a/src/core/renderer/web_channel_ipc_transport.h
+++ b/src/core/renderer/web_channel_ipc_transport.h
@@ -1,48 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef WEB_CHANNEL_IPC_TRANSPORT_H
#define WEB_CHANNEL_IPC_TRANSPORT_H
#include "content/public/renderer/render_frame_observer.h"
-#include "services/service_manager/public/cpp/binder_registry.h"
-#include "mojo/public/cpp/bindings/associated_receiver_set.h"
+#include "mojo/public/cpp/bindings/associated_receiver.h"
+#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "qtwebengine/browser/qtwebchannel.mojom.h"
@@ -61,11 +25,11 @@ private:
// qtwebchannel::mojom::WebChannelTransportRender
void SetWorldId(uint32_t worldId) override;
void ResetWorldId() override;
- void DispatchWebChannelMessage(const std::vector<uint8_t> &binaryJson, uint32_t worldId) override;
+ void DispatchWebChannelMessage(const std::vector<uint8_t> &json, uint32_t worldId) override;
// RenderFrameObserver
+ void DidCreateScriptContext(v8::Local<v8::Context> context, int32_t worldId) override;
void WillReleaseScriptContext(v8::Local<v8::Context> context, int worldId) override;
- void DidClearWindowObject() override;
void OnDestruct() override;
void BindReceiver(mojo::PendingAssociatedReceiver<qtwebchannel::mojom::WebChannelTransportRender> receiver);
@@ -76,7 +40,7 @@ private:
bool m_worldInitialized;
// True means it's currently OK to manipulate the frame's script context.
bool m_canUseContext = false;
- mojo::AssociatedReceiverSet<qtwebchannel::mojom::WebChannelTransportRender> m_receivers;
+ mojo::AssociatedReceiver<qtwebchannel::mojom::WebChannelTransportRender> m_binding;
};
} // namespace
diff --git a/src/core/renderer/web_engine_page_render_frame.cpp b/src/core/renderer/web_engine_page_render_frame.cpp
new file mode 100644
index 000000000..1e7ac62fc
--- /dev/null
+++ b/src/core/renderer/web_engine_page_render_frame.cpp
@@ -0,0 +1,66 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "renderer/web_engine_page_render_frame.h"
+#include "content/public/renderer/render_frame.h"
+#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
+
+#include "third_party/blink/public/platform/web_string.h"
+#include "third_party/blink/public/web/web_frame_content_dumper.h"
+#include "third_party/blink/public/web/web_local_frame.h"
+#include "third_party/blink/public/web/web_view.h"
+
+namespace QtWebEngineCore {
+
+WebEnginePageRenderFrame::WebEnginePageRenderFrame(content::RenderFrame *render_frame)
+ : content::RenderFrameObserver(render_frame), m_binding(this), m_ready(false)
+{
+ render_frame->GetAssociatedInterfaceRegistry()->AddInterface<qtwebenginepage::mojom::WebEnginePageRenderFrame>(
+ base::BindRepeating(&WebEnginePageRenderFrame::BindReceiver, base::Unretained(this)));
+}
+
+void WebEnginePageRenderFrame::BindReceiver(
+ mojo::PendingAssociatedReceiver<qtwebenginepage::mojom::WebEnginePageRenderFrame> receiver)
+{
+ m_binding.Bind(std::move(receiver));
+}
+
+void WebEnginePageRenderFrame::FetchDocumentMarkup(uint64_t requestId,
+ FetchDocumentMarkupCallback callback)
+{
+ blink::WebLocalFrame *frame = render_frame()->GetWebFrame();
+ blink::WebString markup;
+ if (m_ready)
+ markup = blink::WebFrameContentDumper::DumpAsMarkup(frame);
+ else
+ markup = blink::WebString::FromUTF8("<html><head></head><body></body></html>");
+ std::move(callback).Run(requestId, markup.Utf8());
+}
+
+void WebEnginePageRenderFrame::FetchDocumentInnerText(uint64_t requestId,
+ FetchDocumentInnerTextCallback callback)
+{
+ blink::WebLocalFrame *frame = render_frame()->GetWebFrame();
+ blink::WebString text;
+ if (m_ready) {
+ text = blink::WebFrameContentDumper::DumpFrameTreeAsText(
+ frame, std::numeric_limits<int32_t>::max());
+ }
+ std::move(callback).Run(requestId, text.Utf8());
+}
+
+void WebEnginePageRenderFrame::SetBackgroundColor(uint32_t color)
+{
+ render_frame()->GetWebFrame()->View()->SetBaseBackgroundColorOverrideForInspector(color);
+}
+
+void WebEnginePageRenderFrame::OnDestruct()
+{
+ delete this;
+}
+
+void WebEnginePageRenderFrame::DidFinishLoad()
+{
+ m_ready = true;
+}
+}
diff --git a/src/core/renderer/web_engine_page_render_frame.h b/src/core/renderer/web_engine_page_render_frame.h
new file mode 100644
index 000000000..7d0e25267
--- /dev/null
+++ b/src/core/renderer/web_engine_page_render_frame.h
@@ -0,0 +1,41 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+#ifndef WEB_ENGINE_PAGE_RENDER_FRAME_H
+#define WEB_ENGINE_PAGE_RENDER_FRAME_H
+
+#include "content/public/renderer/render_frame_observer.h"
+#include "mojo/public/cpp/bindings/associated_receiver.h"
+#include "qtwebengine/browser/qtwebenginepage.mojom.h"
+
+namespace content {
+class RenderFrame;
+}
+
+namespace QtWebEngineCore {
+
+class WebEnginePageRenderFrame : private content::RenderFrameObserver,
+ public qtwebenginepage::mojom::WebEnginePageRenderFrame
+{
+public:
+ WebEnginePageRenderFrame(content::RenderFrame *render_frame);
+ WebEnginePageRenderFrame(const WebEnginePageRenderFrame &) = delete;
+ WebEnginePageRenderFrame &operator=(const WebEnginePageRenderFrame &) = delete;
+
+private:
+ void FetchDocumentMarkup(uint64_t requestId, FetchDocumentMarkupCallback callback) override;
+ void FetchDocumentInnerText(uint64_t requestId,
+ FetchDocumentInnerTextCallback callback) override;
+ void SetBackgroundColor(uint32_t color) override;
+ void OnDestruct() override;
+ void DidFinishLoad() override;
+ void
+ BindReceiver(mojo::PendingAssociatedReceiver<qtwebenginepage::mojom::WebEnginePageRenderFrame>
+ receiver);
+
+private:
+ mojo::AssociatedReceiver<qtwebenginepage::mojom::WebEnginePageRenderFrame> m_binding;
+ bool m_ready;
+};
+} // namespace QtWebEngineCore
+
+#endif // WEB_ENGINE_PAGE_RENDER_FRAME_H