diff options
author | Michael BrĂ¼ning <michael.bruning@qt.io> | 2019-01-22 18:03:00 +0100 |
---|---|---|
committer | Michael BrĂ¼ning <michael.bruning@qt.io> | 2019-02-01 10:26:00 +0000 |
commit | e3968360b4f1b7b0603b97d50244b18c92207f21 (patch) | |
tree | d326be003ca43991bacc8685a07a051f4e46c898 /src/core/content_browser_client_qt.cpp | |
parent | 3bff0bae7e0c660fc25c5c46dedaf9cb89563a58 (diff) |
Add extension system and PDF viewer to Qt WebEngine
Adds the Chromium extensiuon system to Qt WebEngine.
Currently, it only exposes internal APIs to the internal
PDF viewer extension.
To load a PDF, simply navigate to it.
This feature can be configured via the webengine-extensions flag
and is turned on by default.
Needs patch in Chromium 71-based to build.
Adaptations to 71-based from 69-based include:
* Flag out update installation, add crx file dependency
* Move PostTask over to 71-based implementation
* Move extensions API providers to 71-based implementaion
* Don't use custom guest view and mime handler view delegates
* Adapt the URLRequestResourceBundleJob to match new interface
* Move extension system initialization to end of profile constructor
Change-Id: I4fa5149057291bb5847f048534c11820cd7ff58c
Fixes: QTBUG-50556
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.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 98262570c..846f3b908 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -48,6 +48,7 @@ #if QT_CONFIG(webengine_spellchecker) #include "chrome/browser/spellchecker/spell_check_host_chrome_impl.h" #endif +#include "components/guest_view/browser/guest_view_base.h" #include "components/network_hints/browser/network_hints_message_filter.h" #include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/common/url_schemes.h" @@ -70,6 +71,7 @@ #include "content/public/common/service_names.mojom.h" #include "content/public/common/url_constants.h" #include "media/media_buildflags.h" +#include "extensions/buildflags/buildflags.h" #include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding_set.h" #include "printing/buildflags/buildflags.h" @@ -128,6 +130,16 @@ #include "location_provider_qt.h" #endif +#if BUILDFLAG(ENABLE_EXTENSIONS) +#include "extensions/extensions_browser_client_qt.h" +#include "extensions/browser/extension_message_filter.h" +#include "extensions/browser/guest_view/extensions_guest_view_message_filter.h" +#include "extensions/browser/io_thread_extension_message_filter.h" +#include "extensions/common/constants.h" +#include "common/extensions/extensions_client_qt.h" +#include "renderer_host/resource_dispatcher_host_delegate_qt.h" +#endif + #include <QGuiApplication> #include <QLocale> #ifndef QT_NO_OPENGL @@ -252,6 +264,11 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* #if QT_CONFIG(webengine_printing_and_pdf) host->AddFilter(new PrintingMessageFilterQt(host->GetID())); #endif +#if BUILDFLAG(ENABLE_EXTENSIONS) + host->AddFilter(new extensions::ExtensionMessageFilter(host->GetID(), host->GetBrowserContext())); + host->AddFilter(new extensions::IOThreadExtensionMessageFilter(host->GetID(), host->GetBrowserContext())); + host->AddFilter(new extensions::ExtensionsGuestViewMessageFilter(host->GetID(), host->GetBrowserContext())); +#endif //ENABLE_EXTENSIONS service_manager::mojom::ServicePtr service; *service_request = mojo::MakeRequest(&service); @@ -266,7 +283,11 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* void ContentBrowserClientQt::ResourceDispatcherHostCreated() { +#if BUILDFLAG(ENABLE_EXTENSIONS) + m_resourceDispatcherHostDelegate.reset(new ResourceDispatcherHostDelegateQt); +#else m_resourceDispatcherHostDelegate.reset(new content::ResourceDispatcherHostDelegate); +#endif content::ResourceDispatcherHost::Get()->SetDelegate(m_resourceDispatcherHostDelegate.get()); } @@ -285,6 +306,10 @@ content::MediaObserver *ContentBrowserClientQt::GetMediaObserver() void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, content::WebPreferences *web_prefs) { if (content::WebContents *webContents = rvh->GetDelegate()->GetAsWebContents()) { +#if BUILDFLAG(ENABLE_EXTENSIONS) + if (guest_view::GuestViewBase::IsGuest(webContents)) + return; +#endif // BUILDFLAG(ENABLE_EXTENSIONS) WebContentsDelegateQt* delegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate()); if (delegate) delegate->overrideWebPreferences(webContents, web_prefs); @@ -404,6 +429,11 @@ void ContentBrowserClientQt::GetAdditionalWebUISchemes(std::vector<std::string>* additional_schemes->push_back(content::kChromeDevToolsScheme); } +void ContentBrowserClientQt::GetAdditionalViewSourceSchemes(std::vector<std::string>* additional_schemes) +{ + additional_schemes->push_back(content::kChromeDevToolsScheme); +} + #if defined(Q_OS_LINUX) void ContentBrowserClientQt::GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::PosixFileDescriptorInfo* mappings) { @@ -730,4 +760,13 @@ scoped_refptr<content::LoginDelegate> ContentBrowserClientQt::CreateLoginDelegat return loginDelegate; } +bool ContentBrowserClientQt::ShouldUseProcessPerSite(content::BrowserContext* browser_context, const GURL& effective_url) +{ +#if BUILDFLAG(ENABLE_EXTENSIONS) + return true; +#else + return ContentBrowserClient::ShouldUseProcessPerSite(browser_context, effective_url); +#endif +} + } // namespace QtWebEngineCore |