2013-11-26 23:02:14 +01:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "cefsimple/simple_app.h"
|
|
|
|
|
2014-09-24 19:22:27 +02:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
|
2014-09-30 18:49:22 +02:00
|
|
|
#include "include/base/cef_logging.h"
|
|
|
|
|
2014-09-24 19:22:27 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
int XErrorHandlerImpl(Display *display, XErrorEvent *event) {
|
|
|
|
LOG(WARNING)
|
|
|
|
<< "X error received: "
|
|
|
|
<< "type " << event->type << ", "
|
|
|
|
<< "serial " << event->serial << ", "
|
|
|
|
<< "error_code " << static_cast<int>(event->error_code) << ", "
|
|
|
|
<< "request_code " << static_cast<int>(event->request_code) << ", "
|
|
|
|
<< "minor_code " << static_cast<int>(event->minor_code);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int XIOErrorHandlerImpl(Display *display) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
2013-11-26 23:02:14 +01:00
|
|
|
// Entry point function for all processes.
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
// Provide CEF with command-line arguments.
|
|
|
|
CefMainArgs main_args(argc, argv);
|
|
|
|
|
|
|
|
// CEF applications have multiple sub-processes (render, plugin, GPU, etc)
|
|
|
|
// that share the same executable. This function checks the command-line and,
|
|
|
|
// if this is a sub-process, executes the appropriate logic.
|
2015-12-03 23:27:32 +01:00
|
|
|
int exit_code = CefExecuteProcess(main_args, NULL, NULL);
|
2013-11-26 23:02:14 +01:00
|
|
|
if (exit_code >= 0) {
|
|
|
|
// The sub-process has completed so return here.
|
|
|
|
return exit_code;
|
|
|
|
}
|
|
|
|
|
2014-09-24 19:22:27 +02:00
|
|
|
// Install xlib error handlers so that the application won't be terminated
|
|
|
|
// on non-fatal errors.
|
|
|
|
XSetErrorHandler(XErrorHandlerImpl);
|
|
|
|
XSetIOErrorHandler(XIOErrorHandlerImpl);
|
|
|
|
|
2015-12-03 23:27:32 +01:00
|
|
|
// Specify CEF global settings here.
|
|
|
|
CefSettings settings;
|
|
|
|
|
|
|
|
// SimpleApp implements application-level callbacks for the browser process.
|
|
|
|
// It will create the first browser instance in OnContextInitialized() after
|
|
|
|
// CEF has initialized.
|
|
|
|
CefRefPtr<SimpleApp> app(new SimpleApp);
|
|
|
|
|
2013-11-26 23:02:14 +01:00
|
|
|
// Initialize CEF for the browser process.
|
|
|
|
CefInitialize(main_args, settings, app.get(), NULL);
|
|
|
|
|
|
|
|
// Run the CEF message loop. This will block until CefQuitMessageLoop() is
|
|
|
|
// called.
|
|
|
|
CefRunMessageLoop();
|
|
|
|
|
|
|
|
// Shut down CEF.
|
|
|
|
CefShutdown();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|