mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
chrome: Change popup default behavior with native parent (see issue #3294)
When using a Views-hosted browser window the client receives Views-related callbacks for popups and can thereby customize the Views-hosted popup behavior. When using an external parent window no Views-related callbacks are delivered and customization options are restricted to providing a new parent handle via OnBeforePopup. Consequently, we should default to a normal browser window in the external parent case instead of the very minimial Views-hosted default. To test (A): 1. Run `cefclient --use-default-popup --enable-chrome-runtime --use-native` 2. Select Tests > Popup Window 3. Get a normal Chrome browser window To test (B): 1. Run `cefclient --use-default-popup [--enable-chrome-runtime] [--use-views]` 2. Select Tests > Popup Window 3. Get a native or Views-hosted browser window with title bar only
This commit is contained in:
@@ -7,6 +7,9 @@
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
|
||||
CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() = default;
|
||||
|
||||
@@ -61,7 +64,12 @@ bool CefBrowserPlatformDelegate::
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::RenderViewCreated(
|
||||
content::RenderViewHost* render_view_host) {}
|
||||
content::RenderViewHost* render_view_host) {
|
||||
// Indicate that the view has an external parent (namely us). This setting is
|
||||
// required for proper focus handling on Windows and Linux.
|
||||
if (HasExternalParent() && render_view_host->GetWidget()->GetView())
|
||||
render_view_host->GetWidget()->GetView()->SetHasExternalParent(true);
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::RenderViewReady() {}
|
||||
|
||||
@@ -242,6 +250,12 @@ bool CefBrowserPlatformDelegate::IsViewsHosted() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegate::HasExternalParent() const {
|
||||
// In the majority of cases a Views-hosted browser will not have an external
|
||||
// parent, and visa-versa.
|
||||
return !IsViewsHosted();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegate::WasHidden(bool hidden) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
Reference in New Issue
Block a user