diff --git a/cef3/include/capi/cef_browser_process_handler_capi.h b/cef3/include/capi/cef_browser_process_handler_capi.h index b07c9a90b..3c631175b 100644 --- a/cef3/include/capi/cef_browser_process_handler_capi.h +++ b/cef3/include/capi/cef_browser_process_handler_capi.h @@ -70,6 +70,14 @@ typedef struct _cef_browser_process_handler_t { /// void (CEF_CALLBACK *on_context_initialized)( struct _cef_browser_process_handler_t* self); + + /// + // Called on the browser process IO thread before a child process is launched. + // Provides an opportunity to modify the child process command line. + /// + void (CEF_CALLBACK *on_before_child_process_launch)( + struct _cef_browser_process_handler_t* self, + struct _cef_command_line_t* command_line); } cef_browser_process_handler_t; diff --git a/cef3/include/capi/cef_command_line_capi.h b/cef3/include/capi/cef_command_line_capi.h index 49a883899..fe7ca14e9 100644 --- a/cef3/include/capi/cef_command_line_capi.h +++ b/cef3/include/capi/cef_command_line_capi.h @@ -177,6 +177,13 @@ typedef struct _cef_command_line_t { /// void (CEF_CALLBACK *append_argument)(struct _cef_command_line_t* self, const cef_string_t* argument); + + /// + // Insert a command before the current command. Common for debuggers, like + // "valgrind" or "gdb --args". + /// + void (CEF_CALLBACK *prepend_wrapper)(struct _cef_command_line_t* self, + const cef_string_t* wrapper); } cef_command_line_t; diff --git a/cef3/include/cef_browser_process_handler.h b/cef3/include/cef_browser_process_handler.h index 1095e2da1..02b792300 100644 --- a/cef3/include/cef_browser_process_handler.h +++ b/cef3/include/cef_browser_process_handler.h @@ -39,6 +39,7 @@ #pragma once #include "include/cef_base.h" +#include "include/cef_command_line.h" #include "include/cef_proxy_handler.h" /// @@ -64,6 +65,15 @@ class CefBrowserProcessHandler : public virtual CefBase { /// /*--cef()--*/ virtual void OnContextInitialized() {} + + /// + // Called on the browser process IO thread before a child process is launched. + // Provides an opportunity to modify the child process command line. + /// + /*--cef()--*/ + virtual void OnBeforeChildProcessLaunch( + CefRefPtr command_line) { + } }; #endif // CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_ diff --git a/cef3/include/cef_command_line.h b/cef3/include/cef_command_line.h index 38f1a434d..3f3c65636 100644 --- a/cef3/include/cef_command_line.h +++ b/cef3/include/cef_command_line.h @@ -189,6 +189,13 @@ class CefCommandLine : public virtual CefBase { /// /*--cef()--*/ virtual void AppendArgument(const CefString& argument) =0; + + /// + // Insert a command before the current command. + // Common for debuggers, like "valgrind" or "gdb --args". + /// + /*--cef()--*/ + virtual void PrependWrapper(const CefString& wrapper) =0; }; #endif // CEF_INCLUDE_CEF_COMMAND_LINE_H_ diff --git a/cef3/libcef/browser/content_browser_client.cc b/cef3/libcef/browser/content_browser_client.cc index 15a7d9335..f1bfc002e 100644 --- a/cef3/libcef/browser/content_browser_client.cc +++ b/cef3/libcef/browser/content_browser_client.cc @@ -15,6 +15,7 @@ #include "libcef/browser/resource_dispatcher_host_delegate.h" #include "libcef/browser/thread_util.h" #include "libcef/common/cef_switches.h" +#include "libcef/common/command_line_impl.h" #include "base/command_line.h" #include "base/file_path.h" @@ -125,6 +126,18 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches( command_line->CopySwitchesFrom(browser_cmd, kSwitchNames, arraysize(kSwitchNames)); } + + CefRefPtr app = _Context->application(); + if (app.get()) { + CefRefPtr handler = + app->GetBrowserProcessHandler(); + if (handler.get()) { + CefRefPtr commandLinePtr( + new CefCommandLineImpl(command_line, false, false)); + handler->OnBeforeChildProcessLaunch(commandLinePtr.get()); + commandLinePtr->Detach(NULL); + } + } } content::MediaObserver* CefContentBrowserClient::GetMediaObserver() { diff --git a/cef3/libcef/common/command_line_impl.cc b/cef3/libcef/common/command_line_impl.cc index bbbdcf3b4..714733603 100644 --- a/cef3/libcef/common/command_line_impl.cc +++ b/cef3/libcef/common/command_line_impl.cc @@ -124,6 +124,11 @@ void CefCommandLineImpl::AppendArgument(const CefString& argument) { mutable_value()->AppendArgNative(argument); } +void CefCommandLineImpl::PrependWrapper(const CefString& wrapper) { + CEF_VALUE_VERIFY_RETURN_VOID(true); + mutable_value()->PrependWrapper(wrapper); +} + // CefCommandLine implementation. diff --git a/cef3/libcef/common/command_line_impl.h b/cef3/libcef/common/command_line_impl.h index be9cf73cf..e6fcdec76 100644 --- a/cef3/libcef/common/command_line_impl.h +++ b/cef3/libcef/common/command_line_impl.h @@ -38,6 +38,7 @@ class CefCommandLineImpl : public CefValueBase { virtual bool HasArguments() OVERRIDE; virtual void GetArguments(ArgumentList& arguments) OVERRIDE; virtual void AppendArgument(const CefString& argument) OVERRIDE; + virtual void PrependWrapper(const CefString& wrapper) OVERRIDE; // Must hold the controller lock while using this value. const CommandLine& command_line() { return const_value(); } diff --git a/cef3/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc b/cef3/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc index fbfdfcd4a..a492c973a 100644 --- a/cef3/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc +++ b/cef3/libcef_dll/cpptoc/browser_process_handler_cpptoc.cc @@ -12,6 +12,7 @@ #include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h" #include "libcef_dll/cpptoc/proxy_handler_cpptoc.h" +#include "libcef_dll/ctocpp/command_line_ctocpp.h" // MEMBER FUNCTIONS - Body may be edited by hand. @@ -44,6 +45,24 @@ void CEF_CALLBACK browser_process_handler_on_context_initialized( CefBrowserProcessHandlerCppToC::Get(self)->OnContextInitialized(); } +void CEF_CALLBACK browser_process_handler_on_before_child_process_launch( + struct _cef_browser_process_handler_t* self, + struct _cef_command_line_t* command_line) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: command_line; type: refptr_diff + DCHECK(command_line); + if (!command_line) + return; + + // Execute + CefBrowserProcessHandlerCppToC::Get(self)->OnBeforeChildProcessLaunch( + CefCommandLineCToCpp::Wrap(command_line)); +} + // CONSTRUCTOR - Do not edit by hand. @@ -54,6 +73,8 @@ CefBrowserProcessHandlerCppToC::CefBrowserProcessHandlerCppToC( struct_.struct_.get_proxy_handler = browser_process_handler_get_proxy_handler; struct_.struct_.on_context_initialized = browser_process_handler_on_context_initialized; + struct_.struct_.on_before_child_process_launch = + browser_process_handler_on_before_child_process_launch; } #ifndef NDEBUG diff --git a/cef3/libcef_dll/cpptoc/command_line_cpptoc.cc b/cef3/libcef_dll/cpptoc/command_line_cpptoc.cc index 26a0e6bba..0756a975e 100644 --- a/cef3/libcef_dll/cpptoc/command_line_cpptoc.cc +++ b/cef3/libcef_dll/cpptoc/command_line_cpptoc.cc @@ -350,6 +350,23 @@ void CEF_CALLBACK command_line_append_argument(struct _cef_command_line_t* self, CefString(argument)); } +void CEF_CALLBACK command_line_prepend_wrapper(struct _cef_command_line_t* self, + const cef_string_t* wrapper) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: wrapper; type: string_byref_const + DCHECK(wrapper); + if (!wrapper) + return; + + // Execute + CefCommandLineCppToC::Get(self)->PrependWrapper( + CefString(wrapper)); +} + // CONSTRUCTOR - Do not edit by hand. @@ -375,6 +392,7 @@ CefCommandLineCppToC::CefCommandLineCppToC(CefCommandLine* cls) struct_.struct_.has_arguments = command_line_has_arguments; struct_.struct_.get_arguments = command_line_get_arguments; struct_.struct_.append_argument = command_line_append_argument; + struct_.struct_.prepend_wrapper = command_line_prepend_wrapper; } #ifndef NDEBUG diff --git a/cef3/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc b/cef3/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc index 4f51ae702..0d030ca2a 100644 --- a/cef3/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc +++ b/cef3/libcef_dll/ctocpp/browser_process_handler_ctocpp.cc @@ -10,6 +10,7 @@ // for more information. // +#include "libcef_dll/cpptoc/command_line_cpptoc.h" #include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h" #include "libcef_dll/ctocpp/proxy_handler_ctocpp.h" @@ -39,6 +40,23 @@ void CefBrowserProcessHandlerCToCpp::OnContextInitialized() { struct_->on_context_initialized(struct_); } +void CefBrowserProcessHandlerCToCpp::OnBeforeChildProcessLaunch( + CefRefPtr command_line) { + if (CEF_MEMBER_MISSING(struct_, on_before_child_process_launch)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: command_line; type: refptr_diff + DCHECK(command_line.get()); + if (!command_line.get()) + return; + + // Execute + struct_->on_before_child_process_launch(struct_, + CefCommandLineCppToC::Wrap(command_line)); +} + #ifndef NDEBUG template<> long CefCToCpp GetProxyHandler() OVERRIDE; virtual void OnContextInitialized() OVERRIDE; + virtual void OnBeforeChildProcessLaunch( + CefRefPtr command_line) OVERRIDE; }; #endif // BUILDING_CEF_SHARED diff --git a/cef3/libcef_dll/ctocpp/command_line_ctocpp.cc b/cef3/libcef_dll/ctocpp/command_line_ctocpp.cc index 5838c777b..0c2f41fb5 100644 --- a/cef3/libcef_dll/ctocpp/command_line_ctocpp.cc +++ b/cef3/libcef_dll/ctocpp/command_line_ctocpp.cc @@ -350,6 +350,22 @@ void CefCommandLineCToCpp::AppendArgument(const CefString& argument) { argument.GetStruct()); } +void CefCommandLineCToCpp::PrependWrapper(const CefString& wrapper) { + if (CEF_MEMBER_MISSING(struct_, prepend_wrapper)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: wrapper; type: string_byref_const + DCHECK(!wrapper.empty()); + if (wrapper.empty()) + return; + + // Execute + struct_->prepend_wrapper(struct_, + wrapper.GetStruct()); +} + #ifndef NDEBUG template<> long CefCToCpp