summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2020-10-28 15:59:18 +0100
committerPeter Varga <pvarga@inf.u-szeged.hu>2021-01-20 09:41:11 +0100
commit2b6f6ad066123253b65449033eddcee8b20c470b (patch)
treed074840fb4b83394f3bb2694ec1c3f7cb725e4c9 /src/core
parent34dbb4967cb72717a50ef5cba4b84c06a9b160ef (diff)
Enable hangout services extension
[ChangeLog] Enable hangout services extension and implement its WebRTC desktop capture extension API dependency. Fixes: QTBUG-85731 Task-number: QTBUG-51185 Task-number: QTBUG-61676 Change-Id: I7a659c2b0039243ac8d8c58685716ffc55265e3b Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/common/extensions/api/qtwebengine_extensions_features.gni4
-rw-r--r--src/core/common/extensions/extensions_api_provider_qt.cpp21
-rw-r--r--src/core/content_browser_client_qt.cpp47
-rw-r--r--src/core/content_browser_client_qt.h2
-rw-r--r--src/core/core_chromium.pri4
-rw-r--r--src/core/extensions/extension_host_delegate_qt.cpp125
-rw-r--r--src/core/extensions/extension_host_delegate_qt.h77
-rw-r--r--src/core/extensions/extension_system_qt.cpp45
-rw-r--r--src/core/extensions/extension_system_qt.h9
-rw-r--r--src/core/extensions/extensions_api_client_qt.cpp11
-rw-r--r--src/core/extensions/extensions_api_client_qt.h6
-rw-r--r--src/core/extensions/extensions_browser_client_qt.cpp53
-rw-r--r--src/core/extensions/messaging_delegate_qt.cpp56
-rw-r--r--src/core/extensions/messaging_delegate_qt.h66
-rw-r--r--src/core/media_capture_devices_dispatcher.cpp5
-rw-r--r--src/core/media_capture_devices_dispatcher.h2
-rw-r--r--src/core/qtwebengine_sources.gni6
-rw-r--r--src/core/render_widget_host_view_qt.cpp3
-rw-r--r--src/core/renderer/extensions/extensions_dispatcher_delegate_qt.cpp9
-rw-r--r--src/core/renderer/extensions/extensions_dispatcher_delegate_qt.h3
-rw-r--r--src/core/renderer/extensions/extensions_renderer_client_qt.cpp2
-rw-r--r--src/core/web_contents_delegate_qt.cpp2
22 files changed, 508 insertions, 50 deletions
diff --git a/src/core/common/extensions/api/qtwebengine_extensions_features.gni b/src/core/common/extensions/api/qtwebengine_extensions_features.gni
index ed7e713c6..3873e235a 100644
--- a/src/core/common/extensions/api/qtwebengine_extensions_features.gni
+++ b/src/core/common/extensions/api/qtwebengine_extensions_features.gni
@@ -12,7 +12,8 @@ json_features("qt_permission_features") {
feature_type = "PermissionFeature"
method_name = "AddQtPermissionFeatures"
sources = [
- "//extensions/common/api/_permission_features.json"
+ "//chrome/common/extensions/api/_permission_features.json",
+ "//extensions/common/api/_permission_features.json",
]
}
@@ -20,6 +21,7 @@ group("qtwebengine_extensions_features") {
public_deps = [
":qt_api_features",
":qt_permission_features",
+ "//chrome/common/extensions/api:extensions_features",
"//extensions/common/api:extensions_features",
]
}
diff --git a/src/core/common/extensions/extensions_api_provider_qt.cpp b/src/core/common/extensions/extensions_api_provider_qt.cpp
index 22154a9d1..81eb76f3e 100644
--- a/src/core/common/extensions/extensions_api_provider_qt.cpp
+++ b/src/core/common/extensions/extensions_api_provider_qt.cpp
@@ -39,6 +39,8 @@
#include "extensions_api_provider_qt.h"
+#include "chrome/common/extensions/permissions/chrome_api_permissions.h"
+#include "chrome/common/extensions/api/generated_schemas.h"
#include "chrome/grit/common_resources.h"
#include "extensions/common/api/api_features.h"
@@ -51,6 +53,7 @@
#include "extensions/common/features/json_feature_provider_source.h"
#include "extensions/common/permissions/permissions_info.h"
#include "extensions/grit/extensions_resources.h"
+#include "qtwebengine/common/extensions/api/generated_schemas.h"
#include "qt_api_features.h"
//#include "qt_behavior_features.h"
@@ -85,16 +88,30 @@ void ExtensionsAPIProviderQt::AddPermissionFeatures(FeatureProvider *provider)
bool ExtensionsAPIProviderQt::IsAPISchemaGenerated(const std::string &name)
{
- return api::GeneratedSchemas::IsGenerated(name);
+ return api::GeneratedSchemas::IsGenerated(name) ||
+ api::ChromeGeneratedSchemas::IsGenerated(name) ||
+ api::QtWebEngineGeneratedSchemas::IsGenerated(name);
}
base::StringPiece ExtensionsAPIProviderQt::GetAPISchema(const std::string &name)
{
- return api::GeneratedSchemas::Get(name);
+ if (!api::GeneratedSchemas::Get(name).empty())
+ return api::GeneratedSchemas::Get(name);
+
+ if (!api::ChromeGeneratedSchemas::Get(name).empty())
+ return api::ChromeGeneratedSchemas::Get(name);
+
+ if (!api::QtWebEngineGeneratedSchemas::Get(name).empty())
+ return api::QtWebEngineGeneratedSchemas::Get(name);
+
+ return "";
}
void ExtensionsAPIProviderQt::RegisterPermissions(PermissionsInfo* permissions_info)
{
+ permissions_info->RegisterPermissions(
+ chrome_api_permissions::GetPermissionInfos(),
+ chrome_api_permissions::GetPermissionAliases());
}
}
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index f4475b317..b6b46af5d 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -60,6 +60,7 @@
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/url_schemes.h"
+#include "content/public/browser/browser_main_runner.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
@@ -85,6 +86,7 @@
#include "extensions/buildflags/buildflags.h"
#include "extensions/browser/extension_protocols.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
+#include "extensions/browser/process_map.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/remote.h"
@@ -166,6 +168,7 @@
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "content/public/browser/file_url_loader.h"
#include "extensions/browser/extension_message_filter.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/guest_view/extensions_guest_view_message_filter.h"
#include "extensions/browser/url_loader_factory_manager.h"
#include "extensions/common/constants.h"
@@ -385,6 +388,10 @@ void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, b
#if BUILDFLAG(ENABLE_EXTENSIONS)
if (guest_view::GuestViewBase::IsGuest(webContents))
return;
+
+ WebContentsViewQt *view = WebContentsViewQt::from(static_cast<content::WebContentsImpl *>(webContents)->GetView());
+ if (!view->client())
+ return;
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
WebContentsDelegateQt* delegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate());
if (delegate)
@@ -940,6 +947,11 @@ static bool navigationThrottleCallback(content::WebContents *source,
ProfileQt *profile = static_cast<ProfileQt *>(source->GetBrowserContext());
if (params.is_external_protocol() && !profile->profileAdapter()->urlSchemeHandler(toQByteArray(params.url().scheme())))
return false;
+
+ WebContentsViewQt *view = WebContentsViewQt::from(static_cast<content::WebContentsImpl *>(source)->GetView());
+ if (!view->client())
+ return false;
+
int navigationRequestAction = WebContentsAdapterClient::AcceptRequest;
WebContentsDelegateQt *delegate = static_cast<WebContentsDelegateQt *>(source->GetDelegate());
WebContentsAdapterClient *client = delegate->adapterClient();
@@ -1225,6 +1237,9 @@ bool ContentBrowserClientQt::WillCreateURLLoaderFactory(
if (web_contents) {
WebContentsAdapterClient *client =
WebContentsViewQt::from(static_cast<content::WebContentsImpl *>(web_contents)->GetView())->client();
+ if (!client)
+ return false;
+
page_interceptor = client->webContentsAdapter()->requestInterceptor();
}
@@ -1241,4 +1256,36 @@ bool ContentBrowserClientQt::WillCreateURLLoaderFactory(
return false;
}
+void ContentBrowserClientQt::SiteInstanceGotProcess(content::SiteInstance *site_instance)
+{
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+ content::BrowserContext *context = site_instance->GetBrowserContext();
+ extensions::ExtensionRegistry *registry = extensions::ExtensionRegistry::Get(context);
+ const extensions::Extension *extension = registry->enabled_extensions().GetExtensionOrAppByURL(site_instance->GetSiteURL());
+ if (!extension)
+ return;
+
+ extensions::ProcessMap *processMap = extensions::ProcessMap::Get(context);
+ processMap->Insert(extension->id(), site_instance->GetProcess()->GetID(), site_instance->GetId());
+#endif
+}
+
+void ContentBrowserClientQt::SiteInstanceDeleting(content::SiteInstance *site_instance)
+{
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+ // Don't do anything if we're shutting down.
+ if (content::BrowserMainRunner::ExitedMainMessageLoop() || !site_instance->HasProcess())
+ return;
+
+ content::BrowserContext *context = site_instance->GetBrowserContext();
+ extensions::ExtensionRegistry *registry = extensions::ExtensionRegistry::Get(context);
+ const extensions::Extension *extension = registry->enabled_extensions().GetExtensionOrAppByURL(site_instance->GetSiteURL());
+ if (!extension)
+ return;
+
+ extensions::ProcessMap *processMap = extensions::ProcessMap::Get(context);
+ processMap->Remove(extension->id(), site_instance->GetProcess()->GetID(), site_instance->GetId());
+#endif
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index 754c7e3a9..9e578d9d9 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -260,6 +260,8 @@ public:
NonNetworkURLLoaderFactoryMap *factories) override;
void RegisterNonNetworkWorkerMainResourceURLLoaderFactories(content::BrowserContext* browser_context,
NonNetworkURLLoaderFactoryMap* factories) override;
+ void SiteInstanceGotProcess(content::SiteInstance *site_instance) override;
+ void SiteInstanceDeleting(content::SiteInstance *site_instance) override;
static std::string getUserAgent();
diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri
index 248b245b4..2653c1e57 100644
--- a/src/core/core_chromium.pri
+++ b/src/core/core_chromium.pri
@@ -318,11 +318,13 @@ qtConfig(webengine-extensions) {
common/extensions/extensions_api_provider_qt.cpp \
common/extensions/extensions_client_qt.cpp \
extensions/component_extension_resource_manager_qt.cpp \
+ extensions/extension_host_delegate_qt.cpp \
extensions/extension_system_qt.cpp \
extensions/extension_system_factory_qt.cpp \
extensions/extension_web_contents_observer_qt.cpp \
extensions/extensions_api_client_qt.cpp \
extensions/extensions_browser_client_qt.cpp \
+ extensions/messaging_delegate_qt.cpp \
extensions/mime_handler_view_guest_delegate_qt.cpp \
net/plugin_response_interceptor_url_loader_throttle.cpp \
renderer/extensions/extensions_dispatcher_delegate_qt.cpp \
@@ -334,11 +336,13 @@ qtConfig(webengine-extensions) {
common/extensions/extensions_api_provider_qt.h \
common/extensions/extensions_client_qt.h \
extensions/component_extension_resource_manager_qt.h \
+ extensions/extension_host_delegate_qt.h \
extensions/extension_system_qt.h \
extensions/extension_system_factory_qt.h \
extensions/extension_web_contents_observer_qt.h \
extensions/extensions_api_client_qt.h \
extensions/extensions_browser_client_qt.h \
+ extensions/messaging_delegate_qt.h \
extensions/mime_handler_view_guest_delegate_qt.h \
net/plugin_response_interceptor_url_loader_throttle.h \
renderer/extensions/extensions_dispatcher_delegate_qt.h \
diff --git a/src/core/extensions/extension_host_delegate_qt.cpp b/src/core/extensions/extension_host_delegate_qt.cpp
new file mode 100644
index 000000000..1a44dee7a
--- /dev/null
+++ b/src/core/extensions/extension_host_delegate_qt.cpp
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include "extension_host_delegate_qt.h"
+#include "extension_web_contents_observer_qt.h"
+#include "media_capture_devices_dispatcher.h"
+#include "extension_system_qt.h"
+
+#include "extensions/browser/extension_host.h"
+
+namespace extensions {
+
+ExtensionHostDelegateQt::ExtensionHostDelegateQt()
+{
+}
+
+void ExtensionHostDelegateQt::OnExtensionHostCreated(content::WebContents *web_contents)
+{
+ extensions::ExtensionWebContentsObserverQt::CreateForWebContents(web_contents);
+}
+
+void ExtensionHostDelegateQt::OnRenderViewCreatedForBackgroundPage(ExtensionHost *host)
+{
+ Q_UNUSED(host);
+}
+
+content::JavaScriptDialogManager *ExtensionHostDelegateQt::GetJavaScriptDialogManager()
+{
+ Q_UNREACHABLE();
+ return nullptr;
+}
+
+void ExtensionHostDelegateQt::CreateTab(std::unique_ptr<content::WebContents> web_contents,
+ const std::string &extension_id,
+ WindowOpenDisposition disposition,
+ const gfx::Rect &initial_rect,
+ bool user_gesture)
+{
+ Q_UNUSED(web_contents);
+ Q_UNUSED(extension_id);
+ Q_UNUSED(disposition);
+ Q_UNUSED(initial_rect);
+ Q_UNUSED(user_gesture);
+
+ Q_UNREACHABLE();
+}
+
+void ExtensionHostDelegateQt::ProcessMediaAccessRequest(content::WebContents *web_contents,
+ const content::MediaStreamRequest &request,
+ content::MediaResponseCallback callback,
+ const Extension *extension)
+{
+ Q_UNUSED(extension);
+
+ QtWebEngineCore::MediaCaptureDevicesDispatcher::GetInstance()->processMediaAccessRequest(web_contents, request, std::move(callback));
+}
+
+bool ExtensionHostDelegateQt::CheckMediaAccessPermission(content::RenderFrameHost *render_frame_host,
+ const GURL &security_origin,
+ blink::mojom::MediaStreamType type,
+ const Extension *extension)
+{
+ Q_UNUSED(render_frame_host);
+ Q_UNUSED(security_origin);
+ Q_UNUSED(type);
+ Q_UNUSED(extension);
+
+ Q_UNREACHABLE();
+ return false;
+}
+
+content::PictureInPictureResult ExtensionHostDelegateQt::EnterPictureInPicture(content::WebContents *web_contents,
+ const viz::SurfaceId &surface_id,
+ const gfx::Size &natural_size)
+{
+ Q_UNUSED(web_contents);
+ Q_UNUSED(surface_id);
+ Q_UNUSED(natural_size);
+
+ Q_UNREACHABLE();
+ return content::PictureInPictureResult::kNotSupported;
+}
+
+void ExtensionHostDelegateQt::ExitPictureInPicture()
+{
+ Q_UNREACHABLE();
+}
+
+} // namespace extensions
diff --git a/src/core/extensions/extension_host_delegate_qt.h b/src/core/extensions/extension_host_delegate_qt.h
new file mode 100644
index 000000000..42ff56a53
--- /dev/null
+++ b/src/core/extensions/extension_host_delegate_qt.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef EXTENSION_HOST_DELEGATE_QT_H
+#define EXTENSION_HOST_DELEGATE_QT_H
+
+#include "extensions/browser/extension_host_delegate.h"
+
+namespace extensions {
+
+class ExtensionHostDelegateQt : public ExtensionHostDelegate
+{
+public:
+ ExtensionHostDelegateQt();
+
+ // EtensionHostDelegate implementation.
+ void OnExtensionHostCreated(content::WebContents *web_contents) override;
+ void OnRenderViewCreatedForBackgroundPage(ExtensionHost *host) override;
+ content::JavaScriptDialogManager *GetJavaScriptDialogManager() override;
+ void CreateTab(std::unique_ptr<content::WebContents> web_contents,
+ const std::string &extension_id,
+ WindowOpenDisposition disposition,
+ const gfx::Rect &initial_rect,
+ bool user_gesture) override;
+ void ProcessMediaAccessRequest(content::WebContents *web_contents,
+ const content::MediaStreamRequest &request,
+ content::MediaResponseCallback callback,
+ const Extension *extension) override;
+ bool CheckMediaAccessPermission(content::RenderFrameHost *render_frame_host,
+ const GURL &security_origin,
+ blink::mojom::MediaStreamType type,
+ const Extension *extension) override;
+ content::PictureInPictureResult EnterPictureInPicture(content::WebContents *web_contents,
+ const viz::SurfaceId &surface_id,
+ const gfx::Size &natural_size) override;
+ void ExitPictureInPicture() override;
+};
+
+} // namespace extensions
+
+#endif // EXTENSION_HOST_DELEGATE_QT_H
diff --git a/src/core/extensions/extension_system_qt.cpp b/src/core/extensions/extension_system_qt.cpp
index f40bed207..9c080e9aa 100644
--- a/src/core/extensions/extension_system_qt.cpp
+++ b/src/core/extensions/extension_system_qt.cpp
@@ -61,6 +61,7 @@
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
+#include "chrome/common/buildflags.h"
#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
@@ -87,7 +88,6 @@
#include "extensions/browser/service_worker_manager.h"
#include "extensions/browser/value_store/value_store_factory_impl.h"
#include "extensions/common/constants.h"
-#include "extensions/common/extension_messages.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/mime_types_handler.h"
#include "extensions/common/manifest_url_handlers.h"
@@ -359,15 +359,29 @@ void ExtensionSystemQt::Init(bool extensions_enabled)
// Inform the rest of the extensions system to start.
ready_.Signal();
- std::string pdf_manifest = ui::ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_PDF_MANIFEST).as_string();
- base::ReplaceFirstSubstringAfterOffset(&pdf_manifest, 0, "<NAME>", "chromium-pdf");
+ {
+ std::string pdf_manifest = ui::ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_PDF_MANIFEST).as_string();
+ base::ReplaceFirstSubstringAfterOffset(&pdf_manifest, 0, "<NAME>", "chromium-pdf");
- std::unique_ptr<base::DictionaryValue> pdfManifestDict = ParseManifest(pdf_manifest);
- base::FilePath path;
- base::PathService::Get(base::DIR_QT_LIBRARY_DATA, &path);
- path = path.Append(base::FilePath(FILE_PATH_LITERAL("pdf")));
- std::string id = GenerateId(pdfManifestDict.get(), path);
- LoadExtension(id, std::move(pdfManifestDict), path);
+ std::unique_ptr<base::DictionaryValue> pdfManifestDict = ParseManifest(pdf_manifest);
+ base::FilePath path;
+ base::PathService::Get(base::DIR_QT_LIBRARY_DATA, &path);
+ path = path.Append(base::FilePath(FILE_PATH_LITERAL("pdf")));
+ std::string id = GenerateId(pdfManifestDict.get(), path);
+ LoadExtension(id, std::move(pdfManifestDict), path);
+ }
+
+#if BUILDFLAG(ENABLE_HANGOUT_SERVICES_EXTENSION)
+ {
+ std::string hangout_manifest = ui::ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_HANGOUT_SERVICES_MANIFEST).as_string();
+ std::unique_ptr<base::DictionaryValue> hangoutManifestDict = ParseManifest(hangout_manifest);
+ base::FilePath path;
+ base::PathService::Get(base::DIR_QT_LIBRARY_DATA, &path);
+ path = path.Append(base::FilePath(FILE_PATH_LITERAL("hangout_services")));
+ std::string id = GenerateId(hangoutManifestDict.get(), path);
+ LoadExtension(id, std::move(hangoutManifestDict), path);
+ }
+#endif // BUILDFLAG(ENABLE_HANGOUT_SERVICES_EXTENSION)
}
}
@@ -386,19 +400,6 @@ std::unique_ptr<ExtensionSet> ExtensionSystemQt::GetDependentExtensions(const Ex
return base::WrapUnique(new ExtensionSet());
}
-#if !defined(TOOLKIT_QT)
-void ExtensionSystemQt::InstallUpdate(const std::string &extension_id,
- const std::string &public_key,
- const base::FilePath &unpacked_dir,
- bool install_immediately,
- InstallUpdateCallback install_update_callback)
-{
- NOTREACHED() << "Not yet implemented";
- base::DeleteFile(unpacked_dir, true /* recursive */);
- std::move(install_update_callback).Run(CrxInstallError(CrxInstallErrorType::DECLINED, CrxInstallErrorDetail::DISALLOWED_BY_POLICY));
-}
-#endif
-
void ExtensionSystemQt::RegisterExtensionWithRequestContexts(const Extension *extension,
base::OnceClosure callback)
{
diff --git a/src/core/extensions/extension_system_qt.h b/src/core/extensions/extension_system_qt.h
index 5526d5cb8..59835657a 100644
--- a/src/core/extensions/extension_system_qt.h
+++ b/src/core/extensions/extension_system_qt.h
@@ -106,15 +106,6 @@ public:
ContentVerifier *content_verifier() override;
std::unique_ptr<ExtensionSet> GetDependentExtensions(const Extension *extension) override;
-#if !defined(TOOLKIT_QT)
- void InstallUpdate(const std::string &extension_id,
- const std::string &public_key,
- const base::FilePath &unpacked_dir,
- bool install_immediately,
- InstallUpdateCallback install_update_callback) override;
-#endif // TOOLKIT_QT
- //friend class ExtensionSystemSharedFactory;
-
bool FinishDelayedInstallationIfReady(const std::string &extension_id, bool install_immediately) override;
void Init(bool extensions_enabled);
diff --git a/src/core/extensions/extensions_api_client_qt.cpp b/src/core/extensions/extensions_api_client_qt.cpp
index 731b79a63..81d9efde2 100644
--- a/src/core/extensions/extensions_api_client_qt.cpp
+++ b/src/core/extensions/extensions_api_client_qt.cpp
@@ -43,13 +43,13 @@
// found in the LICENSE file.
#include "extensions_api_client_qt.h"
+#include "messaging_delegate_qt.h"
#include <memory>
-//#include "base/memory/ptr_util.h"
-#include "extension_web_contents_observer_qt.h"
#include "components/pdf/browser/pdf_web_contents_helper.h"
#include "extensions/browser/guest_view/extensions_guest_view_manager_delegate.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h"
+#include "extension_web_contents_observer_qt.h"
#include "printing/print_view_manager_qt.h"
namespace extensions {
@@ -82,4 +82,11 @@ void ExtensionsAPIClientQt::AttachWebContentsHelpers(content::WebContents *web_c
ExtensionWebContentsObserverQt::CreateForWebContents(web_contents);
}
+MessagingDelegate *ExtensionsAPIClientQt::GetMessagingDelegate()
+{
+ if (!m_messagingDelegate)
+ m_messagingDelegate = std::make_unique<MessagingDelegateQt>();
+ return m_messagingDelegate.get();
+}
+
} // namespace extensions
diff --git a/src/core/extensions/extensions_api_client_qt.h b/src/core/extensions/extensions_api_client_qt.h
index 2fa69f539..b1b6356e8 100644
--- a/src/core/extensions/extensions_api_client_qt.h
+++ b/src/core/extensions/extensions_api_client_qt.h
@@ -49,6 +49,8 @@
namespace extensions {
+class MessagingDelegate;
+
class ExtensionsAPIClientQt : public ExtensionsAPIClient
{
public:
@@ -61,6 +63,10 @@ public:
std::unique_ptr<MimeHandlerViewGuestDelegate>
CreateMimeHandlerViewGuestDelegate(MimeHandlerViewGuest *guest) const override;
void AttachWebContentsHelpers(content::WebContents *web_contents) const override;
+ MessagingDelegate *GetMessagingDelegate() override;
+
+private:
+ std::unique_ptr<MessagingDelegate> m_messagingDelegate;
};
} // namespace extensions
diff --git a/src/core/extensions/extensions_browser_client_qt.cpp b/src/core/extensions/extensions_browser_client_qt.cpp
index e59e83f7f..6bcf37d85 100644
--- a/src/core/extensions/extensions_browser_client_qt.cpp
+++ b/src/core/extensions/extensions_browser_client_qt.cpp
@@ -49,25 +49,24 @@
#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
#include "base/path_service.h"
-#include "base/strings/stringprintf.h"
#include "base/task/post_task.h"
#include "base/memory/ref_counted_memory.h"
+#include "chrome/browser/extensions/api/generated_api_registration.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_context.h"
-#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/api/runtime/runtime_api_delegate.h"
-#include "extensions/browser/app_sorting.h"
#include "extensions/browser/core_extensions_browser_api_provider.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_host_delegate.h"
#include "extensions/browser/extension_protocols.h"
+#include "extensions/browser/extensions_browser_api_provider.h"
#include "extensions/browser/extensions_browser_interface_binders.h"
#include "extensions/browser/url_request_util.h"
#include "extensions/common/file_util.h"
-#include "net/base/completion_once_callback.h"
#include "net/base/mime_util.h"
+#include "qtwebengine/browser/extensions/api/generated_api_registration.h"
#include "services/network/public/mojom/url_loader.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "third_party/zlib/google/compression_utils.h"
@@ -78,10 +77,10 @@
#include "extension_web_contents_observer_qt.h"
#include "extensions_api_client_qt.h"
#include "extensions_browser_client_qt.h"
+#include "extension_host_delegate_qt.h"
#include "web_engine_library_info.h"
using content::BrowserContext;
-using content::BrowserThread;
namespace {
@@ -251,11 +250,46 @@ private:
namespace extensions {
+// Copied from chrome/browser/extensions/chrome_extensions_browser_api_provider.(h|cc)
+class ChromeExtensionsBrowserAPIProvider : public ExtensionsBrowserAPIProvider
+{
+public:
+ ChromeExtensionsBrowserAPIProvider() = default;
+ ~ChromeExtensionsBrowserAPIProvider() override = default;
+
+ void RegisterExtensionFunctions(ExtensionFunctionRegistry *registry) override
+ {
+ // Generated APIs from Chrome.
+ api::ChromeGeneratedFunctionRegistry::RegisterAll(registry);
+ }
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsBrowserAPIProvider);
+};
+
+class QtWebEngineExtensionsBrowserAPIProvider : public ExtensionsBrowserAPIProvider
+{
+public:
+ QtWebEngineExtensionsBrowserAPIProvider() = default;
+ ~QtWebEngineExtensionsBrowserAPIProvider() override = default;
+
+ void RegisterExtensionFunctions(ExtensionFunctionRegistry *registry) override
+ {
+ // Generated APIs from QtWebEngine.
+ api::QtWebEngineGeneratedFunctionRegistry::RegisterAll(registry);
+ }
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(QtWebEngineExtensionsBrowserAPIProvider);
+};
+
ExtensionsBrowserClientQt::ExtensionsBrowserClientQt()
: api_client_(new ExtensionsAPIClientQt)
, resource_manager_(new ComponentExtensionResourceManagerQt)
{
AddAPIProvider(std::make_unique<CoreExtensionsBrowserAPIProvider>());
+ AddAPIProvider(std::make_unique<ChromeExtensionsBrowserAPIProvider>());
+ AddAPIProvider(std::make_unique<QtWebEngineExtensionsBrowserAPIProvider>());
}
ExtensionsBrowserClientQt::~ExtensionsBrowserClientQt()
@@ -370,10 +404,13 @@ bool ExtensionsBrowserClientQt::AllowCrossRendererResourceLoad(const GURL &url,
const ExtensionSet &extensions,
const ProcessMap &process_map)
{
-
if (extension && extension->id() == extension_misc::kPdfExtensionId)
return true;
+ // hangout services id
+ if (extension && extension->id() == "nkeimhogjdpnpccoofpliimaahmaaome")
+ return true;
+
bool allowed = false;
if (url_request_util::AllowCrossRendererResourceLoad(url, resource_type,
page_transition, child_id,
@@ -402,9 +439,7 @@ ProcessManagerDelegate *ExtensionsBrowserClientQt::GetProcessManagerDelegate() c
std::unique_ptr<ExtensionHostDelegate> ExtensionsBrowserClientQt::CreateExtensionHostDelegate()
{
- // TODO(extensions): Implement to support Apps.
- NOTREACHED();
- return std::unique_ptr<ExtensionHostDelegate>();
+ return std::unique_ptr<ExtensionHostDelegate>(new ExtensionHostDelegateQt);
}
bool ExtensionsBrowserClientQt::DidVersionUpdate(BrowserContext *context)
diff --git a/src/core/extensions/messaging_delegate_qt.cpp b/src/core/extensions/messaging_delegate_qt.cpp
new file mode 100644
index 000000000..c666daa09
--- /dev/null
+++ b/src/core/extensions/messaging_delegate_qt.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include "messaging_delegate_qt.h"
+
+#include <QtGlobal>
+
+namespace extensions {
+
+MessagingDelegateQt::MessagingDelegateQt()
+{
+}
+
+std::unique_ptr<base::DictionaryValue> MessagingDelegateQt::MaybeGetTabInfo(content::WebContents *web_contents)
+{
+ Q_UNUSED(web_contents);
+ return nullptr;
+}
+
+} // namespace extensions
diff --git a/src/core/extensions/messaging_delegate_qt.h b/src/core/extensions/messaging_delegate_qt.h
new file mode 100644
index 000000000..44bfdc2d5
--- /dev/null
+++ b/src/core/extensions/messaging_delegate_qt.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef MESSAGING_DELEGATE_QT_H
+#define MESSAGING_DELEGATE_QT_H
+
+#include "extensions/browser/api/messaging/messaging_delegate.h"
+
+namespace base {
+class DictionaryValue;
+}
+
+namespace content {
+class WebContents;
+}
+
+namespace extensions {
+
+class MessagingDelegateQt : public MessagingDelegate
+{
+public:
+ MessagingDelegateQt();
+
+ // MessagingDelegate implementation.
+ std::unique_ptr<base::DictionaryValue> MaybeGetTabInfo(content::WebContents *web_contents) override;
+};
+
+} // namespace extensions
+
+#endif // MESSAGING_DELEGATE_QT_H
diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp
index 2c2c8cd47..ef5d65745 100644
--- a/src/core/media_capture_devices_dispatcher.cpp
+++ b/src/core/media_capture_devices_dispatcher.cpp
@@ -381,7 +381,7 @@ void MediaCaptureDevicesDispatcher::Observe(int type, const content::Notificatio
}
}
-void MediaCaptureDevicesDispatcher::processMediaAccessRequest(WebContentsAdapterClient *adapterClient, content::WebContents *webContents, const content::MediaStreamRequest &request, content::MediaResponseCallback callback)
+void MediaCaptureDevicesDispatcher::processMediaAccessRequest(content::WebContents *webContents, const content::MediaStreamRequest &request, content::MediaResponseCallback callback)
{
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -391,6 +391,9 @@ void MediaCaptureDevicesDispatcher::processMediaAccessRequest(WebContentsAdapter
return;
}
+ WebContentsDelegateQt *delegate = static_cast<WebContentsDelegateQt *>(webContents->GetDelegate());
+ WebContentsAdapterClient *adapterClient = delegate->adapterClient();
+
if (flags.testFlag(WebContentsAdapterClient::MediaDesktopVideoCapture)) {
const bool screenCaptureEnabled =
adapterClient->webEngineSettings()->testAttribute(WebEngineSettings::ScreenCaptureEnabled);
diff --git a/src/core/media_capture_devices_dispatcher.h b/src/core/media_capture_devices_dispatcher.h
index 17cb5d5c9..2db457d33 100644
--- a/src/core/media_capture_devices_dispatcher.h
+++ b/src/core/media_capture_devices_dispatcher.h
@@ -66,7 +66,7 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver,
public:
static MediaCaptureDevicesDispatcher *GetInstance();
- void processMediaAccessRequest(WebContentsAdapterClient *, content::WebContents *, const content::MediaStreamRequest &, content::MediaResponseCallback);
+ void processMediaAccessRequest(content::WebContents *, const content::MediaStreamRequest &, content::MediaResponseCallback);
// Called back from our WebContentsAdapter to grant the requested permission.
void handleMediaAccessPermissionResponse(content::WebContents *, const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags);
diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni
index 39c670224..418638536 100644
--- a/src/core/qtwebengine_sources.gni
+++ b/src/core/qtwebengine_sources.gni
@@ -101,8 +101,10 @@ source_set("qtwebengine_sources") {
deps += [
":qtwebengine_extensions_features",
"//chrome/app:generated_resources",
+ "//chrome/browser/extensions/api:api_registration",
"//chrome/browser/resources:component_extension_resources_grit",
"//chrome/common/extensions/api",
+ "//chrome/common/extensions/api:api",
"//chrome/common/extensions/api:extensions_features",
"//components/crx_file",
"//components/crx_file:crx_creator",
@@ -117,8 +119,12 @@ source_set("qtwebengine_sources") {
"//extensions/renderer",
"//extensions:extensions_resources",
"//extensions/strings",
+ "//qtwebengine/browser/extensions/api:api_registration",
+ "//qtwebengine/common/extensions/api:api",
]
sources += [
+ "//chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api.cc",
+ "//chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api.h",
"//chrome/common/extensions/permissions/chrome_api_permissions.cc",
"//chrome/common/extensions/permissions/chrome_api_permissions.h",
"//chrome/common/extensions/permissions/chrome_permission_message_provider.cc",
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index d85542bb0..877f3c630 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -419,6 +419,9 @@ void RenderWidgetHostViewQt::InitAsFullscreen(content::RenderWidgetHostView*)
void RenderWidgetHostViewQt::SetSize(const gfx::Size &sizeInDips)
{
+ if (!m_delegate)
+ return;
+
m_delegate->resize(sizeInDips.width(), sizeInDips.height());
}
diff --git a/src/core/renderer/extensions/extensions_dispatcher_delegate_qt.cpp b/src/core/renderer/extensions/extensions_dispatcher_delegate_qt.cpp
index 418429330..d49845f55 100644
--- a/src/core/renderer/extensions/extensions_dispatcher_delegate_qt.cpp
+++ b/src/core/renderer/extensions/extensions_dispatcher_delegate_qt.cpp
@@ -39,6 +39,9 @@
#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 +52,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..1a19bcbbb 100644
--- a/src/core/renderer/extensions/extensions_dispatcher_delegate_qt.h
+++ b/src/core/renderer/extensions/extensions_dispatcher_delegate_qt.h
@@ -52,6 +52,9 @@ public:
~ExtensionsDispatcherDelegateQt() override;
private:
+ // extensions::DispatcherDelegate implementation.
+ void PopulateSourceMap(extensions::ResourceBundleSourceMap *source_map) override;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionsDispatcherDelegateQt);
};
diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp
index 3d1a8685c..f72113018 100644
--- a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp
+++ b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp
@@ -147,8 +147,6 @@ 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);
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index ff4f8c642..e594f648e 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -641,7 +641,7 @@ void WebContentsDelegateQt::FindReply(content::WebContents *source, int request_
void WebContentsDelegateQt::RequestMediaAccessPermission(content::WebContents *web_contents, const content::MediaStreamRequest &request, content::MediaResponseCallback callback)
{
- MediaCaptureDevicesDispatcher::GetInstance()->processMediaAccessRequest(m_viewClient, web_contents, request, std::move(callback));
+ MediaCaptureDevicesDispatcher::GetInstance()->processMediaAccessRequest(web_contents, request, std::move(callback));
}
void WebContentsDelegateQt::SetContentsBounds(content::WebContents *source, const gfx::Rect &bounds)