From 2a3ae1e2c20355d48518e8026f2f43a0e13967a6 Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Tue, 21 Apr 2020 14:28:35 -0700 Subject: [PATCH] Current versions of CEF no longer support CefFrame::LoadString, so switch to a data-URI scheme instead --- FCHost/fchost/fchost_handler.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/FCHost/fchost/fchost_handler.cc b/FCHost/fchost/fchost_handler.cc index 98ce4417d40..dede6cac40b 100644 --- a/FCHost/fchost/fchost_handler.cc +++ b/FCHost/fchost/fchost_handler.cc @@ -10,6 +10,7 @@ #include "include/base/cef_bind.h" #include "include/cef_app.h" +#include "include/cef_parser.h" #include "include/views/cef_browser_view.h" #include "include/views/cef_window.h" #include "include/wrapper/cef_closure_task.h" @@ -19,6 +20,13 @@ namespace { FCHostHandler* g_instance = NULL; +// Returns a data: URI with the specified contents. +std::string GetDataURI(const std::string& data, const std::string& mime_type) { + return "data:" + mime_type + ";base64," + + CefURIEncode(CefBase64Encode(data.data(), data.size()), false) + .ToString(); +} + } // namespace FCHostHandler::FCHostHandler(bool use_views) @@ -142,7 +150,8 @@ void FCHostHandler::OnLoadError(CefRefPtr<CefBrowser> browser, "<h2>Failed to load URL " << std::string(failedUrl) << " with error " << std::string(errorText) << " (" << errorCode << ").</h2></body></html>"; - frame->LoadString(ss.str(), failedUrl); + + frame->LoadURL(GetDataURI(ss.str(), "text/html")); } void FCHostHandler::OnBeforeDownload(CefRefPtr<CefBrowser> browser, -- GitLab