Googler | 1187115 | 2020-10-01 14:59:09 -0400 | [diff] [blame] | 1 | // Copyright 2016 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_VIEWS_PANEL_VIEW_H_ |
| 6 | #define CEF_LIBCEF_BROWSER_VIEWS_PANEL_VIEW_H_ |
| 7 | #pragma once |
| 8 | |
| 9 | #include "include/views/cef_panel_delegate.h" |
| 10 | |
| 11 | #include "libcef/browser/thread_util.h" |
| 12 | #include "libcef/browser/views/view_view.h" |
| 13 | |
| 14 | #include "base/logging.h" |
| 15 | |
| 16 | // Helpers for template boiler-plate. |
| 17 | #define CEF_PANEL_VIEW_T CEF_VIEW_VIEW_T |
| 18 | #define CEF_PANEL_VIEW_A CEF_VIEW_VIEW_A |
| 19 | #define CEF_PANEL_VIEW_D CefPanelView<CEF_PANEL_VIEW_A> |
| 20 | |
| 21 | // Template for implementing views::View-derived classes that support adding and |
| 22 | // removing children (called a Panel in CEF terminology). See comments in |
| 23 | // view_impl.h for a usage overview. |
| 24 | CEF_PANEL_VIEW_T class CefPanelView : public CEF_VIEW_VIEW_D { |
| 25 | public: |
| 26 | typedef CEF_VIEW_VIEW_D ParentClass; |
| 27 | |
| 28 | // |cef_delegate| may be nullptr. |
| 29 | explicit CefPanelView(CefViewDelegateClass* cef_delegate) |
| 30 | : ParentClass(cef_delegate) {} |
| 31 | |
| 32 | // Returns the CefPanel associated with this view. See comments on |
| 33 | // CefViewView::GetCefView. |
| 34 | CefRefPtr<CefPanel> GetCefPanel() const { |
| 35 | CefRefPtr<CefPanel> panel = ParentClass::GetCefView()->AsPanel(); |
| 36 | DCHECK(panel); |
| 37 | return panel; |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | #endif // CEF_LIBCEF_BROWSER_VIEWS_PANEL_VIEW_H_ |