Skip to content
Snippets Groups Projects
Commit b8bcfd07 authored by ezsh's avatar ezsh
Browse files

Update FCHost to build against new CEF

CEF requires C++11 and thus removed the OVERRIDE macro, requires using
nullptr instead of NULL.
Version 95 removed some settings:
https://bitbucket.org/chromiumembedded/cef/issues/2820/remove-cefbrowsersettings
parent 07272e4d
No related branches found
No related tags found
1 merge request!10477Fixes
......@@ -30,7 +30,7 @@ class SimpleWindowDelegate : public CefWindowDelegate {
explicit SimpleWindowDelegate(CefRefPtr<CefBrowserView> browser_view)
: browser_view_(browser_view) {}
void OnWindowCreated(CefRefPtr<CefWindow> window) OVERRIDE {
void OnWindowCreated(CefRefPtr<CefWindow> window) override {
// Add the browser view and show the window.
window->AddChildView(browser_view_);
window->Show();
......@@ -39,11 +39,11 @@ class SimpleWindowDelegate : public CefWindowDelegate {
browser_view_->RequestFocus();
}
void OnWindowDestroyed(CefRefPtr<CefWindow> window) OVERRIDE {
browser_view_ = NULL;
void OnWindowDestroyed(CefRefPtr<CefWindow> window) override {
browser_view_ = nullptr;
}
bool CanClose(CefRefPtr<CefWindow> window) OVERRIDE {
bool CanClose(CefRefPtr<CefWindow> window) override {
// Allow the window to close if the browser says it's OK.
CefRefPtr<CefBrowser> browser = browser_view_->GetBrowser();
if (browser)
......@@ -51,7 +51,7 @@ class SimpleWindowDelegate : public CefWindowDelegate {
return true;
}
CefSize GetPreferredSize(CefRefPtr<CefView> view) OVERRIDE {
CefSize GetPreferredSize(CefRefPtr<CefView> view) override {
return CefSize(800, 600);
}
......@@ -130,14 +130,10 @@ void FCHostApp::OnContextInitialized() {
std::string url = "file://" + gameHTML.string();
#endif
// Allow some access flexibility for our local file
browser_settings.file_access_from_file_urls = STATE_ENABLED;
browser_settings.universal_access_from_file_urls = STATE_ENABLED;
if (use_views) {
// Create the BrowserView.
CefRefPtr<CefBrowserView> browser_view = CefBrowserView::CreateBrowserView(
handler, url, browser_settings, NULL, NULL, NULL);
handler, url, browser_settings, nullptr, nullptr, nullptr);
// Create the Window. It will show itself after creation.
CefWindow::CreateTopLevelWindow(new SimpleWindowDelegate(browser_view));
......@@ -153,7 +149,7 @@ void FCHostApp::OnContextInitialized() {
// Create the first browser window.
CefBrowserHost::CreateBrowser(window_info, handler, url, browser_settings,
NULL, NULL);
nullptr, nullptr);
}
}
......
......@@ -18,17 +18,17 @@ class FCHostApp : public CefApp, public CefBrowserProcessHandler, public CefRend
// CefApp methods:
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler()
OVERRIDE {
override {
return this;
}
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler()
OVERRIDE {
override {
return this;
}
// CefBrowserProcessHandler methods:
virtual void OnContextInitialized() OVERRIDE;
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) OVERRIDE;
virtual void OnContextInitialized() override;
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) override;
std::filesystem::path GetLocalStorePath();
......
......@@ -9,6 +9,7 @@
#include <fstream>
#include "include/base/cef_bind.h"
#include "include/base/cef_callback.h"
#include "include/cef_app.h"
#include "include/cef_parser.h"
#include "include/views/cef_browser_view.h"
......@@ -244,7 +245,7 @@ bool FCHostHandler::OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
void FCHostHandler::CloseAllBrowsers(bool force_close) {
if (!CefCurrentlyOn(TID_UI)) {
// Execute on the UI thread.
CefPostTask(TID_UI, base::Bind(&FCHostHandler::CloseAllBrowsers, this,
CefPostTask(TID_UI, base::BindOnce(&FCHostHandler::CloseAllBrowsers, this,
force_close));
return;
}
......
......@@ -23,15 +23,15 @@ class FCHostHandler : public CefClient,
static FCHostHandler* GetInstance();
// CefClient methods:
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() override {
return this;
}
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE {
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override {
return this;
}
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE { return this; }
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() OVERRIDE { return this; }
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE { return this; }
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() override { return this; }
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() override { return this; }
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() override { return this; }
CefRefPtr< CefDialogHandler > GetDialogHandler() override { return this; }
bool OnFileDialog(CefRefPtr<CefBrowser> browser, CefDialogHandler::FileDialogMode mode,
......@@ -40,39 +40,39 @@ class FCHostHandler : public CefClient,
// CefDisplayHandler methods:
virtual void OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) OVERRIDE;
const CefString& title) override;
virtual bool OnConsoleMessage(CefRefPtr<CefBrowser> browser,
cef_log_severity_t level,
const CefString& message,
const CefString& source,
int line) OVERRIDE;
int line) override;
// CefLifeSpanHandler methods:
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
virtual bool DoClose(CefRefPtr<CefBrowser> browser) override;
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
// CefLoadHandler methods:
virtual void OnLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const CefString& errorText,
const CefString& failedUrl) OVERRIDE;
const CefString& failedUrl) override;
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int httpStatusCode) OVERRIDE;
int httpStatusCode) override;
// CefDownloadHandler methods:
virtual void OnBeforeDownload(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
const CefString& suggested_name,
CefRefPtr< CefBeforeDownloadCallback > callback) OVERRIDE;
CefRefPtr< CefBeforeDownloadCallback > callback) override;
// CefKeyboardHandler methods:
virtual bool OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
const CefKeyEvent& event,
CefEventHandle os_event,
bool* is_keyboard_shortcut) OVERRIDE;
bool* is_keyboard_shortcut) override;
// Request that all existing browser windows close.
void CloseAllBrowsers(bool force_close);
......
......@@ -67,5 +67,5 @@ int main(int argc, char* argv[]) {
CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
command_line->InitFromArgv(argc, argv);
return app->main(main_args, command_line);
return app->main(main_args, command_line.get());
}
......@@ -33,12 +33,12 @@ void FCHostStorageRegister(const std::filesystem::path& persistPath, CefRefPtr<C
session = std::make_unique<FCHostSessionStorage>();
CefRefPtr<CefV8Handler> sess_handler = new FCHostStorageHandler(false);
CefRefPtr<CefV8Value> obj_sess = CefV8Value::CreateObject(NULL, NULL);
CefRefPtr<CefV8Value> obj_sess = CefV8Value::CreateObject(nullptr, nullptr);
object->SetValue("FCHostSession", obj_sess, V8_PROPERTY_ATTRIBUTE_NONE);
AttachStorageFunctions(obj_sess, sess_handler);
CefRefPtr<CefV8Handler> pers_handler = new FCHostStorageHandler(true);
CefRefPtr<CefV8Value> obj_pers = CefV8Value::CreateObject(NULL, NULL);
CefRefPtr<CefV8Value> obj_pers = CefV8Value::CreateObject(nullptr, nullptr);
object->SetValue("FCHostPersistent", obj_pers, V8_PROPERTY_ATTRIBUTE_NONE);
AttachStorageFunctions(obj_pers, pers_handler);
}
......
......@@ -13,7 +13,7 @@ public:
CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
CefString& exception) OVERRIDE;
CefString& exception) override;
private:
bool persistent;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment