summaryrefslogtreecommitdiffstats
path: root/src/core/content_client_qt.cpp
diff options
context:
space:
mode:
authorMichael BrĂ¼ning <michael.bruning@qt.io>2019-01-22 18:03:00 +0100
committerMichael BrĂ¼ning <michael.bruning@qt.io>2019-02-01 10:26:00 +0000
commite3968360b4f1b7b0603b97d50244b18c92207f21 (patch)
treed326be003ca43991bacc8685a07a051f4e46c898 /src/core/content_client_qt.cpp
parent3bff0bae7e0c660fc25c5c46dedaf9cb89563a58 (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_client_qt.cpp')
-rw-r--r--src/core/content_client_qt.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp
index 41e3f7f6c..9065174b8 100644
--- a/src/core/content_client_qt.cpp
+++ b/src/core/content_client_qt.cpp
@@ -84,6 +84,14 @@ const char kWidevineCdmFileName[] =
#endif
#endif
+#if QT_CONFIG(webengine_printing_and_pdf)
+#include "pdf/pdf.h"
+#include "pdf/pdf_ppapi.h"
+const char kPdfPluginMimeType[] = "application/x-google-chrome-pdf";
+const char kPdfPluginPath[] = "internal-pdf-viewer/";
+const char kPdfPluginSrc[] = "src";
+#endif // QT_CONFIG(webengine_printing_and_pdf)
+
static QString webenginePluginsPath()
{
// Look for plugins in /plugins/webengine or application dir.
@@ -98,7 +106,6 @@ static QString webenginePluginsPath()
}
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
-
#if defined(Q_OS_WIN)
#include <shlobj.h>
static QString getLocalAppDataDir()
@@ -234,10 +241,30 @@ void AddPepperFlashFromCommandLine(std::vector<content::PepperPluginInfo>* plugi
plugins->push_back(CreatePepperFlashInfo(base::FilePath(flash_path), flash_version));
}
+void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins)
+{
+#if QT_CONFIG(webengine_printing_and_pdf)
+ content::PepperPluginInfo pdf_info;
+ pdf_info.is_internal = true;
+ pdf_info.is_out_of_process = true;
+ pdf_info.name = "Chromium PDF Viewer";
+ pdf_info.description = "Portable Document Format";
+ pdf_info.path = base::FilePath::FromUTF8Unsafe(kPdfPluginPath);
+ content::WebPluginMimeType pdf_mime_type(kPdfPluginMimeType, "pdf", "Portable Document Format");
+ pdf_info.mime_types.push_back(pdf_mime_type);
+ pdf_info.internal_entry_points.get_interface = chrome_pdf::PPP_GetInterface;
+ pdf_info.internal_entry_points.initialize_module = chrome_pdf::PPP_InitializeModule;
+ pdf_info.internal_entry_points.shutdown_module = chrome_pdf::PPP_ShutdownModule;
+ pdf_info.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV | ppapi::PERMISSION_PDF;
+ plugins->push_back(pdf_info);
+#endif // QT_CONFIG(webengine_printing_and_pdf)
+}
+
namespace QtWebEngineCore {
void ContentClientQt::AddPepperPlugins(std::vector<content::PepperPluginInfo>* plugins)
{
+ ComputeBuiltInPlugins(plugins);
AddPepperFlashFromSystem(plugins);
AddPepperFlashFromCommandLine(plugins);
}
@@ -319,7 +346,6 @@ static bool IsWidevineAvailable(base::FilePath *cdm_path,
}
#endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
-
void ContentClientQt::AddContentDecryptionModules(std::vector<content::CdmInfo> *cdms,
std::vector<media::CdmHostFilePath> *cdm_host_file_paths)
{
@@ -375,6 +401,11 @@ void ContentClientQt::AddContentDecryptionModules(std::vector<content::CdmInfo>
}
}
+void ContentClientQt::AddAdditionalSchemes(Schemes* schemes)
+{
+ schemes->standard_schemes.push_back("chrome-extension");
+}
+
std::string ContentClientQt::getUserAgent()
{
// Mention the Chromium version we're based on to get passed stupid UA-string-based feature detection (several WebRTC demos need this)