1 // Copyright 2021 The Chromium Embedded Framework Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be found 3 // in the LICENSE file. 4 5 #ifndef CEF_LIBCEF_BROWSER_CHROME_VIEWS_CHROME_BROWSER_VIEW_H_ 6 #define CEF_LIBCEF_BROWSER_CHROME_VIEWS_CHROME_BROWSER_VIEW_H_ 7 #pragma once 8 9 #include "include/views/cef_browser_view.h" 10 #include "include/views/cef_browser_view_delegate.h" 11 #include "libcef/browser/chrome/views/toolbar_view_impl.h" 12 #include "libcef/browser/views/browser_view_view.h" 13 #include "libcef/browser/views/view_view.h" 14 15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/views/frame/browser_view.h" 17 18 namespace views { 19 class WebView; 20 } // namespace views 21 22 // A variant of CefBrowserViewView that extends BrowserView instead of 23 // views::WebView. See chrome_browser_frame.h for related documentation. 24 class ChromeBrowserView 25 : public CefViewView<BrowserView, CefBrowserViewDelegate> { 26 public: 27 using ParentClass = CefViewView<BrowserView, CefBrowserViewDelegate>; 28 using Delegate = CefBrowserViewView::Delegate; 29 30 // |cef_delegate| may be nullptr. 31 // |browser_view_delegate| must be non-nullptr. 32 ChromeBrowserView(CefBrowserViewDelegate* cef_delegate, 33 Delegate* browser_view_delegate); 34 35 ChromeBrowserView(const ChromeBrowserView&) = delete; 36 ChromeBrowserView& operator=(const ChromeBrowserView&) = delete; 37 38 // Called by ChromeBrowserHostImpl. 39 void InitBrowser(std::unique_ptr<Browser> browser, 40 CefRefPtr<CefBrowserView> browser_view); 41 void Destroyed(); 42 43 // View methods: 44 void ViewHierarchyChanged( 45 const views::ViewHierarchyChangedDetails& details) override; 46 void AddedToWidget() override; 47 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; 48 49 // BrowserView methods: 50 ToolbarView* OverrideCreateToolbar(Browser* browser, 51 BrowserView* browser_view) override; 52 cef_toolbar()53 CefRefPtr<CefToolbarViewImpl> cef_toolbar() const { return cef_toolbar_; } 54 55 private: 56 // Not owned by this object. 57 Delegate* browser_view_delegate_; 58 59 Browser* browser_ = nullptr; 60 views::WebView* web_view_ = nullptr; 61 62 bool destroyed_ = false; 63 64 CefRefPtr<CefToolbarViewImpl> cef_toolbar_; 65 }; 66 67 #endif // CEF_LIBCEF_BROWSER_CHROME_VIEWS_CHROME_BROWSER_VIEW_H_ 68