From 1be723b26e51e8d2530034f33bf675d8dd452736 Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Tue, 6 Aug 2019 20:19:17 -0700 Subject: [PATCH] Make "Save to file" function work correctly --- FCHost/fchost/fchost_handler.cc | 10 ++++++++++ FCHost/fchost/fchost_handler.h | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/FCHost/fchost/fchost_handler.cc b/FCHost/fchost/fchost_handler.cc index c52bb4fb0ac..20ca8967434 100644 --- a/FCHost/fchost/fchost_handler.cc +++ b/FCHost/fchost/fchost_handler.cc @@ -141,6 +141,16 @@ void FCHostHandler::OnLoadError(CefRefPtr<CefBrowser> browser, frame->LoadString(ss.str(), failedUrl); } +void FCHostHandler::OnBeforeDownload(CefRefPtr<CefBrowser> browser, + CefRefPtr<CefDownloadItem> download_item, + const CefString& suggested_name, + CefRefPtr< CefBeforeDownloadCallback > callback) +{ + CEF_REQUIRE_UI_THREAD(); + + callback->Continue(suggested_name, true); +} + void FCHostHandler::CloseAllBrowsers(bool force_close) { if (!CefCurrentlyOn(TID_UI)) { // Execute on the UI thread. diff --git a/FCHost/fchost/fchost_handler.h b/FCHost/fchost/fchost_handler.h index 89561bafefd..c4288392505 100644 --- a/FCHost/fchost/fchost_handler.h +++ b/FCHost/fchost/fchost_handler.h @@ -11,7 +11,8 @@ class FCHostHandler : public CefClient, public CefDisplayHandler, public CefLifeSpanHandler, - public CefLoadHandler { + public CefLoadHandler, + public CefDownloadHandler { public: explicit FCHostHandler(bool use_views); ~FCHostHandler(); @@ -27,6 +28,7 @@ class FCHostHandler : public CefClient, return this; } virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE { return this; } + virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() OVERRIDE { return this; } // CefDisplayHandler methods: @@ -49,6 +51,12 @@ class FCHostHandler : public CefClient, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl) OVERRIDE; + + // CefDownloadHandler methods: + virtual void OnBeforeDownload(CefRefPtr<CefBrowser> browser, + CefRefPtr<CefDownloadItem> download_item, + const CefString& suggested_name, + CefRefPtr< CefBeforeDownloadCallback > callback) OVERRIDE; // Request that all existing browser windows close. void CloseAllBrowsers(bool force_close); -- GitLab