2020-09-25 03:40:47 +02:00
|
|
|
// Copyright 2015 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.
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/renderer/render_manager.h"
|
2020-09-25 03:40:47 +02:00
|
|
|
|
2022-01-25 20:40:24 +01:00
|
|
|
#include <tuple>
|
|
|
|
|
2022-02-21 23:23:40 +01:00
|
|
|
#include "build/build_config.h"
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
// Enable deprecation warnings on Windows. See http://crbug.com/585142.
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2020-09-25 03:40:47 +02:00
|
|
|
#if defined(__clang__)
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic error "-Wdeprecated-declarations"
|
|
|
|
#else
|
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(default : 4996)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "base/command_line.h"
|
|
|
|
#include "base/strings/string_number_conversions.h"
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/common/app_manager.h"
|
|
|
|
#include "cef/libcef/common/cef_switches.h"
|
2021-05-14 18:58:55 +02:00
|
|
|
#include "cef/libcef/common/mojom/cef.mojom.h"
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/common/net/scheme_info.h"
|
|
|
|
#include "cef/libcef/common/values_impl.h"
|
|
|
|
#include "cef/libcef/renderer/blink_glue.h"
|
|
|
|
#include "cef/libcef/renderer/browser_impl.h"
|
|
|
|
#include "cef/libcef/renderer/render_frame_observer.h"
|
|
|
|
#include "cef/libcef/renderer/thread_util.h"
|
|
|
|
#include "cef/libcef/renderer/v8_impl.h"
|
2021-11-29 20:58:09 +01:00
|
|
|
#include "content/public/common/content_switches.h"
|
2020-09-25 03:40:47 +02:00
|
|
|
#include "content/public/renderer/render_frame.h"
|
|
|
|
#include "content/public/renderer/render_thread.h"
|
2021-11-29 20:58:09 +01:00
|
|
|
#include "extensions/common/switches.h"
|
2021-05-14 18:58:55 +02:00
|
|
|
#include "mojo/public/cpp/bindings/binder_map.h"
|
2020-09-25 03:40:47 +02:00
|
|
|
#include "services/network/public/mojom/cors_origin_pattern.mojom.h"
|
2021-05-14 18:58:55 +02:00
|
|
|
#include "third_party/blink/public/platform/web_string.h"
|
|
|
|
#include "third_party/blink/public/platform/web_url.h"
|
2022-03-26 02:12:30 +01:00
|
|
|
#include "third_party/blink/public/web/web_frame.h"
|
2024-01-26 03:12:43 +01:00
|
|
|
#include "third_party/blink/public/web/web_local_frame.h"
|
2020-09-25 03:40:47 +02:00
|
|
|
#include "third_party/blink/public/web/web_security_policy.h"
|
|
|
|
#include "third_party/blink/public/web/web_view.h"
|
2021-03-04 23:36:57 +01:00
|
|
|
#include "third_party/blink/public/web/web_view_observer.h"
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
CefRenderManager* g_manager = nullptr;
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2024-04-24 23:23:47 +02:00
|
|
|
// Placeholder object for excluded views.
|
|
|
|
class CefExcludedView : public blink::WebViewObserver {
|
2020-09-25 03:40:47 +02:00
|
|
|
public:
|
2024-04-24 23:23:47 +02:00
|
|
|
CefExcludedView(CefRenderManager* manager,
|
|
|
|
blink::WebView* web_view,
|
|
|
|
std::optional<bool> is_windowless,
|
|
|
|
std::optional<bool> print_preview_enabled)
|
2022-07-21 19:26:10 +02:00
|
|
|
: blink::WebViewObserver(web_view),
|
2020-09-25 03:40:47 +02:00
|
|
|
manager_(manager),
|
2024-04-17 18:01:26 +02:00
|
|
|
is_windowless_(is_windowless),
|
|
|
|
print_preview_enabled_(print_preview_enabled) {}
|
2020-09-25 03:40:47 +02:00
|
|
|
|
2024-04-17 18:01:26 +02:00
|
|
|
std::optional<bool> is_windowless() const { return is_windowless_; }
|
|
|
|
std::optional<bool> print_preview_enabled() const {
|
|
|
|
return print_preview_enabled_;
|
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// RenderViewObserver methods.
|
2024-04-24 23:23:47 +02:00
|
|
|
void OnDestruct() override { manager_->OnExcludedViewDestroyed(this); }
|
2020-09-25 03:40:47 +02:00
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
CefRenderManager* const manager_;
|
2024-04-17 18:01:26 +02:00
|
|
|
const std::optional<bool> is_windowless_;
|
|
|
|
const std::optional<bool> print_preview_enabled_;
|
2020-09-25 03:40:47 +02:00
|
|
|
};
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
CefRenderManager::CefRenderManager() {
|
2020-09-25 03:40:47 +02:00
|
|
|
DCHECK(!g_manager);
|
|
|
|
g_manager = this;
|
|
|
|
}
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
CefRenderManager::~CefRenderManager() {
|
2020-09-25 03:40:47 +02:00
|
|
|
g_manager = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2021-05-14 18:58:55 +02:00
|
|
|
CefRenderManager* CefRenderManager::Get() {
|
2020-09-25 03:40:47 +02:00
|
|
|
CEF_REQUIRE_RT_RETURN(nullptr);
|
|
|
|
return g_manager;
|
|
|
|
}
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
void CefRenderManager::RenderThreadConnected() {
|
2020-09-25 03:40:47 +02:00
|
|
|
// Retrieve the new render thread information synchronously.
|
2021-05-14 18:58:55 +02:00
|
|
|
auto params = cef::mojom::NewRenderThreadInfo::New();
|
|
|
|
GetBrowserManager()->GetNewRenderThreadInfo(¶ms);
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
// Cross-origin entries need to be added after WebKit is initialized.
|
2021-05-14 18:58:55 +02:00
|
|
|
if (params->cross_origin_whitelist_entries) {
|
|
|
|
cross_origin_whitelist_entries_.swap(
|
|
|
|
*params->cross_origin_whitelist_entries);
|
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
WebKitInitialized();
|
|
|
|
}
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
void CefRenderManager::RenderFrameCreated(
|
2020-09-25 03:40:47 +02:00
|
|
|
content::RenderFrame* render_frame,
|
|
|
|
CefRenderFrameObserver* render_frame_observer,
|
|
|
|
bool& browser_created,
|
2024-04-17 18:01:26 +02:00
|
|
|
std::optional<bool>& is_windowless,
|
|
|
|
std::optional<bool>& print_preview_enabled) {
|
2022-07-21 19:26:10 +02:00
|
|
|
auto browser = MaybeCreateBrowser(render_frame->GetWebView(), render_frame,
|
2024-04-17 18:01:26 +02:00
|
|
|
&browser_created, &is_windowless,
|
|
|
|
&print_preview_enabled);
|
2020-09-25 03:40:47 +02:00
|
|
|
if (browser) {
|
|
|
|
// Attach the frame to the observer for message routing purposes.
|
|
|
|
render_frame_observer->AttachFrame(
|
|
|
|
browser->GetWebFrameImpl(render_frame->GetWebFrame()).get());
|
|
|
|
}
|
2024-01-26 03:12:43 +01:00
|
|
|
|
|
|
|
// Enable support for draggable regions.
|
|
|
|
// TODO: This has performance consequences so consider making it configurable
|
|
|
|
// (e.g. only enabled for frameless windows). See issue #3636.
|
2024-04-23 22:06:00 +02:00
|
|
|
render_frame->GetWebView()->SetSupportsDraggableRegions(true);
|
2020-09-25 03:40:47 +02:00
|
|
|
}
|
|
|
|
|
2024-04-17 18:01:26 +02:00
|
|
|
void CefRenderManager::WebViewCreated(
|
|
|
|
blink::WebView* web_view,
|
|
|
|
bool& browser_created,
|
|
|
|
std::optional<bool>& is_windowless,
|
|
|
|
std::optional<bool>& print_preview_enabled) {
|
2021-07-23 18:40:13 +02:00
|
|
|
content::RenderFrame* render_frame = nullptr;
|
|
|
|
if (web_view->MainFrame()->IsWebLocalFrame()) {
|
|
|
|
render_frame = content::RenderFrame::FromWebFrame(
|
|
|
|
web_view->MainFrame()->ToWebLocalFrame());
|
|
|
|
}
|
|
|
|
|
2024-04-17 18:01:26 +02:00
|
|
|
MaybeCreateBrowser(web_view, render_frame, &browser_created, &is_windowless,
|
|
|
|
&print_preview_enabled);
|
2020-09-25 03:40:47 +02:00
|
|
|
}
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
void CefRenderManager::DevToolsAgentAttached() {
|
2020-09-25 03:40:47 +02:00
|
|
|
++devtools_agent_count_;
|
|
|
|
}
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
void CefRenderManager::DevToolsAgentDetached() {
|
2020-09-25 03:40:47 +02:00
|
|
|
--devtools_agent_count_;
|
|
|
|
if (devtools_agent_count_ == 0 && uncaught_exception_stack_size_ > 0) {
|
|
|
|
// When the last DevToolsAgent is detached the stack size is set to 0.
|
|
|
|
// Restore the user-specified stack size here.
|
|
|
|
CefV8SetUncaughtExceptionStackSize(uncaught_exception_stack_size_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
void CefRenderManager::ExposeInterfacesToBrowser(mojo::BinderMap* binders) {
|
2023-01-30 18:43:54 +01:00
|
|
|
auto task_runner = base::SequencedTaskRunner::GetCurrentDefault();
|
2021-05-14 18:58:55 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
binders->Add<cef::mojom::RenderManager>(
|
2021-05-14 18:58:55 +02:00
|
|
|
base::BindRepeating(
|
|
|
|
[](CefRenderManager* render_manager,
|
|
|
|
mojo::PendingReceiver<cef::mojom::RenderManager> receiver) {
|
|
|
|
render_manager->BindReceiver(std::move(receiver));
|
|
|
|
},
|
|
|
|
base::Unretained(this)),
|
|
|
|
task_runner);
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefBrowserImpl> CefRenderManager::GetBrowserForView(
|
2022-07-21 19:26:10 +02:00
|
|
|
blink::WebView* view) {
|
2020-09-25 03:40:47 +02:00
|
|
|
BrowserMap::const_iterator it = browsers_.find(view);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (it != browsers_.end()) {
|
2020-09-25 03:40:47 +02:00
|
|
|
return it->second;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
CefRefPtr<CefBrowserImpl> CefRenderManager::GetBrowserForMainFrame(
|
2020-09-25 03:40:47 +02:00
|
|
|
blink::WebFrame* frame) {
|
|
|
|
BrowserMap::const_iterator it = browsers_.begin();
|
|
|
|
for (; it != browsers_.end(); ++it) {
|
2021-03-04 23:36:57 +01:00
|
|
|
auto web_view = it->second->GetWebView();
|
|
|
|
if (web_view && web_view->MainFrame() == frame) {
|
2020-09-25 03:40:47 +02:00
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
mojo::Remote<cef::mojom::BrowserManager>&
|
|
|
|
CefRenderManager::GetBrowserManager() {
|
|
|
|
if (!browser_manager_) {
|
|
|
|
content::RenderThread::Get()->BindHostReceiver(
|
|
|
|
browser_manager_.BindNewPipeAndPassReceiver());
|
|
|
|
}
|
|
|
|
return browser_manager_;
|
|
|
|
}
|
|
|
|
|
2021-11-29 20:58:09 +01:00
|
|
|
// static
|
|
|
|
bool CefRenderManager::IsExtensionProcess() {
|
|
|
|
return base::CommandLine::ForCurrentProcess()->HasSwitch(
|
|
|
|
extensions::switches::kExtensionProcess);
|
|
|
|
}
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
void CefRenderManager::BindReceiver(
|
|
|
|
mojo::PendingReceiver<cef::mojom::RenderManager> receiver) {
|
|
|
|
receivers_.Add(this, std::move(receiver));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefRenderManager::ModifyCrossOriginWhitelistEntry(
|
|
|
|
bool add,
|
|
|
|
cef::mojom::CrossOriginWhiteListEntryPtr entry) {
|
|
|
|
GURL gurl = GURL(entry->source_origin);
|
|
|
|
if (add) {
|
|
|
|
blink::WebSecurityPolicy::AddOriginAccessAllowListEntry(
|
|
|
|
gurl, blink::WebString::FromUTF8(entry->target_protocol),
|
|
|
|
blink::WebString::FromUTF8(entry->target_domain),
|
|
|
|
/*destination_port=*/0,
|
|
|
|
entry->allow_target_subdomains
|
|
|
|
? network::mojom::CorsDomainMatchMode::kAllowSubdomains
|
|
|
|
: network::mojom::CorsDomainMatchMode::kDisallowSubdomains,
|
|
|
|
network::mojom::CorsPortMatchMode::kAllowAnyPort,
|
|
|
|
network::mojom::CorsOriginAccessMatchPriority::kDefaultPriority);
|
|
|
|
} else {
|
|
|
|
blink::WebSecurityPolicy::ClearOriginAccessListForOrigin(gurl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefRenderManager::ClearCrossOriginWhitelist() {
|
|
|
|
blink::WebSecurityPolicy::ClearOriginAccessList();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefRenderManager::WebKitInitialized() {
|
2020-09-25 03:40:47 +02:00
|
|
|
const base::CommandLine* command_line =
|
|
|
|
base::CommandLine::ForCurrentProcess();
|
|
|
|
|
|
|
|
// Create global objects associated with the default Isolate.
|
|
|
|
CefV8IsolateCreated();
|
|
|
|
|
|
|
|
const CefAppManager::SchemeInfoList* schemes =
|
|
|
|
CefAppManager::Get()->GetCustomSchemes();
|
|
|
|
if (!schemes->empty()) {
|
2021-01-28 00:13:12 +01:00
|
|
|
// Register the custom schemes. Some attributes are excluded here because
|
|
|
|
// they use url/url_util.h APIs instead.
|
2020-09-25 03:40:47 +02:00
|
|
|
CefAppManager::SchemeInfoList::const_iterator it = schemes->begin();
|
|
|
|
for (; it != schemes->end(); ++it) {
|
|
|
|
const CefSchemeInfo& info = *it;
|
|
|
|
const blink::WebString& scheme =
|
|
|
|
blink::WebString::FromUTF8(info.scheme_name);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (info.is_display_isolated) {
|
2020-09-25 03:40:47 +02:00
|
|
|
blink::WebSecurityPolicy::RegisterURLSchemeAsDisplayIsolated(scheme);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (info.is_fetch_enabled) {
|
2020-09-25 03:40:47 +02:00
|
|
|
blink_glue::RegisterURLSchemeAsSupportingFetchAPI(scheme);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cross_origin_whitelist_entries_.empty()) {
|
|
|
|
// Add the cross-origin white list entries.
|
2021-05-14 18:58:55 +02:00
|
|
|
for (auto& entry : cross_origin_whitelist_entries_) {
|
|
|
|
ModifyCrossOriginWhitelistEntry(/*add=*/true, std::move(entry));
|
2020-09-25 03:40:47 +02:00
|
|
|
}
|
|
|
|
cross_origin_whitelist_entries_.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// The number of stack trace frames to capture for uncaught exceptions.
|
|
|
|
if (command_line->HasSwitch(switches::kUncaughtExceptionStackSize)) {
|
|
|
|
int uncaught_exception_stack_size = 0;
|
|
|
|
base::StringToInt(command_line->GetSwitchValueASCII(
|
|
|
|
switches::kUncaughtExceptionStackSize),
|
|
|
|
&uncaught_exception_stack_size);
|
|
|
|
|
|
|
|
if (uncaught_exception_stack_size > 0) {
|
|
|
|
uncaught_exception_stack_size_ = uncaught_exception_stack_size;
|
|
|
|
CefV8SetUncaughtExceptionStackSize(uncaught_exception_stack_size_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Notify the render process handler.
|
|
|
|
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
|
|
|
|
if (application.get()) {
|
|
|
|
CefRefPtr<CefRenderProcessHandler> handler =
|
|
|
|
application->GetRenderProcessHandler();
|
2023-01-02 23:59:03 +01:00
|
|
|
if (handler.get()) {
|
2020-09-25 03:40:47 +02:00
|
|
|
handler->OnWebKitInitialized();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
CefRefPtr<CefBrowserImpl> CefRenderManager::MaybeCreateBrowser(
|
2022-07-21 19:26:10 +02:00
|
|
|
blink::WebView* web_view,
|
2020-09-25 03:40:47 +02:00
|
|
|
content::RenderFrame* render_frame,
|
|
|
|
bool* browser_created,
|
2024-04-17 18:01:26 +02:00
|
|
|
std::optional<bool>* is_windowless,
|
|
|
|
std::optional<bool>* print_preview_enabled) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (browser_created) {
|
2020-09-25 03:40:47 +02:00
|
|
|
*browser_created = false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!web_view || !render_frame) {
|
2020-09-25 03:40:47 +02:00
|
|
|
return nullptr;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
|
2024-04-24 23:23:47 +02:00
|
|
|
// Don't create another browser or excluded view object if one already exists
|
|
|
|
// for the view.
|
2022-07-21 19:26:10 +02:00
|
|
|
auto browser = GetBrowserForView(web_view);
|
2020-09-25 03:40:47 +02:00
|
|
|
if (browser) {
|
|
|
|
if (is_windowless) {
|
|
|
|
*is_windowless = browser->is_windowless();
|
|
|
|
}
|
2024-04-17 18:01:26 +02:00
|
|
|
if (print_preview_enabled) {
|
|
|
|
*print_preview_enabled = browser->print_preview_enabled();
|
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
return browser;
|
|
|
|
}
|
|
|
|
|
2024-04-24 23:23:47 +02:00
|
|
|
auto excluded_view = GetExcludedViewForView(web_view);
|
|
|
|
if (excluded_view) {
|
2020-09-25 03:40:47 +02:00
|
|
|
if (is_windowless) {
|
2024-04-24 23:23:47 +02:00
|
|
|
*is_windowless = excluded_view->is_windowless();
|
2020-09-25 03:40:47 +02:00
|
|
|
}
|
2024-04-17 18:01:26 +02:00
|
|
|
if (print_preview_enabled) {
|
2024-04-24 23:23:47 +02:00
|
|
|
*print_preview_enabled = excluded_view->print_preview_enabled();
|
2024-04-17 18:01:26 +02:00
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-04-17 18:01:26 +02:00
|
|
|
// Retrieve browser information synchronously.
|
2021-05-14 18:58:55 +02:00
|
|
|
auto params = cef::mojom::NewBrowserInfo::New();
|
2024-04-17 18:01:26 +02:00
|
|
|
GetBrowserManager()->GetNewBrowserInfo(
|
|
|
|
render_frame->GetWebFrame()->GetLocalFrameToken(), ¶ms);
|
|
|
|
if (params->browser_id == 0) {
|
|
|
|
// The popup may have been canceled during creation.
|
|
|
|
return nullptr;
|
2021-11-29 20:58:09 +01:00
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
if (is_windowless) {
|
2021-05-14 18:58:55 +02:00
|
|
|
*is_windowless = params->is_windowless;
|
2020-09-25 03:40:47 +02:00
|
|
|
}
|
2024-04-17 18:01:26 +02:00
|
|
|
if (print_preview_enabled) {
|
|
|
|
*print_preview_enabled = params->print_preview_enabled;
|
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
|
2024-04-24 23:23:47 +02:00
|
|
|
if (params->is_excluded || params->browser_id < 0) {
|
|
|
|
// Don't create a CefBrowser for excluded content (PDF renderer, PDF
|
|
|
|
// extension or print preview dialog), or if the new browser info response
|
|
|
|
// has timed out.
|
|
|
|
excluded_views_.insert(std::make_pair(
|
2022-07-21 19:26:10 +02:00
|
|
|
web_view,
|
2024-04-24 23:23:47 +02:00
|
|
|
std::make_unique<CefExcludedView>(this, web_view, params->is_windowless,
|
|
|
|
params->print_preview_enabled)));
|
2020-09-25 03:40:47 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-04-17 18:01:26 +02:00
|
|
|
browser = new CefBrowserImpl(web_view, params->browser_id, *params->is_popup,
|
|
|
|
*params->is_windowless,
|
|
|
|
*params->print_preview_enabled);
|
2022-07-21 19:26:10 +02:00
|
|
|
browsers_.insert(std::make_pair(web_view, browser));
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
// Notify the render process handler.
|
|
|
|
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
|
|
|
|
if (application.get()) {
|
|
|
|
CefRefPtr<CefRenderProcessHandler> handler =
|
|
|
|
application->GetRenderProcessHandler();
|
|
|
|
if (handler.get()) {
|
2021-05-14 18:58:55 +02:00
|
|
|
CefRefPtr<CefDictionaryValueImpl> dictValuePtr;
|
|
|
|
if (params->extra_info) {
|
2023-01-30 22:42:40 +01:00
|
|
|
dictValuePtr =
|
|
|
|
new CefDictionaryValueImpl(std::move(*params->extra_info),
|
|
|
|
/*read_only=*/true);
|
2021-05-14 18:58:55 +02:00
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
handler->OnBrowserCreated(browser.get(), dictValuePtr.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (browser_created) {
|
2020-09-25 03:40:47 +02:00
|
|
|
*browser_created = true;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
return browser;
|
|
|
|
}
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
void CefRenderManager::OnBrowserDestroyed(CefBrowserImpl* browser) {
|
2020-09-25 03:40:47 +02:00
|
|
|
BrowserMap::iterator it = browsers_.begin();
|
|
|
|
for (; it != browsers_.end(); ++it) {
|
|
|
|
if (it->second.get() == browser) {
|
|
|
|
browsers_.erase(it);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No browser was found in the map.
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2020-09-25 03:40:47 +02:00
|
|
|
}
|
|
|
|
|
2024-04-24 23:23:47 +02:00
|
|
|
CefExcludedView* CefRenderManager::GetExcludedViewForView(
|
|
|
|
blink::WebView* view) {
|
2020-09-25 03:40:47 +02:00
|
|
|
CEF_REQUIRE_RT_RETURN(nullptr);
|
|
|
|
|
2024-04-24 23:23:47 +02:00
|
|
|
ExcludedViewMap::const_iterator it = excluded_views_.find(view);
|
|
|
|
if (it != excluded_views_.end()) {
|
2020-09-25 03:40:47 +02:00
|
|
|
return it->second.get();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-04-24 23:23:47 +02:00
|
|
|
void CefRenderManager::OnExcludedViewDestroyed(CefExcludedView* excluded_view) {
|
|
|
|
ExcludedViewMap::iterator it = excluded_views_.begin();
|
|
|
|
for (; it != excluded_views_.end(); ++it) {
|
|
|
|
if (it->second.get() == excluded_view) {
|
|
|
|
excluded_views_.erase(it);
|
2020-09-25 03:40:47 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-24 23:23:47 +02:00
|
|
|
// No excluded view was found in the map.
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2020-09-25 03:40:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Enable deprecation warnings on Windows. See http://crbug.com/585142.
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2020-09-25 03:40:47 +02:00
|
|
|
#if defined(__clang__)
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
#else
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|
|
|
|
#endif
|