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_WIN_H_ 6 #define CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_WIN_H_ 7 8 #include <windows.h> 9 10 #include "libcef/browser/native/browser_platform_delegate_native_aura.h" 11 12 // Windowed browser implementation for Windows. 13 class CefBrowserPlatformDelegateNativeWin 14 : public CefBrowserPlatformDelegateNativeAura { 15 public: 16 CefBrowserPlatformDelegateNativeWin(const CefWindowInfo& window_info, 17 SkColor background_color); 18 19 // CefBrowserPlatformDelegate methods: 20 void BrowserDestroyed(CefBrowserHostBase* browser) override; 21 bool CreateHostWindow() override; 22 void CloseHostWindow() override; 23 CefWindowHandle GetHostWindowHandle() const override; 24 views::Widget* GetWindowWidget() const override; 25 void SetFocus(bool setFocus) override; 26 void NotifyMoveOrResizeStarted() override; 27 void SizeTo(int width, int height) override; 28 gfx::Point GetScreenPoint(const gfx::Point& view) const override; 29 void ViewText(const std::string& text) override; 30 bool HandleKeyboardEvent( 31 const content::NativeWebKeyboardEvent& event) override; 32 CefEventHandle GetEventHandle( 33 const content::NativeWebKeyboardEvent& event) const override; 34 std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override; 35 std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner() 36 override; 37 std::unique_ptr<CefMenuRunner> CreateMenuRunner() override; 38 gfx::Point GetDialogPosition(const gfx::Size& size) override; 39 gfx::Size GetMaximumDialogSize() override; 40 41 // CefBrowserPlatformDelegateNativeAura methods: 42 ui::KeyEvent TranslateUiKeyEvent(const CefKeyEvent& key_event) const override; 43 gfx::Vector2d GetUiWheelEventOffset(int deltaX, int deltaY) const override; 44 45 private: 46 static void RegisterWindowClass(); 47 static LPCTSTR GetWndClass(); 48 static LRESULT CALLBACK WndProc(HWND hwnd, 49 UINT message, 50 WPARAM wParam, 51 LPARAM lParam); 52 53 // True if the host window has been created. 54 bool host_window_created_ = false; 55 56 // Widget hosting the web contents. It will be deleted automatically when the 57 // associated root window is destroyed. 58 views::Widget* window_widget_ = nullptr; 59 60 bool has_frame_ = false; 61 bool called_enable_non_client_dpi_scaling_ = false; 62 }; 63 64 #endif // CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_WIN_H_ 65