// Copyright (c) 2024 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_TESTS_CEFCLIENT_BROWSER_VIEWS_OVERLAY_BROWSER_H_ #define CEF_TESTS_CEFCLIENT_BROWSER_VIEWS_OVERLAY_BROWSER_H_ #pragma once #include "include/base/cef_weak_ptr.h" #include "include/views/cef_browser_view.h" #include "include/views/cef_browser_view_delegate.h" #include "include/views/cef_overlay_controller.h" namespace client { class ViewsWindow; // Implements a browser view that receives absolute positioning on top of the // main browser view. All methods must be called on the browser process UI // thread. class ViewsOverlayBrowser : public CefBrowserViewDelegate { public: explicit ViewsOverlayBrowser(ViewsWindow* owner_window); void Initialize(CefRefPtr window, CefRefPtr client, const std::string& url, const CefBrowserSettings& settings, CefRefPtr request_context); void Destroy(); bool IsValid() const; // Move the overlay BrowserView to/from a popout Window. void ToggleBrowserView(); // Update browser bounds. void UpdateBounds(CefInsets insets); // Exclude all regions obscured by overlays. void UpdateDraggableRegions(std::vector& window_regions); bool OnAccelerator(CefRefPtr window, int command_id); void PopOutWindowDestroyed(); private: // CefViewDelegate methods: CefSize GetMinimumSize(CefRefPtr view) override; // CefBrowserViewDelegate methods: void OnBrowserDestroyed(CefRefPtr browser_view, CefRefPtr browser) override; CefRefPtr GetDelegateForPopupBrowserView( CefRefPtr browser_view, const CefBrowserSettings& settings, CefRefPtr client, bool is_devtools) override; bool OnPopupBrowserViewCreated(CefRefPtr browser_view, CefRefPtr popup_browser_view, bool is_devtools) override; cef_runtime_style_t GetBrowserRuntimeStyle() override; // Move the BrowserView to a new top-level Window. void PopOutBrowserView(); // Return the BrowserView to the overlay. void PopInBrowserView(); ViewsWindow* const owner_window_; CefRefPtr window_; CefRefPtr browser_view_; CefRefPtr controller_; CefInsets last_insets_; CefRefPtr popout_window_; base::WeakPtrFactory weak_ptr_factory_{this}; IMPLEMENT_REFCOUNTING(ViewsOverlayBrowser); DISALLOW_COPY_AND_ASSIGN(ViewsOverlayBrowser); }; } // namespace client #endif // CEF_TESTS_CEFCLIENT_BROWSER_VIEWS_OVERLAY_BROWSER_H_