1 // Copyright 2015 The Chromium Embedded Framework Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_H_ 6 #define CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_H_ 7 8 #include "libcef/browser/alloy/browser_platform_delegate_alloy.h" 9 10 // Base implementation of native browser functionality. 11 class CefBrowserPlatformDelegateNative 12 : public CefBrowserPlatformDelegateAlloy { 13 public: 14 // Used by the windowless implementation to override specific functionality 15 // when delegating to the native implementation. 16 class WindowlessHandler { 17 public: 18 // Returns the parent window handle. 19 virtual CefWindowHandle GetParentWindowHandle() const = 0; 20 21 // Convert from view coordinates to screen coordinates. 22 virtual gfx::Point GetParentScreenPoint(const gfx::Point& view) const = 0; 23 24 protected: ~WindowlessHandler()25 virtual ~WindowlessHandler() {} 26 }; 27 28 // CefBrowserPlatformDelegate methods: 29 SkColor GetBackgroundColor() const override; 30 void WasResized() override; 31 32 // Translate CEF events to Chromium/Blink Web events. 33 virtual content::NativeWebKeyboardEvent TranslateWebKeyEvent( 34 const CefKeyEvent& key_event) const = 0; 35 virtual blink::WebMouseEvent TranslateWebClickEvent( 36 const CefMouseEvent& mouse_event, 37 CefBrowserHost::MouseButtonType type, 38 bool mouseUp, 39 int clickCount) const = 0; 40 virtual blink::WebMouseEvent TranslateWebMoveEvent( 41 const CefMouseEvent& mouse_event, 42 bool mouseLeave) const = 0; 43 virtual blink::WebMouseWheelEvent TranslateWebWheelEvent( 44 const CefMouseEvent& mouse_event, 45 int deltaX, 46 int deltaY) const = 0; 47 window_info()48 const CefWindowInfo& window_info() const { return window_info_; } 49 50 protected: 51 // Delegates that can wrap a native delegate. 52 friend class CefBrowserPlatformDelegateBackground; 53 friend class CefBrowserPlatformDelegateChrome; 54 friend class CefBrowserPlatformDelegateOsr; 55 friend class CefBrowserPlatformDelegateViews; 56 57 CefBrowserPlatformDelegateNative(const CefWindowInfo& window_info, 58 SkColor background_color); 59 60 // Methods used by delegates that can wrap a native delegate. set_windowless_handler(WindowlessHandler * handler)61 void set_windowless_handler(WindowlessHandler* handler) { 62 windowless_handler_ = handler; 63 set_as_secondary(); 64 } 65 66 CefWindowInfo window_info_; 67 const SkColor background_color_; 68 69 WindowlessHandler* windowless_handler_; // Not owned by this object. 70 }; 71 72 #endif // CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_H_ 73