summaryrefslogtreecommitdiffstats
path: root/src/core/content_browser_client_qt.cpp
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/content_browser_client_qt.cpp
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/content_browser_client_qt.cpp')
-rw-r--r--src/core/content_browser_client_qt.cpp47
1 files changed, 47 insertions, 0 deletions
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