• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   using ParentClass = CEF_VIEW_VIEW_D;
27 
28   // |cef_delegate| may be nullptr.
29   template <typename... Args>
CefPanelView(CefViewDelegateClass * cef_delegate,Args...args)30   explicit CefPanelView(CefViewDelegateClass* cef_delegate, Args... args)
31       : ParentClass(cef_delegate, args...) {}
32 
33   // Returns the CefPanel associated with this view. See comments on
34   // CefViewView::GetCefView.
GetCefPanel()35   CefRefPtr<CefPanel> GetCefPanel() const {
36     CefRefPtr<CefPanel> panel = ParentClass::GetCefView()->AsPanel();
37     DCHECK(panel);
38     return panel;
39   }
40 };
41 
42 #endif  // CEF_LIBCEF_BROWSER_VIEWS_PANEL_VIEW_H_
43