mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	Avoid a circular ownership dependency between CefBrowserViewImpl and CefBrowserPlatformDelegate[Chrome]Views (owned by CefBrowserHostBase). Trigger CefBrowserHostBase destruction when the last CefBrowserViewImpl reference is released. This fixes a number of shutdown crashes related to overlay CefBrowsers still existing at CefShutdown.
		
			
				
	
	
		
			86 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			86 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| // Copyright 2021 The Chromium Embedded Framework Authors. Portions copyright
 | |
| // 2011 The Chromium 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_VIEWS_OVERLAY_VIEW_HOST_H_
 | |
| #define CEF_LIBCEF_BROWSER_VIEWS_OVERLAY_VIEW_HOST_H_
 | |
| #pragma once
 | |
| 
 | |
| #include <memory>
 | |
| 
 | |
| #include "base/memory/raw_ptr.h"
 | |
| #include "cef/include/views/cef_overlay_controller.h"
 | |
| #include "cef/include/views/cef_view.h"
 | |
| #include "ui/views/view_observer.h"
 | |
| #include "ui/views/widget/unique_widget_ptr.h"
 | |
| #include "ui/views/widget/widget_delegate.h"
 | |
| 
 | |
| class CefWindowView;
 | |
| 
 | |
| // Host class for a child Widget that behaves as an overlay control. Based on
 | |
| // Chrome's DropdownBarHost.
 | |
| class CefOverlayViewHost : public views::WidgetDelegate,
 | |
|                            public views::ViewObserver {
 | |
|  public:
 | |
|   // |window_view| is the top-level view that contains this overlay.
 | |
|   CefOverlayViewHost(CefWindowView* window_view,
 | |
|                      cef_docking_mode_t docking_mode);
 | |
| 
 | |
|   CefOverlayViewHost(const CefOverlayViewHost&) = delete;
 | |
|   CefOverlayViewHost& operator=(const CefOverlayViewHost&) = delete;
 | |
| 
 | |
|   // Initializes the CefOverlayViewHost. This creates the Widget that |view|
 | |
|   // paints into. On Aura platforms, |host_view| is the view whose position in
 | |
|   // the |window_view_| view hierarchy determines the z-order of the widget
 | |
|   // relative to views with layers and views with associated NativeViews.
 | |
|   void Init(views::View* host_view, CefRefPtr<CefView> view, bool can_activate);
 | |
| 
 | |
|   void Close();
 | |
| 
 | |
|   void MoveIfNecessary();
 | |
| 
 | |
|   void SetOverlayBounds(const gfx::Rect& bounds);
 | |
|   void SetOverlayInsets(const CefInsets& insets);
 | |
| 
 | |
|   // views::ViewObserver methods:
 | |
|   void OnViewBoundsChanged(views::View* observed_view) override;
 | |
|   void OnViewIsDeleting(views::View* observed_view) override;
 | |
| 
 | |
|   cef_docking_mode_t docking_mode() const { return docking_mode_; }
 | |
|   CefRefPtr<CefOverlayController> controller() const { return cef_controller_; }
 | |
|   CefWindowView* window_view() const { return window_view_; }
 | |
|   views::Widget* widget() const { return widget_.get(); }
 | |
|   views::View* view() const { return view_; }
 | |
|   gfx::Rect bounds() const { return bounds_; }
 | |
|   CefInsets insets() const { return insets_; }
 | |
| 
 | |
|  private:
 | |
|   gfx::Rect ComputeBounds() const;
 | |
| 
 | |
|   void Cleanup();
 | |
| 
 | |
|   // The CefWindowView that created us.
 | |
|   raw_ptr<CefWindowView> window_view_;
 | |
| 
 | |
|   const cef_docking_mode_t docking_mode_;
 | |
| 
 | |
|   // The host view that the overlay is positioned relative to.
 | |
|   raw_ptr<views::View> host_view_ = nullptr;
 | |
| 
 | |
|   // Our view, which is responsible for drawing the UI.
 | |
|   raw_ptr<views::View> view_ = nullptr;
 | |
| 
 | |
|   // The Widget implementation that is created and maintained by the overlay.
 | |
|   // It contains |view_|.
 | |
|   views::UniqueWidgetPtr widget_;
 | |
| 
 | |
|   CefRefPtr<CefOverlayController> cef_controller_;
 | |
| 
 | |
|   gfx::Rect bounds_;
 | |
|   bool bounds_changing_ = false;
 | |
| 
 | |
|   CefInsets insets_;
 | |
| };
 | |
| 
 | |
| #endif  // CEF_LIBCEF_BROWSER_VIEWS_OVERLAY_VIEW_HOST_H_
 |