mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-01-05 22:48:06 +01:00
dca0435d2f
Split the Alloy runtime into bootstrap and style components. Support creation of Alloy style browsers and windows with the Chrome runtime. Chrome runtime (`--enable-chrome-runtime`) + Alloy style (`--use-alloy-style`) supports Views (`--use-views`), native parent (`--use-native`) and windowless rendering (`--off-screen-rendering-enabled`). Print preview is supported in all cases except with windowless rendering on all platforms and native parent on MacOS. It is disabled by default with Alloy style for legacy compatibility. Where supported it can be enabled or disabled globally using `--[enable|disable]-print-preview` or configured on a per-RequestContext basis using the `printing.print_preview_disabled` preference. It also behaves as expected when triggered via the PDF viewer print button. Chrome runtime + Alloy style behavior differs from Alloy runtime in the following significant ways: - Supports Chrome error pages by default. - DevTools popups are Chrome style only (cannot be windowless). - The Alloy extension API will not supported. Chrome runtime + Alloy style passes all expected Alloy ceftests except the following: - `DisplayTest.AutoResize` (Alloy extension API not supported) - `DownloadTest.*` (Download API not yet supported) - `ExtensionTest.*` (Alloy extension API not supported) This change also adds Chrome runtime support for CefContextMenuHandler::RunContextMenu (see #3293). This change also explicitly blocks (and doesn't retry) FrameAttached requests from PDF viewer and print preview excluded frames (see #3664). Known issues specific to Chrome runtime + Alloy style: - DevTools popup with windowless rendering doesn't load successfully. Use windowed rendering or remote debugging as a workaround. - Chrome style Window with Alloy style BrowserView (`--use-alloy-style --use-chrome-style-window`) does not show Chrome theme changes. To test: - Run `ceftests --enable-chrome-runtime --use-alloy-style [--use-chrome-style-window] [--use-views|--use-native] --gtest_filter=...` - Run `cefclient --enable-chrome-runtime --use-alloy-style [--use-chrome-style-window] [--use-views|--use-native|--off-screen-rendering-enabled]` - Run `cefsimple --enable-chrome-runtime --use-alloy-style [--use-views]`
132 lines
4.3 KiB
C++
132 lines
4.3 KiB
C++
// 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.
|
|
|
|
#ifndef CEF_LIBCEF_RENDERER_RENDER_MANAGER_H_
|
|
#define CEF_LIBCEF_RENDERER_RENDER_MANAGER_H_
|
|
#pragma once
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <optional>
|
|
|
|
#include "include/internal/cef_ptr.h"
|
|
|
|
#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"
|
|
|
|
namespace blink {
|
|
class WebFrame;
|
|
class WebView;
|
|
} // namespace blink
|
|
|
|
namespace content {
|
|
class RenderFrame;
|
|
} // namespace content
|
|
|
|
namespace mojo {
|
|
class BinderMap;
|
|
} // namespace mojo
|
|
|
|
class CefBrowserImpl;
|
|
class CefGuestView;
|
|
class CefRenderFrameObserver;
|
|
|
|
// Singleton object for managing BrowserImpl instances. Only accessed on the
|
|
// main renderer thread.
|
|
class CefRenderManager : public cef::mojom::RenderManager {
|
|
public:
|
|
CefRenderManager();
|
|
|
|
CefRenderManager(const CefRenderManager&) = delete;
|
|
CefRenderManager& operator=(const CefRenderManager&) = delete;
|
|
|
|
~CefRenderManager() override;
|
|
|
|
// Returns this singleton instance of this class.
|
|
static CefRenderManager* Get();
|
|
|
|
// Called from ContentRendererClient methods of the same name.
|
|
void RenderThreadConnected();
|
|
void RenderFrameCreated(content::RenderFrame* render_frame,
|
|
CefRenderFrameObserver* render_frame_observer,
|
|
bool& browser_created,
|
|
std::optional<bool>& is_windowless,
|
|
std::optional<bool>& print_preview_enabled);
|
|
void WebViewCreated(blink::WebView* web_view,
|
|
bool& browser_created,
|
|
std::optional<bool>& is_windowless,
|
|
std::optional<bool>& print_preview_enabled);
|
|
void DevToolsAgentAttached();
|
|
void DevToolsAgentDetached();
|
|
void ExposeInterfacesToBrowser(mojo::BinderMap* binders);
|
|
|
|
// Returns the browser associated with the specified RenderView.
|
|
CefRefPtr<CefBrowserImpl> GetBrowserForView(blink::WebView* view);
|
|
|
|
// Returns the browser associated with the specified main WebFrame.
|
|
CefRefPtr<CefBrowserImpl> GetBrowserForMainFrame(blink::WebFrame* frame);
|
|
|
|
// Connects to CefBrowserManager in the browser process.
|
|
mojo::Remote<cef::mojom::BrowserManager>& GetBrowserManager();
|
|
|
|
// Returns true if this renderer process is hosting an extension.
|
|
static bool IsExtensionProcess();
|
|
|
|
private:
|
|
friend class CefBrowserImpl;
|
|
friend class CefGuestView;
|
|
|
|
// 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;
|
|
|
|
void WebKitInitialized();
|
|
|
|
// Maybe create a new browser object, return the existing one, or return
|
|
// nullptr for guest views.
|
|
CefRefPtr<CefBrowserImpl> MaybeCreateBrowser(
|
|
blink::WebView* web_view,
|
|
content::RenderFrame* render_frame,
|
|
bool* browser_created,
|
|
std::optional<bool>* is_windowless,
|
|
std::optional<bool>* print_preview_enabled);
|
|
|
|
// Called from CefBrowserImpl::OnDestruct().
|
|
void OnBrowserDestroyed(CefBrowserImpl* browser);
|
|
|
|
// Returns the guest view associated with the specified RenderView if any.
|
|
CefGuestView* GetGuestViewForView(blink::WebView* view);
|
|
|
|
// Called from CefGuestView::OnDestruct().
|
|
void OnGuestViewDestroyed(CefGuestView* guest_view);
|
|
|
|
// Map of RenderView pointers to CefBrowserImpl references.
|
|
using BrowserMap = std::map<blink::WebView*, CefRefPtr<CefBrowserImpl>>;
|
|
BrowserMap browsers_;
|
|
|
|
// Map of RenderView poiners to CefGuestView implementations.
|
|
using GuestViewMap = std::map<blink::WebView*, std::unique_ptr<CefGuestView>>;
|
|
GuestViewMap guest_views_;
|
|
|
|
// Cross-origin white list entries that need to be registered with WebKit.
|
|
std::vector<cef::mojom::CrossOriginWhiteListEntryPtr>
|
|
cross_origin_whitelist_entries_;
|
|
|
|
int devtools_agent_count_ = 0;
|
|
int uncaught_exception_stack_size_ = 0;
|
|
|
|
mojo::ReceiverSet<cef::mojom::RenderManager> receivers_;
|
|
|
|
mojo::Remote<cef::mojom::BrowserManager> browser_manager_;
|
|
};
|
|
|
|
#endif // CEF_LIBCEF_RENDERER_RENDER_MANAGER_H_
|