mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
cefclient: views: Add overlay BrowserView demo (see #3790)
Adds new `--show-overlay-browser` command-line flag that creates an overlay containing an Alloy-style BrowserView. The main BrowserView may be Chrome- (default) or Alloy-style (add `--use-alloy-style`). This overlay will only be added to standalone (non-popup) windows. Popups triggered via the overlay will receive standard Alloy-style handling in cefclient (e.g. Views-hosted window). Add `--use-default-popup` for default popup handling.
This commit is contained in:
@@ -4,8 +4,16 @@
|
||||
|
||||
#include "tests/cefclient/browser/default_client_handler.h"
|
||||
|
||||
#include "tests/cefclient/browser/main_context.h"
|
||||
#include "tests/cefclient/browser/root_window_manager.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
DefaultClientHandler::DefaultClientHandler(std::optional<bool> use_alloy_style)
|
||||
: use_alloy_style_(
|
||||
use_alloy_style.value_or(MainContext::Get()->UseAlloyStyleGlobal())) {
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<DefaultClientHandler> DefaultClientHandler::GetForClient(
|
||||
CefRefPtr<CefClient> client) {
|
||||
@@ -16,4 +24,39 @@ CefRefPtr<DefaultClientHandler> DefaultClientHandler::GetForClient(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool DefaultClientHandler::OnBeforePopup(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& target_url,
|
||||
const CefString& target_frame_name,
|
||||
CefLifeSpanHandler::WindowOpenDisposition target_disposition,
|
||||
bool user_gesture,
|
||||
const CefPopupFeatures& popupFeatures,
|
||||
CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient>& client,
|
||||
CefBrowserSettings& settings,
|
||||
CefRefPtr<CefDictionaryValue>& extra_info,
|
||||
bool* no_javascript_access) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
if (target_disposition == CEF_WOD_NEW_PICTURE_IN_PICTURE) {
|
||||
// Use default handling for document picture-in-picture popups.
|
||||
client = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Used to configure default values.
|
||||
RootWindowConfig config(/*command_line=*/nullptr);
|
||||
|
||||
// Potentially create a new RootWindow for the popup browser that will be
|
||||
// created asynchronously.
|
||||
MainContext::Get()->GetRootWindowManager()->CreateRootWindowAsPopup(
|
||||
config.use_views, use_alloy_style_, config.with_controls,
|
||||
/*is_osr=*/false, /*is_devtools=*/false, popupFeatures, windowInfo,
|
||||
client, settings);
|
||||
|
||||
// Allow popup creation.
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
Reference in New Issue
Block a user