2015-11-17 19:20:13 +01: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.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_H_
|
|
|
|
|
2024-05-11 17:48:38 +02:00
|
|
|
#include "base/memory/raw_ptr.h"
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/browser/alloy/browser_platform_delegate_alloy.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
// Base implementation of native browser functionality.
|
2020-07-04 20:21:34 +02:00
|
|
|
class CefBrowserPlatformDelegateNative
|
|
|
|
: public CefBrowserPlatformDelegateAlloy {
|
2015-11-17 19:20:13 +01:00
|
|
|
public:
|
|
|
|
// Used by the windowless implementation to override specific functionality
|
|
|
|
// when delegating to the native implementation.
|
|
|
|
class WindowlessHandler {
|
|
|
|
public:
|
|
|
|
// Returns the parent window handle.
|
|
|
|
virtual CefWindowHandle GetParentWindowHandle() const = 0;
|
|
|
|
|
2022-05-13 13:38:41 +02:00
|
|
|
// Convert from view DIP coordinates to screen coordinates. If
|
|
|
|
// |want_dip_coords| is true return DIP instead of device (pixel)
|
|
|
|
// coordinates on Windows/Linux.
|
|
|
|
virtual gfx::Point GetParentScreenPoint(const gfx::Point& view,
|
|
|
|
bool want_dip_coords) const = 0;
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
protected:
|
2024-01-20 23:48:57 +01:00
|
|
|
virtual ~WindowlessHandler() = default;
|
2015-11-17 19:20:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// CefBrowserPlatformDelegate methods:
|
2017-04-20 21:28:17 +02:00
|
|
|
SkColor GetBackgroundColor() const override;
|
2020-01-31 23:54:26 +01:00
|
|
|
void WasResized() override;
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2020-01-23 22:58:01 +01:00
|
|
|
// Translate CEF events to Chromium/Blink Web events.
|
2024-06-14 19:01:45 +02:00
|
|
|
virtual input::NativeWebKeyboardEvent TranslateWebKeyEvent(
|
2020-01-23 22:58:01 +01:00
|
|
|
const CefKeyEvent& key_event) const = 0;
|
|
|
|
virtual blink::WebMouseEvent TranslateWebClickEvent(
|
|
|
|
const CefMouseEvent& mouse_event,
|
|
|
|
CefBrowserHost::MouseButtonType type,
|
|
|
|
bool mouseUp,
|
|
|
|
int clickCount) const = 0;
|
|
|
|
virtual blink::WebMouseEvent TranslateWebMoveEvent(
|
|
|
|
const CefMouseEvent& mouse_event,
|
|
|
|
bool mouseLeave) const = 0;
|
|
|
|
virtual blink::WebMouseWheelEvent TranslateWebWheelEvent(
|
|
|
|
const CefMouseEvent& mouse_event,
|
|
|
|
int deltaX,
|
|
|
|
int deltaY) const = 0;
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2020-01-23 22:58:01 +01:00
|
|
|
const CefWindowInfo& window_info() const { return window_info_; }
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
protected:
|
2020-01-23 22:58:01 +01:00
|
|
|
// Delegates that can wrap a native delegate.
|
|
|
|
friend class CefBrowserPlatformDelegateBackground;
|
2020-09-25 03:40:47 +02:00
|
|
|
friend class CefBrowserPlatformDelegateChrome;
|
2020-01-23 22:58:01 +01:00
|
|
|
friend class CefBrowserPlatformDelegateOsr;
|
|
|
|
friend class CefBrowserPlatformDelegateViews;
|
|
|
|
|
2017-04-20 21:28:17 +02:00
|
|
|
CefBrowserPlatformDelegateNative(const CefWindowInfo& window_info,
|
2020-07-04 20:21:34 +02:00
|
|
|
SkColor background_color);
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2020-01-23 22:58:01 +01:00
|
|
|
// Methods used by delegates that can wrap a native delegate.
|
|
|
|
void set_windowless_handler(WindowlessHandler* handler) {
|
|
|
|
windowless_handler_ = handler;
|
2020-09-25 03:40:47 +02:00
|
|
|
set_as_secondary();
|
2020-01-23 22:58:01 +01:00
|
|
|
}
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
CefWindowInfo window_info_;
|
2017-04-20 21:28:17 +02:00
|
|
|
const SkColor background_color_;
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2024-01-20 23:48:57 +01:00
|
|
|
// Not owned by this object.
|
2024-05-11 17:48:38 +02:00
|
|
|
raw_ptr<WindowlessHandler> windowless_handler_ = nullptr;
|
2015-11-17 19:20:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_H_
|