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>
|
|
|
|
|
|
|
|
#include "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"
|
2021-06-04 03:34:56 +02:00
|
|
|
#include "third_party/abseil-cpp/absl/types/optional.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;
|
|
|
|
class RenderView;
|
|
|
|
} // 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;
|
|
|
|
class CefGuestView;
|
|
|
|
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();
|
|
|
|
~CefRenderManager();
|
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,
|
2021-06-04 03:34:56 +02:00
|
|
|
absl::optional<bool>& is_windowless);
|
2021-07-23 18:40:13 +02:00
|
|
|
void WebViewCreated(blink::WebView* web_view,
|
|
|
|
bool& browser_created,
|
|
|
|
absl::optional<bool>& is_windowless);
|
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.
|
|
|
|
CefRefPtr<CefBrowserImpl> GetBrowserForView(content::RenderView* view);
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
private:
|
|
|
|
friend class CefBrowserImpl;
|
|
|
|
friend class CefGuestView;
|
|
|
|
|
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
|
|
|
|
// nullptr for guest views.
|
|
|
|
CefRefPtr<CefBrowserImpl> MaybeCreateBrowser(
|
|
|
|
content::RenderView* render_view,
|
|
|
|
content::RenderFrame* render_frame,
|
|
|
|
bool* browser_created,
|
2021-06-04 03:34:56 +02:00
|
|
|
absl::optional<bool>* is_windowless);
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
// Called from CefBrowserImpl::OnDestruct().
|
|
|
|
void OnBrowserDestroyed(CefBrowserImpl* browser);
|
|
|
|
|
|
|
|
// Returns the guest view associated with the specified RenderView if any.
|
|
|
|
CefGuestView* GetGuestViewForView(content::RenderView* view);
|
|
|
|
|
|
|
|
// Called from CefGuestView::OnDestruct().
|
|
|
|
void OnGuestViewDestroyed(CefGuestView* guest_view);
|
|
|
|
|
|
|
|
// Map of RenderView pointers to CefBrowserImpl references.
|
|
|
|
typedef std::map<content::RenderView*, CefRefPtr<CefBrowserImpl>> BrowserMap;
|
|
|
|
BrowserMap browsers_;
|
|
|
|
|
|
|
|
// Map of RenderView poiners to CefGuestView implementations.
|
|
|
|
typedef std::map<content::RenderView*, std::unique_ptr<CefGuestView>>
|
|
|
|
GuestViewMap;
|
|
|
|
GuestViewMap guest_views_;
|
|
|
|
|
|
|
|
// 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_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefRenderManager);
|
2020-09-25 03:40:47 +02:00
|
|
|
};
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
#endif // CEF_LIBCEF_RENDERER_RENDER_MANAGER_H_
|