mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
chrome: win/linux: Add support for browser with native parent (see issue #3294)
This change adds Chrome runtime support on Windows and Linux for creating a browser parented to a native window supplied by the client application. Expected API usage and window behavior is similar to what already exists with the Alloy runtime. The parent window handle should be specified by using CefWindowInfo::SetAsChild in combination with the CefBrowserHost::CreateBrowser and CefLifeSpanHandler::OnBeforePopup callbacks. The previously existing behavior of creating a fully-featured Chrome browser window when empty CefWindowInfo is used with CreateBrowser remains unchanged and Views is still the preferred API for creating top-level Chrome windows with custom styling (e.g. title bar only, frameless, etc). The cefclient Popup Window test with a native parent window continues to crash on Linux with both the Alloy and Chrome runtimes (see issue #3165). Also adds Chrome runtime support for CefDisplayHandler::OnCursorChange. To test: - Run `cefclient --enable-chrome-runtime [--use-views]` for the default (and previously existing) Views-based behavior. - Run `cefclient --enable-chrome-runtime --use-native` for the new native parent window behavior. - Run `cefclient --enable-chrome-runtime --use-native --no-activate` and the window will not be activated (take input focus) on launch (Windows only). - Run `cefclient --enable-chrome-runtime [--use-views|--use-native] --mouse-cursor-change-disabled` and the mouse cursor will not change on mouseover of DOM elements.
This commit is contained in:
@@ -37,7 +37,7 @@ CefBrowserPlatformDelegateNativeLinux::CefBrowserPlatformDelegateNativeLinux(
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::BrowserDestroyed(
|
||||
CefBrowserHostBase* browser) {
|
||||
CefBrowserPlatformDelegateNative::BrowserDestroyed(browser);
|
||||
CefBrowserPlatformDelegateNativeAura::BrowserDestroyed(browser);
|
||||
|
||||
if (host_window_created_) {
|
||||
// Release the reference added in CreateHostWindow().
|
||||
@@ -155,7 +155,7 @@ void CefBrowserPlatformDelegateNativeLinux::SetFocus(bool setFocus) {
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::NotifyMoveOrResizeStarted() {
|
||||
// Call the parent method to dismiss any existing popups.
|
||||
CefBrowserPlatformDelegateNative::NotifyMoveOrResizeStarted();
|
||||
CefBrowserPlatformDelegateNativeAura::NotifyMoveOrResizeStarted();
|
||||
|
||||
if (!web_contents_)
|
||||
return;
|
||||
|
@@ -156,9 +156,18 @@ CefBrowserPlatformDelegateNativeWin::CefBrowserPlatformDelegateNativeWin(
|
||||
SkColor background_color)
|
||||
: CefBrowserPlatformDelegateNativeAura(window_info, background_color) {}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::set_widget(
|
||||
views::Widget* widget,
|
||||
CefWindowHandle widget_handle) {
|
||||
DCHECK(!window_widget_);
|
||||
window_widget_ = widget;
|
||||
DCHECK(!window_info_.window);
|
||||
window_info_.window = widget_handle;
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::BrowserDestroyed(
|
||||
CefBrowserHostBase* browser) {
|
||||
CefBrowserPlatformDelegateNative::BrowserDestroyed(browser);
|
||||
CefBrowserPlatformDelegateNativeAura::BrowserDestroyed(browser);
|
||||
|
||||
if (host_window_created_) {
|
||||
// Release the reference added in CreateHostWindow().
|
||||
@@ -315,7 +324,7 @@ void CefBrowserPlatformDelegateNativeWin::SetFocus(bool setFocus) {
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::NotifyMoveOrResizeStarted() {
|
||||
// Call the parent method to dismiss any existing popups.
|
||||
CefBrowserPlatformDelegateNative::NotifyMoveOrResizeStarted();
|
||||
CefBrowserPlatformDelegateNativeAura::NotifyMoveOrResizeStarted();
|
||||
|
||||
if (!window_widget_)
|
||||
return;
|
||||
|
@@ -16,6 +16,9 @@ class CefBrowserPlatformDelegateNativeWin
|
||||
CefBrowserPlatformDelegateNativeWin(const CefWindowInfo& window_info,
|
||||
SkColor background_color);
|
||||
|
||||
// Called from chrome_child_window.cc after |widget| is created.
|
||||
void set_widget(views::Widget* widget, CefWindowHandle widget_handle);
|
||||
|
||||
// CefBrowserPlatformDelegate methods:
|
||||
void BrowserDestroyed(CefBrowserHostBase* browser) override;
|
||||
bool CreateHostWindow() override;
|
||||
|
@@ -12,8 +12,8 @@
|
||||
|
||||
namespace cursor_util {
|
||||
|
||||
bool OnCursorChange(CefBrowserHostBase* browser, const ui::Cursor& ui_cursor) {
|
||||
auto client = browser->GetClient();
|
||||
bool OnCursorChange(CefRefPtr<CefBrowser> browser, const ui::Cursor& ui_cursor) {
|
||||
auto client = browser->GetHost()->GetClient();
|
||||
if (!client)
|
||||
return false;
|
||||
auto handler = client->GetDisplayHandler();
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#ifndef CEF_LIBCEF_BROWSER_NATIVE_CURSOR_UTIL_H_
|
||||
#define CEF_LIBCEF_BROWSER_NATIVE_CURSOR_UTIL_H_
|
||||
|
||||
#include "include/internal/cef_types.h"
|
||||
#include "include/cef_browser.h"
|
||||
|
||||
#include "ui/base/cursor/cursor.h"
|
||||
#include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
|
||||
@@ -14,8 +14,6 @@
|
||||
#include "ui/base/cursor/platform_cursor.h"
|
||||
#endif
|
||||
|
||||
class CefBrowserHostBase;
|
||||
|
||||
namespace cursor_util {
|
||||
|
||||
#if defined(USE_AURA)
|
||||
@@ -24,7 +22,7 @@ cef_cursor_handle_t ToCursorHandle(scoped_refptr<ui::PlatformCursor> cursor);
|
||||
#endif // defined(USE_AURA)
|
||||
|
||||
// Returns true if the client handled the cursor change.
|
||||
bool OnCursorChange(CefBrowserHostBase* browser, const ui::Cursor& ui_cursor);
|
||||
bool OnCursorChange(CefRefPtr<CefBrowser> browser, const ui::Cursor& ui_cursor);
|
||||
|
||||
} // namespace cursor_util
|
||||
|
||||
|
Reference in New Issue
Block a user