2 #include <cef_browser.h>
3 #include <cef_client.h>
4 #include <cef_version.h>
8 #include "nageru_cef_app.h"
12 void NageruCefApp::OnBeforeCommandLineProcessing(
13 const CefString& process_type,
14 CefRefPtr<CefCommandLine> command_line)
16 command_line->AppendSwitch("disable-gpu");
17 command_line->AppendSwitch("disable-gpu-compositing");
18 command_line->AppendSwitch("enable-begin-frame-scheduling");
20 // https://bitbucket.org/chromiumembedded/cef/issues/2717/xmlhttprequest-empty-responsetext
21 command_line->AppendSwitch("disable-web-security");
24 void NageruCefApp::initialize_cef()
26 unique_lock<mutex> lock(cef_mutex);
27 if (cef_thread_refcount++ == 0) {
28 cef_thread = thread(&NageruCefApp::cef_thread_func, this);
30 cef_initialized_cond.wait(lock, [this]{ return cef_initialized; });
33 void NageruCefApp::close_browser(CefRefPtr<CefBrowser> browser)
35 lock_guard<mutex> lock(cef_mutex);
36 browser->GetHost()->CloseBrowser(/*force_close=*/true);
39 void NageruCefApp::unref_cef()
41 unique_lock<mutex> lock(cef_mutex);
42 if (--cef_thread_refcount == 0) {
43 CefPostTask(TID_UI, new CEFTaskAdapter(&CefQuitMessageLoop));
49 void NageruCefApp::cef_thread_func()
51 CefMainArgs main_args;
53 //settings.log_severity = LOGSEVERITY_VERBOSE;
54 settings.windowless_rendering_enabled = true;
55 settings.no_sandbox = true;
56 settings.command_line_args_disabled = false;
57 CefInitialize(main_args, settings, this, nullptr);
60 lock_guard<mutex> lock(cef_mutex);
61 cef_initialized = true;
63 cef_initialized_cond.notify_all();