1 // Copyright 2017 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_VIEWS_BROWSER_PLATFORM_DELEGATE_BACKGROUND_H_ 6 #define CEF_LIBCEF_BROWSER_VIEWS_BROWSER_PLATFORM_DELEGATE_BACKGROUND_H_ 7 8 #include "libcef/browser/alloy/browser_platform_delegate_alloy.h" 9 #include "libcef/browser/native/browser_platform_delegate_native.h" 10 11 // Implementation of browser functionality for background script hosts. 12 class CefBrowserPlatformDelegateBackground 13 : public CefBrowserPlatformDelegateAlloy, 14 public CefBrowserPlatformDelegateNative::WindowlessHandler { 15 public: 16 // Platform-specific behaviors will be delegated to |native_delegate|. 17 CefBrowserPlatformDelegateBackground( 18 std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate); 19 20 // CefBrowserPlatformDelegate methods: 21 bool CreateHostWindow() override; 22 void CloseHostWindow() override; 23 CefWindowHandle GetHostWindowHandle() const override; 24 SkColor GetBackgroundColor() const override; 25 void WasResized() override; 26 void SendKeyEvent(const CefKeyEvent& event) override; 27 void SendMouseClickEvent(const CefMouseEvent& event, 28 CefBrowserHost::MouseButtonType type, 29 bool mouseUp, 30 int clickCount) override; 31 void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override; 32 void SendMouseWheelEvent(const CefMouseEvent& event, 33 int deltaX, 34 int deltaY) override; 35 void SendTouchEvent(const CefTouchEvent& event) override; 36 void SetFocus(bool setFocus) override; 37 gfx::Point GetScreenPoint(const gfx::Point& view) const override; 38 void ViewText(const std::string& text) override; 39 bool HandleKeyboardEvent( 40 const content::NativeWebKeyboardEvent& event) override; 41 CefEventHandle GetEventHandle( 42 const content::NativeWebKeyboardEvent& event) const override; 43 std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override; 44 std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner() 45 override; 46 std::unique_ptr<CefMenuRunner> CreateMenuRunner() override; 47 48 // CefBrowserPlatformDelegateNative::WindowlessHandler methods: 49 CefWindowHandle GetParentWindowHandle() const override; 50 gfx::Point GetParentScreenPoint(const gfx::Point& view) const override; 51 52 private: 53 std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate_; 54 }; 55 56 #endif // CEF_LIBCEF_BROWSER_VIEWS_BROWSER_PLATFORM_DELEGATE_BACKGROUND_H_ 57