From bd6e656747ebbcf7f3c54289a75e14976f991d6e Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 3 Dec 2015 17:27:32 -0500 Subject: [PATCH] cefsimple: Only instantiate SimpleApp in the browser process (issue #1776) --- tests/cefsimple/cefsimple_linux.cc | 17 +++++++++-------- tests/cefsimple/cefsimple_mac.mm | 9 +++++---- tests/cefsimple/cefsimple_win.cc | 11 ++++++----- tests/cefsimple/simple_app.h | 1 + 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/tests/cefsimple/cefsimple_linux.cc b/tests/cefsimple/cefsimple_linux.cc index 98c7dfee3..f937dbacf 100644 --- a/tests/cefsimple/cefsimple_linux.cc +++ b/tests/cefsimple/cefsimple_linux.cc @@ -33,27 +33,28 @@ int main(int argc, char* argv[]) { // Provide CEF with command-line arguments. CefMainArgs main_args(argc, argv); - // SimpleApp implements application-level callbacks. It will create the first - // browser instance in OnContextInitialized() after CEF has initialized. - CefRefPtr app(new SimpleApp); - // 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. - int exit_code = CefExecuteProcess(main_args, app.get(), NULL); + int exit_code = CefExecuteProcess(main_args, NULL, NULL); if (exit_code >= 0) { // The sub-process has completed so return here. return exit_code; } - // Specify CEF global settings here. - CefSettings settings; - // Install xlib error handlers so that the application won't be terminated // on non-fatal errors. XSetErrorHandler(XErrorHandlerImpl); XSetIOErrorHandler(XIOErrorHandlerImpl); + // 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 app(new SimpleApp); + // Initialize CEF for the browser process. CefInitialize(main_args, settings, app.get(), NULL); diff --git a/tests/cefsimple/cefsimple_mac.mm b/tests/cefsimple/cefsimple_mac.mm index 61c9470f5..f4658352d 100644 --- a/tests/cefsimple/cefsimple_mac.mm +++ b/tests/cefsimple/cefsimple_mac.mm @@ -111,10 +111,6 @@ int main(int argc, char* argv[]) { // Provide CEF with command-line arguments. CefMainArgs main_args(argc, argv); - // SimpleApp implements application-level callbacks. It will create the first - // browser instance in OnContextInitialized() after CEF has initialized. - CefRefPtr app(new SimpleApp); - // Initialize the AutoRelease pool. NSAutoreleasePool* autopool = [[NSAutoreleasePool alloc] init]; @@ -124,6 +120,11 @@ int main(int argc, char* argv[]) { // 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 app(new SimpleApp); + // Initialize CEF for the browser process. CefInitialize(main_args, settings, app.get(), NULL); diff --git a/tests/cefsimple/cefsimple_win.cc b/tests/cefsimple/cefsimple_win.cc index 8b2356ae7..96c0b9420 100644 --- a/tests/cefsimple/cefsimple_win.cc +++ b/tests/cefsimple/cefsimple_win.cc @@ -44,14 +44,10 @@ int APIENTRY wWinMain(HINSTANCE hInstance, // Provide CEF with command-line arguments. CefMainArgs main_args(hInstance); - // SimpleApp implements application-level callbacks. It will create the first - // browser instance in OnContextInitialized() after CEF has initialized. - CefRefPtr app(new SimpleApp); - // 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. - int exit_code = CefExecuteProcess(main_args, app.get(), sandbox_info); + int exit_code = CefExecuteProcess(main_args, NULL, sandbox_info); if (exit_code >= 0) { // The sub-process has completed so return here. return exit_code; @@ -64,6 +60,11 @@ int APIENTRY wWinMain(HINSTANCE hInstance, settings.no_sandbox = true; #endif + // SimpleApp implements application-level callbacks for the browser process. + // It will create the first browser instance in OnContextInitialized() after + // CEF has initialized. + CefRefPtr app(new SimpleApp); + // Initialize CEF. CefInitialize(main_args, settings, app.get(), sandbox_info); diff --git a/tests/cefsimple/simple_app.h b/tests/cefsimple/simple_app.h index 1e454a428..c40b9cc68 100644 --- a/tests/cefsimple/simple_app.h +++ b/tests/cefsimple/simple_app.h @@ -7,6 +7,7 @@ #include "include/cef_app.h" +// Implement application-level callbacks for the browser process. class SimpleApp : public CefApp, public CefBrowserProcessHandler { public: