- Pass information to the renderer process synchronously on render thread creation and new browser creation to avoid race conditions (issue #744).

- Add the ability to pass extra information to child processes using a new CefBrowserProcessHandler::OnRenderProcessThreadCreated callback (issue #744).
- Fix OnBeforeChildProcessLaunch documentation (issue #754).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@910 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-11-20 20:08:36 +00:00
parent 8a504d3d25
commit 1e871cc2c8
32 changed files with 957 additions and 234 deletions

View File

@@ -5,12 +5,17 @@
#include "libcef/browser/browser_message_filter.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/content_browser_client.h"
#include "libcef/browser/context.h"
#include "libcef/browser/origin_whitelist_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/common/cef_messages.h"
#include "libcef/common/values_impl.h"
#include "base/compiler_specific.h"
#include "base/bind.h"
#include "content/public/browser/render_process_host.h"
CefBrowserMessageFilter::CefBrowserMessageFilter(
content::RenderProcessHost* host)
@@ -31,22 +36,50 @@ void CefBrowserMessageFilter::OnFilterRemoved() {
bool CefBrowserMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(CefBrowserMessageFilter, message)
IPC_MESSAGE_HANDLER(CefProcessHostMsg_RenderThreadStarted,
OnRenderThreadStarted)
IPC_MESSAGE_HANDLER(CefProcessHostMsg_GetNewRenderThreadInfo,
OnGetNewRenderThreadInfo)
IPC_MESSAGE_HANDLER(CefProcessHostMsg_GetNewBrowserInfo,
OnGetNewBrowserInfo)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void CefBrowserMessageFilter::OnRenderThreadStarted() {
// Execute registration on the UI thread.
CEF_POST_TASK(CEF_UIT,
base::Bind(&CefBrowserMessageFilter::RegisterOnUIThread, this));
bool CefBrowserMessageFilter::Send(IPC::Message* message) {
return host_->Send(message);
}
void CefBrowserMessageFilter::RegisterOnUIThread() {
CEF_REQUIRE_UIT();
// Send existing registrations to the new render process.
RegisterCrossOriginWhitelistEntriesWithHost(host_);
void CefBrowserMessageFilter::OnGetNewRenderThreadInfo(
CefProcessHostMsg_GetNewRenderThreadInfo_Params* params) {
GetCrossOriginWhitelistEntries(&params->cross_origin_whitelist_entries);
CefRefPtr<CefApp> app = _Context->application();
if (app.get()) {
CefRefPtr<CefBrowserProcessHandler> handler =
app->GetBrowserProcessHandler();
if (handler.get()) {
CefRefPtr<CefListValueImpl> listValuePtr(
new CefListValueImpl(&params->extra_info, false, false));
handler->OnRenderProcessThreadCreated(listValuePtr.get());
listValuePtr->Detach(NULL);
}
}
}
void CefBrowserMessageFilter::OnGetNewBrowserInfo(
int routing_id, CefProcessHostMsg_GetNewBrowserInfo_Params* params) {
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::GetBrowserByRoutingID(host_->GetID(), routing_id);
if (browser.get()) {
params->browser_id = browser->GetIdentifier();
params->is_popup = browser->IsPopup();
} else {
CefContentBrowserClient::NewPopupBrowserInfo info;
CefContentBrowserClient::Get()->GetNewPopupBrowserInfo(host_->GetID(),
routing_id,
&info);
DCHECK_GT(info.browser_id, 0);
params->browser_id = info.browser_id;
params->is_popup = true;
}
}