Commit 8957947c authored by Marshall Greenblatt's avatar Marshall Greenblatt

Add CefBrowserProcessHandler::OnBeforeChildProcessLaunch and...

Add CefBrowserProcessHandler::OnBeforeChildProcessLaunch and CefCommandLine::PrependWrapper to support custom construction of the command line for child processes (issue #628).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@810 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
parent cc3b8c9c
......@@ -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;
......
......@@ -184,6 +184,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;
......
......@@ -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<CefCommandLine> command_line) {
}
};
#endif // CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_
......@@ -196,6 +196,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_
......@@ -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<CefApp> app = _Context->application();
if (app.get()) {
CefRefPtr<CefBrowserProcessHandler> handler =
app->GetBrowserProcessHandler();
if (handler.get()) {
CefRefPtr<CefCommandLineImpl> commandLinePtr(
new CefCommandLineImpl(command_line, false, false));
handler->OnBeforeChildProcessLaunch(commandLinePtr.get());
commandLinePtr->Detach(NULL);
}
}
}
content::MediaObserver* CefContentBrowserClient::GetMediaObserver() {
......
......@@ -132,6 +132,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.
......
......@@ -39,6 +39,7 @@ class CefCommandLineImpl : public CefValueBase<CefCommandLine, CommandLine> {
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(); }
......
......@@ -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
......
......@@ -375,6 +375,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.
......@@ -401,6 +418,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
......
......@@ -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<CefCommandLine> 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<CefBrowserProcessHandlerCToCpp,
......
......@@ -36,6 +36,8 @@ class CefBrowserProcessHandlerCToCpp
// CefBrowserProcessHandler methods
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() OVERRIDE;
virtual void OnContextInitialized() OVERRIDE;
virtual void OnBeforeChildProcessLaunch(
CefRefPtr<CefCommandLine> command_line) OVERRIDE;
};
#endif // BUILDING_CEF_SHARED
......
......@@ -374,6 +374,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<CefCommandLineCToCpp, CefCommandLine,
......
......@@ -55,6 +55,7 @@ class CefCommandLineCToCpp
virtual bool HasArguments() OVERRIDE;
virtual void GetArguments(ArgumentList& arguments) OVERRIDE;
virtual void AppendArgument(const CefString& argument) OVERRIDE;
virtual void PrependWrapper(const CefString& wrapper) OVERRIDE;
};
#endif // USING_CEF_SHARED
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment