mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2024-12-13 10:06:28 +01:00
955097ea77
With the introduction of prerendering in Chromium it is now possible for RenderFrameHosts (RFH) to move between FrameTrees. As a consequence we can no longer rely on FrameTreeNode IDs to uniquely identify a RFH over its lifespan. We must now switch to using GlobalRenderFrameHostId (child_id, frame_routing_id) instead for that purpose. Additionally, we simplify existing code by using the GlobalRenderFrameHostId struct in all places that previously used a (render_process_id, render_frame_id) pair, since these concepts are equivalent. See https://crbug.com/1179502#c8 for additional background.
59 lines
2.1 KiB
C++
59 lines
2.1 KiB
C++
// Copyright 2021 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 "libcef/browser/browser_manager.h"
|
|
|
|
#include "libcef/browser/browser_info_manager.h"
|
|
#include "libcef/browser/origin_whitelist_impl.h"
|
|
#include "libcef/common/frame_util.h"
|
|
|
|
#include "content/public/browser/render_process_host.h"
|
|
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
|
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
|
|
#include "services/service_manager/public/cpp/binder_registry.h"
|
|
|
|
CefBrowserManager::CefBrowserManager(int render_process_id)
|
|
: render_process_id_(render_process_id) {}
|
|
|
|
CefBrowserManager::~CefBrowserManager() = default;
|
|
|
|
// static
|
|
void CefBrowserManager::ExposeInterfacesToRenderer(
|
|
service_manager::BinderRegistry* registry,
|
|
blink::AssociatedInterfaceRegistry* associated_registry,
|
|
content::RenderProcessHost* host) {
|
|
registry->AddInterface(base::BindRepeating(
|
|
[](int render_process_id,
|
|
mojo::PendingReceiver<cef::mojom::BrowserManager> receiver) {
|
|
mojo::MakeSelfOwnedReceiver(
|
|
std::make_unique<CefBrowserManager>(render_process_id),
|
|
std::move(receiver));
|
|
},
|
|
host->GetID()));
|
|
}
|
|
|
|
// static
|
|
mojo::Remote<cef::mojom::RenderManager>
|
|
CefBrowserManager::GetRenderManagerForProcess(
|
|
content::RenderProcessHost* host) {
|
|
mojo::Remote<cef::mojom::RenderManager> client;
|
|
host->BindReceiver(client.BindNewPipeAndPassReceiver());
|
|
return client;
|
|
}
|
|
|
|
void CefBrowserManager::GetNewRenderThreadInfo(
|
|
cef::mojom::BrowserManager::GetNewRenderThreadInfoCallback callback) {
|
|
auto info = cef::mojom::NewRenderThreadInfo::New();
|
|
GetCrossOriginWhitelistEntries(&info->cross_origin_whitelist_entries);
|
|
std::move(callback).Run(std::move(info));
|
|
}
|
|
|
|
void CefBrowserManager::GetNewBrowserInfo(
|
|
int32_t render_frame_routing_id,
|
|
cef::mojom::BrowserManager::GetNewBrowserInfoCallback callback) {
|
|
CefBrowserInfoManager::GetInstance()->OnGetNewBrowserInfo(
|
|
frame_util::MakeGlobalId(render_process_id_, render_frame_routing_id),
|
|
std::move(callback));
|
|
}
|