diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-07-11 16:32:50 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-08-11 20:30:20 +0200 |
commit | f1cb0ab451f3282648caec6ec359be356c921942 (patch) | |
tree | afd59a2282208e1afcbb7359f06d6872ea82c3fb /src/core/content_browser_client_qt.cpp | |
parent | 772d86b92bba4c1e63fbb4c555e9a6789991b68c (diff) |
Fix PDF viewer
It was broken after 102-based merge
Submodule src/3rdparty c57592220..8496e1340:
> Revert "Jumbo build mojom files"
> FIXUP: Fix building with optimize_webui=false
> Revert "Add remove_v8base_debug_symbols to GN"
> FIXUP: Fix crashes and asserts
> Add missing node modules for PDF support
> [Backport] CVE-2022-2614: Use after free in Sign-In Flow
> [Backport] CVE-2022-2618: Insufficient validation of untrusted input in Internals
> [Backport] CVE-2022-2612: Side-channel information leakage in Keyboard input
> [Backport] CVE-2022-2613: Use after free in Input
> [Backport] CVE-2022-2624: Heap buffer overflow in PDF
> [Backport] CVE-2022-2610: Insufficient policy enforcement in Background Fetch
> [Backport] CVE-2022-2615: Insufficient policy enforcement in Cookies
> [Backport] CVE-2022-2294: Heap buffer overflow in WebRTC
> [Backport] CVE-2022-2478 : Use after free in PDF
> Jumbo build mojom files
Pick-to: 6.4
Change-Id: I4fc608c21ab8aaa508329e708446b57cccbddf76
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'src/core/content_browser_client_qt.cpp')
-rw-r--r-- | src/core/content_browser_client_qt.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 973517404..fdca05760 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -27,6 +27,7 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/shared_cors_origin_access_list.h" +#include "content/public/browser/url_loader_request_interceptor.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_user_data.h" #include "content/public/browser/web_ui_url_loader_factory.h" @@ -35,6 +36,7 @@ #include "content/public/common/user_agent.h" #include "extensions/buildflags/buildflags.h" #include "mojo/public/cpp/bindings/self_owned_associated_receiver.h" +#include "pdf/buildflags.h" #include "net/ssl/client_cert_identity.h" #include "net/ssl/client_cert_store.h" #include "net/ssl/ssl_private_key.h" @@ -139,6 +141,14 @@ #include "printing/print_view_manager_qt.h" #endif +#if BUILDFLAG(ENABLE_PDF) +#include "printing/pdf_stream_delegate_qt.h" + +#include "components/pdf/browser/pdf_navigation_throttle.h" +#include "components/pdf/browser/pdf_url_loader_request_interceptor.h" +#include "components/pdf/browser/pdf_web_contents_helper.h" +#endif + #include <QGuiApplication> #include <QStandardPaths> #include <qpa/qplatformnativeinterface.h> @@ -501,7 +511,14 @@ void ContentBrowserClientQt::RegisterAssociatedInterfaceBindersForRenderFrameHos mojo::PendingAssociatedReceiver<autofill::mojom::AutofillDriver> receiver) { autofill::ContentAutofillDriverFactory::BindAutofillDriver(std::move(receiver), render_frame_host); }, &rfh)); - +#if BUILDFLAG(ENABLE_PDF) + associated_registry.AddInterface( + base::BindRepeating( + [](content::RenderFrameHost *render_frame_host, + mojo::PendingAssociatedReceiver<pdf::mojom::PdfService> receiver) { + pdf::PDFWebContentsHelper::BindPdfService(std::move(receiver), render_frame_host); + }, &rfh)); +#endif // BUILDFLAG(ENABLE_PDF) ContentBrowserClient::RegisterAssociatedInterfaceBindersForRenderFrameHost(rfh, associated_registry); } @@ -829,6 +846,9 @@ std::vector<std::unique_ptr<content::NavigationThrottle>> ContentBrowserClientQt #if BUILDFLAG(ENABLE_EXTENSIONS) MaybeAddThrottle(extensions::PDFIFrameNavigationThrottleQt::MaybeCreateThrottleFor(navigation_handle), &throttles); #endif +#if BUILDFLAG(ENABLE_PDF) + MaybeAddThrottle(pdf::PdfNavigationThrottle::MaybeCreateThrottleFor(navigation_handle, std::make_unique<PdfStreamDelegateQt>()), &throttles); +#endif // BUILDFLAG(ENABLE_PDF) return throttles; } @@ -1153,6 +1173,9 @@ base::flat_set<std::string> ContentBrowserClientQt::GetPluginMimeTypesWithExtern } } #endif +#if BUILDFLAG(ENABLE_PDF) + mime_types.insert("application/x-google-chrome-pdf"); +#endif return mime_types; } @@ -1190,6 +1213,25 @@ bool ContentBrowserClientQt::WillCreateURLLoaderFactory( return true; } +std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>> +ContentBrowserClientQt::WillCreateURLLoaderRequestInterceptors(content::NavigationUIData* navigation_ui_data, + int frame_tree_node_id, + const scoped_refptr<network::SharedURLLoaderFactory>& network_loader_factory) +{ + std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>> interceptors; +#if BUILDFLAG(ENABLE_PDF) + { + std::unique_ptr<content::URLLoaderRequestInterceptor> pdf_interceptor = + pdf::PdfURLLoaderRequestInterceptor::MaybeCreateInterceptor( + frame_tree_node_id, std::make_unique<PdfStreamDelegateQt>()); + if (pdf_interceptor) + interceptors.push_back(std::move(pdf_interceptor)); + } +#endif + + return interceptors; +} + bool ContentBrowserClientQt::WillInterceptWebSocket(content::RenderFrameHost *frame) { Q_UNUSED(frame); |