Command:
- Code: Select all
g++ -Wall src/entry_main.cpp -I/home/name/Downloads/temp/chrome-to-libbb/CEF src/ClientApp.cpp src/ClientHandler.cpp -Wl,libcef_dll_wrapper.a,libcef.so -g -o build/entry_test
Errors (with logging enabled at v=1):
- Code: Select all
[0731/171621.246988:INFO:cpu_info.cc(53)] Available number of cores: 4
[0731/171621.247106:INFO:cpu_info.cc(53)] Available number of cores: 4
[0731/171621.247245:VERBOSE1:zygote_main_linux.cc(217)] ZygoteMain: initializing 0 fork delegates
[0731/171621.247089:VERBOSE1:zygote_main_linux.cc(217)] ZygoteMain: initializing 0 fork delegates
[0731/171621.248445:VERBOSE1:node_controller.cc(153)] Initializing node 8BFCA0370CE3BA85.A959AA344C7E5243
[0731/171621.249254:INFO:content_main_runner_impl.cc(977)] Chrome is running in full browser mode.
[0731/171621.266084:VERBOSE1:proxy_config_service_linux.cc(500)] All gsettings tests OK. Will get proxy config from gsettings.
[0731/171621.266277:VERBOSE1:proxy_config_service_linux.cc(1261)] Obtained proxy settings from annotation hash code 11258689
[0731/171621.266368:VERBOSE1:pref_proxy_config_tracker_impl.cc(185)] 0x55b5204a3ab0: set chrome proxy config service to 0x55b5204a6a00
[0731/171621.266986:VERBOSE1:font_render_params_linux.cc(211)] Computing params for 1794297614
[0731/171621.268281:ERROR:viz_process_transport_factory.cc(308)] Switching to software compositing.
[0731/171621.268559:VERBOSE1:webrtc_internals.cc(119)] Could not get the download directory.
[0731/171621.269864:VERBOSE1:media_stream_manager.cc(685)] MSM::InitializeMaybeAsync([this=0x55b5204b3c60])
[0731/171621.269915:VERBOSE1:media_stream_manager.cc(685)] MDM::MediaDevicesManager()
[0731/171621.269949:VERBOSE1:media_stream_manager.cc(685)] MSM::MediaStreamManager([this=0x55b5204b3c60]))
[0731/171621.270550:ERROR:edid_parser.cc(102)] Too short EDID data: manufacturer id
[0731/171621.272423:VERBOSE1:memory_linux.cc(100)] Adjusting oom_score_adj of 16217 to 200
[0731/171621.272863:FATAL:field_trial.cc(445)] Check failed: !global_.
[0731/171621.285859:VERBOSE1:proxy_config_service_linux.cc(500)] All gsettings tests OK. Will get proxy config from gsettings.
[0731/171621.286044:VERBOSE1:proxy_config_service_linux.cc(1261)] Obtained proxy settings from annotation hash code 11258689
[0731/171621.286109:VERBOSE1:pref_proxy_config_tracker_impl.cc(185)] 0x55b5205e6dd0: set chrome proxy config service to 0x55b5205eb590
[0731/171621.294114:VERBOSE1:node.cc(492)] Merging local ports 94CF4535E53E98F.A0A0CDBBDA0D74E9@8BFCA0370CE3BA85.A959AA344C7E5243 and 8A5BFBBBE1A3C6E2.EB6B6B755286D9B6@8BFCA0370CE3BA85.A959AA344C7E5243
[0731/171621.295218:VERBOSE1:font_render_params_linux.cc(203)] Returning cached params for 1794297614
[0731/171621.301512:VERBOSE1:font_render_params_linux.cc(203)] Returning cached params for 1794297614
[0731/171621.307884:VERBOSE1:x11_event_source.cc(211)] Making a round trip to get a recent server timestamp.
[0731/171621.308417:VERBOSE1:x11_event_source.cc(211)] Making a round trip to get a recent server timestamp.
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 42 (X_SetInputFocus)
Serial number of failed request: 267
Current serial number in output stream: 269
[0731/171621.311325:FATAL:context.cc(58)] Check failed: !g_context. CefShutdown was not called
[0731/171621.312383:FATAL:field_trial.cc(445)] Check failed: !global_.
Trace/breakpoint trap (core dumped)
Here are the files that I'm using for some context.
main.cpp
- Code: Select all
#include <thread>
#include <chrono>
#include <include/internal/cef_linux.h>
#include <include/cef_app.h>
#include <include/cef_browser.h>
#include <include/cef_frame.h>
#include "ClientHandler.h"
#include "ClientApp.h"
void CefInitSettings(CefSettings& settings)
{
CefString(&settings.resources_dir_path) = CefString();
CefString(&settings.locales_dir_path) = CefString();
settings.multi_threaded_message_loop = false;
settings.ignore_certificate_errors = false;
#if !defined(CEF_USE_SANDBOX)
settings.no_sandbox = true;
#endif
}
int main(int argc, char* argv[])
{
CefMainArgs main_args(argc, argv);
CefRefPtr<ClientApp> app(new ClientApp);
CefSettings settings;
CefInitSettings(settings);
CefString(&settings.locales_dir_path) = "/my/path/to/locales";
CefString(&settings.resources_dir_path) = "/my/path/to/resource/directory/";
CefInitialize(main_args, settings, app.get(), NULL);
CefRunMessageLoop();
CefShutdown();
return 0;
}
ClientApp.cpp (I can share ClientApp.h as well, if required)
- Code: Select all
#include "ClientApp.h"
#include "ClientHandler.h"
#include <include/wrapper/cef_helpers.h>
#include <include/views/cef_browser_view.h>
ClientApp::ClientApp()
{
printf("ClientApp constructor\n");
}
void
ClientApp::OnContextInitialized()
{
CEF_REQUIRE_UI_THREAD();
CefRefPtr<CefCommandLine> command_line = CefCommandLine::GetGlobalCommandLine();
CefRefPtr<ClientHandler> handler(new ClientHandler());
CefBrowserSettings browser_settings;
std::string url;
url = command_line->GetSwitchValue("url");
if (url.empty())
{
url = "http://www.google.com";
}
CefWindowInfo window_info;
CefBrowserHost::CreateBrowser(window_info, handler, url, browser_settings, NULL, NULL);
}
void
ClientApp::OnBeforeCommandLineProcessing(
const CefString& process_type,
CefRefPtr<CefCommandLine> command_line)
{
command_line->AppendSwitch("disable-gpu");
command_line->AppendSwitch("enable-logging");
command_line->AppendSwitchWithValue("v", "1");
}
ClientHandler.cpp (I can share ClientHandler.h as well, if required)
- Code: Select all
#include "ClientHandler.h"
#include <sstream>
#include <string>
#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>
#include <include/wrapper/cef_helpers.h>
ClientHandler *g_instance = NULL;
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();
}
ClientHandler::ClientHandler()
{
printf("ClientHandler constructor\n");
is_closing_ = false;
DCHECK(!g_instance);
g_instance = this;
}
ClientHandler::~ClientHandler()
{
printf("ClientHandler destructor\n");
g_instance = NULL;
}
ClientHandler *
ClientHandler::GetInstance()
{
return g_instance;
}
void
ClientHandler::OnAfterCreated(
CefRefPtr<CefBrowser> browser)
{
CEF_REQUIRE_UI_THREAD();
browser_list_.push_back(browser);
}
bool
ClientHandler::DoClose(
CefRefPtr<CefBrowser> browser)
{
CEF_REQUIRE_UI_THREAD();
if (browser_list_.size() == 1)
{
is_closing_ = true;
}
return false;
}
void
ClientHandler::OnBeforeClose(
CefRefPtr<CefBrowser> browser)
{
CEF_REQUIRE_UI_THREAD();
BrowserList::iterator bit = browser_list_.begin();
for (; bit != browser_list_.end(); ++bit)
{
if ((*bit)->IsSame(browser))
{
browser_list_.erase(bit);
break;
}
}
if (browser_list_.empty())
{
CefQuitMessageLoop();
}
}
void
ClientHandler::OnLoadError(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const CefString& errorText,
const CefString& failedUrl)
{
CEF_REQUIRE_UI_THREAD();
/* Don't display an error for downloaded files */
if (errorCode == ERR_ABORTED)
{
return;
}
std::stringstream ss;
ss << "<html><body bgcolor=\"white\">"
"<h2>Failed to load URL "
<< std::string(failedUrl) << " with error " << std::string(errorText)
<< " (" << errorCode << ").</h2></body></html>";
frame->LoadURL(GetDataURI(ss.str(), "text/html"));
}
void
ClientHandler::CloseAllBrowsers(
bool force_close)
{
if (!CefCurrentlyOn(TID_UI))
{
CefPostTask(TID_UI, base::Bind(&ClientHandler::CloseAllBrowsers, this, force_close));
return;
}
if (browser_list_.empty())
{
return;
}
BrowserList::const_iterator it = browser_list_.begin();
for (; it != browser_list_.end(); ++it)
{
(*it)->GetHost()->CloseBrowser(force_close);
}
}
Also, this is the current contents of my directory:
- Code: Select all
build debug.log libGLESv2.so
CEF devtools_resources.pak locales
cef_100_percent.pak files media
cef_200_percent.pak GPUCache snapshot_blob.bin
cef_extensions.pak icudtl.dat src
cef.pak libcef_dll_wrapper.a swiftshader
cefsimple libcef.so v8_context_snapshot.bin
My ClientApp and ClientHandler were based off of the Linux example for cefsimple, but converted to C++. I'm very new to all of this so any help would be appreciated. I can provide you with any information you require, so just let me know.