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.
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
#ifndef CEF_LIBCEF_RENDERER_RENDER_MANAGER_H_
|
|
|
|
#define CEF_LIBCEF_RENDERER_RENDER_MANAGER_H_
|
2020-09-25 03:40:47 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
2024-03-19 22:11:42 +01:00
|
|
|
#include <optional>
|
2020-09-25 03:40:47 +02:00
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/include/internal/cef_ptr.h"
|
2021-05-14 18:58:55 +02:00
|
|
|
#include "cef/libcef/common/mojom/cef.mojom.h"
|
|
|
|
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
|
|
|
#include "mojo/public/cpp/bindings/receiver_set.h"
|
|
|
|
#include "mojo/public/cpp/bindings/remote.h"
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
namespace blink {
|
|
|
|
class WebFrame;
|
2021-07-23 18:40:13 +02:00
|
|
|
class WebView;
|
|
|
|
} // namespace blink
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
namespace content {
|
|
|
|
class RenderFrame;
|
|
|
|
} // namespace content
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
namespace mojo {
|
|
|
|
class BinderMap;
|
|
|
|
} // namespace mojo
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
class CefBrowserImpl;
|
2024-04-24 23:23:47 +02:00
|
|
|
class CefExcludedView;
|
2020-09-25 03:40:47 +02:00
|
|
|
class CefRenderFrameObserver;
|
|
|
|
|
|
|
|
// Singleton object for managing BrowserImpl instances. Only accessed on the
|
|
|
|
// main renderer thread.
|
2021-05-14 18:58:55 +02:00
|
|
|
class CefRenderManager : public cef::mojom::RenderManager {
|
2020-09-25 03:40:47 +02:00
|
|
|
public:
|
2021-05-14 18:58:55 +02:00
|
|
|
CefRenderManager();
|
2021-12-06 21:40:25 +01:00
|
|
|
|
|
|
|
CefRenderManager(const CefRenderManager&) = delete;
|
|
|
|
CefRenderManager& operator=(const CefRenderManager&) = delete;
|
|
|
|
|
2024-01-20 23:48:57 +01:00
|
|
|
~CefRenderManager() override;
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
// Returns this singleton instance of this class.
|
2021-05-14 18:58:55 +02:00
|
|
|
static CefRenderManager* Get();
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
// Called from ContentRendererClient methods of the same name.
|
|
|
|
void RenderThreadConnected();
|
|
|
|
void RenderFrameCreated(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);
|
2021-07-23 18:40:13 +02:00
|
|
|
void WebViewCreated(blink::WebView* web_view,
|
|
|
|
bool& browser_created,
|
2024-04-17 18:01:26 +02:00
|
|
|
std::optional<bool>& is_windowless,
|
|
|
|
std::optional<bool>& print_preview_enabled);
|
2020-09-25 03:40:47 +02:00
|
|
|
void DevToolsAgentAttached();
|
|
|
|
void DevToolsAgentDetached();
|
2021-05-14 18:58:55 +02:00
|
|
|
void ExposeInterfacesToBrowser(mojo::BinderMap* binders);
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
// Returns the browser associated with the specified RenderView.
|
2022-07-21 19:26:10 +02:00
|
|
|
CefRefPtr<CefBrowserImpl> GetBrowserForView(blink::WebView* view);
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
// Returns the browser associated with the specified main WebFrame.
|
|
|
|
CefRefPtr<CefBrowserImpl> GetBrowserForMainFrame(blink::WebFrame* frame);
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
// Connects to CefBrowserManager in the browser process.
|
|
|
|
mojo::Remote<cef::mojom::BrowserManager>& GetBrowserManager();
|
|
|
|
|
2021-11-29 20:58:09 +01:00
|
|
|
// Returns true if this renderer process is hosting an extension.
|
|
|
|
static bool IsExtensionProcess();
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
private:
|
|
|
|
friend class CefBrowserImpl;
|
2024-04-24 23:23:47 +02:00
|
|
|
friend class CefExcludedView;
|
2020-09-25 03:40:47 +02:00
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
// Binds receivers for the RenderManager interface.
|
|
|
|
void BindReceiver(mojo::PendingReceiver<cef::mojom::RenderManager> receiver);
|
|
|
|
|
|
|
|
// cef::mojom::RenderManager methods:
|
|
|
|
void ModifyCrossOriginWhitelistEntry(
|
|
|
|
bool add,
|
|
|
|
cef::mojom::CrossOriginWhiteListEntryPtr entry) override;
|
|
|
|
void ClearCrossOriginWhitelist() override;
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
void WebKitInitialized();
|
|
|
|
|
|
|
|
// Maybe create a new browser object, return the existing one, or return
|
2024-04-24 23:23:47 +02:00
|
|
|
// nullptr for excluded views.
|
2020-09-25 03:40:47 +02:00
|
|
|
CefRefPtr<CefBrowserImpl> 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);
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
// Called from CefBrowserImpl::OnDestruct().
|
|
|
|
void OnBrowserDestroyed(CefBrowserImpl* browser);
|
|
|
|
|
2024-04-24 23:23:47 +02:00
|
|
|
// Returns the excluded view associated with the specified RenderView if any.
|
|
|
|
CefExcludedView* GetExcludedViewForView(blink::WebView* view);
|
2020-09-25 03:40:47 +02:00
|
|
|
|
2024-04-24 23:23:47 +02:00
|
|
|
// Called from CefExcludedView::OnDestruct().
|
|
|
|
void OnExcludedViewDestroyed(CefExcludedView* excluded_view);
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
// Map of RenderView pointers to CefBrowserImpl references.
|
2022-07-21 19:26:10 +02:00
|
|
|
using BrowserMap = std::map<blink::WebView*, CefRefPtr<CefBrowserImpl>>;
|
2020-09-25 03:40:47 +02:00
|
|
|
BrowserMap browsers_;
|
|
|
|
|
2024-04-24 23:23:47 +02:00
|
|
|
// Map of RenderView poiners to CefExcludedView implementations.
|
|
|
|
using ExcludedViewMap =
|
|
|
|
std::map<blink::WebView*, std::unique_ptr<CefExcludedView>>;
|
|
|
|
ExcludedViewMap excluded_views_;
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
// Cross-origin white list entries that need to be registered with WebKit.
|
2021-05-14 18:58:55 +02:00
|
|
|
std::vector<cef::mojom::CrossOriginWhiteListEntryPtr>
|
|
|
|
cross_origin_whitelist_entries_;
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
int devtools_agent_count_ = 0;
|
|
|
|
int uncaught_exception_stack_size_ = 0;
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
mojo::ReceiverSet<cef::mojom::RenderManager> receivers_;
|
|
|
|
|
|
|
|
mojo::Remote<cef::mojom::BrowserManager> browser_manager_;
|
2020-09-25 03:40:47 +02:00
|
|
|
};
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
#endif // CEF_LIBCEF_RENDERER_RENDER_MANAGER_H_
|