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("disable-software-rasterizer");
19 command_line->AppendSwitch("enable-begin-frame-scheduling");
21 // https://bitbucket.org/chromiumembedded/cef/issues/2717/xmlhttprequest-empty-responsetext
22 command_line->AppendSwitch("disable-web-security");
25 void NageruCefApp::initialize_cef()
27 unique_lock<mutex> lock(cef_mutex);
28 if (cef_thread_refcount++ == 0) {
29 cef_thread = thread(&NageruCefApp::cef_thread_func, this);
31 cef_initialized_cond.wait(lock, [this]{ return cef_initialized; });
34 void NageruCefApp::close_browser(CefRefPtr<CefBrowser> browser)
36 lock_guard<mutex> lock(cef_mutex);
37 browser->GetHost()->CloseBrowser(/*force_close=*/true);
40 void NageruCefApp::unref_cef()
42 unique_lock<mutex> lock(cef_mutex);
43 if (--cef_thread_refcount == 0) {
44 CefPostTask(TID_UI, new CEFTaskAdapter(&CefQuitMessageLoop));
50 void NageruCefApp::cef_thread_func()
52 CefMainArgs main_args;
54 //settings.log_severity = LOGSEVERITY_VERBOSE;
55 settings.windowless_rendering_enabled = true;
56 settings.no_sandbox = true;
57 settings.command_line_args_disabled = false;
58 CefInitialize(main_args, settings, this, nullptr);
61 lock_guard<mutex> lock(cef_mutex);
62 cef_initialized = true;
64 cef_initialized_cond.notify_all();